mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Initial commit of redesigned internal processing and audio management.
Note: Several of the decoders are currently non-functioning in this commit. If you want the latest functioning codebase, please checkout the commit prior to this one. All decoders will eventually be updated with this new architecture. Currently broken: - Logging and recording - Aux decoders (Fleetsync/MDC/LoJack/Tait) - LTR/Passport decoders Changes in this commit: - Module architecture for decoders and components with central provisioning by the DecoderFactory - Transition from Complex sample stream processing to float buffer processing for improved memory management - Redesigned filter structures - to support buffers and streams - Resolved several memory leak issues - Universal sharing of the thread pool manager - Added centralized audio management with call/user prioritization and new gui with mute/volume controls - Embedded audio metadata for eventual streaming support - Redesigned ProcessingChain to support independent re-use - Added new TrafficChannelManager to handle traffic channel allocations - Traffic Channel pool size and Call timeout available in P25 and MPT1327 configs - Redesigned channel and decoder gui components
This commit is contained in:
279
src/module/decode/tait/Tait1200ANIMessage.java
Normal file
279
src/module/decode/tait/Tait1200ANIMessage.java
Normal file
@@ -0,0 +1,279 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import map.Plottable;
|
||||
import message.Message;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.Alias;
|
||||
import alias.AliasList;
|
||||
import bits.BinaryMessage;
|
||||
import edac.CRC;
|
||||
|
||||
public class Tait1200ANIMessage extends Message
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( Tait1200ANIMessage.class );
|
||||
|
||||
public static int[] REVS_1 = { 0,1,2,3 };
|
||||
public static int[] SYNC = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 };
|
||||
public static int[] SIZE = { 20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 };
|
||||
public static int[] FROM_DIGIT_1 = { 36,37,38,39,40,41,42,43 };
|
||||
public static int[] FROM_DIGIT_2 = { 44,45,46,47,48,49,50,51 };
|
||||
public static int[] FROM_DIGIT_3 = { 52,53,54,55,56,57,58,59 };
|
||||
public static int[] FROM_DIGIT_4 = { 60,61,62,63,64,65,66,67 };
|
||||
public static int[] FROM_DIGIT_5 = { 68,69,70,71,72,73,74,75 };
|
||||
public static int[] FROM_DIGIT_6 = { 76,77,78,79,80,81,82,83 };
|
||||
public static int[] FROM_DIGIT_7 = { 84,85,86,87,88,89,90,91 };
|
||||
public static int[] FROM_DIGIT_8 = { 92,93,94,95,96,97,98,99 };
|
||||
public static int[] CHECKSUM_1 = { 100,101,102,103,104,105,106,107,108,109,
|
||||
110,111,112,113,114,115 };
|
||||
|
||||
public static int[] REVS_2 = { 116,117,118,119,120,121,122,123,124,125,126,127,
|
||||
128,129,130,131 };
|
||||
public static int[] SIZE_2 = { 188,189,190,191,192,193,194,195,196,197,198,
|
||||
199,200,201,202,203 };
|
||||
public static int[] TO_DIGIT_1 = { 204,205,206,207,208,209,210,211 };
|
||||
public static int[] TO_DIGIT_2 = { 212,213,214,215,216,217,218,219 };
|
||||
public static int[] TO_DIGIT_3 = { 220,221,222,223,224,225,226,227 };
|
||||
public static int[] TO_DIGIT_4 = { 228,229,230,231,232,233,234,235 };
|
||||
public static int[] TO_DIGIT_5 = { 236,237,238,239,240,241,242,243 };
|
||||
public static int[] TO_DIGIT_6 = { 244,245,246,247,248,249,250,251 };
|
||||
public static int[] TO_DIGIT_7 = { 252,253,254,255,256,257,258,259 };
|
||||
public static int[] TO_DIGIT_8 = { 260,261,262,263,264,265,266,267 };
|
||||
public static int[] UNKNOWN_1 = { 268,269,270,271,272,273,274,275 };
|
||||
public static int[] CHECKSUM_2 = { 276,277,278,279,280,281,282,283,284,285,
|
||||
286,287,288,289,290,291 };
|
||||
|
||||
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
|
||||
|
||||
private BinaryMessage mMessage;
|
||||
private AliasList mAliasList;
|
||||
private CRC mCRC;
|
||||
|
||||
public Tait1200ANIMessage( BinaryMessage message, AliasList list )
|
||||
{
|
||||
mMessage = message;
|
||||
mAliasList = list;
|
||||
|
||||
// checkCRC();
|
||||
//
|
||||
// switch( mCRC )
|
||||
// {
|
||||
// case CORRECTED:
|
||||
// mLog.debug( "CORR:" + message.toString() );
|
||||
// break;
|
||||
// case FAILED_CRC:
|
||||
// mLog.debug( "FAIL:" + message.toString() );
|
||||
// break;
|
||||
// case PASSED:
|
||||
// mLog.debug( "PASS:" + message.toString() );
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFromID()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( getCharacter( FROM_DIGIT_1 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_2 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_3 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_4 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_5 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_6 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_7 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_8 ) );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getFromIDAlias()
|
||||
{
|
||||
if( mAliasList != null )
|
||||
{
|
||||
return mAliasList.getTalkgroupAlias( getFromID() );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToID()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( getCharacter( TO_DIGIT_1 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_2 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_3 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_4 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_5 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_6 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_7 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_8 ) );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getToIDAlias()
|
||||
{
|
||||
if( mAliasList != null )
|
||||
{
|
||||
return mAliasList.getTalkgroupAlias( getToID() );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public char getCharacter( int[] bits )
|
||||
{
|
||||
int value = mMessage.getInt( bits );
|
||||
|
||||
return (char)value;
|
||||
}
|
||||
|
||||
private void checkCRC()
|
||||
{
|
||||
// mCRC = CRCLJ.checkAndCorrect( mMessage );
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
// return mCRC == CRC.PASSED || mCRC == CRC.CORRECTED;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "ANI FROM:" );
|
||||
sb.append( getFromID() );
|
||||
sb.append( " TO:" );
|
||||
sb.append( getToID() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads spaces onto the end of the value to make it 'places' long
|
||||
*/
|
||||
public String pad( String value, int places, String padCharacter )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( value );
|
||||
|
||||
while( sb.length() < places )
|
||||
{
|
||||
sb.append( padCharacter );
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads an integer value with additional zeroes to make it decimalPlaces long
|
||||
*/
|
||||
public String format( int number, int decimalPlaces )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
int paddingRequired = decimalPlaces - ( String.valueOf( number ).length() );
|
||||
|
||||
for( int x = 0; x < paddingRequired; x++)
|
||||
{
|
||||
sb.append( "0" );
|
||||
}
|
||||
|
||||
sb.append( number );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBinaryMessage()
|
||||
{
|
||||
return mMessage.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol()
|
||||
{
|
||||
return "Tait-1200";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType()
|
||||
{
|
||||
return "ANI";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorStatus()
|
||||
{
|
||||
return "UNKNOWN";
|
||||
// return mCRC.getDisplayText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plottable getPlottable()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a listing of aliases contained in the message.
|
||||
*/
|
||||
public List<Alias> getAliases()
|
||||
{
|
||||
List<Alias> aliases = new ArrayList<Alias>();
|
||||
|
||||
Alias from = getFromIDAlias();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
aliases.add( from );
|
||||
}
|
||||
|
||||
Alias to = getToIDAlias();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
aliases.add( to );
|
||||
}
|
||||
|
||||
return aliases;
|
||||
}
|
||||
}
|
||||
67
src/module/decode/tait/Tait1200ANIMessageProcessor.java
Normal file
67
src/module/decode/tait/Tait1200ANIMessageProcessor.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import message.Message;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import alias.AliasList;
|
||||
import bits.BinaryMessage;
|
||||
|
||||
public class Tait1200ANIMessageProcessor implements Listener<BinaryMessage>
|
||||
{
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( Tait1200ANIMessageProcessor.class );
|
||||
|
||||
private Listener<Message> mMessageListener;
|
||||
|
||||
private AliasList mAliasList;
|
||||
|
||||
public Tait1200ANIMessageProcessor( AliasList list )
|
||||
{
|
||||
mAliasList = list;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mMessageListener = null;
|
||||
mAliasList = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( BinaryMessage buffer )
|
||||
{
|
||||
if( mMessageListener != null )
|
||||
{
|
||||
mMessageListener.receive( new Tait1200ANIMessage( buffer, mAliasList ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessageListener( Listener<Message> listener )
|
||||
{
|
||||
mMessageListener = listener;
|
||||
}
|
||||
|
||||
public void removeMessageListener( Listener<Message> listener )
|
||||
{
|
||||
mMessageListener = null;
|
||||
}
|
||||
}
|
||||
137
src/module/decode/tait/Tait1200CallEvent.java
Normal file
137
src/module/decode/tait/Tait1200CallEvent.java
Normal file
@@ -0,0 +1,137 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import module.decode.DecoderType;
|
||||
import module.decode.event.CallEvent;
|
||||
import alias.Alias;
|
||||
import alias.AliasList;
|
||||
|
||||
public class Tait1200CallEvent extends CallEvent
|
||||
{
|
||||
public Tait1200CallEvent( CallEventType callEventType,
|
||||
AliasList aliasList,
|
||||
String fromID,
|
||||
String toID,
|
||||
String details )
|
||||
{
|
||||
super( DecoderType.TAIT_1200, callEventType,
|
||||
aliasList, fromID, toID, details );
|
||||
}
|
||||
|
||||
private Alias getAlias( String ident )
|
||||
{
|
||||
if( hasAliasList() )
|
||||
{
|
||||
return getAliasList().getFleetsyncAlias( ident );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getFromIDAlias()
|
||||
{
|
||||
return getAlias( getFromID() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getToIDAlias()
|
||||
{
|
||||
return getAlias( getToID() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannel()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFrequency()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
/* Required parameters */
|
||||
private CallEventType mCallEventType;
|
||||
|
||||
/* Optional parameters */
|
||||
private AliasList mAliasList;
|
||||
private String mFromID;
|
||||
private String mToID;
|
||||
private String mDetails;
|
||||
|
||||
public Builder( CallEventType callEventType )
|
||||
{
|
||||
mCallEventType = callEventType;
|
||||
}
|
||||
|
||||
public Builder aliasList( AliasList aliasList )
|
||||
{
|
||||
mAliasList = aliasList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder from( String val )
|
||||
{
|
||||
mFromID = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder details( String details )
|
||||
{
|
||||
mDetails = details;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder to( String toID )
|
||||
{
|
||||
mToID = toID;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Tait1200CallEvent build()
|
||||
{
|
||||
return new Tait1200CallEvent( this );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor for the builder
|
||||
*/
|
||||
private Tait1200CallEvent( Builder builder )
|
||||
{
|
||||
this( builder.mCallEventType,
|
||||
builder.mAliasList,
|
||||
builder.mFromID,
|
||||
builder.mToID,
|
||||
builder.mDetails );
|
||||
}
|
||||
|
||||
public static Tait1200CallEvent getLJ1200Event( Tait1200GPSMessage message )
|
||||
{
|
||||
CallEventType type = CallEventType.COMMAND;
|
||||
|
||||
return new Tait1200CallEvent.Builder( type )
|
||||
.details( message.getMessage() )
|
||||
.build();
|
||||
}
|
||||
}
|
||||
188
src/module/decode/tait/Tait1200Decoder.java
Normal file
188
src/module/decode/tait/Tait1200Decoder.java
Normal file
@@ -0,0 +1,188 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import instrument.Instrumentable;
|
||||
import instrument.tap.Tap;
|
||||
import instrument.tap.stream.BinaryTap;
|
||||
import instrument.tap.stream.FloatBufferTap;
|
||||
import instrument.tap.stream.FloatTap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import module.decode.Decoder;
|
||||
import module.decode.DecoderType;
|
||||
import sample.Broadcaster;
|
||||
import sample.Listener;
|
||||
import sample.real.IRealBufferListener;
|
||||
import sample.real.RealBuffer;
|
||||
import alias.AliasList;
|
||||
import bits.MessageFramer;
|
||||
import bits.SyncPattern;
|
||||
import dsp.filter.Filters;
|
||||
import dsp.filter.fir.real.RealFIRFilter_RB_RB;
|
||||
import dsp.filter.halfband.real.HalfBandFilter_RB_RB;
|
||||
import dsp.fsk.FSK2Decoder;
|
||||
import dsp.fsk.FSK2Decoder.Output;
|
||||
|
||||
/**
|
||||
* TAIT 1200 - 1200 baud 2FSK decoder
|
||||
*/
|
||||
public class Tait1200Decoder extends Decoder implements IRealBufferListener,
|
||||
Instrumentable
|
||||
{
|
||||
/* Decimated sample rate ( 48,000 / 2 = 24,000 ) feeding the decoder */
|
||||
private static final int DECIMATED_SAMPLE_RATE = 24000;
|
||||
|
||||
/* Baud or Symbol Rate */
|
||||
private static final int SYMBOL_RATE = 1200;
|
||||
|
||||
/* Message length ... */
|
||||
private static final int MESSAGE_LENGTH = 440;
|
||||
|
||||
/* Instrumentation Taps */
|
||||
private ArrayList<Tap> mAvailableTaps;
|
||||
private static final String INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD =
|
||||
"Tap Point: Bandpass Filter > < FSK2 Decoder";
|
||||
private static final String INSTRUMENT_FSK2_DECODER_TO_MESSAGE_FRAMER =
|
||||
"Tap Point: FSK2 Decoder > < Message Framer";
|
||||
|
||||
private FSK2Decoder mFSKDecoder;
|
||||
|
||||
private HalfBandFilter_RB_RB mDecimationFilter;
|
||||
private RealFIRFilter_RB_RB mBandPassFilter;
|
||||
private MessageFramer mMessageFramerGPS;
|
||||
private MessageFramer mMessageFramerANI;
|
||||
private Broadcaster<Boolean> mFSKBroadcaster = new Broadcaster<Boolean>();
|
||||
private Tait1200GPSMessageProcessor mMessageAProcessor;
|
||||
private Tait1200ANIMessageProcessor mMessageBProcessor;
|
||||
|
||||
public Tait1200Decoder( AliasList aliasList )
|
||||
{
|
||||
super( new Tait1200DecoderState( aliasList ) );
|
||||
|
||||
mDecimationFilter = new HalfBandFilter_RB_RB(
|
||||
Filters.FIR_HALF_BAND_31T_ONE_EIGHTH_FCO.getCoefficients(), 1.0002f, true );
|
||||
|
||||
mBandPassFilter = new RealFIRFilter_RB_RB(
|
||||
Filters.FIRBP_1200FSK_24000FS.getCoefficients(), 1.02f );
|
||||
mDecimationFilter.setListener( mBandPassFilter );
|
||||
|
||||
mFSKDecoder = new FSK2Decoder( DECIMATED_SAMPLE_RATE,
|
||||
SYMBOL_RATE, Output.INVERTED );
|
||||
mBandPassFilter.setListener( mFSKDecoder );
|
||||
|
||||
|
||||
mFSKDecoder.setListener( mFSKBroadcaster );
|
||||
|
||||
mMessageFramerGPS = new MessageFramer(
|
||||
SyncPattern.TAIT_CCDI_GPS_MESSAGE.getPattern(), MESSAGE_LENGTH );
|
||||
mMessageFramerANI = new MessageFramer(
|
||||
SyncPattern.TAIT_SELCAL_MESSAGE.getPattern(), MESSAGE_LENGTH );
|
||||
|
||||
mFSKBroadcaster.addListener( mMessageFramerGPS );
|
||||
mFSKBroadcaster.addListener( mMessageFramerANI );
|
||||
|
||||
mMessageAProcessor = new Tait1200GPSMessageProcessor( aliasList );
|
||||
mMessageBProcessor = new Tait1200ANIMessageProcessor( aliasList );
|
||||
|
||||
mMessageFramerGPS.addMessageListener( mMessageAProcessor );
|
||||
mMessageFramerANI.addMessageListener( mMessageBProcessor );
|
||||
|
||||
mMessageAProcessor.setMessageListener( mMessageBroadcaster );
|
||||
mMessageBProcessor.setMessageListener( mMessageBroadcaster );
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
|
||||
mDecimationFilter.dispose();
|
||||
mBandPassFilter.dispose();
|
||||
mFSKDecoder.dispose();
|
||||
mMessageFramerGPS.dispose();
|
||||
mMessageFramerANI.dispose();
|
||||
mMessageAProcessor.dispose();
|
||||
mMessageBProcessor.dispose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tap> getTaps()
|
||||
{
|
||||
if( mAvailableTaps == null )
|
||||
{
|
||||
mAvailableTaps = new ArrayList<Tap>();
|
||||
|
||||
mAvailableTaps.add( new FloatTap(
|
||||
INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD, 0, 0.5f ) );
|
||||
mAvailableTaps.addAll( mFSKDecoder.getTaps() );
|
||||
mAvailableTaps.add( new BinaryTap(
|
||||
INSTRUMENT_FSK2_DECODER_TO_MESSAGE_FRAMER, 0, 0.025f ) );
|
||||
}
|
||||
|
||||
return mAvailableTaps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTap( Tap tap )
|
||||
{
|
||||
mFSKDecoder.addTap( tap );
|
||||
|
||||
switch( tap.getName() )
|
||||
{
|
||||
case INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD:
|
||||
FloatBufferTap bpTap = (FloatBufferTap)tap;
|
||||
mBandPassFilter.setListener( bpTap );
|
||||
bpTap.setListener( mFSKDecoder );
|
||||
break;
|
||||
case INSTRUMENT_FSK2_DECODER_TO_MESSAGE_FRAMER:
|
||||
BinaryTap decoderTap = (BinaryTap)tap;
|
||||
mFSKBroadcaster.addListener( decoderTap );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTap( Tap tap )
|
||||
{
|
||||
mFSKDecoder.removeTap( tap );
|
||||
|
||||
switch( tap.getName() )
|
||||
{
|
||||
case INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD:
|
||||
mBandPassFilter.setListener( mFSKDecoder );
|
||||
break;
|
||||
case INSTRUMENT_FSK2_DECODER_TO_MESSAGE_FRAMER:
|
||||
mFSKBroadcaster.removeListener( (BinaryTap)tap );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener<RealBuffer> getRealBufferListener()
|
||||
{
|
||||
return mDecimationFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DecoderType getDecoderType()
|
||||
{
|
||||
return DecoderType.TAIT_1200;
|
||||
}
|
||||
}
|
||||
236
src/module/decode/tait/Tait1200DecoderState.java
Normal file
236
src/module/decode/tait/Tait1200DecoderState.java
Normal file
@@ -0,0 +1,236 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
|
||||
import message.Message;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderState;
|
||||
import module.decode.state.DecoderStateEvent;
|
||||
import alias.Alias;
|
||||
import alias.AliasList;
|
||||
|
||||
public class Tait1200DecoderState extends DecoderState
|
||||
{
|
||||
private TreeSet<String> mIdents = new TreeSet<String>();
|
||||
|
||||
private String mFrom;
|
||||
private Alias mFromAlias;
|
||||
|
||||
private String mTo;
|
||||
private Alias mToAlias;
|
||||
|
||||
private String mMessage;
|
||||
private String mMessageType;
|
||||
|
||||
public Tait1200DecoderState( AliasList aliasList )
|
||||
{
|
||||
super( aliasList );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset()
|
||||
{
|
||||
mIdents.clear();
|
||||
|
||||
resetState();
|
||||
}
|
||||
|
||||
private void resetState()
|
||||
{
|
||||
setFromID( null );
|
||||
setFromIDAlias( null );
|
||||
setToID( null );
|
||||
setToIDAlias( null );
|
||||
setMessage( null );
|
||||
setMessageType( null );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( Message message )
|
||||
{
|
||||
if( message instanceof Tait1200GPSMessage )
|
||||
{
|
||||
Tait1200GPSMessage gps = (Tait1200GPSMessage)message;
|
||||
|
||||
setFromID( gps.getFromID() );
|
||||
setFromIDAlias( gps.getFromIDAlias() );
|
||||
mIdents.add( gps.getFromID() );
|
||||
|
||||
setToID( gps.getToID() );
|
||||
setToIDAlias( gps.getToIDAlias() );
|
||||
mIdents.add( gps.getToID());
|
||||
|
||||
GeoPosition position = gps.getGPSLocation();
|
||||
|
||||
if( position != null )
|
||||
{
|
||||
setMessage( gps.getGPSLocation().toString().replace( "[", "" )
|
||||
.replace( "]", "" ) );
|
||||
}
|
||||
setMessageType( "GPS" );
|
||||
}
|
||||
else if( message instanceof Tait1200ANIMessage )
|
||||
{
|
||||
Tait1200ANIMessage ani = (Tait1200ANIMessage)message;
|
||||
|
||||
setFromID( ani.getFromID() );
|
||||
setFromIDAlias( ani.getFromIDAlias() );
|
||||
mIdents.add( ani.getFromID() );
|
||||
|
||||
setToID( ani.getToID() );
|
||||
setToIDAlias( ani.getToIDAlias() );
|
||||
mIdents.add( ani.getToID());
|
||||
|
||||
setMessage( null );
|
||||
setMessageType( "ANI" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getActivitySummary()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "=============================\n" );
|
||||
sb.append( "Decoder:\tTait-1200I\n\n" );
|
||||
|
||||
if( !mIdents.isEmpty() )
|
||||
{
|
||||
sb.append( "Radio Identifiers:\n" );
|
||||
|
||||
List<String> idents = new ArrayList<String>( mIdents );
|
||||
|
||||
Collections.sort( idents );
|
||||
|
||||
for( String ident: idents )
|
||||
{
|
||||
sb.append( "\t" );
|
||||
sb.append( ident );
|
||||
|
||||
if( hasAliasList() )
|
||||
{
|
||||
Alias alias = getAliasList().getTalkgroupAlias( ident );
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
sb.append( "\t" );
|
||||
sb.append( alias.getName() );
|
||||
}
|
||||
}
|
||||
sb.append( "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
/* No initialization required */
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to reset events issued by the channel state
|
||||
*/
|
||||
@Override
|
||||
public void receiveDecoderStateEvent( DecoderStateEvent event )
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case RESET:
|
||||
resetState();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public String getFromID()
|
||||
{
|
||||
return mFrom;
|
||||
}
|
||||
|
||||
public void setFromID( String from )
|
||||
{
|
||||
mFrom = from;
|
||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
||||
}
|
||||
|
||||
public Alias getFromIDAlias()
|
||||
{
|
||||
return mFromAlias;
|
||||
}
|
||||
|
||||
public void setFromIDAlias( Alias alias )
|
||||
{
|
||||
mFromAlias = alias;
|
||||
broadcast( ChangedAttribute.FROM_TALKGROUP_ALIAS );
|
||||
}
|
||||
|
||||
public String getToID()
|
||||
{
|
||||
return mTo;
|
||||
}
|
||||
|
||||
public void setToID( String to )
|
||||
{
|
||||
mTo = to;
|
||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
||||
}
|
||||
|
||||
public Alias getToIDAlias()
|
||||
{
|
||||
return mToAlias;
|
||||
}
|
||||
|
||||
public void setToIDAlias( Alias alias )
|
||||
{
|
||||
mToAlias = alias;
|
||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
||||
}
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return mMessage;
|
||||
}
|
||||
|
||||
public void setMessage( String message )
|
||||
{
|
||||
mMessage = message;
|
||||
broadcast( ChangedAttribute.MESSAGE );
|
||||
}
|
||||
|
||||
public String getMessageType()
|
||||
{
|
||||
return mMessageType;
|
||||
}
|
||||
|
||||
public void setMessageType( String type )
|
||||
{
|
||||
mMessageType = type;
|
||||
broadcast( ChangedAttribute.MESSAGE_TYPE );
|
||||
}
|
||||
}
|
||||
415
src/module/decode/tait/Tait1200GPSMessage.java
Normal file
415
src/module/decode/tait/Tait1200GPSMessage.java
Normal file
@@ -0,0 +1,415 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import map.Plottable;
|
||||
import message.Message;
|
||||
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import alias.Alias;
|
||||
import alias.AliasList;
|
||||
import bits.BinaryMessage;
|
||||
import edac.CRC;
|
||||
|
||||
public class Tait1200GPSMessage extends Message
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( Tait1200GPSMessage.class );
|
||||
|
||||
public static int[] REVS_1 = { 0,1,2,3 };
|
||||
public static int[] SYNC = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 };
|
||||
public static int[] SIZE = { 20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35 };
|
||||
public static int[] FROM_DIGIT_1 = { 36,37,38,39,40,41,42,43 };
|
||||
public static int[] FROM_DIGIT_2 = { 44,45,46,47,48,49,50,51 };
|
||||
public static int[] FROM_DIGIT_3 = { 52,53,54,55,56,57,58,59 };
|
||||
public static int[] FROM_DIGIT_4 = { 60,61,62,63,64,65,66,67 };
|
||||
public static int[] FROM_DIGIT_5 = { 68,69,70,71,72,73,74,75 };
|
||||
public static int[] FROM_DIGIT_6 = { 76,77,78,79,80,81,82,83 };
|
||||
public static int[] FROM_DIGIT_7 = { 84,85,86,87,88,89,90,91 };
|
||||
public static int[] FROM_DIGIT_8 = { 92,93,94,95,96,97,98,99 };
|
||||
public static int[] CHECKSUM_1 = { 100,101,102,103,104,105,106,107,108,109,
|
||||
110,111,112,113,114,115 };
|
||||
|
||||
public static int[] REVS_2 = { 116,117,118,119,120,121,122,123,124,125,126,127,
|
||||
128,129,130,131 };
|
||||
public static int[] SIZE_2 = { 188,189,190,191,192,193,194,195,196,197,198,
|
||||
199,200,201,202,203 };
|
||||
public static int[] TO_DIGIT_1 = { 204,205,206,207,208,209,210,211 };
|
||||
public static int[] TO_DIGIT_2 = { 212,213,214,215,216,217,218,219 };
|
||||
public static int[] TO_DIGIT_3 = { 220,221,222,223,224,225,226,227 };
|
||||
public static int[] TO_DIGIT_4 = { 228,229,230,231,232,233,234,235 };
|
||||
public static int[] TO_DIGIT_5 = { 236,237,238,239,240,241,242,243 };
|
||||
public static int[] TO_DIGIT_6 = { 244,245,246,247,248,249,250,251 };
|
||||
public static int[] TO_DIGIT_7 = { 252,253,254,255,256,257,258,259 };
|
||||
public static int[] TO_DIGIT_8 = { 260,261,262,263,264,265,266,267 };
|
||||
public static int[] UNKNOWN_1 = { 268,269,270,271,272,273,274,275 };
|
||||
public static int[] CHECKSUM_2 = { 276,277,278,279,280,281,282,283,284,285,
|
||||
286,287,288,289,290,291 };
|
||||
public static int DIVIDER_1 = 292;
|
||||
public static int[] HOUR_TENS = { 293,294,295 };
|
||||
public static int[] HOUR_ONES = { 296,297,298,299 };
|
||||
public static int DIVIDER_2 = 300;
|
||||
public static int[] MINUTES_TENS = { 301,302,303 };
|
||||
public static int[] MINUTES_ONES = { 304,305,306,307 };
|
||||
public static int DIVIDER_3 = 308;
|
||||
public static int[] SECONDS_TENS = { 309,310,311 };
|
||||
public static int[] SECONDS_ONES = { 312,313,314,315 };
|
||||
public static int DIVIDER_4 = 316;
|
||||
public static int[] LATITUDE_SIGN = { 317,318 };
|
||||
public static int DIVIDER_5 = 319;
|
||||
public static int[] LATITUDE_DEGREES_TENS = { 320,321,322,323 };
|
||||
public static int[] LATITUDE_DEGREES_ONES = { 324,325,326,327 };
|
||||
public static int DIVIDER_6 = 328;
|
||||
public static int[] LATITUDE_MINUTES_TENS = { 329,330,331 };
|
||||
public static int[] LATITUDE_MINUTES_ONES = { 332,333,334,335 };
|
||||
public static int[] LATITUDE_SECONDS_HUND = { 336,337,338,339 };
|
||||
public static int[] LATITUDE_SECONDS_TENS = { 340,341,342,344 };
|
||||
public static int[] LATITUDE_SECONDS_ONES = { 344,345,346,347 };
|
||||
public static int DIVIDER_7 = 348;
|
||||
public static int[] LONGITUDE_SIGN = { 349,350 };
|
||||
public static int LONGITUDE_DEGREES_HUNDREDS = 351;
|
||||
public static int[] LONGITUDE_DEGREES_TENS = { 352,353,354,355 };
|
||||
public static int[] LONGITUDE_DEGREES_ONES = { 356,357,358,359 };
|
||||
public static int DIVIDER_9 = 360;
|
||||
public static int[] LONGITUDE_MINUTES_TENS = { 361,362,363 };
|
||||
public static int[] LONGITUDE_MINUTES_ONES = { 364,365,366,367 };
|
||||
public static int[] LONGITUDE_SECONDS_HUND = { 368,369,370,371 };
|
||||
public static int[] LONGITUDE_SECONDS_TENS = { 372,373,374,375 };
|
||||
public static int[] LONGITUDE_SECONDS_ONES = { 376,377,378,379 };
|
||||
public static int DIVIDER_10 = 380;
|
||||
public static int[] DATE_DAY_TENS = { 381,382,383 };
|
||||
public static int[] DATE_DAY_ONES = { 384,385,386,387 };
|
||||
|
||||
//TODO: not sure if this field is the month field or the speed field
|
||||
public static int[] DATE_MONTH = { 388,389,390,391 };
|
||||
public static int[] SPEED_HUNDREDS = { 388,389,390,391 };
|
||||
|
||||
public static int[] SPEED_TENS = { 392,393,394,395 };
|
||||
public static int[] SPEED_ONES = { 396,397,398,399 };
|
||||
public static int[] SPEED_TENTHS = { 400,401,402,403 };
|
||||
|
||||
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
|
||||
|
||||
private BinaryMessage mMessage;
|
||||
private AliasList mAliasList;
|
||||
private CRC mCRC;
|
||||
|
||||
public Tait1200GPSMessage( BinaryMessage message, AliasList list )
|
||||
{
|
||||
mMessage = message;
|
||||
mAliasList = list;
|
||||
|
||||
mLog.debug( toString() );
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
//TODO: Override until we figure out the CRC
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getMessage1Size()
|
||||
{
|
||||
return mMessage.getInt( SIZE );
|
||||
}
|
||||
|
||||
public int getMessage2Size()
|
||||
{
|
||||
return mMessage.getInt( SIZE_2 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( "GPS FROM:" );
|
||||
sb.append( getFromID() );
|
||||
sb.append( " TO:" );
|
||||
sb.append( getToID() );
|
||||
sb.append( " LOCATION:" );
|
||||
|
||||
GeoPosition location = getGPSLocation();
|
||||
|
||||
sb.append( location.getLatitude() );
|
||||
sb.append( " " );
|
||||
sb.append( location.getLongitude() );
|
||||
|
||||
sb.append( " SPEED:" );
|
||||
sb.append( getSpeed() );
|
||||
sb.append( "KPH" );
|
||||
|
||||
sb.append( " GPS TIME:" );
|
||||
sb.append( mSDF.format( new Date( getGPSTime() ) ) );
|
||||
|
||||
sb.append( " " );
|
||||
sb.append( mMessage.toString() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public GeoPosition getGPSLocation()
|
||||
{
|
||||
double latitude = mMessage.getInt( LATITUDE_DEGREES_TENS ) * 10.0d;
|
||||
latitude += mMessage.getInt( LATITUDE_DEGREES_ONES );
|
||||
latitude += (double)mMessage.getInt( LATITUDE_MINUTES_TENS ) / 6.0d;
|
||||
latitude += (double)mMessage.getInt( LATITUDE_MINUTES_ONES ) / 60.0d;
|
||||
latitude += (double)mMessage.getInt( LATITUDE_SECONDS_HUND ) / 600.0d;
|
||||
latitude += (double)mMessage.getInt( LATITUDE_SECONDS_TENS ) / 6000.0d;
|
||||
latitude += (double)mMessage.getInt( LATITUDE_SECONDS_ONES ) / 60000.0d;
|
||||
|
||||
if( mMessage.getInt( LATITUDE_SIGN ) == 0 )
|
||||
{
|
||||
latitude *= -1;
|
||||
}
|
||||
|
||||
double longitude = mMessage.get( LONGITUDE_DEGREES_HUNDREDS ) ? 100.0d : 0.0d;
|
||||
|
||||
longitude += mMessage.getInt( LONGITUDE_DEGREES_TENS ) * 10.0d;
|
||||
longitude += mMessage.getInt( LONGITUDE_DEGREES_ONES );
|
||||
longitude += (double)mMessage.getInt( LONGITUDE_MINUTES_TENS ) / 6.0d;
|
||||
longitude += (double)mMessage.getInt( LONGITUDE_MINUTES_ONES ) / 60.0d;
|
||||
longitude += (double)mMessage.getInt( LONGITUDE_SECONDS_HUND ) / 600.0d;
|
||||
longitude += (double)mMessage.getInt( LONGITUDE_SECONDS_TENS ) / 6000.0d;
|
||||
longitude += (double)mMessage.getInt( LONGITUDE_SECONDS_ONES ) / 60000.0d;
|
||||
|
||||
if( mMessage.getInt( LONGITUDE_SIGN ) == 0 )
|
||||
{
|
||||
longitude = -1;
|
||||
}
|
||||
|
||||
return new GeoPosition( latitude, longitude );
|
||||
}
|
||||
|
||||
public long getGPSTime()
|
||||
{
|
||||
Calendar cal = new GregorianCalendar( TimeZone.getTimeZone( "UTC" ) );
|
||||
|
||||
cal.clear();
|
||||
|
||||
/* Use current time to get current year */
|
||||
cal.setTimeInMillis( System.currentTimeMillis() );
|
||||
|
||||
//TODO: this field is either the month field, or the speed hundredths field
|
||||
cal.set( Calendar.MONTH, mMessage.getInt( DATE_MONTH ) );
|
||||
|
||||
int day = mMessage.getInt( DATE_DAY_TENS ) * 10 +
|
||||
mMessage.getInt( DATE_DAY_ONES );
|
||||
cal.set( Calendar.DAY_OF_MONTH, day );
|
||||
|
||||
cal.set( Calendar.HOUR_OF_DAY, ( mMessage.getInt( HOUR_TENS ) * 10 ) +
|
||||
mMessage.getInt( HOUR_ONES ) );
|
||||
cal.set( Calendar.MINUTE, ( mMessage.getInt( MINUTES_TENS ) * 10 ) +
|
||||
mMessage.getInt( MINUTES_ONES ) );
|
||||
cal.set( Calendar.SECOND, ( mMessage.getInt( SECONDS_TENS ) * 10 ) +
|
||||
mMessage.getInt( SECONDS_ONES ) );
|
||||
cal.set( Calendar.MILLISECOND, 0 );
|
||||
|
||||
return cal.getTimeInMillis();
|
||||
}
|
||||
|
||||
public String getSpeed()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( getDigit( SPEED_HUNDREDS ) );
|
||||
sb.append( getDigit( SPEED_TENS ) );
|
||||
sb.append( getDigit( SPEED_ONES ) );
|
||||
sb.append( "." );
|
||||
sb.append( getDigit( SPEED_TENTHS ) );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private String getDigit( int[] field )
|
||||
{
|
||||
int value = mMessage.getInt( field );
|
||||
return ( 0 <= value && value <= 9 ) ? String.valueOf( value ) : "?";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFromID()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( getCharacter( FROM_DIGIT_1 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_2 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_3 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_4 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_5 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_6 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_7 ) );
|
||||
sb.append( getCharacter( FROM_DIGIT_8 ) );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getFromIDAlias()
|
||||
{
|
||||
if( mAliasList != null )
|
||||
{
|
||||
return mAliasList.getTalkgroupAlias( getFromID() );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getToID()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( getCharacter( TO_DIGIT_1 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_2 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_3 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_4 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_5 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_6 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_7 ) );
|
||||
sb.append( getCharacter( TO_DIGIT_8 ) );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Alias getToIDAlias()
|
||||
{
|
||||
if( mAliasList != null )
|
||||
{
|
||||
return mAliasList.getTalkgroupAlias( getToID() );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public char getCharacter( int[] bits )
|
||||
{
|
||||
int value = mMessage.getInt( bits );
|
||||
|
||||
return (char)value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads spaces onto the end of the value to make it 'places' long
|
||||
*/
|
||||
public String pad( String value, int places, String padCharacter )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append( value );
|
||||
|
||||
while( sb.length() < places )
|
||||
{
|
||||
sb.append( padCharacter );
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Pads an integer value with additional zeroes to make it decimalPlaces long
|
||||
*/
|
||||
public String format( int number, int decimalPlaces )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
int paddingRequired = decimalPlaces - ( String.valueOf( number ).length() );
|
||||
|
||||
for( int x = 0; x < paddingRequired; x++)
|
||||
{
|
||||
sb.append( "0" );
|
||||
}
|
||||
|
||||
sb.append( number );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBinaryMessage()
|
||||
{
|
||||
return mMessage.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtocol()
|
||||
{
|
||||
return "Tait-1200";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType()
|
||||
{
|
||||
return "GPS";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage()
|
||||
{
|
||||
return toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorStatus()
|
||||
{
|
||||
return "UNKNOWN";
|
||||
// return mCRC.getDisplayText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Plottable getPlottable()
|
||||
{
|
||||
return new Plottable( getGPSTime(), getGPSLocation(), getFromID(),
|
||||
getFromIDAlias() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a listing of aliases contained in the message.
|
||||
*/
|
||||
public List<Alias> getAliases()
|
||||
{
|
||||
List<Alias> aliases = new ArrayList<Alias>();
|
||||
|
||||
Alias from = getFromIDAlias();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
aliases.add( from );
|
||||
}
|
||||
|
||||
Alias to = getToIDAlias();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
aliases.add( to );
|
||||
}
|
||||
|
||||
return aliases;
|
||||
}
|
||||
}
|
||||
67
src/module/decode/tait/Tait1200GPSMessageProcessor.java
Normal file
67
src/module/decode/tait/Tait1200GPSMessageProcessor.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import message.Message;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import alias.AliasList;
|
||||
import bits.BinaryMessage;
|
||||
|
||||
public class Tait1200GPSMessageProcessor implements Listener<BinaryMessage>
|
||||
{
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( Tait1200GPSMessageProcessor.class );
|
||||
|
||||
private Listener<Message> mMessageListener;
|
||||
|
||||
private AliasList mAliasList;
|
||||
|
||||
public Tait1200GPSMessageProcessor( AliasList list )
|
||||
{
|
||||
mAliasList = list;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mMessageListener = null;
|
||||
mAliasList = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( BinaryMessage buffer )
|
||||
{
|
||||
if( mMessageListener != null )
|
||||
{
|
||||
mMessageListener.receive( new Tait1200GPSMessage( buffer, mAliasList ) );
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessageListener( Listener<Message> listener )
|
||||
{
|
||||
mMessageListener = listener;
|
||||
}
|
||||
|
||||
public void removeMessageListener()
|
||||
{
|
||||
mMessageListener = null;
|
||||
}
|
||||
}
|
||||
52
src/module/decode/tait/Tait1200MessageFilter.java
Normal file
52
src/module/decode/tait/Tait1200MessageFilter.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import message.Message;
|
||||
import filter.Filter;
|
||||
import filter.FilterElement;
|
||||
|
||||
public class Tait1200MessageFilter extends Filter<Message>
|
||||
{
|
||||
|
||||
public Tait1200MessageFilter()
|
||||
{
|
||||
super( "Tait-1200 Message Filter" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean passes( Message message )
|
||||
{
|
||||
return mEnabled && canProcess( message );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProcess( Message message )
|
||||
{
|
||||
return message instanceof Tait1200GPSMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FilterElement<?>> getFilterElements()
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
}
|
||||
179
src/module/decode/tait/Tait1200Panel.java
Normal file
179
src/module/decode/tait/Tait1200Panel.java
Normal file
@@ -0,0 +1,179 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
public class Tait1200Panel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String PROTOCOL = "TAIT-1200";
|
||||
|
||||
private JLabel mFromLabel = new JLabel( " " );
|
||||
private JLabel mFrom = new JLabel();
|
||||
private JLabel mFromAlias = new JLabel();
|
||||
|
||||
private JLabel mToLabel = new JLabel();
|
||||
private JLabel mTo = new JLabel( " " );
|
||||
private JLabel mToAlias = new JLabel();
|
||||
|
||||
private JLabel mProtocol = new JLabel( PROTOCOL );
|
||||
private JLabel mMessage = new JLabel();
|
||||
private JLabel mMessageType = new JLabel();
|
||||
|
||||
public Tait1200Panel( SettingsManager settingsManager, Tait1200Decoder decoder )
|
||||
{
|
||||
super( settingsManager, decoder );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public Tait1200DecoderState getState()
|
||||
{
|
||||
return (Tait1200DecoderState)getDecoder().getDecoderState();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 1 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
|
||||
add( mFromLabel );
|
||||
add( mFrom );
|
||||
add( mFromAlias, "wrap" );
|
||||
|
||||
add( mToLabel );
|
||||
add( mTo );
|
||||
add( mToAlias, "wrap" );
|
||||
|
||||
add( mProtocol );
|
||||
add( mMessageType );
|
||||
add( mMessage, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getState().getFromID();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
mFromLabel.setText( "FM:" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText( " " );
|
||||
}
|
||||
mFrom.setText( from );
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = getState().getFromIDAlias();
|
||||
|
||||
if( fromAlias != null )
|
||||
{
|
||||
mFromAlias.setText( fromAlias.getName() );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getState().getToID();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mToLabel.setText( "TO:" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText( " " );
|
||||
}
|
||||
mTo.setText( to );
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = getState().getToIDAlias();
|
||||
|
||||
if( toAlias != null )
|
||||
{
|
||||
mToAlias.setText( toAlias.getName() );
|
||||
}
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText( getState().getMessage() );
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText( getState().getMessageType() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting color = (ColorSetting)setting;
|
||||
|
||||
if( color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER )
|
||||
{
|
||||
mFromLabel.setForeground( color.getColor() );
|
||||
mFrom.setForeground( color.getColor() );
|
||||
mFromAlias.setForeground( color.getColor() );
|
||||
mToLabel.setForeground( color.getColor() );
|
||||
mTo.setForeground( color.getColor() );
|
||||
mToAlias.setForeground( color.getColor() );
|
||||
mProtocol.setForeground( color.getColor() );
|
||||
mMessageType.setForeground( color.getColor() );
|
||||
mMessage.setForeground( color.getColor() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user