Identifier Framework and Message/Event Processing Overhaul (#455)

* WIP on new P25 message framer.

* WIP on new P25 message framer.

* Adds new 1/2 and 3/4 rate trellis decoders.  Still trying to chase
down why there is a sync pattern mismatch in the NID buffer queue.

* WIP - new p25 message framer works correctly now.  PDU's are dectected
and decoded using the 1/2 and 3/4 rate trellis decoders.  Packet
Sequences are assembled.  Need to add a new packet sequence message
factory that can detect Motorola Auto Registration Service (ARS)
formatted UDP/ID packets and SNDCP command packets.

* WIP - removes nullify on channel results queue.

* WIP - updates message framer for TSBK 1/2/3 processing.

* WIP removing P25 sync pattern and nid bits from all message parsers.

* WIP - merges identifier framework branch changes into this branch.

* WIP on updating link control words to new format and identifier framework.

* WIP - implements rest of link control words for extended formats

* WIP - initial work on ISP/OSP TSBK message restructuring.

* WIP - adds more TSBK ISP and OSP messages

* WIP - finished updating most of the TSBK ISP and OSP messages.  Converted
all messages to no longer include the NID (nac + dataunitID) so that
each message can simply hold the parsed values.  Removed AliasList as
an argument to each message and updated all messges to use the new
IIdentifer and IAPCO25Channel interfaces.

Removed legacy TDU and LDU link control messages and replaced with a
single LinkControlWord class hierarchy.

P25 decoder state is not yet updated for the new message structure.

PDU message parsing is not fully implemented.

* WIP - adds some Multi-Block trunking control messages with Alternate
and Unconfirmed formats.

* WIP - Fully implements AMBTC and UMBTC PDU message parsers.

Some package restructuring.

* WIP - Resolves Link control parsing in LDU1 and 2 messages.

* WIP - finishes updating TSBK and Link Control messages.  Adds support
for moto link control messages for patch groups.

* WIP - finishes updating TSBK and Link Control messages.  Adds support
for moto link control messages for patch groups.  Adds support for moto
ARS service, IPV4 decoding, and UDP/IP packets.

* WIP - finishes SNDCP packet data with header parsing.  Compressed IP or
UDP headers are not yet supported, but are logged as such.

* WIP - converts all talkgroup identifiers to integers and updates
alias list to create a per-protocol map of talkgroup id's to alias.

Inserts a legacy talkgroup (ltr, p25, passport, mpt1327, mdc, etc.)
conversion utility to convert existing legacy (string) talkgroups to
new integer talkgroup format.

Creates an audio packet manager to insert metadata into audio packets
before streaming packets for playback, recording, and/or streaming.

Creates identifier collection to manage current identifiers in each of
the channel and decoder states.

Creates simplified channel metadata to maintain the now playing display.

Moves channel attributes (alias list, system, site, name) as configuration
identifiers in the channel state.

Many other refactoring and updates.

* WIP - numerous updates to push use of identifier collection throughout
the system.  Updates the channel metadata and audio packet processing
logic.  Implements a large portion of the P25 decode state processing.
Updates traffic channel management.  Adds user preferences for timestamp
and identifier formatting, however doesn't add a user interface yet.

* WIP - initial implementation of user preferences editor window.

* WIP - updates preferences editor window to close and dispose window but
retain javafx event thread running.

* WIP - fully updates p25 decoder state and traffic channel processing to
use the new identifier framework.

Cleans up channel event processing and removes channel model as the sole
broadcaster of channel events.  Channel processing manager now listens
for all start/stop events and requestors dispatch event directly to the
channel processing manager.

Resolves issue in airspy that was causing user interface to lock-up.  The
issue appears to occur when the dongle is plugged into a usb port that
can't fully support the data rate.  sdrtrunk now recognizes these errors
and warns the user that they should use another usb port.

* WIP - updates alias action manager and adds new talkgroup range alias identifier.

Updates playlist to incorporate a version number so that the playlist
updater only runs when needed, to update a playlist to the correct
version format.

Updates user preferences to use the google event bus to broadcast
preference update notifications to remove the need for listeners to
register directly on the user preferences instance.

* WIP - updates alias id editors to flag invalid values and moves legacy
alias ids to legacy package.

Updates event logging configuration to add traffic channel decode events
and decoded message logging.  Removes binary message logging since that
is now replaced with demodulated bitstream recording.

* Removes system properties from user preferences.  Preferences are stored
in the OS-dependent settings store (windows - registry)

* Updates MapService to use new PlottableDecodeEvent instead of monitoring
all of the decoded messages.

Updates Fleetsync decoder and related messages to identifier framework.

* Updates LTR-Net, Fleetsync and LJ1200 decoders to new identifier
framework and adds support for user preferences for formatting of
LTR-Net and fleetsync talkgroup identifiers.

Breaks LTR-Net messages into various message types and uses a new
message factory.

Removes alias list from message processing for ltr-net, fleetsync and
lj1200.

* Updates LTR-Standard messages to Identifier framework.

* Removes Plottable and IPlottable from codebase.

* wip

* WIP on MPT-1327 messages.

* Updates MPT1327 decoder to identifier framework and new traffic channel
manager.  This decoder still needs to be updated with a new message
parser factory and a sync detector like what is now used for P25.

* Updates MDC1200 decoder and message to identifier framework.

* Updates Tait1200 and Passport decoders to identifier framework.

* Merges changes from master branch.

* Removes legacy alias support classes.  Updates passport message processor
to only pass valid messages.  Adds support to playlist updater for
converting passport mobile ids to become passport talkgroup values.

* Updates P25 decoder state and channel state to better track allocated
traffic channels.  Resolves issue in timestamp manager for trackig
message timestamps. Resolves issue in airspy tuner that was causing
the tuner to stop sending samples to the application.

* Update P25 Decoder state to process SNDCP management messages and
PDU messages.

Updates P25 activity summary to display network and site details.

Resolves issue with overlay panel that prevented enabled channels from
rendering correctly when zoomed in.

* Creates a new FilePreferences as part of the user preferences to begin
the transition of SystemProperties over to user preferences and consolidate
file preferences in one location.

Updates playlist manager to use the new file preferences and to use
default.xml as the new default playlist name, following conversion of
a playlist_v2.xml format to the new format.

In the near future, the user will be able to edit file locations and to
create/use other playlists.

Resolved an issue with all decoder states where not all identifiers were
being included in decode events.
This commit is contained in:
Denny Sheirer
2018-12-24 09:08:34 -05:00
committed by GitHub
parent 735fca16d6
commit b67d4d92dc
869 changed files with 64776 additions and 45233 deletions

View File

@@ -17,10 +17,11 @@
******************************************************************************/
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.sample.Listener;
public interface ActivitySummaryProvider extends Listener<Message>
public interface ActivitySummaryProvider extends Listener<IMessage>
{
public String getActivitySummary();
}

View File

@@ -20,9 +20,12 @@ package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.module.decode.DecoderType;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
public abstract class CallEvent implements Comparable<CallEvent>
@@ -40,8 +43,31 @@ public abstract class CallEvent implements Comparable<CallEvent>
protected String mToID;
protected String mDetails;
//New call event format member variables
protected IChannelDescriptor mChannelDescriptor;
protected Collection<Identifier> mIdentifiers;
private boolean mValid = true;
/**
* Constructs a call event
* @param decoder type
* @param callEventType description
* @param channelDescriptor that identifies the channel and frequency value(s)
* @param identifiers for to, from, comments, etc.
*/
public CallEvent(DecoderType decoder, CallEventType callEventType, IChannelDescriptor channelDescriptor, Collection<Identifier> identifiers)
{
mDecoderType = decoder;
mCallEventType = callEventType;
mChannelDescriptor = channelDescriptor;
mIdentifiers = identifiers;
}
/**
* Legacy call event constructor
*/
@Deprecated //Remove once all decoder states have been updated to new constructor
public CallEvent(DecoderType decoder, CallEventType callEventType, AliasList aliasList, String fromID,
String toID, String details)
{
@@ -53,6 +79,14 @@ public abstract class CallEvent implements Comparable<CallEvent>
mDetails = details;
}
/**
* Identifier collection for this call event
*/
public Collection<Identifier> getIdentifiers()
{
return mIdentifiers;
}
/**
* Indicates if this event is valid. Use this method to mark a previously
* dispatched event as invalid and resend it so that any downstream
@@ -168,7 +202,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
public static String getCSVHeader()
{
return "START_DATE,START_TIME,END_DATE,END_TIME,DECODER,EVENT,FROM,FROM_ALIAS,TO,TO_ALIAS,CHANNEL," +
return "START_DATE,START_TIME,END_DATE,END_TIME,DECODER,EVENT,FROM,FROM_ALIAS,TO,TO_ALIAS,CHANNEL_NUMBER," +
"FREQUENCY,DETAILS";
}
@@ -252,6 +286,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
public enum CallEventType
{
ANNOUNCEMENT("Announcement"),
AUTOMATIC_REGISTRATION_SERVICE("Motorola ARS"),
CALL("Call"),
CALL_ALERT("Call Alert"),
CALL_DETECT("Call Detect"),
@@ -262,6 +297,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
CALL_TIMEOUT("Call Timeout"),
COMMAND("Command"),
DATA_CALL("Data Call"),
DATA_PACKET("Data Packet"),
DEREGISTER("Deregister"),
EMERGENCY("EMERGENCY"),
ENCRYPTED_CALL("Encrypted Call"),
@@ -270,6 +306,7 @@ public abstract class CallEvent implements Comparable<CallEvent>
GROUP_CALL("Group Call"),
ID_ANI("ANI"),
ID_UNIQUE("Unique ID"),
IP_PACKET("IP Packet"),
NOTIFICATION("Notification"),
PAGE("Page"),
PATCH_GROUP_ADD("Patch Group Add"),
@@ -279,10 +316,14 @@ public abstract class CallEvent implements Comparable<CallEvent>
REGISTER("Register"),
REGISTER_ESN("ESN"),
RESPONSE("Response"),
RESPONSE_PACKET("Response Packet"),
SDM("Short Data Message"),
SNDCP_PACKET("SNDCP Packet"),
STATION_ID("Station ID"),
STATUS("Status"),
TCP_PACKET("TCP/IP Packet"),
TELEPHONE_INTERCONNECT("Telephone Interconnect"),
UDP_PACKET("UDP/IP Packet"),
UNIT_TO_UNIT_CALL("Unit To Unit Call"),
UNKNOWN("Unknown"),
INVALID("Invalid");

View File

@@ -1,70 +0,0 @@
/*******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 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.event;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.icon.IconManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
/**
* Custom renderer for JTable cells that contain Alias objects. Renders the
* alias name, and if there is an icon name, attempts to get that icon from
* the settings manager and render it.
*/
public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger(CallEventAliasCellRenderer.class);
private IconManager mIconManager;
public CallEventAliasCellRenderer(IconManager iconManager)
{
super();
mIconManager = iconManager;
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof Alias)
{
Alias alias = (Alias)value;
label.setText(alias.getName());
label.setForeground(alias.getDisplayColor());
label.setIcon(mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
}
else
{
label.setText("");
label.setForeground(table.getForeground());
label.setIcon(null);
}
return label;
}
}

View File

@@ -1,220 +0,0 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.sample.Listener;
import javax.swing.table.AbstractTableModel;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
public class CallEventModel extends AbstractTableModel implements Listener<CallEvent>
{
private static final long serialVersionUID = 1L;
private static DecimalFormat mFrequencyFormatter = new DecimalFormat("0.000000");
public static final int TIME = 0;
public static final int EVENT = 1;
public static final int FROM_ID = 2;
public static final int FROM_ALIAS = 3;
public static final int TO_ID = 4;
public static final int TO_ALIAS = 5;
public static final int CHANNEL = 6;
public static final int FREQUENCY = 7;
public static final int DETAILS = 8;
protected int mMaxMessages = 500;
protected List<CallEvent> mEvents = new ArrayList<CallEvent>();
protected String[] mHeaders = new String[]{"Time",
"Event",
"From",
"Alias",
"To",
"Alias",
"Channel",
"Frequency",
"Details"};
private SimpleDateFormat mSDFTime = new SimpleDateFormat("HH:mm:ss");
public CallEventModel()
{
}
public void dispose()
{
mEvents.clear();
}
public void reset()
{
mEvents.clear();
fireTableDataChanged();
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
public void setMaxMessageCount(int count)
{
mMaxMessages = count;
}
/**
* Adds, updates or deletes the event from the model. Producers can send
* the same call event multiple times to indicate that information in the
* event is updated. Producers can also mark the event as invalid and the
* event will be removed from the model.
*/
public void receive(final CallEvent event)
{
if(event.isValid())
{
if(!mEvents.contains(event))
{
mEvents.add(0, event);
fireTableRowsInserted(0, 0);
prune();
}
else
{
int row = mEvents.indexOf(event);
fireTableRowsUpdated(row, row);
}
}
else
{
if(mEvents.contains(event))
{
int row = mEvents.indexOf(event);
mEvents.remove(event);
fireTableRowsDeleted(row, row);
}
}
}
private void prune()
{
while(mEvents.size() > mMaxMessages)
{
int index = mEvents.size() - 1;
mEvents.remove(index);
fireTableRowsDeleted(index, index);
}
}
@Override
public int getRowCount()
{
return mEvents.size();
}
@Override
public int getColumnCount()
{
return mHeaders.length;
}
public String getColumnName(int column)
{
return mHeaders[column];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
synchronized(mEvents)
{
switch(columnIndex)
{
case TIME:
StringBuilder sb = new StringBuilder();
sb.append(mSDFTime.format(
mEvents.get(rowIndex).getEventStartTime()));
if(mEvents.get(rowIndex).getEventEndTime() != 0)
{
sb.append(" - ");
sb.append(mSDFTime.format(
mEvents.get(rowIndex).getEventEndTime()));
}
else if(mEvents.get(rowIndex)
.getCallEventType() == CallEvent.CallEventType.CALL)
{
sb.append(" - In Progress");
}
return sb.toString();
case EVENT:
return mEvents.get(rowIndex).getCallEventType();
case FROM_ID:
return mEvents.get(rowIndex).getFromID();
case FROM_ALIAS:
return mEvents.get(rowIndex).getFromIDAlias();
case TO_ID:
return mEvents.get(rowIndex).getToID();
case TO_ALIAS:
return mEvents.get(rowIndex).getToIDAlias();
case CHANNEL:
return mEvents.get(rowIndex).getChannel();
case FREQUENCY:
long frequency = mEvents.get(rowIndex).getFrequency();
if(frequency != 0)
{
return mFrequencyFormatter.format((double) frequency / 1E6d);
}
else
{
return null;
}
case DETAILS:
return mEvents.get(rowIndex).getDetails();
}
}
return null;
}
@Override
public Class<?> getColumnClass(int columnIndex)
{
if(columnIndex == FROM_ALIAS || columnIndex == TO_ALIAS)
{
return Alias.class;
}
return super.getColumnClass(columnIndex);
}
}

View File

@@ -1,75 +0,0 @@
/*******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 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.event;
import io.github.dsheirer.icon.IconManager;
import io.github.dsheirer.module.ProcessingChain;
import io.github.dsheirer.sample.Listener;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import java.awt.*;
public class CallEventPanel extends JPanel implements Listener<ProcessingChain>
{
private static final long serialVersionUID = 1L;
private JTable mTable;
private CallEventModel mEmptyCallEventModel = new CallEventModel();
private JScrollPane mEmptyScroller;
private CallEventAliasCellRenderer mRenderer;
/**
* View for call event table
* @param iconManager to display alias icons in table rows
*/
public CallEventPanel(IconManager iconManager)
{
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
mTable = new JTable(mEmptyCallEventModel);
mTable.setAutoCreateRowSorter(true);
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
mRenderer = new CallEventAliasCellRenderer(iconManager);
mEmptyScroller = new JScrollPane(mTable);
add(mEmptyScroller);
}
@Override
public void receive(ProcessingChain processingChain)
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mTable.setModel(processingChain != null ? processingChain.getCallEventModel() : mEmptyCallEventModel);
if(processingChain != null)
{
mTable.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
mTable.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
}
}
});
}
}

View File

@@ -0,0 +1,297 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.protocol.Protocol;
/**
* Decode event implementation. A decode event is a discrete event such as a call or text message
* or radio registration.
*/
public class DecodeEvent implements IDecodeEvent
{
private long mTimeStart;
private long mDuration;
private String mEventDescription;
private IdentifierCollection mIdentifierCollection;
private IChannelDescriptor mChannelDescriptor;
private String mDetails;
private Protocol mProtocol;
public DecodeEvent(long start)
{
mTimeStart = start;
}
/**
* Creates a new decode event builder with the specified start timestamp.
* @param timeStart for the event
* @return builder
*/
public static DecodeEventBuilder builder(long timeStart)
{
return new DecodeEventBuilder(timeStart);
}
/**
* Updates the duration value using the end - start timestamps. Note: this method can be
* invoked multiple times and the duration will be set to the value of the final invocation.
* @param timestamp for end of the event.
*/
public void end(long timestamp)
{
if(timestamp > mTimeStart)
{
mDuration = timestamp - mTimeStart;
}
}
/**
* Updates the current in-progress call with the latest timestamp
*/
public void update(long timestamp)
{
end(timestamp);
}
/**
* Event start in milliseconds
*/
@Override
public long getTimeStart()
{
return mTimeStart;
}
/**
* Event duration in milliseconds
*/
@Override
public long getDuration()
{
return mDuration;
}
/**
* Sets the event duration in milliseconds
*/
public void setDuration(long duration)
{
mDuration = duration;
}
/**
* Event description
*/
@Override
public String getEventDescription()
{
return mEventDescription;
}
/**
* Sets the event description text
*/
public void setEventDescription(String description)
{
mEventDescription = description;
}
/**
* Identifier collection for this event.
*/
@Override
public IdentifierCollection getIdentifierCollection()
{
return mIdentifierCollection;
}
/**
* Sets the identifier collection for this event. Note: identifier collection should contain
* a FrequencyConfigurationIdentifier and optionally an AliasListConfigurationIdentifier so that
* display elements can be properly configured to display the event.
*/
public void setIdentifierCollection(IdentifierCollection identifierCollection)
{
mIdentifierCollection = identifierCollection;
}
/**
* Channel descriptor for the channel
*/
@Override
public IChannelDescriptor getChannelDescriptor()
{
return mChannelDescriptor;
}
/**
* Sets the channel descriptor for the event
*/
public void setChannelDescriptor(IChannelDescriptor channelDescriptor)
{
mChannelDescriptor = channelDescriptor;
}
/**
* Event details text
*/
@Override
public String getDetails()
{
return mDetails;
}
/**
* Sets the event details text
*/
public void setDetails(String details)
{
mDetails = details;
}
/**
* Protocol (ie decoder type) for the event
*/
@Override
public Protocol getProtocol()
{
return mProtocol;
}
/**
* Sets the protocol for the event
*/
public void setProtocol(Protocol protocol)
{
mProtocol = protocol;
}
/**
* Builder pattern for constructing decode events.
*/
public static class DecodeEventBuilder
{
protected long mTimeStart;
protected long mDuration;
protected String mEventDescription;
protected IdentifierCollection mIdentifierCollection;
protected IChannelDescriptor mChannelDescriptor;
protected String mDetails;
protected Protocol mProtocol = Protocol.UNKNOWN;
/**
* Constructs a builder instance with the specified start time in milliseconds
*/
public DecodeEventBuilder(long timeStart)
{
mTimeStart = timeStart;
}
/**
* Sets the duration value
* @param duration in milliseconds
*/
public DecodeEventBuilder duration(long duration)
{
mDuration = duration;
return this;
}
/**
* Sets the duration value using the end - start timestamps
* @param timestamp for end of event
*/
public DecodeEventBuilder end(long timestamp)
{
mDuration = timestamp - mTimeStart;
return this;
}
/**
* Sets the channel descriptor for this event
* @param channelDescriptor
*/
public DecodeEventBuilder channel(IChannelDescriptor channelDescriptor)
{
mChannelDescriptor = channelDescriptor;
return this;
}
/**
* Sets the event description text
* @param description of the event
*/
public DecodeEventBuilder eventDescription(String description)
{
mEventDescription = description;
return this;
}
/**
* Sets the identifier collection.
* @param identifierCollection containing optional identifiers like TO, FROM, frequency and
* alias list configuration name.
*/
public DecodeEventBuilder identifiers(IdentifierCollection identifierCollection)
{
mIdentifierCollection = identifierCollection;
return this;
}
/**
* Sets the details for the event
* @param details
*/
public DecodeEventBuilder details(String details)
{
mDetails = details;
return this;
}
/**
* Sets the protocol for this event
* @param protocol
*/
public DecodeEventBuilder protocol(Protocol protocol)
{
mProtocol = protocol;
return this;
}
/**
* Builds the decode event
*/
public DecodeEvent build()
{
DecodeEvent decodeEvent = new DecodeEvent(mTimeStart);
decodeEvent.setChannelDescriptor(mChannelDescriptor);
decodeEvent.setDetails(mDetails);
decodeEvent.setDuration(mDuration);
decodeEvent.setEventDescription(mEventDescription);
decodeEvent.setIdentifierCollection(mIdentifierCollection);
decodeEvent.setProtocol(mProtocol);
return decodeEvent;
}
}
}

View File

@@ -0,0 +1,222 @@
/*******************************************************************************
* 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/>
******************************************************************************/
package io.github.dsheirer.module.decode.event;
import com.google.common.eventbus.Subscribe;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.sample.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.table.AbstractTableModel;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class DecodeEventModel extends AbstractTableModel implements Listener<IDecodeEvent>
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger(DecodeEventModel.class);
public static final int COLUMN_TIME = 0;
public static final int COLUMN_DURATION = 1;
public static final int COLUMN_EVENT = 2;
public static final int COLUMN_FROM_ID = 3;
public static final int COLUMN_FROM_ALIAS = 4;
public static final int COLUMN_TO_ID = 5;
public static final int COLUMN_TO_ALIAS = 6;
public static final int COLUMN_CHANNEL = 7;
public static final int COLUMN_FREQUENCY = 8;
public static final int COLUMN_DETAILS = 9;
protected int mMaxMessages = 500;
protected List<IDecodeEvent> mEvents = new ArrayList<>();
protected String[] mHeaders = new String[]{"Time", "Duration", "Event", "From", "Alias", "To", "Alias", "Channel", "Frequency", "Details"};
public DecodeEventModel()
{
MyEventBus.getEventBus().register(this);
}
/**
* Receives preference update notifications via the event bus
* @param preferenceType that was updated
*/
@Subscribe
public void preferenceUpdated(PreferenceType preferenceType)
{
if(preferenceType == PreferenceType.DECODE_EVENT)
{
for(int row = 0; row < mEvents.size(); row++)
{
fireTableCellUpdated(row, COLUMN_TIME);
}
}
else if(preferenceType == PreferenceType.IDENTIFIER)
{
for(int row = 0; row < mEvents.size(); row++)
{
fireTableCellUpdated(row, COLUMN_FROM_ID);
fireTableCellUpdated(row, COLUMN_TO_ID);
}
}
}
public void dispose()
{
MyEventBus.getEventBus().unregister(this);
Iterator<IDecodeEvent> it = mEvents.iterator();
while(it.hasNext())
{
it.remove();
}
}
public void reset()
{
dispose();
fireTableDataChanged();
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
public void setMaxMessageCount(int count)
{
mMaxMessages = count;
}
/**
* Adds, updates or deletes the event from the model. Producers can send
* the same call event multiple times to indicate that information in the
* event is updated. Producers can also mark the event as invalid and the
* event will be removed from the model.
*/
public void receive(final IDecodeEvent event)
{
if(!mEvents.contains(event))
{
mEvents.add(0, event);
fireTableRowsInserted(0, 0);
prune();
}
else
{
int row = mEvents.indexOf(event);
fireTableRowsUpdated(row, row);
}
}
private void prune()
{
while(mEvents.size() > mMaxMessages)
{
int index = mEvents.size() - 1;
mEvents.remove(index);
fireTableRowsDeleted(index, index);
}
}
@Override
public int getRowCount()
{
return mEvents.size();
}
@Override
public int getColumnCount()
{
return mHeaders.length;
}
public String getColumnName(int column)
{
return mHeaders[column];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
synchronized(mEvents)
{
IDecodeEvent event = mEvents.get(rowIndex);
if(event != null)
{
switch(columnIndex)
{
case COLUMN_TIME:
return event.getTimeStart();
case COLUMN_DURATION:
return event.getDuration();
case COLUMN_EVENT:
return event.getEventDescription();
case COLUMN_FROM_ID:
return event.getIdentifierCollection();
case COLUMN_FROM_ALIAS:
return event.getIdentifierCollection();
case COLUMN_TO_ID:
return event.getIdentifierCollection();
case COLUMN_TO_ALIAS:
return event.getIdentifierCollection();
case COLUMN_CHANNEL:
return event.getChannelDescriptor();
case COLUMN_FREQUENCY:
return event.getChannelDescriptor();
case COLUMN_DETAILS:
return event.getDetails();
}
}
}
return null;
}
@Override
public Class<?> getColumnClass(int columnIndex)
{
switch(columnIndex)
{
case COLUMN_DURATION:
case COLUMN_TIME:
return Long.class;
case COLUMN_DETAILS:
case COLUMN_EVENT:
return String.class;
case COLUMN_FREQUENCY:
case COLUMN_FROM_ALIAS:
case COLUMN_FROM_ID:
case COLUMN_TO_ALIAS:
case COLUMN_TO_ID:
return IdentifierCollection.class;
case COLUMN_CHANNEL:
return IChannelDescriptor.class;
}
return super.getColumnClass(columnIndex);
}
}

View File

@@ -0,0 +1,411 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
import com.google.common.eventbus.Subscribe;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.AliasModel;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.eventbus.MyEventBus;
import io.github.dsheirer.icon.IconManager;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.module.ProcessingChain;
import io.github.dsheirer.preference.PreferenceType;
import io.github.dsheirer.preference.UserPreferences;
import io.github.dsheirer.sample.Listener;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class DecodeEventPanel extends JPanel implements Listener<ProcessingChain>
{
private final static Logger mLog = LoggerFactory.getLogger(DecodeEventPanel.class);
private static final long serialVersionUID = 1L;
private JTable mTable;
private DecodeEventModel mEmptyDecodeEventModel;
private JScrollPane mEmptyScroller;
private IconManager mIconManager;
private AliasModel mAliasModel;
private UserPreferences mUserPreferences;
private TimestampCellRenderer mTimestampCellRenderer;
/**
* View for call event table
* @param iconManager to display alias icons in table rows
*/
public DecodeEventPanel(IconManager iconManager, UserPreferences userPreferences, AliasModel aliasModel)
{
MyEventBus.getEventBus().register(this);
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
mIconManager = iconManager;
mAliasModel = aliasModel;
mUserPreferences = userPreferences;
mTimestampCellRenderer = new TimestampCellRenderer();
mEmptyDecodeEventModel = new DecodeEventModel();
mTable = new JTable(mEmptyDecodeEventModel);
mTable.setAutoCreateRowSorter(true);
mTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
updateCellRenderers();
mEmptyScroller = new JScrollPane(mTable);
add(mEmptyScroller);
}
/**
* Receives preference update notifications via the event bus
* @param preferenceType that was updated
*/
@Subscribe
public void preferenceUpdated(PreferenceType preferenceType)
{
if(preferenceType == PreferenceType.DECODE_EVENT || preferenceType == PreferenceType.IDENTIFIER)
{
EventQueue.invokeLater(() -> mTimestampCellRenderer.updatePreferences());
}
}
private void updateCellRenderers()
{
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TIME)
.setCellRenderer(mTimestampCellRenderer);
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_DURATION)
.setCellRenderer(new DurationCellRenderer());
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ID)
.setCellRenderer(new IdentifierCellRenderer(Role.FROM));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FROM_ALIAS)
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.FROM));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ID)
.setCellRenderer(new IdentifierCellRenderer(Role.TO));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_TO_ALIAS)
.setCellRenderer(new AliasedIdentifierCellRenderer(Role.TO));
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_CHANNEL)
.setCellRenderer(new ChannelDescriptorCellRenderer());
mTable.getColumnModel().getColumn(DecodeEventModel.COLUMN_FREQUENCY)
.setCellRenderer(new FrequencyCellRenderer());
}
@Override
public void receive(ProcessingChain processingChain)
{
EventQueue.invokeLater(() -> {
mTable.setModel(processingChain != null ? processingChain.getDecodeEventModel() : mEmptyDecodeEventModel);
if(processingChain != null)
{
updateCellRenderers();
}
});
}
/**
* Custom cell renderer for displaying identifiers from an identifier collection
*/
public class IdentifierCellRenderer extends DefaultTableCellRenderer
{
protected Role mRole;
/**
* Constructs an instance of the cell renderer.
*
* @param role of the identifier
*/
public IdentifierCellRenderer(Role role)
{
mRole = role;
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof IdentifierCollection)
{
List<Identifier> identifiers = ((IdentifierCollection)value).getIdentifiers(mRole);
// if(identifiers.size() > 1)
// {
// StringBuilder sb = new StringBuilder();
// sb.append("Multiple Identifiers:\n");
// for(Identifier identifier: identifiers)
// {
// sb.append("ID:").append(identifier.debug()).append("\n");
// }
// mLog.debug(sb.toString());
// }
label.setText(format(identifiers));
}
else
{
label.setText(null);
}
return label;
}
/**
* Formats a list of identifiers as a comma separated list of values
* @param identifiers to format
* @return formatted list or null
*/
protected String format(List<Identifier> identifiers)
{
if(identifiers == null || identifiers.isEmpty())
{
return null;
}
StringBuilder sb = new StringBuilder();
for(Identifier identifier: identifiers)
{
if(sb.length() > 0)
{
sb.append(",");
}
sb.append(mUserPreferences.getTalkgroupFormatPreference().format(identifier));
}
return sb.toString();
}
}
/**
* Cell renderer for identifier aliases
*/
public class AliasedIdentifierCellRenderer extends DefaultTableCellRenderer
{
private Role mRole;
/**
* Constructs an instance of the cell renderer.
*
* @param role of the identifier
*/
public AliasedIdentifierCellRenderer(Role role)
{
mRole = role;
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
Color color = mTable.getForeground();
ImageIcon icon = null;
String text = null;
if(value instanceof IdentifierCollection)
{
IdentifierCollection identifierCollection = (IdentifierCollection)value;
List<Identifier> identifiers = identifierCollection.getIdentifiers(mRole);
if(identifiers != null && !identifiers.isEmpty())
{
AliasList aliasList = mAliasModel.getAliasList(identifierCollection);
if(aliasList != null)
{
StringBuilder sb = new StringBuilder();
for(Identifier identifier: identifiers)
{
Alias alias = aliasList.getAlias(identifier);
if(alias != null)
{
if(sb.length() > 0)
{
sb.append(",");
}
sb.append(alias.getName());
color = alias.getDisplayColor();
icon = mIconManager.getIcon(alias.getIconName(), IconManager.DEFAULT_ICON_SIZE);
}
}
text = sb.toString();
}
}
}
label.setText(text);
label.setForeground(color);
label.setIcon(icon);
return label;
}
}
public class TimestampCellRenderer extends DefaultTableCellRenderer
{
private SimpleDateFormat mTimestampFormatter;
public TimestampCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
updatePreferences();
}
public void updatePreferences()
{
mTimestampFormatter = mUserPreferences.getDecodeEventPreference().getTimestampFormat().getFormatter();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof Long)
{
label.setText(mTimestampFormatter.format(new Date((long)value)));
}
else
{
label.setText(null);
}
return label;
}
}
public class DurationCellRenderer extends DefaultTableCellRenderer
{
private DecimalFormat mDecimalFormat = new DecimalFormat("0.0");
public DurationCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String formatted = null;
if(value instanceof Long)
{
long duration = (long)value;
if(duration > 0)
{
formatted = mDecimalFormat.format((double)duration / 1e3d);
}
}
label.setText(formatted);
return label;
}
}
/**
* Frequency value cell renderer
*/
public class FrequencyCellRenderer extends DefaultTableCellRenderer
{
private DecimalFormat mFrequencyFormatter = new DecimalFormat("0.00000 MHz");
public FrequencyCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
String formatted = null;
if(value instanceof IChannelDescriptor)
{
IChannelDescriptor channelDescriptor = (IChannelDescriptor)value;
long frequency = channelDescriptor.getDownlinkFrequency();
if(frequency > 0)
{
formatted = mFrequencyFormatter.format(frequency / 1e6d);
}
}
label.setText(formatted);
return label;
}
}
/**
* Channel descriptor value cell renderer
*/
public class ChannelDescriptorCellRenderer extends DefaultTableCellRenderer
{
public ChannelDescriptorCellRenderer()
{
setHorizontalAlignment(JLabel.CENTER);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
{
JLabel label = (JLabel)super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(value instanceof IChannelDescriptor)
{
label.setText(value.toString());
}
else
{
label.setText(null);
}
return label;
}
}
}

View File

@@ -0,0 +1,85 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
public enum DecodeEventType
{
ANNOUNCEMENT("Announcement"),
AUTOMATIC_REGISTRATION_SERVICE("Motorola ARS"),
CALL("Call"),
CALL_ENCRYPTED("Encrypted Call"),
CALL_GROUP("Group Call"),
CALL_GROUP_ENCRYPTED("Encrypted Group Call"),
CALL_PATCH_GROUP("Patch Call"),
CALL_PATCH_GROUP_ENCRYPTED("Encrypted Patch Call"),
CALL_ALERT("Call Alert"),
CALL_DETECT("Call Detect"),
CALL_DO_NOT_MONITOR("Call-Do Not Monitor"),
CALL_END("Call End"),
CALL_INTERCONNECT("Telephone Call"),
CALL_INTERCONNECT_ENCRYPTED("Encrypted Telephone Call"),
CALL_UNIQUE_ID("UID Call"),
CALL_UNIT_TO_UNIT("Unit To Unit Call"),
CALL_UNIT_TO_UNIT_ENCRYPTED("Encrypted Unit To Unit Call"),
CALL_NO_TUNER("Call - No Tuner"),
CALL_TIMEOUT("Call Timeout"),
COMMAND("Command"),
DATA_CALL("Data Call"),
DATA_CALL_ENCRYPTED("Encrypted Data Call"),
DATA_PACKET("Data Packet"),
DEREGISTER("Deregister"),
EMERGENCY("EMERGENCY"),
FUNCTION("Function"),
GPS("GPS"),
ID_ANI("ANI"),
ID_UNIQUE("Unique ID"),
IP_PACKET("IP Packet"),
NOTIFICATION("Notification"),
PAGE("Page"),
QUERY("Query"),
REGISTER("Register"),
REGISTER_ESN("ESN"),
REQUEST("Request"),
RESPONSE("Response"),
RESPONSE_PACKET("Response Packet"),
SDM("Short Data Message"),
STATION_ID("Station ID"),
STATUS("Status"),
UDP_PACKET("UDP/IP Packet"),
UNKNOWN("Unknown");
private String mLabel;
DecodeEventType(String label)
{
mLabel = label;
}
public String getLabel()
{
return mLabel;
}
public String toString()
{
return mLabel;
}
}

View File

@@ -1,8 +0,0 @@
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.sample.Listener;
public interface ICallEventListener
{
public Listener<CallEvent> getCallEventListener();
}

View File

@@ -1,9 +0,0 @@
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.sample.Listener;
public interface ICallEventProvider
{
public void addCallEventListener( Listener<CallEvent> listener );
public void removeCallEventListener( Listener<CallEvent> listener );
}

View File

@@ -0,0 +1,74 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.protocol.Protocol;
/**
* Decode event interface
*/
public interface IDecodeEvent
{
/**
* Event start time
*
* @return timestamp in milliseconds
*/
long getTimeStart();
/**
* Event duration.
*
* @return event duration in milliseconds or 0 if there is no duration
*/
long getDuration();
/**
* A description of the event or event type
*/
String getEventDescription();
/**
* Collection of identifiers associated with the event. This collection should contain a
* Role.FROM and a Role.TO identifier, a Decoder Type identifier, and (optionally) an Alias List
* Configuration identifier.
*/
IdentifierCollection getIdentifierCollection();
/**
* Channel descriptor for the channel where the event occurred
*
* @return descriptor or null
*/
IChannelDescriptor getChannelDescriptor();
/**
* Optional Details about the event
*/
String getDetails();
/**
* Protocol for the decoder that produced the event
*/
Protocol getProtocol();
}

View File

@@ -0,0 +1,28 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
import io.github.dsheirer.sample.Listener;
public interface IDecodeEventListener
{
Listener<IDecodeEvent> getDecodeEventListener();
}

View File

@@ -0,0 +1,9 @@
package io.github.dsheirer.module.decode.event;
import io.github.dsheirer.sample.Listener;
public interface IDecodeEventProvider
{
void addDecodeEventListener(Listener<IDecodeEvent> listener );
void removeDecodeEventListener(Listener<IDecodeEvent> listener );
}

View File

@@ -1,193 +1,180 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014-2016 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.event;
import io.github.dsheirer.filter.FilterSet;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.sample.Listener;
import javax.swing.table.AbstractTableModel;
import java.awt.*;
import java.awt.EventQueue;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
public class MessageActivityModel extends AbstractTableModel
implements Listener<Message>
public class MessageActivityModel extends AbstractTableModel implements Listener<IMessage>
{
private static final long serialVersionUID = 1L;
private static final int TIME = 0;
private static final int PROTOCOL = 1;
private static final int ERROR_STATUS = 2;
private static final int MESSAGE = 3;
private static final int MESSAGE_BITS = 4;
private static final int MESSAGE = 2;
protected int mMaxMessages = 500;
protected LinkedList<Message> mMessages = new LinkedList<Message>();
protected int mMaxMessages = 500;
protected LinkedList<MessageItem> mMessageItems = new LinkedList<>();
protected int[] mColumnWidths = {20, 20, 500};
protected String[] mHeaders = new String[]{"Time", "Protocol", "Message"};
protected int[] mColumnWidths = { 110, 110, 110, -1, -1 };
private SimpleDateFormat mSDFTime = new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
protected String[] mHeaders = new String[] { "Time",
"Protocol",
"Error Check",
"Message",
"Binary" };
private FilterSet<IMessage> mMessageFilter;
private SimpleDateFormat mSDFTime = new SimpleDateFormat( "HH:mm:ss" );
private boolean mNewMessagesFirst = true;
private FilterSet<Message> mMessageFilter;
public MessageActivityModel( FilterSet<Message> messageFilter )
{
mMessageFilter = messageFilter;
}
public MessageActivityModel()
{
}
/**
* Clears all messages from history
*/
public void clear()
{
EventQueue.invokeLater( new Runnable()
{
@Override
public MessageActivityModel(FilterSet<IMessage> messageFilter)
{
mMessageFilter = messageFilter;
}
public MessageActivityModel()
{
}
/**
* Clears all messages from history
*/
public void clear()
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
int messageCount = mMessages.size();
mMessages.clear();
int messageCount = mMessageItems.size();
fireTableRowsDeleted( 0, messageCount - 1 );
mMessageItems.clear();
fireTableRowsDeleted(0, messageCount - 1);
}
});
}
public FilterSet<Message> getMessageFilter()
{
return mMessageFilter;
}
public void dispose()
{
mMessages.clear();
}
public int[] getColumnWidths()
{
return mColumnWidths;
}
public void setColumnWidths( int[] widths )
{
if( widths.length != 5 )
{
throw new IllegalArgumentException( "MessageActivityModel - "
+ "column widths array should have 5 elements" );
}
else
{
mColumnWidths = widths;
}
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
});
}
public void setMaxMessageCount( int count )
{
mMaxMessages = count;
}
public void receive( final Message message )
{
if( message.isValid() && mMessageFilter.passes( message ) )
{
EventQueue.invokeLater( new Runnable()
{
@Override
public void run()
{
mMessages.addFirst( message );
public FilterSet<IMessage> getMessageFilter()
{
return mMessageFilter;
}
MessageActivityModel.this.fireTableRowsInserted( 0, 0 );
public void dispose()
{
mMessageItems.clear();
}
prune();
}
} );
}
}
private void prune()
{
while( mMessages.size() > mMaxMessages )
{
mMessages.removeLast();
super.fireTableRowsDeleted( mMessages.size() - 1, mMessages.size() - 1 );
}
}
public int[] getColumnWidths()
{
return mColumnWidths;
}
@Override
public void setColumnWidths(int[] widths)
{
if(widths.length != 3)
{
throw new IllegalArgumentException("MessageActivityModel - column widths array should have 3 elements");
}
else
{
mColumnWidths = widths;
}
}
public int getMaxMessageCount()
{
return mMaxMessages;
}
public void setMaxMessageCount(int count)
{
mMaxMessages = count;
}
public void receive(final IMessage message)
{
if(mMessageFilter.passes(message))
{
final MessageItem messageItem = new MessageItem(message);
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mMessageItems.addFirst(messageItem);
MessageActivityModel.this.fireTableRowsInserted(0, 0);
prune();
}
});
}
}
private void prune()
{
while(mMessageItems.size() > mMaxMessages)
{
MessageItem removed = mMessageItems.removeLast();
removed.dispose();
super.fireTableRowsDeleted(mMessageItems.size() - 1, mMessageItems.size() - 1);
}
}
@Override
public int getRowCount()
{
return mMessages.size();
return mMessageItems.size();
}
@Override
@Override
public int getColumnCount()
{
return mHeaders.length;
return mHeaders.length;
}
public String getColumnName( int column )
{
return mHeaders[ column ];
}
@Override
public Object getValueAt( int rowIndex, int columnIndex )
public String getColumnName(int column)
{
if( 0 <= rowIndex && rowIndex < mMessages.size() )
{
Message message = mMessages.get( rowIndex );
switch( columnIndex )
{
case TIME:
return mSDFTime.format( new Date( message.getTimeReceived() ) );
case PROTOCOL:
return message.getProtocol();
case ERROR_STATUS:
return message.getErrorStatus();
case MESSAGE:
return message.getMessage();
case MESSAGE_BITS:
return message.getBinaryMessage();
}
}
return null;
return mHeaders[column];
}
@Override
public Object getValueAt(int rowIndex, int columnIndex)
{
if(0 <= rowIndex && rowIndex < mMessageItems.size())
{
MessageItem messageItem = mMessageItems.get(rowIndex);
switch(columnIndex)
{
case TIME:
return messageItem.getTimestamp(mSDFTime);
case PROTOCOL:
return messageItem.getProtocol();
case MESSAGE:
return messageItem.getText();
default:
break;
}
}
return null;
}
}

View File

@@ -23,7 +23,7 @@ import com.jidesoft.swing.JideSplitButton;
import io.github.dsheirer.controller.channel.ChannelProcessingManager;
import io.github.dsheirer.filter.FilterEditorPanel;
import io.github.dsheirer.filter.FilterSet;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.module.ProcessingChain;
import io.github.dsheirer.sample.Listener;
import net.miginfocom.swing.MigLayout;
@@ -81,6 +81,10 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
{
mTable.setModel(processingChain != null ? processingChain.getMessageActivityModel() : EMPTY_MODEL);
mTable.getColumnModel().getColumn(0).setPreferredWidth(18);
mTable.getColumnModel().getColumn(1).setPreferredWidth(15);
mTable.getColumnModel().getColumn(2).setPreferredWidth(600);
if(processingChain != null)
{
mManagementPanel.enableButtons();
@@ -170,13 +174,13 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
}
});
slider.setValue(((MessageActivityModel)mTable.getModel()).getMaxMessageCount());
slider.setValue(((MessageActivityModel) mTable.getModel()).getMaxMessageCount());
slider.addChangeListener(new ChangeListener()
{
@Override
public void stateChanged(ChangeEvent arg0)
{
((MessageActivityModel)mTable.getModel()).setMaxMessageCount(slider.getValue());
((MessageActivityModel) mTable.getModel()).setMaxMessageCount(slider.getValue());
}
});
@@ -184,13 +188,13 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
add(historyPanel);
/* Clear messages */
/* Clear messages */
addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
((MessageActivityModel)mTable.getModel()).clear();
((MessageActivityModel) mTable.getModel()).clear();
}
});
}
@@ -216,12 +220,13 @@ public class MessageActivityPanel extends JPanel implements Listener<ProcessingC
editor.setLocationRelativeTo(MessageFilterButton.this);
editor.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
editor.setLayout(new MigLayout("", "[grow,fill]",
"[grow,fill][][]"));
"[grow,fill][][]"));
@SuppressWarnings("unchecked")
FilterSet<Message> filter = (FilterSet<Message>) ((MessageActivityModel)mTable.getModel()).getMessageFilter();
FilterSet<IMessage> filter = (FilterSet<IMessage>) ((MessageActivityModel) mTable.getModel())
.getMessageFilter();
FilterEditorPanel<Message> panel = new FilterEditorPanel<Message>(filter);
FilterEditorPanel<IMessage> panel = new FilterEditorPanel<>(filter);
JScrollPane scroller = new JScrollPane(panel);
scroller.setViewportView(panel);

View File

@@ -0,0 +1,97 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
import io.github.dsheirer.message.IMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Simple message carrier class that persists activity model column values so that they do not need
* to be recalculated with each row update.
*/
public class MessageItem
{
private final static Logger mLog = LoggerFactory.getLogger(MessageItem.class);
private IMessage mMessage;
private String mTimestamp;
private String mProtocol;
private String mText;
public MessageItem(IMessage message)
{
mMessage = message;
}
public IMessage getMessage()
{
return mMessage;
}
public void dispose()
{
mMessage = null;
mTimestamp = null;
mProtocol = null;
mText = null;
}
public String getTimestamp(SimpleDateFormat simpleDateFormat)
{
if(mTimestamp == null)
{
mTimestamp = simpleDateFormat.format(new Date(getMessage().getTimestamp()));
}
return mTimestamp;
}
public String getText()
{
if(mText == null)
{
try
{
mText = getMessage().toString();
}
catch(Throwable t)
{
mLog.error("Error accessing message toString() method - protocol [" + getProtocol() + "]", t);
mText = "MESSAGE ITEM ENCOUNTERED PARSING ERROR";
}
}
return mText;
}
public String getProtocol()
{
if(mProtocol == null)
{
mProtocol = getMessage().getProtocol().toString();
}
return mProtocol;
}
}

View File

@@ -0,0 +1,239 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 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.event;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.IdentifierCollection;
import io.github.dsheirer.protocol.Protocol;
import org.jdesktop.swingx.mapviewer.GeoPosition;
public class PlottableDecodeEvent extends DecodeEvent
{
private GeoPosition mGeoPosition;
private double mHeading;
private double mSpeed;
public PlottableDecodeEvent(long start)
{
super(start);
}
/**
* Creates a new decode event builder with the specified start timestamp.
* @param timeStart for the event
* @return builder
*/
public static PlottableDecodeEventBuilder plottableBuilder(long timeStart)
{
return new PlottableDecodeEventBuilder(timeStart);
}
/**
* Sets the location for the event
*/
public void setLocation(GeoPosition geoPosition)
{
mGeoPosition = geoPosition;
}
/**
* Location of the event
*/
public GeoPosition getLocation()
{
return mGeoPosition;
}
/**
* Sets the heading for the mobile plottable event
* @param heading
*/
public void setHeading(double heading)
{
mHeading = heading;
}
/**
* Heading of the mobile plottable event
*/
public double getHeading()
{
return mHeading;
}
/**
* Sets the speed of the mobile plottable event in kph
*/
public void setSpeed(double speed)
{
mSpeed = speed;
}
/**
* Speed of the mobile plottable event in kph
*/
public double getSpeed()
{
return mSpeed;
}
/**
* Builder pattern for constructing decode events.
*/
public static class PlottableDecodeEventBuilder
{
private long mTimeStart;
private long mDuration;
private String mEventDescription;
private IdentifierCollection mIdentifierCollection;
private IChannelDescriptor mChannelDescriptor;
private String mDetails;
private Protocol mProtocol = Protocol.UNKNOWN;
private GeoPosition mGeoPosition;
private double mHeading;
private double mSpeed;
/**
* Constructs a builder instance with the specified start time in milliseconds
*/
public PlottableDecodeEventBuilder(long timeStart)
{
mTimeStart = timeStart;
}
/**
* Sets the duration value
* @param duration in milliseconds
*/
public PlottableDecodeEventBuilder duration(long duration)
{
mDuration = duration;
return this;
}
/**
* Sets the duration value using the end - start timestamps
* @param timestamp for end of event
*/
public PlottableDecodeEventBuilder end(long timestamp)
{
mDuration = timestamp - mTimeStart;
return this;
}
/**
* Sets the channel descriptor for this event
* @param channelDescriptor
*/
public PlottableDecodeEventBuilder channel(IChannelDescriptor channelDescriptor)
{
mChannelDescriptor = channelDescriptor;
return this;
}
/**
* Sets the event description text
* @param description of the event
*/
public PlottableDecodeEventBuilder eventDescription(String description)
{
mEventDescription = description;
return this;
}
/**
* Sets the identifier collection.
* @param identifierCollection containing optional identifiers like TO, FROM, frequency and
* alias list configuration name.
*/
public PlottableDecodeEventBuilder identifiers(IdentifierCollection identifierCollection)
{
mIdentifierCollection = identifierCollection;
return this;
}
/**
* Sets the details for the event
* @param details
*/
public PlottableDecodeEventBuilder details(String details)
{
mDetails = details;
return this;
}
/**
* Sets the protocol for this event
* @param protocol
*/
public PlottableDecodeEventBuilder protocol(Protocol protocol)
{
mProtocol = protocol;
return this;
}
/**
* Sets the location for the plottable event
*/
public PlottableDecodeEventBuilder location(GeoPosition geoPosition)
{
mGeoPosition = geoPosition;
return this;
}
/**
* Sets the speed for the plottable event in kph
*/
public PlottableDecodeEventBuilder speed(double speed)
{
mSpeed = speed;
return this;
}
/**
* Sets the heading for the plottable event in degrees relative to true North
*/
public PlottableDecodeEventBuilder heading(double heading)
{
mHeading = heading;
return this;
}
/**
* Builds the decode event
*/
public PlottableDecodeEvent build()
{
PlottableDecodeEvent decodeEvent = new PlottableDecodeEvent(mTimeStart);
decodeEvent.setChannelDescriptor(mChannelDescriptor);
decodeEvent.setDetails(mDetails);
decodeEvent.setDuration(mDuration);
decodeEvent.setEventDescription(mEventDescription);
decodeEvent.setIdentifierCollection(mIdentifierCollection);
decodeEvent.setProtocol(mProtocol);
decodeEvent.setLocation(mGeoPosition);
decodeEvent.setHeading(mHeading);
decodeEvent.setSpeed(mSpeed);
return decodeEvent;
}
}
}