Updates pull request from Roman Tsypuk to convert the build system from

ant to gradle.  Removes linux and windows application launch scripts and
produces an executable jar with all resources included.
This commit is contained in:
Denny
2017-12-17 07:28:03 -05:00
parent a1535c4157
commit 9316599dec
981 changed files with 8368 additions and 9049 deletions

View File

@@ -0,0 +1,161 @@
/*******************************************************************************
* SDR Trunk
* Copyright (C) 2014,2015 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
******************************************************************************/
package io.github.dsheirer.module.decode.mdc1200;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.module.decode.event.CallEvent;
public class MDCCallEvent extends CallEvent
{
public MDCCallEvent( CallEventType callEventType,
AliasList aliasList,
String fromID,
String toID,
String details )
{
super( DecoderType.MDC1200, callEventType,
aliasList, fromID, toID, details );
}
private Alias getAlias( String ident )
{
if( hasAliasList() )
{
return getAliasList().getMDC1200Alias( 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 MDCCallEvent build()
{
return new MDCCallEvent( this );
}
}
/**
* Private constructor for the builder
*/
private MDCCallEvent( Builder builder )
{
this( builder.mCallEventType,
builder.mAliasList,
builder.mFromID,
builder.mToID,
builder.mDetails );
}
public static MDCCallEvent
getMDCCallEvent( MDCMessage message )
{
CallEventType type = CallEventType.UNKNOWN;
StringBuilder sbDetails = new StringBuilder();
sbDetails.append( "MDC-1200 OPCODE:" );
sbDetails.append( String.valueOf( message.getOpcode() ) );
switch( message.getMessageType() )
{
case ACKNOWLEDGE:
type = CallEventType.RESPONSE;
break;
case ANI:
type = CallEventType.ID_ANI;
break;
case EMERGENCY:
type = CallEventType.EMERGENCY;
break;
case PAGING:
type = CallEventType.PAGE;
break;
default:
break;
}
return new MDCCallEvent.Builder( type )
.details( sbDetails.toString() )
.from( message.getFromID() )
.to( message.getToID() )
.build();
}
}

View File

@@ -0,0 +1,225 @@
/*******************************************************************************
* 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.decode.mdc1200;
import io.github.dsheirer.bits.MessageFramer;
import io.github.dsheirer.bits.SyncPattern;
import io.github.dsheirer.instrument.Instrumentable;
import io.github.dsheirer.instrument.tap.Tap;
import io.github.dsheirer.instrument.tap.TapGroup;
import io.github.dsheirer.instrument.tap.stream.BinaryTap;
import io.github.dsheirer.instrument.tap.stream.FloatBufferTap;
import io.github.dsheirer.instrument.tap.stream.FloatTap;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.real.IFilteredRealBufferListener;
import io.github.dsheirer.sample.real.RealBuffer;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.dsp.NRZDecoder;
import io.github.dsheirer.dsp.filter.Filters;
import io.github.dsheirer.dsp.filter.fir.real.RealFIRFilter_RB_RB;
import io.github.dsheirer.dsp.filter.halfband.real.HalfBandFilter_RB_RB;
import io.github.dsheirer.dsp.fsk.FSK2Decoder;
import io.github.dsheirer.dsp.fsk.FSK2Decoder.Output;
import io.github.dsheirer.module.decode.Decoder;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;
/**
* MDC1200 Decoder - 1200 baud 2FSK decoder that can process 48k sample rate
* complex or floating point samples and output fully framed MDC1200 messages
*/
public class MDCDecoder extends Decoder implements IFilteredRealBufferListener,
Instrumentable
{
/* Decimated sample rate ( 48,000 / 2 = 24,000 ) feeding the decoder */
private static final int sDECIMATED_SAMPLE_RATE = 24000;
/* Baud or Symbol Rate */
private static final int sSYMBOL_RATE = 1200;
/* Message length */
private static final int sMESSAGE_LENGTH = 304;
/* Instrumentation Taps */
private ArrayList<TapGroup> 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_NRZ_DECODER =
"Tap Point: FSK2 Decoder > < NRZI Decoder";
private static final String INSTRUMENT_NRZI_DECODER_TO_MESSAGE_FRAMER =
"Tap Point: NRZ Decoder > < Message Framer";
private FSK2Decoder mFSKDecoder;
private HalfBandFilter_RB_RB mDecimationFilter;
private RealFIRFilter_RB_RB mBandPassFilter;
private NRZDecoder mNRZDecoder;
private MessageFramer mMessageFramer;
private MDCMessageProcessor mMessageProcessor;
public MDCDecoder( AliasList aliasList )
{
/* Decimation filter: 48000 / 2 = 24000 */
mDecimationFilter = new HalfBandFilter_RB_RB(
Filters.FIR_HALF_BAND_31T_ONE_EIGHTH_FCO.getCoefficients(), 1.0f, true );
/* Bandpass filter - predefined */
mBandPassFilter = new RealFIRFilter_RB_RB(
Filters.FIRBP_1200FSK_24000FS.getCoefficients(), 1.02f );
mDecimationFilter.setListener( mBandPassFilter );
/* 2FSK Decoder */
mFSKDecoder = new FSK2Decoder( sDECIMATED_SAMPLE_RATE,
sSYMBOL_RATE, Output.NORMAL );
mBandPassFilter.setListener( mFSKDecoder );
/* NRZ Decoder */
mNRZDecoder = new NRZDecoder( NRZDecoder.MODE_INVERTED );
mFSKDecoder.setListener( mNRZDecoder );
/* Message Framer */
mMessageFramer = new MessageFramer( SyncPattern.MDC1200.getPattern(),
sMESSAGE_LENGTH );
mNRZDecoder.setListener( mMessageFramer );
/* Message Processor */
mMessageProcessor = new MDCMessageProcessor( aliasList );
mMessageFramer.addMessageListener( mMessageProcessor );
mMessageProcessor.addMessageListener( this );
}
public void dispose()
{
super.dispose();
mDecimationFilter.dispose();
mBandPassFilter.dispose();
mFSKDecoder.dispose();
mNRZDecoder.dispose();
mMessageFramer.dispose();
mMessageProcessor.dispose();
}
/* Instrumentation */
@Override
public List<TapGroup> getTapGroups()
{
if( mAvailableTaps == null )
{
mAvailableTaps = new ArrayList<TapGroup>();
TapGroup group = new TapGroup( "MDC-1200 Decoder" );
group.add(
new FloatTap( INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD, 0, 0.5f ) );
group.add(
new BinaryTap( INSTRUMENT_FSK2_DECODER_TO_NRZ_DECODER, 0, 0.025f ) );
group.add(
new BinaryTap( INSTRUMENT_NRZI_DECODER_TO_MESSAGE_FRAMER, 0, 0.025f ) );
mAvailableTaps.add( group );
mAvailableTaps.addAll( mFSKDecoder.getTapGroups() );
}
return mAvailableTaps;
}
@Override
public void registerTap( Tap tap )
{
mFSKDecoder.registerTap( tap );
switch( tap.getName() )
{
case INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD:
/* wire the tap between the bandpass filter and the demod */
FloatBufferTap floatTap = (FloatBufferTap)tap;
mBandPassFilter.setListener( floatTap );
floatTap.setListener( mFSKDecoder );
break;
case INSTRUMENT_FSK2_DECODER_TO_NRZ_DECODER:
/* wire between FSK2 decoder and NRZ decoder */
BinaryTap binTap = (BinaryTap)tap;
mFSKDecoder.setListener( binTap );
binTap.setListener( mNRZDecoder );
break;
case INSTRUMENT_NRZI_DECODER_TO_MESSAGE_FRAMER:
/* wire between demod and framer */
BinaryTap binInvTap = (BinaryTap)tap;
mNRZDecoder.setListener( binInvTap );
binInvTap.setListener( mMessageFramer );
break;
default:
}
}
@Override
public void unregisterTap( Tap tap )
{
mFSKDecoder.unregisterTap( tap );
switch( tap.getName() )
{
case INSTRUMENT_BANDPASS_FILTER_TO_FSK2_DEMOD:
mBandPassFilter.setListener( mFSKDecoder );
break;
case INSTRUMENT_FSK2_DECODER_TO_NRZ_DECODER:
mFSKDecoder.setListener( mNRZDecoder );
break;
case INSTRUMENT_NRZI_DECODER_TO_MESSAGE_FRAMER:
mNRZDecoder.setListener( mMessageFramer );
break;
default:
}
}
@Override
public DecoderType getDecoderType()
{
return DecoderType.MDC1200;
}
@Override
public Listener<RealBuffer> getFilteredRealBufferListener()
{
return mDecimationFilter;
}
@Override
public void reset()
{
// TODO Auto-generated method stub
}
@Override
public void start( ScheduledExecutorService executor )
{
// TODO Auto-generated method stub
}
@Override
public void stop()
{
// TODO Auto-generated method stub
}
}

View File

@@ -0,0 +1,269 @@
/*******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2017 Dennis Sheirer
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
******************************************************************************/
package io.github.dsheirer.module.decode.mdc1200;
import io.github.dsheirer.channel.metadata.AliasedStringAttributeMonitor;
import io.github.dsheirer.channel.metadata.Attribute;
import io.github.dsheirer.channel.metadata.AttributeChangeRequest;
import io.github.dsheirer.channel.state.DecoderState;
import io.github.dsheirer.channel.state.DecoderStateEvent;
import io.github.dsheirer.channel.state.DecoderStateEvent.Event;
import io.github.dsheirer.channel.state.State;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.module.decode.DecoderType;
import io.github.dsheirer.util.StringUtils;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.alias.id.AliasIDType;
import java.util.Iterator;
import java.util.TreeSet;
import java.util.concurrent.ScheduledExecutorService;
public class MDCDecoderState extends DecoderState
{
private TreeSet<String> mIdents = new TreeSet<String>();
private TreeSet<String> mEmergencyIdents = new TreeSet<String>();
private AliasedStringAttributeMonitor mFromAttribute;
private String mMessage;
private String mMessageType;
public MDCDecoderState(AliasList aliasList)
{
super(aliasList);
mFromAttribute = new AliasedStringAttributeMonitor(Attribute.SECONDARY_ADDRESS_FROM,
getAttributeChangeRequestListener(), getAliasList(), AliasIDType.MDC1200);
}
@Override
public DecoderType getDecoderType()
{
return DecoderType.MDC1200;
}
@Override
public void start(ScheduledExecutorService executor)
{
}
@Override
public void stop()
{
}
@Override
public void reset()
{
mIdents.clear();
mEmergencyIdents.clear();
resetState();
}
private void resetState()
{
mFromAttribute.reset();
mMessage = null;
mMessageType = null;
}
@Override
public void receive(Message message)
{
if(message instanceof MDCMessage)
{
MDCMessage mdc = (MDCMessage) message;
mIdents.add(mdc.getUnitID());
if(mdc.isEmergency())
{
mEmergencyIdents.add(mdc.getUnitID());
}
mFromAttribute.process(mdc.getFromID());
MDCMessageType type = mdc.getMessageType();
setMessageType(type.getLabel());
StringBuilder sb = new StringBuilder();
sb.append("OPCODE ");
sb.append(String.valueOf(mdc.getOpcode()));
if(mdc.isBOT())
{
sb.append(" TYPE:BOT");
}
if(mdc.isEOT())
{
sb.append(" TYPE:EOT");
}
setMessage(sb.toString());
MDCCallEvent event = MDCCallEvent.getMDCCallEvent(mdc);
event.setAliasList(getAliasList());
broadcast(event);
switch(type)
{
case ANI:
broadcast(new DecoderStateEvent(this, Event.DECODE, State.CALL));
break;
case ACKNOWLEDGE:
case EMERGENCY:
case PAGING:
case STATUS:
default:
broadcast(new DecoderStateEvent(this, Event.DECODE, State.DATA));
break;
}
}
}
public String getMessage()
{
return mMessage;
}
public void setMessage(String message)
{
if(!StringUtils.isEqual(mMessage, message))
{
mMessage = message;
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE, mMessage));
}
}
public String getMessageType()
{
return mMessageType;
}
public void setMessageType(String type)
{
if(!StringUtils.isEqual(mMessageType, type))
{
mMessageType = type;
broadcast(new AttributeChangeRequest<String>(Attribute.MESSAGE_TYPE, "MDC:" + mMessageType));
}
}
@Override
public String getActivitySummary()
{
StringBuilder sb = new StringBuilder();
sb.append("=============================\n");
sb.append("Decoder:\tMDC-1200\n\n");
sb.append("MDC-1200 Idents\n");
if(mIdents.isEmpty())
{
sb.append(" None\n");
}
else
{
Iterator<String> it = mIdents.iterator();
while(it.hasNext())
{
String ident = it.next();
sb.append(" ");
sb.append(ident);
sb.append(" ");
if(hasAliasList())
{
Alias alias = getAliasList().getMDC1200Alias(ident);
if(alias != null)
{
sb.append(alias.getName());
}
}
sb.append("\n");
}
}
sb.append("MDC-1200 Emergency Idents\n");
if(mEmergencyIdents.isEmpty())
{
sb.append(" None\n");
}
else
{
Iterator<String> it = mEmergencyIdents.iterator();
while(it.hasNext())
{
String ident = it.next();
sb.append(" ");
sb.append(ident);
sb.append(" ");
if(hasAliasList())
{
Alias alias = getAliasList().getMDC1200Alias(ident);
if(alias != null)
{
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;
}
}
}

View File

@@ -0,0 +1,345 @@
/*******************************************************************************
* 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.decode.mdc1200;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.map.Plottable;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.alias.Alias;
import io.github.dsheirer.alias.AliasList;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MDCMessage extends Message
{
private static SimpleDateFormat mSDF = new SimpleDateFormat( "yyyyMMdd HHmmss" );
private static int[] sSYNC1 = { 0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39 };
private static int[] sOPCODE = { 47,46,45,44,43,42,41,40 };
private static int sANI_FLAG = 40;
private static int sDIRECTION_FLAG = 45;
private static int sACKNOWLEDGE_REQUIRED_FLAG = 46;
private static int sPACKET_TYPE_FLAG = 47;
private static int sEMERGENCY_FLAG = 48;
private static int[] sARGUMENT = { 49,50,51,52,53,54 };
private static int sBOT_EOT_FLAG = 55;
private static int[] sDIGIT_2 = { 59,58,57,56 };
private static int[] sDIGIT_1 = { 63,62,61,60 };
private static int[] sDIGIT_4 = { 67,66,65,64 };
private static int[] sDIGIT_3 = { 71,70,69,68 };
private BinaryMessage mMessage;
private AliasList mAliasList;
public MDCMessage( BinaryMessage message, AliasList list )
{
mMessage = message;
mAliasList = list;
}
public boolean isValid()
{
//TODO: add CRC and/or convolution decoding/repair
return true;
}
public PacketType getPacketType()
{
if( mMessage.get( sPACKET_TYPE_FLAG ) )
{
return PacketType.DATA;
}
else
{
return PacketType.CMND;
}
}
public Acknowledge getResponse()
{
if( mMessage.get( sACKNOWLEDGE_REQUIRED_FLAG ) )
{
return Acknowledge.YES;
}
else
{
return Acknowledge.NO;
}
}
public Direction getDirection()
{
if( mMessage.get( sDIRECTION_FLAG ) )
{
return Direction.OUT;
}
else
{
return Direction.IN;
}
}
public int getOpcode()
{
return mMessage.getInt( sOPCODE );
}
public int getArgument()
{
return mMessage.getInt( sARGUMENT );
}
public boolean isEmergency()
{
return mMessage.get( sEMERGENCY_FLAG );
}
public boolean isANI()
{
return mMessage.get( sANI_FLAG );
}
public boolean isBOT()
{
return mMessage.get( sBOT_EOT_FLAG );
}
public boolean isEOT()
{
return !mMessage.get( sBOT_EOT_FLAG );
}
public String getUnitID()
{
StringBuilder sb = new StringBuilder();
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_1 ) ).toUpperCase() );
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_2 ) ).toUpperCase() );
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_3 ) ).toUpperCase() );
sb.append( Integer.toHexString( mMessage.getInt( sDIGIT_4 ) ).toUpperCase() );
return sb.toString();
}
public MDCMessageType getMessageType()
{
switch( getOpcode() )
{
case 0:
if( isEmergency() )
{
return MDCMessageType.EMERGENCY;
}
case 1:
return MDCMessageType.ANI;
default:
return MDCMessageType.UNKNOWN;
}
}
@Override
public String toString()
{
StringBuilder sb = new StringBuilder();
sb.append( mSDF.format( new Date( System.currentTimeMillis() ) ) );
sb.append( getMessage() );
sb.append( " [" + mMessage.toString() + "]" );
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();
}
@SuppressWarnings( "unused" )
private int getInt( int[] bits )
{
int retVal = 0;
for( int x = 0; x < bits.length; x++ )
{
if( mMessage.get( bits[ x ] ) )
{
retVal += 1<<x;
}
}
return retVal;
}
@Override
public String getBinaryMessage()
{
return mMessage.toString();
}
@Override
public String getProtocol()
{
return "MDC-1200";
}
@Override
public String getEventType()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getFromID()
{
return getUnitID();
}
@Override
public Alias getFromIDAlias()
{
return mAliasList.getMDC1200Alias( getFromID() );
}
@Override
public String getToID()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Alias getToIDAlias()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getMessage()
{
StringBuilder sb = new StringBuilder();
sb.append( "MDC1200 UNIT:" + getUnitID() );
if( isEmergency() )
{
sb.append( " **EMERGENCY**" );
}
if( isBOT() )
{
sb.append( " BOT" );
}
if( isEOT() )
{
sb.append( " EOT" );
}
sb.append( " OPCODE:" + format( getOpcode(), 2 ) );
sb.append( " ARG:" + format( getArgument(), 3 ) );
sb.append( " TYPE:" + getPacketType().toString() );
sb.append( " ACK:" + getResponse().toString() );
sb.append( " DIR:" + pad( getDirection().toString(), 3, " " ) );
return sb.toString();
}
@Override
public String getErrorStatus()
{
// TODO Auto-generated method stub
return null;
}
@Override
public Plottable getPlottable()
{
// TODO Auto-generated method stub
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;
}
private enum PacketType { CMND, DATA };
private enum Acknowledge { YES, NO };
private enum Direction { IN, OUT };
}

View File

@@ -0,0 +1,56 @@
package io.github.dsheirer.module.decode.mdc1200;
import io.github.dsheirer.filter.Filter;
import io.github.dsheirer.filter.FilterElement;
import io.github.dsheirer.message.Message;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class MDCMessageFilter extends Filter<Message>
{
private HashMap<MDCMessageType, FilterElement<MDCMessageType>> mElements =
new HashMap<MDCMessageType, FilterElement<MDCMessageType>>();
public MDCMessageFilter()
{
super( "MDC-1200 Message Filter" );
for( MDCMessageType type: MDCMessageType.values() )
{
if( type != MDCMessageType.UNKNOWN )
{
mElements.put( type, new FilterElement<MDCMessageType>( type ) );
}
}
}
@Override
public boolean passes( Message message )
{
if( mEnabled && canProcess( message ) )
{
MDCMessage mdc = (MDCMessage)message;
if( mElements.containsKey( mdc.getMessageType() ) )
{
return mElements.get( mdc.getMessageType() ).isEnabled();
}
}
return false;
}
@Override
public boolean canProcess( Message message )
{
return message instanceof MDCMessage;
}
@Override
public List<FilterElement<?>> getFilterElements()
{
return new ArrayList<FilterElement<?>>( mElements.values() );
}
}

View File

@@ -0,0 +1,155 @@
/*******************************************************************************
* 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.decode.mdc1200;
import io.github.dsheirer.bits.BinaryMessage;
import io.github.dsheirer.message.Message;
import io.github.dsheirer.sample.Broadcaster;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.alias.AliasList;
public class MDCMessageProcessor implements Listener<BinaryMessage>
{
private static int sMESSAGE_LENGTH = 112;
private Broadcaster<Message> mBroadcaster = new Broadcaster<Message>();
private AliasList mAliasList;
public MDCMessageProcessor( AliasList aliasList )
{
mAliasList = aliasList;
}
public void dispose()
{
mBroadcaster.dispose();
}
@Override
public void receive( BinaryMessage buffer )
{
/**
* De-interleave the 112 bits of message one, starting after the sync
* pattern
*/
deinterleave( buffer, 40 );
/**
* For simplicity, we also deinterleave message 2, which may or may not
* be there, starting after the initial sync ( 0 - 39 ) and the initial
* message ( 40 - 151 ) and the second sync ( 152 - 191 ).
*/
deinterleave( buffer, 192 );
/**
* Wrap the buffer in a message along with the designated alias list
* and send it on its merry way
*/
MDCMessage message = new MDCMessage( buffer, mAliasList );
mBroadcaster.receive( message );
}
public void addMessageListener( Listener<Message> listener )
{
mBroadcaster.addListener( listener );
}
public void removeMessageListener( Listener<Message> listener )
{
mBroadcaster.removeListener( listener );
}
/**
* Removes NRZ-I encoding from the entire buffer. Assumes that the initial
* bit will be a 0 after decode, despite what is currently in the buffer,
* in order to maintain correct polarity of the decoded message.
*/
private void removeNRZIEncoding( BinaryMessage buffer )
{
/**
* Clear bit position 0, the first bit of the sync pattern, to start
* the decode with the correct polarity
*/
buffer.clear( 0 );
/**
* Set each bit according to the state of the previous bit using XOR
* as follows:
*
* 0 = same as previous state
* 1 = inverse of previous state
*/
for( int x = 1; x < buffer.size(); x++ )
{
if( buffer.get( x - 1 ) ^ buffer.get( x ) )
{
buffer.set( x );
}
else
{
buffer.clear( x );
}
}
}
/**
* Deinterleaves a 112-bit packet, starting at the offset into the buffer
*/
private void deinterleave( BinaryMessage buffer, int offset )
{
if( buffer.size() < sMESSAGE_LENGTH + offset )
{
throw new IllegalArgumentException( "MDCMessageProcessor - "
+ "cannot deinterleave message - message buffer too short" );
}
BinaryMessage deinterleaved = new BinaryMessage( 112 );
int deinterleavedPointer = 0;
for( int column = 0; column < 16; column++ )
{
for( int row = 0; row < 7; row++ )
{
if( buffer.get( ( row * 16 ) + column + offset ) )
{
deinterleaved.set( deinterleavedPointer );
}
deinterleavedPointer++;
}
}
//Overlay the deinterleaved bits back onto the source message and
//return it
buffer.clear( offset, offset + sMESSAGE_LENGTH );
for( int x = 0; x < sMESSAGE_LENGTH; x++ )
{
if( deinterleaved.get( x ) )
{
buffer.set( x + offset );
}
else
{
buffer.clear( x + offset );
}
}
}
}

View File

@@ -0,0 +1,40 @@
/*******************************************************************************
* 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.decode.mdc1200;
public enum MDCMessageType
{
ACKNOWLEDGE( "Acknowledge" ),
ANI( "ANI" ),
EMERGENCY( "Emergency" ),
PAGING( "Paging" ),
STATUS( "Status" ),
UNKNOWN( "Unk" );
private String mLabel;
private MDCMessageType( String label )
{
mLabel = label;
}
public String getLabel()
{
return mLabel;
}
}