#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.tait;
@@ -34,9 +31,8 @@ import io.github.dsheirer.module.decode.event.DecodeEventType;
import io.github.dsheirer.module.decode.event.PlottableDecodeEvent;
import io.github.dsheirer.module.decode.tait.identifier.TaitIdentifier;
import io.github.dsheirer.protocol.Protocol;
import org.jdesktop.swingx.mapviewer.GeoPosition;
import java.util.TreeSet;
import org.jdesktop.swingx.mapviewer.GeoPosition;
public class Tait1200DecoderState extends DecoderState
{
@@ -97,10 +93,8 @@ public class Tait1200DecoderState extends DecoderState
ic.remove(IdentifierClass.USER);
ic.update(message.getIdentifiers());
PlottableDecodeEvent event = PlottableDecodeEvent.plottableBuilder(gps.getTimestamp())
PlottableDecodeEvent event = PlottableDecodeEvent.plottableBuilder(DecodeEventType.GPS, gps.getTimestamp())
.protocol(PROTOCOL_TAIT_1200)
.eventType(DecodeEventType.GPS)
.eventDescription("GPS")
.identifiers(ic)
.location(position)
.speed(gps.getSpeed())
@@ -111,9 +105,8 @@ public class Tait1200DecoderState extends DecoderState
broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));
}
else if(message instanceof Tait1200ANIMessage)
else if(message instanceof Tait1200ANIMessage ani)
{
Tait1200ANIMessage ani = (Tait1200ANIMessage)message;
mIdents.add(ani.getFromIdentifier());
mIdents.add(ani.getToIdentifier());
@@ -121,10 +114,8 @@ public class Tait1200DecoderState extends DecoderState
ic.remove(IdentifierClass.USER);
ic.update(message.getIdentifiers());
broadcast(DecodeEvent.builder(ani.getTimestamp())
broadcast(DecodeEvent.builder(DecodeEventType.ID_ANI, ani.getTimestamp())
.protocol(PROTOCOL_TAIT_1200)
.eventType(DecodeEventType.ID_ANI)
.eventDescription("ANI")
.identifiers(ic)
.details("Automatic Number Identification")
.build());

View File

@@ -1,52 +1,64 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,2015 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/>
******************************************************************************/
/*
* *****************************************************************************
* 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 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.tait;
import io.github.dsheirer.filter.Filter;
import io.github.dsheirer.filter.FilterElement;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import java.util.function.Function;
import java.util.Collections;
import java.util.List;
public class Tait1200MessageFilter extends Filter<Message>
/**
* Filter for Tait1200 messages
*/
public class Tait1200MessageFilter extends Filter<IMessage,String>
{
public Tait1200MessageFilter()
{
super( "Tait-1200 Message Filter" );
}
@Override
public boolean passes( Message message )
private static final String TAIT1200_KEY = "Tait-1200";
private final KeyExtractor mKeyExtractor = new KeyExtractor();
/**
* Constructor
*/
public Tait1200MessageFilter()
{
return mEnabled && canProcess( message );
super("Tait-1200 Messages");
}
@Override
public boolean canProcess( Message message )
@Override
public boolean canProcess(IMessage message)
{
return message instanceof Tait1200GPSMessage;
return message instanceof Tait1200GPSMessage;
}
@Override
public List<FilterElement<?>> getFilterElements()
@Override
public Function<IMessage, String> getKeyExtractor()
{
return Collections.EMPTY_LIST;
return mKeyExtractor;
}
/**
* Key extractor
*/
private class KeyExtractor implements Function<IMessage,String>
{
@Override
public String apply(IMessage message)
{
return TAIT1200_KEY;
}
}
}