#1368 Restructures Message and Event filter framework.

This commit is contained in:
Dennis Sheirer
2023-07-12 04:41:57 -04:00
parent d246ffff30
commit b0a524cf62
121 changed files with 4869 additions and 4950 deletions

View File

@@ -1,23 +1,20 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
*
* * ******************************************************************************
* * Copyright (C) 2014-2019 Dennis Sheirer
* *
* * This program is free software: you can redistribute it and/or modify
* * it under the terms of the GNU General Public License as published by
* * the Free Software Foundation, either version 3 of the License, or
* * (at your option) any later version.
* *
* * This program is distributed in the hope that it will be useful,
* * but WITHOUT ANY WARRANTY; without even the implied warranty of
* * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* * GNU General Public License for more details.
* *
* * You should have received a copy of the GNU General Public License
* * along with this program. If not, see <http://www.gnu.org/licenses/>
* * *****************************************************************************
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.module.decode.lj1200;
@@ -31,14 +28,14 @@ import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.module.decode.event.DecodeEvent;
import io.github.dsheirer.module.decode.event.DecodeEventType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.github.dsheirer.protocol.Protocol;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class LJ1200DecoderState extends DecoderState
{
@@ -73,12 +70,11 @@ public class LJ1200DecoderState extends DecoderState
ic.remove(IdentifierClass.USER);
ic.update(lj.getIdentifiers());
DecodeEvent event = DecodeEvent.builder(System.currentTimeMillis())
DecodeEvent event = DecodeEvent.builder(DecodeEventType.DATA_PACKET, System.currentTimeMillis())
.protocol(Protocol.LOJACK)
.identifiers(ic)
.eventType(DecodeEventType.DATA_PACKET)
.channel(getCurrentChannel())
.details("LOJACK")
.eventDescription(lj.toString())
.details("LOJACK " + lj)
.build();
broadcast(event);
@@ -93,12 +89,11 @@ public class LJ1200DecoderState extends DecoderState
ic.remove(IdentifierClass.USER);
ic.update(transponder.getIdentifiers());
DecodeEvent transponderEvent = DecodeEvent.builder(System.currentTimeMillis())
DecodeEvent transponderEvent = DecodeEvent.builder(DecodeEventType.GPS, System.currentTimeMillis())
.protocol(Protocol.LOJACK)
.identifiers(ic)
.eventType(DecodeEventType.GPS)
.channel(getCurrentChannel())
.details("LOJACK TRANSPONDER")
.eventDescription(transponder.toString())
.details("LOJACK TRANSPONDER " + transponder)
.build();
broadcast(transponderEvent);
@@ -117,7 +112,7 @@ public class LJ1200DecoderState extends DecoderState
{
sb.append("Transponder Addresses:\n");
List<String> addresses = new ArrayList<String>(mAddresses);
List<String> addresses = new ArrayList<>(mAddresses);
Collections.sort(addresses);

View File

@@ -1,52 +1,66 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,2015 Dennis Sheirer
/*
* *****************************************************************************
* Copyright (C) 2014-2023 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
******************************************************************************/
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
* ****************************************************************************
*/
package io.github.dsheirer.module.decode.lj1200;
import io.github.dsheirer.filter.Filter;
import io.github.dsheirer.filter.FilterElement;
import io.github.dsheirer.message.IMessage;
import java.util.function.Function;
import java.util.Collections;
import java.util.List;
public class LJ1200MessageFilter extends Filter<IMessage>
/**
* Filter for LJ1200 messages
*/
public class LJ1200MessageFilter extends Filter<IMessage,String>
{
private static final String LJ1200_KEY = "LJ-1200";
private final LJ1200KeyExtractor mKeyExtractor = new LJ1200KeyExtractor();
/**
* Constructor
*/
public LJ1200MessageFilter()
{
super("LJ-1200 Message Filter");
}
@Override
public boolean passes(IMessage message)
{
return mEnabled && canProcess(message);
super("LJ-1200 Messages");
add(new FilterElement<>(LJ1200_KEY));
}
@Override
public boolean canProcess(IMessage message)
{
return message instanceof LJ1200Message || message instanceof LJ1200TransponderMessage;
return (message instanceof LJ1200Message || message instanceof LJ1200TransponderMessage);
}
@Override
public List<FilterElement<?>> getFilterElements()
public Function<IMessage, String> getKeyExtractor()
{
return Collections.EMPTY_LIST;
return mKeyExtractor;
}
/**
* Key extractor
*/
public class LJ1200KeyExtractor implements Function<IMessage,String>
{
@Override
public String apply(IMessage message)
{
return LJ1200_KEY;
}
}
}