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:
denny
2015-09-01 07:10:26 -04:00
parent 538a299246
commit f4d8ea281d
570 changed files with 21578 additions and 17012 deletions

View File

@@ -0,0 +1,138 @@
/*******************************************************************************
* 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.lj1200;
import module.decode.DecoderType;
import module.decode.event.CallEvent;
import alias.Alias;
import alias.AliasList;
public class LJ1200CallEvent extends CallEvent
{
public LJ1200CallEvent( CallEventType callEventType,
AliasList aliasList,
String fromID,
String toID,
String details )
{
super( DecoderType.LJ_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 173075000;
}
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 LJ1200CallEvent build()
{
return new LJ1200CallEvent( this );
}
}
/**
* Private constructor for the builder
*/
private LJ1200CallEvent( Builder builder )
{
this( builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mDetails );
}
public static LJ1200CallEvent getLJ1200Event( LJ1200Message message )
{
CallEventType type = CallEventType.COMMAND;
return new LJ1200CallEvent.Builder( type )
.to( message.getAddress() )
.details( message.getMessage() )
.build();
}
}

View File

@@ -0,0 +1,191 @@
/*******************************************************************************
* 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.lj1200;
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 sample.real.RealSampleListener;
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;
/**
* LJ1200 - 1200 baud 2FSK decoder
*/
public class LJ1200Decoder 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 - 16-bit sync plus 64 bit message */
private static final int MESSAGE_LENGTH = 80;
/* 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 Broadcaster<Boolean> mFSKDecoderBroadcaster =
new Broadcaster<Boolean>();
private HalfBandFilter_RB_RB mDecimationFilter;
private RealFIRFilter_RB_RB mBandPassFilter;
private MessageFramer mTowerMessageFramer;
private MessageFramer mTransponderMessageFramer;
private LJ1200MessageProcessor mMessageProcessor;
public LJ1200Decoder( AliasList aliasList )
{
super( new LJ1200DecoderState( aliasList ) );
mDecimationFilter = new HalfBandFilter_RB_RB(
Filters.FIR_HALF_BAND_31T_ONE_EIGHTH_FCO.getCoefficients(), 1.0f, 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( mFSKDecoderBroadcaster );
mTowerMessageFramer = new MessageFramer(
SyncPattern.LJ1200.getPattern(), MESSAGE_LENGTH );
mTransponderMessageFramer = new MessageFramer(
SyncPattern.LJ1200_TRANSPONDER.getPattern(), MESSAGE_LENGTH );
mFSKDecoderBroadcaster.addListener( mTowerMessageFramer );
mFSKDecoderBroadcaster.addListener( mTransponderMessageFramer );
mMessageProcessor = new LJ1200MessageProcessor( aliasList );
mTowerMessageFramer.addMessageListener( mMessageProcessor );
mTransponderMessageFramer.addMessageListener( mMessageProcessor );
mMessageProcessor.setMessageListener( mMessageBroadcaster );
}
@Override
public DecoderType getDecoderType()
{
return DecoderType.LJ_1200;
}
public void dispose()
{
super.dispose();
mDecimationFilter.dispose();
mBandPassFilter.dispose();
mFSKDecoder.dispose();
mTowerMessageFramer.dispose();
mMessageProcessor.dispose();
}
/**
* Returns a float listener interface for connecting this decoder to a
* float stream provider
*/
public RealSampleListener getRealReceiver()
{
return (RealSampleListener)mDecimationFilter;
}
@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;
mFSKDecoder.setListener( decoderTap );
decoderTap.setListener( mTowerMessageFramer );
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:
mFSKDecoder.setListener( mTowerMessageFramer );
break;
}
}
@Override
public Listener<RealBuffer> getRealBufferListener()
{
return mDecimationFilter;
}
}

View File

@@ -0,0 +1,144 @@
/*******************************************************************************
* 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.lj1200;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import message.Message;
import module.decode.state.ChangedAttribute;
import module.decode.state.DecoderState;
import module.decode.state.DecoderStateEvent;
import module.decode.state.DecoderStateEvent.Event;
import module.decode.state.State;
import alias.Alias;
import alias.AliasList;
public class LJ1200DecoderState extends DecoderState
{
private Set<String> mAddresses = new TreeSet<String>();
private String mAddress;
private Alias mAddressAlias;
public LJ1200DecoderState( AliasList aliasList )
{
super( aliasList );
}
public String getAddress()
{
return mAddress;
}
public Alias getAddressAlias()
{
return mAddressAlias;
}
@Override
public void receive( Message message )
{
if( message instanceof LJ1200Message )
{
LJ1200Message lj = (LJ1200Message)message;
if( lj.isValid() )
{
setAddress( lj.getAddress() );
setAddressAlias( lj.getAddressAlias() );
mAddresses.add( mAddress );
broadcast( LJ1200CallEvent.getLJ1200Event( lj ) );
broadcast( new DecoderStateEvent( this, Event.DECODE, State.DATA ) );
}
}
else if( message instanceof LJ1200TransponderMessage )
{
}
}
private void setAddress( String address )
{
mAddress = address;
broadcast( ChangedAttribute.TO_TALKGROUP );
}
private void setAddressAlias( Alias alias )
{
mAddressAlias = alias;
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
}
@Override
public String getActivitySummary()
{
StringBuilder sb = new StringBuilder();
sb.append( "=============================\n" );
sb.append( "Decoder:\tLJ-1200I\n\n" );
if( !mAddresses.isEmpty() )
{
sb.append( "Transponder Addresses:\n" );
List<String> addresses = new ArrayList<String>( mAddresses );
Collections.sort( addresses );
for( String address: addresses )
{
sb.append( "\t" );
sb.append( address );
sb.append( "\n" );
}
}
return sb.toString();
}
@Override
public void init()
{
/* No initialization steps */
}
@Override
public void receiveDecoderStateEvent( DecoderStateEvent event )
{
if( event.getEvent() == Event.RESET )
{
}
}
@Override
public void reset()
{
mAddresses.clear();
setAddress( null );
setAddressAlias( null );
}
}

View File

@@ -0,0 +1,424 @@
/*******************************************************************************
* 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.lj1200;
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;
import edac.CRCLJ;
public class LJ1200Message extends Message
{
private final static Logger mLog = LoggerFactory.getLogger( LJ1200Message.class );
public static final String[] REPLY_CODE = { "0","1","2","3","4","5","6","7",
"8","9","A","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S",
"T","U","V","W","X","Y" };
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static int[] VRC = { 23,22,21,20,19,18,17,16 };
public static int[] LRC = { 31,30,29,28,27,26,25,24 };
public static int[] FUNCTION = { 35,34,33,32 };
public static int[] ADDRESS = { 63,62,61,60,59,58,57,56,55,54,53,52,51,50,
49,48,47,46,45,44,43,42,41,40,39,38,37,36 };
public static int[] REPLY_1 = { 39,38,37,36,43 };
public static int[] REPLY_2 = { 42,41,40,47,46 };
public static int[] REPLY_3 = { 45,44,51,50,49 };
public static int[] REPLY_4 = { 48,55,54,53,52 };
public static int[] REPLY_5 = { 59,58,57,56,63 };
public static int[] MESSAGE_CRC = { 79,78,77,76,75,74,73,72,71,70,69,68,67,
66,65,64 };
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
private BinaryMessage mMessage;
private AliasList mAliasList;
private CRC mCRC;
public LJ1200Message( 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;
}
}
private void checkCRC()
{
mCRC = CRCLJ.checkAndCorrect( mMessage );
}
public boolean isValid()
{
return mCRC == CRC.PASSED || mCRC == CRC.CORRECTED;
}
public String getVRC()
{
return mMessage.getHex( VRC, 2 );
}
public String getLRC()
{
return mMessage.getHex( LRC, 2 );
}
public String getCRC()
{
return mMessage.getHex( MESSAGE_CRC, 4 );
}
public Function getFunction()
{
return Function.fromValue( mMessage.getInt( FUNCTION ),
mMessage.getInt( REPLY_3 ) );
}
public String getAddress()
{
return mMessage.getHex( ADDRESS, 7 );
}
public Alias getAddressAlias()
{
if( mAliasList != null )
{
return mAliasList.getESNAlias( getAddress() );
}
return null;
}
public Alias getSiteAndReplyCodeAlias()
{
if( mAliasList != null &&
( getFunction() == Function.F1_SITE_ID ||
getFunction() == Function.F1_SPEED_UP ) )
{
return mAliasList.getSiteID( getReplyCode() );
}
return null;
}
/**
* 5 character reply code for function E and F, transponder activation.
* @return - reply code
*/
public String getReplyCode()
{
StringBuilder sb = new StringBuilder();
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_1 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_2 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_3 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_4 ) ] );
sb.append( REPLY_CODE[ mMessage.getInt( REPLY_5 ) ] );
return sb.toString();
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
Function function = getFunction();
sb.append( "FUNCTION: " );
sb.append( function.toString() );
switch( function )
{
case F1_SITE_ID:
sb.append( " SITE [" );
break;
case F1_SPEED_UP:
case F2_TEST:
case F3_DEACTIVATE:
case F4_ACTIVATE:
case FF_TRACK_PULSE:
default:
sb.append( " REPLY CODE [" );
break;
}
sb.append( getReplyCode() );
Alias site = getSiteAndReplyCodeAlias();
if( site != null )
{
sb.append( "/" );
sb.append( site.getName() );
}
sb.append( "] ADDRESS [" );
sb.append( getAddress() );
sb.append( "] VRC [" + getVRC() );
sb.append( "] LRC [" + getLRC() );
sb.append( "] CRC [" + getCRC() );
sb.append( "]" );
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 "LJ-1200";
}
@Override
public String getEventType()
{
if( getFunction() == Function.F1_SPEED_UP )
{
return "TRANSPONDER";
}
return "TOWER";
}
@Override
public String getFromID()
{
return getReplyCode();
}
@Override
public Alias getFromIDAlias()
{
return getSiteAndReplyCodeAlias();
}
@Override
public String getToID()
{
return getAddress();
}
@Override
public Alias getToIDAlias()
{
return null;
}
@Override
public String getMessage()
{
return toString();
}
@Override
public String getErrorStatus()
{
return mCRC.getDisplayText();
}
@Override
public Plottable getPlottable()
{
return null;
}
public enum Function
{
/* Big Endian Format */
F0_UNKNOWN( "0-UNKNOWN" ),
F1_SITE_ID( "1Y-SITE ID" ),
F1_SPEED_UP( "1-SPEED UP" ),
F2_TEST( "2-TOWER TEST" ),
F3_DEACTIVATE( "3-DEACTIVATE" ),
F4_ACTIVATE( "4-ACTIVATE" ),
F5_TRANSPONDER_TEST_REPLY( "5-TRANSPONDER TEST REPLY" ),
F6_TRANSPONDER_TEST_COMMAND( "6-TRANSPONDER TEST COMMAND" ),
F7_QUIET_COMMAND( "7-QUIET COMMAND" ),
F8_UNKNOWN( "8-UNKNOWN" ),
F9_UNKNOWN( "9-UNKNOWN" ),
FA_UNKNOWN( "A-UNKNOWN" ),
FB_UNKNOWN( "B-UNKNOWN" ),
FC_ALT_DEACTIVATE( "C-ALT-DEACTIVATE" ),
FD_UNKNOWN( "D-UNKNOWN" ),
FE_UNKNOWN( "E-UNKNOWN" ),
FF_TRACK_PULSE( "F-TRACK PULSE" ),
UNKNOWN( "UNKNOWN" );
private String mLabel;
private Function( String label )
{
mLabel = label;
}
public String getLabel()
{
return mLabel;
}
public String toString()
{
return getLabel();
}
public static Function fromValue( int value, int replyCodeDigit3 )
{
switch( value )
{
case 0:
return Function.F0_UNKNOWN;
case 1:
if( replyCodeDigit3 == 31 ) /* 'Y' middle character */
{
return Function.F1_SITE_ID;
}
else
{
return Function.F1_SPEED_UP;
}
case 2:
return Function.F2_TEST;
case 3:
return Function.F3_DEACTIVATE;
case 4:
return Function.F4_ACTIVATE;
case 5:
return Function.F5_TRANSPONDER_TEST_REPLY;
case 6:
return Function.F6_TRANSPONDER_TEST_COMMAND;
case 7:
return Function.F7_QUIET_COMMAND;
case 8:
return Function.F8_UNKNOWN;
case 9:
return Function.F9_UNKNOWN;
case 10:
return Function.FA_UNKNOWN;
case 11:
return Function.FB_UNKNOWN;
case 12:
return Function.FC_ALT_DEACTIVATE;
case 13:
return Function.FD_UNKNOWN;
case 14:
return Function.FE_UNKNOWN;
case 15:
return Function.FF_TRACK_PULSE;
default:
return Function.UNKNOWN;
}
}
}
/**
* Provides a listing of aliases contained in the message.
*/
public List<Alias> getAliases()
{
List<Alias> aliases = new ArrayList<Alias>();
Alias siteAndReply = getSiteAndReplyCodeAlias();
if( siteAndReply != null )
{
aliases.add( siteAndReply );
}
Alias address = getAddressAlias();
if( address != null )
{
aliases.add( address );
}
return aliases;
}
}

View File

@@ -0,0 +1,53 @@
/*******************************************************************************
* 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.lj1200;
import java.util.Collections;
import java.util.List;
import message.Message;
import filter.Filter;
import filter.FilterElement;
public class LJ1200MessageFilter extends Filter<Message>
{
public LJ1200MessageFilter()
{
super( "LJ-1200 Message Filter" );
}
@Override
public boolean passes( Message message )
{
return mEnabled && canProcess( message );
}
@Override
public boolean canProcess( Message message )
{
return message instanceof LJ1200Message ||
message instanceof LJ1200TransponderMessage;
}
@Override
public List<FilterElement<?>> getFilterElements()
{
return Collections.EMPTY_LIST;
}
}

View File

@@ -0,0 +1,84 @@
/*******************************************************************************
* 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.lj1200;
import message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sample.Listener;
import alias.AliasList;
import bits.BinaryMessage;
public class LJ1200MessageProcessor implements Listener<BinaryMessage>
{
private final static Logger mLog =
LoggerFactory.getLogger( LJ1200MessageProcessor.class );
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static int SYNC_TOWER = 0x550F;
public static int SYNC_TRANSPONDER = 0x2AD5;
private Listener<Message> mMessageListener;
private AliasList mAliasList;
public LJ1200MessageProcessor( AliasList list )
{
mAliasList = list;
}
public void dispose()
{
mAliasList = null;
mMessageListener = null;
}
@Override
public void receive( BinaryMessage buffer )
{
int sync = buffer.getInt( SYNC );
if( sync == SYNC_TOWER )
{
if( mMessageListener != null )
{
mMessageListener.receive( new LJ1200Message( buffer, mAliasList ) );
}
}
else if( sync == SYNC_TRANSPONDER )
{
if( mMessageListener != null )
{
mMessageListener.receive( new LJ1200TransponderMessage( buffer, mAliasList ) );
}
}
}
public void setMessageListener( Listener<Message> listener )
{
mMessageListener = listener;
}
public void removeMessageListener()
{
mMessageListener = null;
}
}

View File

@@ -0,0 +1,111 @@
/*******************************************************************************
* 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.lj1200;
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 LJ1200Panel extends DecoderPanel
{
private static final long serialVersionUID = 1L;
private static final String PROTOCOL = "LJ-1200";
private JLabel mProtocol = new JLabel( PROTOCOL );
private JLabel mTo = new JLabel();
private JLabel mToAlias = new JLabel();
public LJ1200Panel( SettingsManager settingsManager, LJ1200Decoder decoder )
{
super( settingsManager, decoder );
init();
}
public void dispose()
{
super.dispose();
}
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]", "" ) );
add( mProtocol );
add( mTo );
add( mToAlias, "wrap" );
}
private LJ1200DecoderState getState()
{
return (LJ1200DecoderState)getDecoder().getDecoderState();
}
@Override
public void receive( final ChangedAttribute changedAttribute )
{
switch( changedAttribute )
{
case TO_TALKGROUP:
mTo.setText( getState().getAddress() );
repaint();
break;
case FROM_TALKGROUP_ALIAS:
Alias alias = getState().getAddressAlias();
if( alias != null )
{
mToAlias.setText( alias.getName() );
repaint();
}
break;
default:
break;
}
}
@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 )
{
mProtocol.setForeground( color.getColor() );
mTo.setForeground( color.getColor() );
mToAlias.setForeground( color.getColor() );
}
}
}
}

View File

@@ -0,0 +1,195 @@
/*******************************************************************************
* 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.lj1200;
import java.text.SimpleDateFormat;
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;
import edac.CRCLJ;
public class LJ1200TransponderMessage extends Message
{
private final static Logger mLog = LoggerFactory.getLogger( LJ1200TransponderMessage.class );
public static int[] SYNC = { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
public static int[] MESSAGE_CRC = { 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79 };
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
private BinaryMessage mMessage;
private AliasList mAliasList;
private CRC mCRC;
public LJ1200TransponderMessage( 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;
case UNKNOWN:
mLog.debug( "UNKNOWN:" + message.toString() );
break;
}
}
private void checkCRC()
{
mCRC = CRC.UNKNOWN;
}
public boolean isValid()
{
// return mCRC == CRC.PASSED || mCRC == CRC.CORRECTED;
/* Override validity check until proper CRC is implemented */
return true;
}
public String getCRC()
{
return mMessage.getHex( MESSAGE_CRC, 4 );
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( "TRANSPONDER TEST" );
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 "LJ-1200";
}
@Override
public String getEventType()
{
return "TRANSPONDER";
}
@Override
public String getFromID()
{
return null;
}
@Override
public Alias getFromIDAlias()
{
return null;
}
@Override
public String getToID()
{
return null;
}
@Override
public Alias getToIDAlias()
{
return null;
}
@Override
public String getMessage()
{
return toString();
}
@Override
public String getErrorStatus()
{
return mCRC.getDisplayText();
}
@Override
public Plottable getPlottable()
{
return null;
}
}