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

@@ -1,62 +0,0 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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.log;
import io.github.dsheirer.module.decode.event.CallEvent;
import io.github.dsheirer.module.decode.event.ICallEventListener;
import io.github.dsheirer.sample.Listener;
import java.nio.file.Path;
public class CallEventLogger extends EventLogger implements ICallEventListener,
Listener<CallEvent>
{
public CallEventLogger( Path logDirectory, String fileNameSuffix )
{
super( logDirectory, fileNameSuffix );
}
@Override
public void receive( CallEvent callEvent )
{
write( callEvent.toCSV() );
}
@Override
public String getHeader()
{
return CallEvent.getCSVHeader();
}
@Override
public Listener<CallEvent> getCallEventListener()
{
return this;
}
@Override
public void dispose()
{
super.stop();
}
@Override
public void reset()
{
}
}

View File

@@ -0,0 +1,136 @@
/*
* ******************************************************************************
* 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.log;
import io.github.dsheirer.channel.IChannelDescriptor;
import io.github.dsheirer.identifier.Form;
import io.github.dsheirer.identifier.Identifier;
import io.github.dsheirer.identifier.IdentifierClass;
import io.github.dsheirer.identifier.Role;
import io.github.dsheirer.identifier.configuration.FrequencyConfigurationIdentifier;
import io.github.dsheirer.module.decode.event.IDecodeEvent;
import io.github.dsheirer.module.decode.event.IDecodeEventListener;
import io.github.dsheirer.preference.TimestampFormat;
import io.github.dsheirer.sample.Listener;
import java.nio.file.Path;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
public class DecodeEventLogger extends EventLogger implements IDecodeEventListener, Listener<IDecodeEvent>
{
private SimpleDateFormat mTimestampFormat = TimestampFormat.TIMESTAMP_COLONS.getFormatter();
private DecimalFormat mFrequencyFormat = new DecimalFormat("0.000000");
public DecodeEventLogger(Path logDirectory, String fileNameSuffix, long frequency)
{
super(logDirectory, fileNameSuffix, frequency);
}
@Override
public void receive(IDecodeEvent decodeEvent)
{
write(toCSV(decodeEvent));
}
@Override
public String getHeader()
{
return getCSVHeader();
}
@Override
public Listener<IDecodeEvent> getDecodeEventListener()
{
return this;
}
@Override
public void dispose()
{
super.stop();
}
@Override
public void reset()
{
}
public static String getCSVHeader()
{
return "TIMESTAMP,DURATION_MS,PROTOCOL,EVENT,FROM,TO,CHANNEL_NUMBER,FREQUENCY,DETAILS";
}
private String toCSV(IDecodeEvent event)
{
StringBuilder sb = new StringBuilder();
sb.append("\"").append(mTimestampFormat.format(new Date(event.getTimeStart()))).append("\"");
sb.append(",\"").append(event.getDuration() > 0 ? event.getDuration() : "").append("\"");
sb.append(",\"").append(event.getProtocol()).append("\"");
String description = event.getEventDescription();
sb.append(",\"").append(description != null ? description : "").append("\"");
List<Identifier> fromIdentifiers = event.getIdentifierCollection().getIdentifiers(Role.FROM);
if(fromIdentifiers != null && !fromIdentifiers.isEmpty())
{
sb.append(",\"").append(fromIdentifiers.get(0)).append("\"");
}
else
{
sb.append(",\"\"");
}
List<Identifier> toIdentifiers = event.getIdentifierCollection().getIdentifiers(Role.TO);
if(toIdentifiers != null && !toIdentifiers.isEmpty())
{
sb.append(",\"").append(toIdentifiers.get(0)).append("\"");
}
else
{
sb.append(",\"\"");
}
IChannelDescriptor descriptor = event.getChannelDescriptor();
sb.append(",\"").append(descriptor != null ? descriptor : "").append("\"");
Identifier frequency = event.getIdentifierCollection().getIdentifier(IdentifierClass.CONFIGURATION, Form.CHANNEL_FREQUENCY, Role.ANY);
if(frequency instanceof FrequencyConfigurationIdentifier)
{
sb.append(",\"").append(mFrequencyFormat.format(((FrequencyConfigurationIdentifier)frequency).getValue() / 1e6d)).append("\"");
}
else
{
sb.append(",\"\"");
}
String details = event.getDetails();
sb.append(",\"").append(details != null ? details : "").append("\"");
return sb.toString();
}
}

View File

@@ -1,20 +1,22 @@
/*******************************************************************************
* 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/>
******************************************************************************/
/*
* ******************************************************************************
* 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.log;
import io.github.dsheirer.controller.channel.Channel;
@@ -22,7 +24,7 @@ import io.github.dsheirer.gui.editor.Editor;
import io.github.dsheirer.module.log.config.EventLogConfiguration;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.JCheckBox;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
@@ -30,121 +32,144 @@ import java.util.List;
public class EventLogConfigurationEditor extends Editor<Channel>
{
private static final long serialVersionUID = 1L;
private JCheckBox mBinaryLogger;
private JCheckBox mDecodedLogger;
private JCheckBox mCallEventLogger;
private JCheckBox mDecodedMessageLogger;
private JCheckBox mTrafficCallEventLogger;
private JCheckBox mTrafficDecodedMessageLogger;
public EventLogConfigurationEditor()
{
init();
}
{
init();
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 4", "", "[][grow]" ) );
setLayout(new MigLayout("fill,wrap 2", "", "[][][grow]"));
mBinaryLogger = new JCheckBox( "Binary Messages" );
mBinaryLogger.setEnabled( false );
mBinaryLogger.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
setModified( true );
}
} );
add( mBinaryLogger );
mDecodedLogger = new JCheckBox( "Decoded Messages" );
mDecodedLogger.setEnabled( false );
mDecodedLogger.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
setModified( true );
}
} );
add( mDecodedLogger );
mCallEventLogger = new JCheckBox( "Call Events" );
mCallEventLogger.setEnabled( false );
mCallEventLogger.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
setModified( true );
}
} );
add( mCallEventLogger );
mCallEventLogger = new JCheckBox("Call Events");
mCallEventLogger.setEnabled(false);
mCallEventLogger.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
setModified(true);
}
});
add(mCallEventLogger);
mDecodedMessageLogger = new JCheckBox("Decoded Messages");
mDecodedMessageLogger.setEnabled(false);
mDecodedMessageLogger.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
setModified(true);
}
});
add(mDecodedMessageLogger);
mTrafficCallEventLogger = new JCheckBox("Traffic Channel Call Events");
mTrafficCallEventLogger.setEnabled(false);
mTrafficCallEventLogger.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
setModified(true);
}
});
add(mTrafficCallEventLogger);
mTrafficDecodedMessageLogger = new JCheckBox("Traffic Channel Decoded Messages");
mTrafficDecodedMessageLogger.setEnabled(false);
mTrafficDecodedMessageLogger.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
setModified(true);
}
});
add(mTrafficDecodedMessageLogger);
}
/**
* Saves the current configuration as the stored configuration
*/
@Override
@Override
public void save()
{
if( hasItem() )
{
EventLogConfiguration config = getItem().getEventLogConfiguration();
if(hasItem())
{
EventLogConfiguration config = getItem().getEventLogConfiguration();
config.clear();
if( mBinaryLogger.isSelected() )
{
config.addLogger( EventLogType.BINARY_MESSAGE );
}
if( mDecodedLogger.isSelected() )
{
config.addLogger( EventLogType.DECODED_MESSAGE );
}
if( mCallEventLogger.isSelected() )
{
config.addLogger( EventLogType.CALL_EVENT );
}
}
setModified( false );
config.clear();
if(mCallEventLogger.isSelected())
{
config.addLogger(EventLogType.CALL_EVENT);
}
if(mDecodedMessageLogger.isSelected())
{
config.addLogger(EventLogType.DECODED_MESSAGE);
}
if(mTrafficCallEventLogger.isSelected())
{
config.addLogger(EventLogType.TRAFFIC_CALL_EVENT);
}
if(mTrafficDecodedMessageLogger.isSelected())
{
config.addLogger(EventLogType.TRAFFIC_DECODED_MESSAGE);
}
}
setModified(false);
}
@Override
public void setItem( Channel channel )
{
super.setItem( channel );
@Override
public void setItem(Channel channel)
{
super.setItem(channel);
if( hasItem() )
{
setControlsEnabled( true );
if(hasItem())
{
setControlsEnabled(true);
List<EventLogType> loggers = getItem().getEventLogConfiguration().getLoggers();
mBinaryLogger.setSelected( loggers.contains( EventLogType.BINARY_MESSAGE ) );
mDecodedLogger.setSelected( loggers.contains( EventLogType.DECODED_MESSAGE ) );
mCallEventLogger.setSelected( loggers.contains( EventLogType.CALL_EVENT ) );
}
else
{
setControlsEnabled( false );
}
}
private void setControlsEnabled( boolean enabled )
{
if( mBinaryLogger.isEnabled() != enabled )
{
mBinaryLogger.setEnabled( enabled );
}
if( mDecodedLogger.isEnabled() != enabled )
{
mDecodedLogger.setEnabled( enabled );
}
if( mCallEventLogger.isEnabled() != enabled )
{
mCallEventLogger.setEnabled( enabled );
}
}
List<EventLogType> loggers = getItem().getEventLogConfiguration().getLoggers();
mDecodedMessageLogger.setSelected(loggers.contains(EventLogType.DECODED_MESSAGE));
mCallEventLogger.setSelected(loggers.contains(EventLogType.CALL_EVENT));
mTrafficCallEventLogger.setSelected(loggers.contains(EventLogType.TRAFFIC_CALL_EVENT));
mTrafficDecodedMessageLogger.setSelected(loggers.contains(EventLogType.TRAFFIC_DECODED_MESSAGE));
}
else
{
setControlsEnabled(false);
}
}
private void setControlsEnabled(boolean enabled)
{
if(mDecodedMessageLogger.isEnabled() != enabled)
{
mDecodedMessageLogger.setEnabled(enabled);
}
if(mCallEventLogger.isEnabled() != enabled)
{
mCallEventLogger.setEnabled(enabled);
}
if(mTrafficDecodedMessageLogger.isEnabled() != enabled)
{
mTrafficDecodedMessageLogger.setEnabled(enabled);
}
if(mTrafficCallEventLogger.isEnabled() != enabled)
{
mTrafficCallEventLogger.setEnabled(enabled);
}
}
}

View File

@@ -1,6 +1,7 @@
/*******************************************************************************
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
* 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
@@ -14,13 +15,16 @@
*
* 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.log;
import io.github.dsheirer.controller.channel.Channel;
import io.github.dsheirer.module.Module;
import io.github.dsheirer.module.log.config.EventLogConfiguration;
import io.github.dsheirer.properties.SystemProperties;
import io.github.dsheirer.source.config.SourceConfigTuner;
import io.github.dsheirer.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,46 +34,73 @@ import java.util.List;
public class EventLogManager
{
private final static Logger mLog = LoggerFactory.getLogger(EventLogManager.class);
private final static Logger mLog = LoggerFactory.getLogger(EventLogManager.class);
private Path mDirectory;
public EventLogManager()
{
mDirectory = SystemProperties.getInstance()
.getApplicationFolder( "event_logs" );
}
private Path mDirectory;
public List<Module> getLoggers(EventLogConfiguration config, String prefix )
{
List<Module> loggers = new ArrayList<Module>();
public EventLogManager()
{
mDirectory = SystemProperties.getInstance()
.getApplicationFolder("event_logs");
}
for( EventLogType type: config.getLoggers() )
{
loggers.add( getLogger( type, prefix ) );
}
public List<Module> getLoggers(Channel channel)
{
EventLogConfiguration config = channel.getEventLogConfiguration();
String prefix = StringUtils.replaceIllegalCharacters(channel.getName());
long frequency = 0;
return loggers;
}
public EventLogger getLogger( EventLogType eventLogType, String prefix )
{
StringBuilder sb = new StringBuilder();
if(channel.getSourceConfiguration() instanceof SourceConfigTuner)
{
frequency = ((SourceConfigTuner)channel.getSourceConfiguration()).getFrequency();
}
sb.append( prefix );
sb.append( eventLogType.getFileSuffix() );
sb.append( ".log" );
List<Module> loggers = new ArrayList<Module>();
switch( eventLogType )
{
case BINARY_MESSAGE:
return new MessageEventLogger( mDirectory, sb.toString(), MessageEventLogger.Type.BINARY );
case DECODED_MESSAGE:
return new MessageEventLogger( mDirectory, sb.toString(), MessageEventLogger.Type.DECODED );
case CALL_EVENT:
return new CallEventLogger( mDirectory, sb.toString() );
default:
return null;
}
}
for(EventLogType type : config.getLoggers())
{
switch(type)
{
case CALL_EVENT:
case DECODED_MESSAGE:
if(channel.getChannelType() == Channel.ChannelType.STANDARD)
{
loggers.add(getLogger(type, prefix, frequency));
}
break;
case TRAFFIC_CALL_EVENT:
case TRAFFIC_DECODED_MESSAGE:
if(channel.getChannelType() == Channel.ChannelType.TRAFFIC)
{
loggers.add(getLogger(type, prefix, frequency));
}
break;
}
}
return loggers;
}
public EventLogger getLogger(EventLogType eventLogType, String prefix, long frequency)
{
StringBuilder sb = new StringBuilder();
sb.append(prefix);
sb.append(eventLogType.getFileSuffix());
sb.append(".log");
switch(eventLogType)
{
case CALL_EVENT:
return new DecodeEventLogger(mDirectory, sb.toString(), frequency);
case DECODED_MESSAGE:
return new MessageEventLogger(mDirectory, sb.toString(), MessageEventLogger.Type.DECODED, frequency);
case TRAFFIC_CALL_EVENT:
return new DecodeEventLogger(mDirectory, sb.toString(), frequency);
case TRAFFIC_DECODED_MESSAGE:
return new MessageEventLogger(mDirectory, sb.toString(), MessageEventLogger.Type.DECODED, frequency);
default:
return null;
}
}
}

View File

@@ -20,10 +20,16 @@ package io.github.dsheirer.module.log;
public enum EventLogType
{
/**
* Legacy logging type - do not use - superceded by bitstream recorder
*/
BINARY_MESSAGE( "Binary Messages", "_binary_messages" ),
DECODED_MESSAGE( "Decoded Messages", "_decoded_messages" ),
CALL_EVENT( "Call Events", "_call_events" );
TRAFFIC_DECODED_MESSAGE( "Traffic Channel Decoded Messages", "_decoded_messages" ),
CALL_EVENT( "Call Events", "_call_events" ),
TRAFFIC_CALL_EVENT( "Traffic Channel Call Events", "_call_events" );
private String mDisplayString;
private String mFileSuffix;

View File

@@ -26,7 +26,6 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.file.Path;
@@ -38,12 +37,14 @@ public abstract class EventLogger extends Module
private Path mLogDirectory;
private String mFileNameSuffix;
private String mLogFileName;
private long mFrequency;
protected Writer mLogFile;
public EventLogger(Path logDirectory, String fileNameSuffix)
public EventLogger(Path logDirectory, String fileNameSuffix, long frequency)
{
mLogDirectory = logDirectory;
mFileNameSuffix = fileNameSuffix;
mFrequency = frequency;
}
public String toString()
@@ -70,8 +71,10 @@ public abstract class EventLogger extends Module
StringBuilder sb = new StringBuilder();
sb.append(mLogDirectory);
sb.append(File.separator);
sb.append(TimeStamp.getTimeStamp("_"));
sb.append(TimeStamp.getLongTimeStamp("_"));
sb.append("_");
sb.append(mFrequency);
sb.append("_Hz_");
sb.append(mFileNameSuffix);
mLogFileName = sb.toString();
@@ -110,10 +113,13 @@ public abstract class EventLogger extends Module
{
try
{
mLogFile.write(eventLogEntry + "\n");
mLogFile.flush();
if(mLogFile != null)
{
mLogFile.write((eventLogEntry != null ? eventLogEntry : "") + "\n");
mLogFile.flush();
}
}
catch(IOException e)
catch(Exception e)
{
mLog.error("Error writing entry to event log file", e);
}

View File

@@ -1,88 +1,77 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014 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.log;
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.message.IMessageListener;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.util.TimeStamp;
import java.nio.file.Path;
public class MessageEventLogger extends EventLogger implements
IMessageListener, Listener<Message>
public class MessageEventLogger extends EventLogger implements IMessageListener, Listener<IMessage>
{
public enum Type
{
BINARY, DECODED
};
public enum Type
{
BINARY, DECODED
}
private Type mType;
private Type mType;
public MessageEventLogger( Path logDirectory,
String fileNameSuffix,
Type type )
{
super( logDirectory, fileNameSuffix );
public MessageEventLogger(Path logDirectory, String fileNameSuffix, Type type, long frequency)
{
super(logDirectory, fileNameSuffix, frequency);
mType = type;
}
mType = type;
}
@Override
public Listener<IMessage> getMessageListener()
{
return this;
}
@Override
public Listener<Message> getMessageListener()
{
return this;
}
@Override
public void dispose()
{
super.stop();
}
@Override
public void dispose()
{
super.stop();
}
@Override
public void reset()
{
}
@Override
public void reset()
{
}
@Override
public void receive(IMessage message)
{
StringBuilder sb = new StringBuilder();
sb.append(TimeStamp.getTimeStamp(message.getTimestamp(), " "));
sb.append(",");
sb.append((message.isValid() ? "PASSED" : "FAILED"));
sb.append(",");
sb.append(message.toString());
@Override
public void receive( Message message )
{
StringBuilder sb = new StringBuilder();
sb.append( TimeStamp.getTimeStamp( " " ) );
sb.append( "," );
sb.append( ( message.isValid() ? "PASSED" : "FAILED" ) );
sb.append( "," );
write(sb.toString());
}
if ( mType == Type.BINARY )
{
sb.append( message.getBinaryMessage() );
} else
{
sb.append( message.getMessage() );
}
write( sb.toString() );
}
@Override
public String getHeader()
{
return mType.toString() + " Message Logger\n";
}
@Override
public String getHeader()
{
return mType.toString() + " Message Logger\n";
}
}