mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 12:36:07 -05:00
Revert "Merges master onto development branch"
This reverts commit 2420bc901c63ad9d41e7c99ac95a426f826182ff.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
/*.class
|
/*.class
|
||||||
/classes*
|
/classes*
|
||||||
/product*
|
/product*
|
||||||
/bin/
|
|
||||||
31
README.md
31
README.md
@@ -1,22 +1,19 @@
|
|||||||
# sdrtrunk #
|
# sdrtrunk
|
||||||
A cross-platform java application for decoding, monitoring and recording trunked
|
A cross-platform java application for decoding, monitoring, recording and streaming trunked mobile and related radio protocols using Software Defined Radios (SDR).
|
||||||
mobile and related radio protocols using Software Defined Radios (SDR).
|
|
||||||
|
|
||||||
# Documentation #
|
|
||||||
* [Getting Started](https://github.com/DSheirer/sdrtrunk/wiki/GettingStarted)
|
* [Getting Started](https://github.com/DSheirer/sdrtrunk/wiki/GettingStarted)
|
||||||
* [User's Manual (Version 0.2.0)](https://github.com/DSheirer/sdrtrunk/wiki/UserManual)
|
* [User's Manual](https://github.com/DSheirer/sdrtrunk/wiki/UserManual)
|
||||||
* [Wiki](https://github.com/DSheirer/sdrtrunk/wiki)
|
* [Download](https://drive.google.com/folderview?id=0B7BHsssXUq8eOHBTNndCczZTd0k&usp=sharing)
|
||||||
|
|
||||||
# Support Group and Error Reporting #
|
|
||||||
You can get help with setting up the sdrtrunk application or report any errors
|
|
||||||
that you encounter while running the application in the sdrtrunk Google Group at:
|
|
||||||
|
|
||||||
* [Support](https://groups.google.com/forum/#!forum/sdrtrunk)
|
* [Support](https://groups.google.com/forum/#!forum/sdrtrunk)
|
||||||
|
|
||||||
# Updates #
|
|
||||||
Subscribe to this group to receive updates about new releases and the ongoing
|
|
||||||
application development effort.
|
|
||||||
|
|
||||||
* [Subscribe for Updates](https://groups.google.com/forum/#!forum/sdrtrunk)
|
|
||||||
|
|
||||||

|

|
||||||
|
<script>
|
||||||
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
|
ga('create', 'UA-67489234-1', 'auto');
|
||||||
|
ga('send', 'pageview');
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|||||||
114
build/build.xml
114
build/build.xml
@@ -7,115 +7,113 @@
|
|||||||
<property name="major" value="0"/>
|
<property name="major" value="0"/>
|
||||||
<property name="minor" value="2"/>
|
<property name="minor" value="2"/>
|
||||||
<property name="patch" value="0"/>
|
<property name="patch" value="0"/>
|
||||||
<property name="release" value="beta.5"/>
|
<property name="release" value="beta.2"/>
|
||||||
<property name="filename" value="sdrtrunk_${major}.${minor}.${patch}-${release}"/>
|
|
||||||
|
|
||||||
<!-- Build properties -->
|
|
||||||
<property name="repo" location=".."/>
|
|
||||||
<property name="source.code" location="${repo}/src"/>
|
|
||||||
<property name="source.configs" location="${repo}/config"/>
|
|
||||||
<property name="source.images" location="${repo}/images"/>
|
|
||||||
<property name="source.libs" location="${repo}/imports"/>
|
|
||||||
<property name="source.license" location="${repo}/license"/>
|
|
||||||
<property name="source.scripts" location="${repo}/scripts"/>
|
|
||||||
|
|
||||||
<property name="output" location="${repo}/product"/>
|
<!-- Build properties -->
|
||||||
<property name="output.classes" location="${repo}/classes"/>
|
<property name="classes" location="../classes"/>
|
||||||
<property name="output.folder" location="${output}/sdrtrunk"/>
|
<property name="configs" location="../config"/>
|
||||||
<property name="output.config" location="${output.folder}/config"/>
|
<property name="images" location="../images"/>
|
||||||
<property name="output.images" location="${output.folder}/images"/>
|
<property name="libs" location="../imports"/>
|
||||||
<property name="output.libs" location="${output.folder}/libs"/>
|
<property name="license" location="../license"/>
|
||||||
|
<property name="product" location="../product"/>
|
||||||
|
<property name="scripts" location="../scripts"/>
|
||||||
|
<property name="src" location="../src"/>
|
||||||
|
|
||||||
<path id="classpath">
|
<path id="classpath">
|
||||||
<fileset dir="${source.libs}" includes="*.jar" />
|
<fileset dir="${libs}" includes="*.jar" />
|
||||||
</path>
|
</path>
|
||||||
|
|
||||||
<target name="init">
|
<target name="init">
|
||||||
<!-- Create the classes folder to contain the compiled java classes -->
|
<!-- Create the classes folder to contain the compiled java classes -->
|
||||||
<mkdir dir="${output.classes}"/>
|
<mkdir dir="${classes}"/>
|
||||||
|
|
||||||
<!-- Create version file -->
|
<!-- Create version file -->
|
||||||
<echo message="${major}.${minor}.${patch}-${release}" file="${output.classes}/sdrtrunk-version"/>
|
<echo message="${major}.${minor}.${patch}-${release}" file="${classes}/sdrtrunk-version"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="compile" depends="clean,init" description="Compile java classes" >
|
<target name="compile" depends="clean,init"
|
||||||
<javac srcdir="${source.code}" destdir="${output.classes}" classpathref="classpath" includeantruntime="false" />
|
description="Compile java classes" >
|
||||||
|
<!-- Compile the java code from ${src} into ${classes} -->
|
||||||
|
<javac srcdir="${src}"
|
||||||
|
destdir="${classes}"
|
||||||
|
classpathref="classpath"
|
||||||
|
includeantruntime="false" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="SDRTrunk" depends="compile" description="Create SDRTrunk application" >
|
<target name="SDRTrunk" depends="compile" description="Create SDRTrunk application" >
|
||||||
<!-- Create the distribution directory -->
|
<!-- Create the distribution directory -->
|
||||||
<mkdir dir="${output.folder}"/>
|
<mkdir dir="${product}"/>
|
||||||
|
|
||||||
<!-- Create jar file -->
|
<!-- Create jar file -->
|
||||||
<jar jarfile="${output.folder}/sdrtrunk.jar" basedir="${output.classes}">
|
<jar jarfile="${product}/SDRTrunk.jar" basedir="${classes}">
|
||||||
<manifest>
|
<manifest>
|
||||||
<attribute name="Title" value="sdrtrunk"/>
|
|
||||||
<attribute name="Main-Class" value="gui.SDRTrunk"/>
|
<attribute name="Main-Class" value="gui.SDRTrunk"/>
|
||||||
<attribute name="Version" value="${major}.${minor}.${patch}-${release}"/>
|
|
||||||
</manifest>
|
</manifest>
|
||||||
<fileset dir="${source.configs}">
|
<fileset dir="${configs}">
|
||||||
<exclude name="*.rules"/>
|
<exclude name="*.rules"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
|
|
||||||
<fileset dir="${source.license}">
|
<fileset dir="${license}">
|
||||||
<include name="license.txt"/>
|
<include name="license.txt"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</jar>
|
</jar>
|
||||||
|
|
||||||
<!-- Copy third-party libraries -->
|
<!-- Copy third-party libraries -->
|
||||||
<mkdir dir="${output.libs}"/>
|
<mkdir dir="${product}/libs"/>
|
||||||
<copy todir="${output.libs}">
|
<copy todir="${product}/libs">
|
||||||
<fileset dir="${source.libs}" includes="*.jar" />
|
<fileset dir="${libs}" includes="*.jar" />
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<!-- Copy config files -->
|
<!-- Copy config files -->
|
||||||
<mkdir dir="${output.config}"/>
|
<mkdir dir="${product}/config"/>
|
||||||
|
|
||||||
<copy todir="${output.config}">
|
<copy todir="${product}/config">
|
||||||
<fileset dir="${source.configs}">
|
<fileset dir="${configs}">
|
||||||
<include name="*.rules"/>
|
<include name="*.rules"/>
|
||||||
</fileset>
|
</fileset>
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<!-- Copy image files -->
|
<!-- Copy image files -->
|
||||||
<mkdir dir="${output.images}"/>
|
<mkdir dir="${product}/images"/>
|
||||||
<copy todir="${output.images}">
|
<copy todir="${product}/images">
|
||||||
<fileset dir="${source.images}" />
|
<fileset dir="${images}" />
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<!-- Copy license file -->
|
<!-- Copy license file -->
|
||||||
<copy todir="${output.folder}">
|
<copy todir="${product}">
|
||||||
<fileset dir="${source.license}">
|
<fileset dir="${license}" />
|
||||||
<include name="license.txt"/>
|
|
||||||
</fileset>
|
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
<!-- Copy program scripts -->
|
<!-- Copy program scripts -->
|
||||||
<copy todir="${output.folder}">
|
<copy todir="${product}">
|
||||||
<fileset dir="${source.scripts}" />
|
<fileset dir="${scripts}" />
|
||||||
</copy>
|
</copy>
|
||||||
|
|
||||||
|
<!-- Set linux permissions on start script -->
|
||||||
|
<chmod file="${product}/run_sdrtrunk_linux.sh" perm="777" />
|
||||||
|
|
||||||
|
<tstamp prefix="build" />
|
||||||
|
|
||||||
|
<property name="filename" value="sdrtrunk_${build.DSTAMP}_${build.TSTAMP}_${major}.${minor}.${patch}-${release}"/>
|
||||||
|
|
||||||
<!-- Bundle the files into .zip -->
|
<!-- Bundle the files into .zip -->
|
||||||
<zip destfile="${output}/${filename}.zip" basedir="${output}" />
|
<zip destfile="${product}/${filename}.zip" basedir="${product}" />
|
||||||
|
|
||||||
<!-- Remove linux start script before tar task -->
|
|
||||||
<delete file="${output.folder}/run_sdrtrunk_linux.sh"/>
|
|
||||||
|
|
||||||
<!-- Bundle files into .tar.gz and copy/set permissions on linux start script -->
|
|
||||||
<tar destfile="${output}/${filename}.tar.gz" compression="gzip">
|
|
||||||
<tarfileset dir="${output.folder}" prefix="sdrtrunk" />
|
|
||||||
<tarfileset dir="${source.scripts}" prefix="sdrtrunk" filemode="777">
|
|
||||||
<include name="run_sdrtrunk_linux.sh"/>
|
|
||||||
</tarfileset>
|
|
||||||
</tar>
|
|
||||||
|
|
||||||
<delete dir="${output.folder}"/>
|
<!-- Bundle the files into .tar.gz to preserve linux script permissions -->
|
||||||
|
<tar destfile="${product}/${filename}.tar.gz" compression="gzip">
|
||||||
|
<tarfileset dir="${product}" filemode="777">
|
||||||
|
<include name="*.sh"/>
|
||||||
|
</tarfileset>
|
||||||
|
<tarfileset dir="${product}">
|
||||||
|
<exclude name="*.sh"/>
|
||||||
|
<exclude name="${filename}.zip"/>
|
||||||
|
</tarfileset>
|
||||||
|
</tar>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="clean" description="Clean previous build artifacts" >
|
<target name="clean" description="Clean previous build artifacts" >
|
||||||
<delete dir="${output.classes}"/>
|
<delete dir="${classes}"/>
|
||||||
<delete dir="${output}"/>
|
<delete dir="${product}"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -1 +1 @@
|
|||||||
java -XX:+UseG1GC -cp "sdrtrunk.jar;*;libs/*;config/*;images/*" gui.SDRTrunk
|
java -XX:+UseG1GC -cp "SDRTrunk.jar;*;libs/*;config/*;images/*" gui.SDRTrunk
|
||||||
@@ -48,11 +48,8 @@ public class AudioChannelPanel extends JPanel
|
|||||||
private JLabel mFromLabel = new JLabel( "FROM:" );
|
private JLabel mFromLabel = new JLabel( "FROM:" );
|
||||||
private JLabel mFrom = new JLabel( "" );
|
private JLabel mFrom = new JLabel( "" );
|
||||||
private JLabel mFromAlias = new JLabel( "" );
|
private JLabel mFromAlias = new JLabel( "" );
|
||||||
|
|
||||||
private enum AudioStatus { STARTED,STOPPED };
|
|
||||||
private AudioStatus mAudioStatus = AudioStatus.STOPPED;
|
|
||||||
|
|
||||||
private AudioMetadata mAudioMetadata;
|
private boolean mConfigured = false;
|
||||||
|
|
||||||
public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
|
public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
|
||||||
{
|
{
|
||||||
@@ -137,19 +134,15 @@ public class AudioChannelPanel extends JPanel
|
|||||||
{
|
{
|
||||||
switch( audioEvent.getType() )
|
switch( audioEvent.getType() )
|
||||||
{
|
{
|
||||||
case AUDIO_STARTED:
|
|
||||||
synchronized( mAudioStatus )
|
|
||||||
{
|
|
||||||
mAudioStatus = AudioStatus.STARTED;
|
|
||||||
updateLabels();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case AUDIO_STOPPED:
|
case AUDIO_STOPPED:
|
||||||
synchronized( mAudioStatus )
|
EventQueue.invokeLater( new Runnable()
|
||||||
{
|
{
|
||||||
mAudioStatus = AudioStatus.STOPPED;
|
@Override
|
||||||
resetLabels();
|
public void run()
|
||||||
}
|
{
|
||||||
|
resetLabels();
|
||||||
|
}
|
||||||
|
} );
|
||||||
break;
|
break;
|
||||||
case AUDIO_MUTED:
|
case AUDIO_MUTED:
|
||||||
case AUDIO_UNMUTED:
|
case AUDIO_UNMUTED:
|
||||||
@@ -173,55 +166,13 @@ public class AudioChannelPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
private void resetLabels()
|
private void resetLabels()
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater( new Runnable()
|
mFrom.setText( "" );
|
||||||
{
|
updateAlias( mFromAlias, null );
|
||||||
@Override
|
|
||||||
public void run()
|
mTo.setText( "" );
|
||||||
{
|
updateAlias( mToAlias, null );
|
||||||
mFrom.setText( "" );
|
|
||||||
updateAlias( mFromAlias, null );
|
mConfigured = false;
|
||||||
|
|
||||||
mTo.setText( "" );
|
|
||||||
updateAlias( mToAlias, null );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateLabels()
|
|
||||||
{
|
|
||||||
if( mAudioMetadata != null )
|
|
||||||
{
|
|
||||||
final Metadata from = mAudioMetadata.getMetadata( MetadataType.FROM );
|
|
||||||
|
|
||||||
final Metadata to = mAudioMetadata.getMetadata( MetadataType.TO );
|
|
||||||
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
if( from != null )
|
|
||||||
{
|
|
||||||
mFrom.setText( from.getValue() );
|
|
||||||
updateAlias( mFromAlias, from.getAlias() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFrom.setText( "-----" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( to != null )
|
|
||||||
{
|
|
||||||
mTo.setText( to.getValue() );
|
|
||||||
updateAlias( mToAlias, to.getAlias() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mTo.setText( "-----" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,17 +214,32 @@ public class AudioChannelPanel extends JPanel
|
|||||||
@Override
|
@Override
|
||||||
public void receive( AudioMetadata audioMetadata )
|
public void receive( AudioMetadata audioMetadata )
|
||||||
{
|
{
|
||||||
mAudioMetadata = audioMetadata;
|
if( !mConfigured || audioMetadata.isUpdated() )
|
||||||
|
|
||||||
if( audioMetadata.isUpdated() )
|
|
||||||
{
|
{
|
||||||
synchronized( mAudioStatus )
|
final Metadata from = audioMetadata.getMetadata( MetadataType.FROM );
|
||||||
|
|
||||||
|
final Metadata to = audioMetadata.getMetadata( MetadataType.TO );
|
||||||
|
|
||||||
|
EventQueue.invokeLater( new Runnable()
|
||||||
{
|
{
|
||||||
if( mAudioStatus == AudioStatus.STARTED )
|
@Override
|
||||||
|
public void run()
|
||||||
{
|
{
|
||||||
updateLabels();
|
if( from != null )
|
||||||
|
{
|
||||||
|
mFrom.setText( from.getValue() );
|
||||||
|
updateAlias( mFromAlias, from.getAlias() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( to != null )
|
||||||
|
{
|
||||||
|
mTo.setText( to.getValue() );
|
||||||
|
updateAlias( mToAlias, to.getAlias() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
} );
|
||||||
|
|
||||||
|
mConfigured = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package audio;
|
|||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014,2015 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,12 +17,16 @@ package audio;
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.LinkedTransferQueue;
|
import java.util.concurrent.LinkedTransferQueue;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -33,12 +37,10 @@ import javax.sound.sampled.Mixer;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import properties.SystemProperties;
|
|
||||||
import sample.Broadcaster;
|
import sample.Broadcaster;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import source.mixer.MixerChannel;
|
import source.mixer.MixerChannel;
|
||||||
import source.mixer.MixerChannelConfiguration;
|
import source.mixer.MixerChannelConfiguration;
|
||||||
import source.mixer.MixerManager;
|
|
||||||
import audio.AudioEvent.Type;
|
import audio.AudioEvent.Type;
|
||||||
import audio.output.AudioOutput;
|
import audio.output.AudioOutput;
|
||||||
import audio.output.MonoAudioOutput;
|
import audio.output.MonoAudioOutput;
|
||||||
@@ -51,9 +53,7 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
private static final Logger mLog = LoggerFactory.getLogger( AudioManager.class );
|
private static final Logger mLog = LoggerFactory.getLogger( AudioManager.class );
|
||||||
|
|
||||||
public static final int AUDIO_TIMEOUT = 2000; //2 seconds
|
public static final int AUDIO_TIMEOUT = 2000; //2 seconds
|
||||||
|
public static final int NO_SOURCE = 0;
|
||||||
public static final String AUDIO_CHANNELS_PROPERTY = "audio.manager.channels";
|
|
||||||
public static final String AUDIO_MIXER_PROPERTY = "audio.manager.mixer";
|
|
||||||
|
|
||||||
public static final AudioEvent CONFIGURATION_CHANGE_STARTED =
|
public static final AudioEvent CONFIGURATION_CHANGE_STARTED =
|
||||||
new AudioEvent( Type.AUDIO_CONFIGURATION_CHANGE_STARTED, null );
|
new AudioEvent( Type.AUDIO_CONFIGURATION_CHANGE_STARTED, null );
|
||||||
@@ -62,90 +62,49 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
new AudioEvent( Type.AUDIO_CONFIGURATION_CHANGE_COMPLETE, null );
|
new AudioEvent( Type.AUDIO_CONFIGURATION_CHANGE_COMPLETE, null );
|
||||||
|
|
||||||
private LinkedTransferQueue<AudioPacket> mAudioPacketQueue = new LinkedTransferQueue<>();
|
private LinkedTransferQueue<AudioPacket> mAudioPacketQueue = new LinkedTransferQueue<>();
|
||||||
private Map<Integer,AudioOutputConnection> mChannelConnectionMap = new HashMap<>();
|
private Map<Integer,AudioChannelAssignment> mChannelAssignments = new HashMap<>();
|
||||||
private List<AudioOutputConnection> mAudioOutputConnections = new ArrayList<>();
|
private int mLowestPrioritySource;
|
||||||
private AudioOutputConnection mLowestPriorityConnection;
|
|
||||||
private int mAvailableConnectionCount;
|
|
||||||
|
|
||||||
|
private List<AudioOutput> mAvailableAudioOutputs = new ArrayList<>();
|
||||||
private Map<String,AudioOutput> mAudioOutputMap = new HashMap<>();
|
private Map<String,AudioOutput> mAudioOutputMap = new HashMap<>();
|
||||||
|
private List<String> mChannelNames = new ArrayList<>();
|
||||||
|
|
||||||
private Broadcaster<AudioEvent> mControllerBroadcaster = new Broadcaster<>();
|
private Broadcaster<AudioEvent> mControllerBroadcaster = new Broadcaster<>();
|
||||||
|
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
private ScheduledFuture<?> mProcessingTask;
|
private ScheduledFuture<?> mProcessingTask;
|
||||||
private MixerManager mMixerManager;
|
|
||||||
|
|
||||||
private MixerChannelConfiguration mMixerChannelConfiguration;
|
private MixerChannelConfiguration mMixerChannel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes all audio produced by the decoding channels and routes audio
|
* Processes all audio produced by the decoding channels and routes audio
|
||||||
* packets to any combination of outputs based on any alias audio routing
|
* packets to any combination of outputs based on any alias audio routing
|
||||||
* options specified by the user.
|
* options specified by the user.
|
||||||
*/
|
*/
|
||||||
public AudioManager( ThreadPoolManager manager, MixerManager mixerManager )
|
public AudioManager( ThreadPoolManager manager )
|
||||||
{
|
{
|
||||||
mThreadPoolManager = manager;
|
mThreadPoolManager = manager;
|
||||||
mMixerManager = mixerManager;
|
|
||||||
|
|
||||||
loadSettings();
|
//TODO: save audio system preferences to the settings manager
|
||||||
}
|
|
||||||
|
|
||||||
private void loadSettings()
|
|
||||||
{
|
|
||||||
MixerChannelConfiguration configuration = null;
|
|
||||||
|
|
||||||
SystemProperties properties = SystemProperties.getInstance();
|
/* Use the system default mixer and mono channel as default startup */
|
||||||
|
Mixer mixer = AudioSystem.getMixer( null );
|
||||||
|
|
||||||
Mixer defaultMixer = AudioSystem.getMixer( null );
|
if( mixer != null )
|
||||||
|
|
||||||
String mixer = properties.get( AUDIO_MIXER_PROPERTY, defaultMixer.getMixerInfo().getName() );
|
|
||||||
|
|
||||||
String channels = properties.get( AUDIO_CHANNELS_PROPERTY, MixerChannel.MONO.name() );
|
|
||||||
|
|
||||||
MixerChannelConfiguration[] mixerConfigurations = mMixerManager.getOutputMixers();
|
|
||||||
|
|
||||||
for( MixerChannelConfiguration mixerConfig: mixerConfigurations )
|
|
||||||
{
|
{
|
||||||
if( mixerConfig.matches( mixer, channels ) )
|
mMixerChannel = new MixerChannelConfiguration( mixer, MixerChannel.MONO );
|
||||||
{
|
|
||||||
configuration = mixerConfig;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( configuration == null )
|
|
||||||
{
|
|
||||||
configuration = getDefaultConfiguration();
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
setMixerChannelConfiguration( configuration );
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
mLog.error( "Couldn't set stored audio mixer/channel configuration"
|
|
||||||
+ " - using default", e );
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
setMixerChannelConfiguration( getDefaultConfiguration() );
|
setMixerChannelConfiguration( mMixerChannel );
|
||||||
}
|
}
|
||||||
catch( Exception e2 )
|
catch ( AudioException e )
|
||||||
{
|
{
|
||||||
mLog.error( "Couldn't set default audio mixer/channel "
|
mLog.error( "Couldn't create an audio output device", e );
|
||||||
+ "configuration - no audio will be available", e2 );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private MixerChannelConfiguration getDefaultConfiguration()
|
|
||||||
{
|
|
||||||
/* Use the system default mixer and mono channel as default startup */
|
|
||||||
Mixer defaultMixer = AudioSystem.getMixer( null );
|
|
||||||
|
|
||||||
return new MixerChannelConfiguration( defaultMixer, MixerChannel.MONO );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
if( mThreadPoolManager != null && mProcessingTask != null )
|
if( mThreadPoolManager != null && mProcessingTask != null )
|
||||||
@@ -157,15 +116,6 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
|
|
||||||
mThreadPoolManager = null;
|
mThreadPoolManager = null;
|
||||||
mProcessingTask = null;
|
mProcessingTask = null;
|
||||||
|
|
||||||
mChannelConnectionMap.clear();
|
|
||||||
|
|
||||||
for( AudioOutputConnection connection: mAudioOutputConnections )
|
|
||||||
{
|
|
||||||
connection.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
mAudioOutputConnections.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,44 +124,207 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
mAudioPacketQueue.add( packet );
|
mAudioPacketQueue.add( packet );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public class AudioPacketProcessor implements Runnable
|
||||||
* Checks each audio channel assignment and disconnects any inactive connections
|
|
||||||
*/
|
|
||||||
private void disconnectInactiveChannelAssignments()
|
|
||||||
{
|
{
|
||||||
boolean changed = false;
|
@Override
|
||||||
|
public void run()
|
||||||
for( AudioOutputConnection connection: mAudioOutputConnections )
|
|
||||||
{
|
{
|
||||||
if( connection.isInactive() &&
|
removeCompletedChannelAssignments();
|
||||||
mChannelConnectionMap.containsKey( connection.getSource() ) )
|
|
||||||
|
if( mAudioPacketQueue != null )
|
||||||
{
|
{
|
||||||
mChannelConnectionMap.remove( connection.getSource() );
|
List<AudioPacket> packets = new ArrayList<AudioPacket>();
|
||||||
connection.disconnect();
|
|
||||||
changed = true;
|
mAudioPacketQueue.drainTo( packets );
|
||||||
|
|
||||||
|
for( AudioPacket packet: packets )
|
||||||
|
{
|
||||||
|
/* Don't process any packet's marked as do not monitor */
|
||||||
|
if( !packet.getAudioMetadata().isDoNotMonitor() )
|
||||||
|
{
|
||||||
|
int source = packet.getAudioMetadata().getSource();
|
||||||
|
|
||||||
|
if( packet.getType() != AudioPacket.Type.END )
|
||||||
|
{
|
||||||
|
/* Existing channel assignment */
|
||||||
|
if( mChannelAssignments.containsKey( source ) )
|
||||||
|
{
|
||||||
|
mChannelAssignments.get( source ).getAudioOutput()
|
||||||
|
.receive( packet );
|
||||||
|
}
|
||||||
|
/* Start a new channel assignment */
|
||||||
|
else if( !mAvailableAudioOutputs.isEmpty() )
|
||||||
|
{
|
||||||
|
AudioOutput channel = mAvailableAudioOutputs.remove( 0 );
|
||||||
|
|
||||||
|
mChannelAssignments.put( packet.getAudioMetadata().getSource(),
|
||||||
|
new AudioChannelAssignment( channel, packet.getAudioMetadata().getPriority() ) );
|
||||||
|
|
||||||
|
updateLowestPriorityAssignment();
|
||||||
|
|
||||||
|
channel.receive( packet );
|
||||||
|
}
|
||||||
|
/* Override the lowest priority assignment */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( mLowestPrioritySource > -1 )
|
||||||
|
{
|
||||||
|
int priority = packet.getAudioMetadata().getPriority();
|
||||||
|
|
||||||
|
if( packet.getAudioMetadata().isSelected() ||
|
||||||
|
priority < mChannelAssignments
|
||||||
|
.get( mLowestPrioritySource ).getPriority() )
|
||||||
|
{
|
||||||
|
AudioChannelAssignment assignment =
|
||||||
|
mChannelAssignments.remove( mLowestPrioritySource );
|
||||||
|
|
||||||
|
if( assignment != null )
|
||||||
|
{
|
||||||
|
assignment.setPriority( priority );
|
||||||
|
|
||||||
|
int overrideSource = packet.getAudioMetadata().getSource();
|
||||||
|
|
||||||
|
mChannelAssignments.put( overrideSource, assignment );
|
||||||
|
|
||||||
|
mLowestPrioritySource = overrideSource;
|
||||||
|
|
||||||
|
assignment.getAudioOutput().receive( packet );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mLowestPrioritySource = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if( changed )
|
|
||||||
|
/**
|
||||||
|
* Checks each audio channel assignment and removes any completed channels.
|
||||||
|
*/
|
||||||
|
private void removeCompletedChannelAssignments()
|
||||||
|
{
|
||||||
|
if( !mChannelAssignments.isEmpty() )
|
||||||
{
|
{
|
||||||
updateLowestPriorityAssignment();
|
Iterator<Entry<Integer,AudioChannelAssignment>> it =
|
||||||
|
mChannelAssignments.entrySet().iterator();
|
||||||
|
|
||||||
|
Entry<Integer,AudioChannelAssignment> entry;
|
||||||
|
|
||||||
|
boolean removed = false;
|
||||||
|
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
entry = it.next();
|
||||||
|
|
||||||
|
if( entry.getValue().isComplete() )
|
||||||
|
{
|
||||||
|
mAvailableAudioOutputs.add( entry.getValue().getAudioOutput() );
|
||||||
|
entry.getValue().dispose();
|
||||||
|
it.remove();
|
||||||
|
removed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( removed )
|
||||||
|
{
|
||||||
|
updateLowestPriorityAssignment();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Identifies the lowest priority channel connection
|
* Identifies the lowest priority channel assignment ... the one that can
|
||||||
|
* be overridden with a higher priority call
|
||||||
*/
|
*/
|
||||||
private void updateLowestPriorityAssignment()
|
private void updateLowestPriorityAssignment()
|
||||||
{
|
{
|
||||||
mLowestPriorityConnection = null;
|
int lowestPriority = -1;
|
||||||
|
|
||||||
for( AudioOutputConnection connection: mAudioOutputConnections )
|
mLowestPrioritySource = -1;
|
||||||
|
|
||||||
|
for( int source: mChannelAssignments.keySet() )
|
||||||
{
|
{
|
||||||
if( connection.isConnected() &&
|
AudioChannelAssignment assignment = mChannelAssignments.get( source );
|
||||||
( mLowestPriorityConnection == null ||
|
|
||||||
mLowestPriorityConnection.getPriority() > connection.getPriority() ) )
|
if( assignment.getPriority() > lowestPriority )
|
||||||
{
|
{
|
||||||
mLowestPriorityConnection = connection;
|
lowestPriority = assignment.getPriority();
|
||||||
|
|
||||||
|
mLowestPrioritySource = source;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void endAllAudioAssignments()
|
||||||
|
{
|
||||||
|
for( AudioOutput output: mAudioOutputMap.values() )
|
||||||
|
{
|
||||||
|
output.receive( new AudioPacket( AudioPacket.Type.END, null ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AudioChannelAssignment implements Listener<AudioEvent>
|
||||||
|
{
|
||||||
|
private static final long CALL_END_DELAY = 2000; //2 seconds
|
||||||
|
|
||||||
|
private AudioOutput mAudioOutput;
|
||||||
|
private int mPriority;
|
||||||
|
private long mAudioStoppedTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
public AudioChannelAssignment( AudioOutput audioOutput, int priority )
|
||||||
|
{
|
||||||
|
mAudioOutput = audioOutput;
|
||||||
|
mPriority = priority;
|
||||||
|
|
||||||
|
mAudioOutput.addAudioEventListener( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isComplete()
|
||||||
|
{
|
||||||
|
return mAudioStoppedTime != Long.MAX_VALUE &&
|
||||||
|
mAudioStoppedTime + CALL_END_DELAY < System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dispose()
|
||||||
|
{
|
||||||
|
mAudioOutput.removeAudioEventListener( this );
|
||||||
|
mAudioOutput.reset();
|
||||||
|
mAudioOutput = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AudioOutput getAudioOutput()
|
||||||
|
{
|
||||||
|
return mAudioOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPriority()
|
||||||
|
{
|
||||||
|
return mPriority;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPriority( int priority )
|
||||||
|
{
|
||||||
|
mPriority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void receive( AudioEvent event )
|
||||||
|
{
|
||||||
|
switch( event.getType() )
|
||||||
|
{
|
||||||
|
case AUDIO_STARTED:
|
||||||
|
case AUDIO_STOPPED:
|
||||||
|
case AUDIO_CONTINUATION:
|
||||||
|
mAudioStoppedTime = System.currentTimeMillis();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,29 +342,41 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
{
|
{
|
||||||
mThreadPoolManager.cancel( mProcessingTask );
|
mThreadPoolManager.cancel( mProcessingTask );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
endAllAudioAssignments();
|
||||||
|
|
||||||
disposeCurrentConfiguration();
|
for( Entry<Integer,AudioChannelAssignment> e: mChannelAssignments.entrySet() )
|
||||||
|
{
|
||||||
|
e.getValue().getAudioOutput().dispose();
|
||||||
|
}
|
||||||
|
mChannelAssignments.clear();
|
||||||
|
|
||||||
|
for( AudioOutput output: mAvailableAudioOutputs )
|
||||||
|
{
|
||||||
|
output.dispose();
|
||||||
|
}
|
||||||
|
mAvailableAudioOutputs.clear();
|
||||||
|
|
||||||
|
mChannelNames.clear();
|
||||||
|
mAudioOutputMap.clear();
|
||||||
|
|
||||||
switch( entry.getMixerChannel() )
|
switch( entry.getMixerChannel() )
|
||||||
{
|
{
|
||||||
case MONO:
|
case MONO:
|
||||||
AudioOutput mono = new MonoAudioOutput( mThreadPoolManager,
|
AudioOutput mono = new MonoAudioOutput( entry.getMixer() );
|
||||||
entry.getMixer() );
|
mAvailableAudioOutputs.add( mono );
|
||||||
mAudioOutputConnections.add( new AudioOutputConnection( mono ) );
|
mChannelNames.add( mono.getChannelName() );
|
||||||
mAvailableConnectionCount++;
|
|
||||||
mAudioOutputMap.put( mono.getChannelName(), mono );
|
mAudioOutputMap.put( mono.getChannelName(), mono );
|
||||||
break;
|
break;
|
||||||
case STEREO:
|
case STEREO:
|
||||||
AudioOutput left = new StereoAudioOutput( mThreadPoolManager,
|
AudioOutput left = new StereoAudioOutput( entry.getMixer(), MixerChannel.LEFT );
|
||||||
entry.getMixer(), MixerChannel.LEFT );
|
mAvailableAudioOutputs.add( left );
|
||||||
mAudioOutputConnections.add( new AudioOutputConnection( left ) );
|
mChannelNames.add( left.getChannelName() );
|
||||||
mAvailableConnectionCount++;
|
|
||||||
mAudioOutputMap.put( left.getChannelName(), left );
|
mAudioOutputMap.put( left.getChannelName(), left );
|
||||||
|
|
||||||
AudioOutput right = new StereoAudioOutput( mThreadPoolManager,
|
AudioOutput right = new StereoAudioOutput( entry.getMixer(), MixerChannel.RIGHT );
|
||||||
entry.getMixer(), MixerChannel.RIGHT );
|
mAvailableAudioOutputs.add( right );
|
||||||
mAudioOutputConnections.add( new AudioOutputConnection( right ) );
|
mChannelNames.add( right.getChannelName() );
|
||||||
mAvailableConnectionCount++;
|
|
||||||
mAudioOutputMap.put( right.getChannelName(), right );
|
mAudioOutputMap.put( right.getChannelName(), right );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -264,12 +389,6 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
TimeUnit.MILLISECONDS );
|
TimeUnit.MILLISECONDS );
|
||||||
|
|
||||||
mControllerBroadcaster.broadcast( CONFIGURATION_CHANGE_COMPLETE );
|
mControllerBroadcaster.broadcast( CONFIGURATION_CHANGE_COMPLETE );
|
||||||
|
|
||||||
SystemProperties properties = SystemProperties.getInstance();
|
|
||||||
|
|
||||||
properties.set( AUDIO_MIXER_PROPERTY, entry.getMixer().getMixerInfo().getName() );
|
|
||||||
properties.set( AUDIO_CHANNELS_PROPERTY, entry.getMixerChannel().name() );
|
|
||||||
properties.save();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,33 +415,10 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
mLowestPriorityConnection = null;
|
mLowestPriorityConnection = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears all channel assignments and terminates all audio outputs in
|
|
||||||
* preparation for complete shutdown or change to another mixer/channel
|
|
||||||
* configuration
|
|
||||||
*/
|
|
||||||
private void disposeCurrentConfiguration()
|
|
||||||
{
|
|
||||||
mChannelConnectionMap.clear();
|
|
||||||
|
|
||||||
for( AudioOutputConnection connection : mAudioOutputConnections )
|
|
||||||
{
|
|
||||||
connection.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
mAvailableConnectionCount = 0;
|
|
||||||
|
|
||||||
mAudioOutputConnections.clear();
|
|
||||||
|
|
||||||
mAudioOutputMap.clear();
|
|
||||||
|
|
||||||
mLowestPriorityConnection = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MixerChannelConfiguration getMixerChannelConfiguration() throws AudioException
|
public MixerChannelConfiguration getMixerChannelConfiguration() throws AudioException
|
||||||
{
|
{
|
||||||
return mMixerChannelConfiguration;
|
return mMixerChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -353,244 +449,4 @@ public class AudioManager implements Listener<AudioPacket>, IAudioController
|
|||||||
{
|
{
|
||||||
mControllerBroadcaster.removeListener( listener );
|
mControllerBroadcaster.removeListener( listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an audio output connection for the packet if one is
|
|
||||||
* available, or overrides an existing lower priority connection.
|
|
||||||
* Returns null if no connection is available for the audio packet.
|
|
||||||
*
|
|
||||||
* @param packet from a source
|
|
||||||
* @return an audio output connection or null
|
|
||||||
*/
|
|
||||||
private AudioOutputConnection getConnection( AudioPacket packet )
|
|
||||||
{
|
|
||||||
int source = packet.getAudioMetadata().getSource();
|
|
||||||
|
|
||||||
//Use an existing connection
|
|
||||||
if( mChannelConnectionMap.containsKey( source ) )
|
|
||||||
{
|
|
||||||
return mChannelConnectionMap.get( source );
|
|
||||||
}
|
|
||||||
|
|
||||||
//Connect to and use an available connection
|
|
||||||
if( mAvailableConnectionCount > 0 )
|
|
||||||
{
|
|
||||||
for( AudioOutputConnection connection: mAudioOutputConnections )
|
|
||||||
{
|
|
||||||
if( connection.isDisconnected() )
|
|
||||||
{
|
|
||||||
connection.connect( source );
|
|
||||||
mChannelConnectionMap.put( source, connection );
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Preempt an existing connection and connect it to this higher priority source
|
|
||||||
else //Check for a channel priority override
|
|
||||||
{
|
|
||||||
int priority = packet.getAudioMetadata().getPriority();
|
|
||||||
|
|
||||||
if( mLowestPriorityConnection != null &&
|
|
||||||
priority < mLowestPriorityConnection.getPriority() )
|
|
||||||
{
|
|
||||||
AudioOutputConnection connection = mLowestPriorityConnection;
|
|
||||||
|
|
||||||
mChannelConnectionMap.remove( connection.getSource() );
|
|
||||||
|
|
||||||
connection.connect( source );
|
|
||||||
|
|
||||||
mChannelConnectionMap.put( source, connection );
|
|
||||||
|
|
||||||
updateLowestPriorityAssignment();
|
|
||||||
|
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AudioPacketProcessor implements Runnable
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
disconnectInactiveChannelAssignments();
|
|
||||||
|
|
||||||
if( mAudioPacketQueue != null )
|
|
||||||
{
|
|
||||||
List<AudioPacket> packets = new ArrayList<AudioPacket>();
|
|
||||||
|
|
||||||
mAudioPacketQueue.drainTo( packets );
|
|
||||||
|
|
||||||
for( AudioPacket packet: packets )
|
|
||||||
{
|
|
||||||
/* Don't process any packet's marked as do not monitor */
|
|
||||||
if( !packet.getAudioMetadata().isDoNotMonitor() &&
|
|
||||||
packet.getType() == AudioPacket.Type.AUDIO )
|
|
||||||
{
|
|
||||||
AudioOutputConnection connection = getConnection( packet );
|
|
||||||
|
|
||||||
if( connection != null )
|
|
||||||
{
|
|
||||||
connection.receive( packet );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
mLog.error( "Encountered error while processing audio packets", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Audio output connection manages a connection between a source and an audio
|
|
||||||
* output and maintains current state information about the audio activity
|
|
||||||
* received form the source.
|
|
||||||
*/
|
|
||||||
public class AudioOutputConnection implements Listener<AudioEvent>
|
|
||||||
{
|
|
||||||
private static final long CALL_END_DELAY = 2000; //2 seconds
|
|
||||||
private static final int DISCONNECTED = -1;
|
|
||||||
|
|
||||||
private AudioOutput mAudioOutput;
|
|
||||||
private int mPriority = 0;
|
|
||||||
private long mLastActivity = System.currentTimeMillis();
|
|
||||||
private int mSource = DISCONNECTED;
|
|
||||||
|
|
||||||
public AudioOutputConnection( AudioOutput audioOutput )
|
|
||||||
{
|
|
||||||
mAudioOutput = audioOutput;
|
|
||||||
mAudioOutput.addAudioEventListener( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void receive( AudioPacket packet )
|
|
||||||
{
|
|
||||||
if( packet.hasAudioMetadata() &&
|
|
||||||
packet.getAudioMetadata().getSource() == mSource )
|
|
||||||
{
|
|
||||||
int priority = packet.getAudioMetadata().getPriority();
|
|
||||||
|
|
||||||
if( mPriority != priority )
|
|
||||||
{
|
|
||||||
mPriority = priority;
|
|
||||||
updateLowestPriorityAssignment();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTimestamp();
|
|
||||||
|
|
||||||
if( mAudioOutput != null )
|
|
||||||
{
|
|
||||||
mAudioOutput.receive( packet );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if( packet.hasAudioMetadata() )
|
|
||||||
{
|
|
||||||
mLog.error( "Received audio packet from channel source [" +
|
|
||||||
packet.getAudioMetadata().getSource() +
|
|
||||||
"] however this assignment is currently connected "
|
|
||||||
+ "to channel source [" + mSource + "]" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mLog.error( "Received audio packet with no metadata - "
|
|
||||||
+ "cannot route audio packet" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateTimestamp()
|
|
||||||
{
|
|
||||||
mLastActivity = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminates the audio output and prepares this connection for disposal
|
|
||||||
*/
|
|
||||||
public void dispose()
|
|
||||||
{
|
|
||||||
mAudioOutput.dispose();
|
|
||||||
mAudioOutput = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if this assignment is currently disconnected from a channel source
|
|
||||||
*/
|
|
||||||
public boolean isDisconnected()
|
|
||||||
{
|
|
||||||
return mSource == DISCONNECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if this assignment is currently connected to a channel source
|
|
||||||
*/
|
|
||||||
public boolean isConnected()
|
|
||||||
{
|
|
||||||
return !isDisconnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Connects this assignment to the indicated source so that audio
|
|
||||||
* packets from this source can be sent to the audio output
|
|
||||||
*/
|
|
||||||
public void connect( int source )
|
|
||||||
{
|
|
||||||
mSource = source;
|
|
||||||
updateTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Currently connected source or -1 if disconnected
|
|
||||||
*/
|
|
||||||
public int getSource()
|
|
||||||
{
|
|
||||||
return mSource;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects this assignment from the source and prevents any audio
|
|
||||||
* from being routed to the audio output until another source is assigned
|
|
||||||
*/
|
|
||||||
public void disconnect()
|
|
||||||
{
|
|
||||||
mSource = DISCONNECTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if audio output is current inactive, meaning that the
|
|
||||||
* audio output hasn't recently processed any audio packets.
|
|
||||||
*/
|
|
||||||
public boolean isInactive()
|
|
||||||
{
|
|
||||||
return mLastActivity != Long.MAX_VALUE &&
|
|
||||||
mLastActivity + CALL_END_DELAY < System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPriority()
|
|
||||||
{
|
|
||||||
return mPriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void receive( AudioEvent event )
|
|
||||||
{
|
|
||||||
switch( event.getType() )
|
|
||||||
{
|
|
||||||
case AUDIO_STARTED:
|
|
||||||
case AUDIO_STOPPED:
|
|
||||||
case AUDIO_CONTINUATION:
|
|
||||||
updateTimestamp();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package audio.output;
|
package audio.output;
|
||||||
|
|
||||||
import java.util.concurrent.LinkedTransferQueue;
|
import java.util.concurrent.LinkedTransferQueue;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.sound.sampled.FloatControl;
|
import javax.sound.sampled.FloatControl;
|
||||||
import javax.sound.sampled.LineListener;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -11,26 +12,23 @@ import org.slf4j.LoggerFactory;
|
|||||||
import sample.Broadcaster;
|
import sample.Broadcaster;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import audio.AudioEvent;
|
import audio.AudioEvent;
|
||||||
|
import audio.AudioEvent.Type;
|
||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.metadata.AudioMetadata;
|
import audio.metadata.AudioMetadata;
|
||||||
import controller.ThreadPoolManager;
|
|
||||||
|
|
||||||
public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
public abstract class AudioOutput implements Listener<AudioPacket>
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger( AudioOutput.class );
|
private final static Logger mLog = LoggerFactory.getLogger( AudioOutput.class );
|
||||||
|
|
||||||
|
private AtomicBoolean mSquelched = new AtomicBoolean( false );
|
||||||
private Listener<AudioMetadata> mAudioMetadataListener;
|
private Listener<AudioMetadata> mAudioMetadataListener;
|
||||||
|
|
||||||
protected Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>();
|
protected Broadcaster<AudioEvent> mAudioEventBroadcaster = new Broadcaster<>();
|
||||||
protected LinkedTransferQueue<AudioPacket> mBuffer = new LinkedTransferQueue<>();
|
protected LinkedTransferQueue<AudioPacket> mBuffer = new LinkedTransferQueue<>();
|
||||||
protected ThreadPoolManager mThreadPoolManager;
|
protected ScheduledExecutorService mExecutorService;
|
||||||
protected boolean mCanProcessAudio;
|
protected boolean mCanProcessAudio;
|
||||||
protected long mLastActivity;
|
protected long mLastActivity;
|
||||||
|
|
||||||
public AudioOutput( ThreadPoolManager threadPoolManager )
|
|
||||||
{
|
|
||||||
mThreadPoolManager = threadPoolManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
broadcast( new AudioEvent( AudioEvent.Type.AUDIO_STOPPED,
|
broadcast( new AudioEvent( AudioEvent.Type.AUDIO_STOPPED,
|
||||||
@@ -43,11 +41,14 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
|||||||
|
|
||||||
mBuffer.clear();
|
mBuffer.clear();
|
||||||
|
|
||||||
|
if( mExecutorService != null )
|
||||||
|
{
|
||||||
|
mExecutorService.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
mAudioEventBroadcaster.dispose();
|
mAudioEventBroadcaster.dispose();
|
||||||
mAudioEventBroadcaster = null;
|
mAudioEventBroadcaster = null;
|
||||||
mAudioMetadataListener = null;
|
mAudioMetadataListener = null;
|
||||||
|
|
||||||
mThreadPoolManager = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getChannelName();
|
public abstract String getChannelName();
|
||||||
@@ -71,6 +72,19 @@ public abstract class AudioOutput implements Listener<AudioPacket>, LineListener
|
|||||||
mAudioEventBroadcaster.broadcast( audioEvent );
|
mAudioEventBroadcaster.broadcast( audioEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSquelched( boolean squelched )
|
||||||
|
{
|
||||||
|
mSquelched.set( squelched );
|
||||||
|
|
||||||
|
broadcast( new AudioEvent( squelched ? Type.AUDIO_SQUELCHED :
|
||||||
|
Type.AUDIO_UNSQUELCHED, getChannelName() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSquelched()
|
||||||
|
{
|
||||||
|
return mSquelched.get();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a single listener to receive audio start and audio stop events
|
* Registers a single listener to receive audio start and audio stop events
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import java.nio.ByteOrder;
|
|||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.sound.sampled.BooleanControl;
|
import javax.sound.sampled.BooleanControl;
|
||||||
import javax.sound.sampled.Control;
|
import javax.sound.sampled.Control;
|
||||||
import javax.sound.sampled.FloatControl;
|
import javax.sound.sampled.FloatControl;
|
||||||
import javax.sound.sampled.LineEvent;
|
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.Mixer;
|
import javax.sound.sampled.Mixer;
|
||||||
import javax.sound.sampled.SourceDataLine;
|
import javax.sound.sampled.SourceDataLine;
|
||||||
@@ -25,8 +24,8 @@ import audio.AudioEvent;
|
|||||||
import audio.AudioFormats;
|
import audio.AudioFormats;
|
||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.AudioPacket.Type;
|
import audio.AudioPacket.Type;
|
||||||
import controller.ThreadPoolManager;
|
import audio.output.StereoAudioOutput.QueueProcessor;
|
||||||
import controller.ThreadPoolManager.ThreadType;
|
import controller.NamingThreadFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mono Audio output with automatic flow control based on the availability of
|
* Mono Audio output with automatic flow control based on the availability of
|
||||||
@@ -51,14 +50,14 @@ public class MonoAudioOutput extends AudioOutput
|
|||||||
private SourceDataLine mOutput;
|
private SourceDataLine mOutput;
|
||||||
private FloatControl mGainControl;
|
private FloatControl mGainControl;
|
||||||
private BooleanControl mMuteControl;
|
private BooleanControl mMuteControl;
|
||||||
|
|
||||||
private AudioEvent mAudioStartEvent;
|
private AudioEvent mAudioStartEvent;
|
||||||
private AudioEvent mAudioStopEvent;
|
private AudioEvent mAudioStopEvent;
|
||||||
private AudioEvent mAudioContinuationEvent;
|
private AudioEvent mAudioContinuationEvent;
|
||||||
private ScheduledFuture<?> mProcessorTask;
|
|
||||||
|
|
||||||
public MonoAudioOutput( ThreadPoolManager threadPoolManager, Mixer mixer )
|
public MonoAudioOutput( Mixer mixer )
|
||||||
{
|
{
|
||||||
super( threadPoolManager );
|
super();
|
||||||
|
|
||||||
mAudioStartEvent = new AudioEvent( AudioEvent.Type.AUDIO_STARTED,
|
mAudioStartEvent = new AudioEvent( AudioEvent.Type.AUDIO_STARTED,
|
||||||
getChannelName() );
|
getChannelName() );
|
||||||
@@ -75,8 +74,15 @@ public class MonoAudioOutput extends AudioOutput
|
|||||||
if( mOutput != null )
|
if( mOutput != null )
|
||||||
{
|
{
|
||||||
mOutput.open( AudioFormats.PCM_SIGNED_48KHZ_16BITS_MONO, BUFFER_SIZE );
|
mOutput.open( AudioFormats.PCM_SIGNED_48KHZ_16BITS_MONO, BUFFER_SIZE );
|
||||||
mOutput.addLineListener( this );
|
|
||||||
mCanProcessAudio = true;
|
mCanProcessAudio = true;
|
||||||
|
|
||||||
|
mExecutorService = Executors.newSingleThreadScheduledExecutor(
|
||||||
|
new NamingThreadFactory( "audio (mono) output" ) );
|
||||||
|
|
||||||
|
/* Run the queue processor task every 40 milliseconds */
|
||||||
|
mExecutorService.scheduleAtFixedRate( new QueueProcessor(),
|
||||||
|
0, 40, TimeUnit.MILLISECONDS );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( LineUnavailableException e )
|
catch ( LineUnavailableException e )
|
||||||
@@ -109,10 +115,12 @@ public class MonoAudioOutput extends AudioOutput
|
|||||||
mixer.getMixerInfo().getName() + "]" );
|
mixer.getMixerInfo().getName() + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mExecutorService = Executors.newSingleThreadScheduledExecutor(
|
||||||
|
new NamingThreadFactory( "audio (mono) output" ) );
|
||||||
|
|
||||||
/* Run the queue processor task every 40 milliseconds */
|
/* Run the queue processor task every 40 milliseconds */
|
||||||
mProcessorTask = mThreadPoolManager.scheduleFixedRate(
|
mExecutorService.scheduleAtFixedRate( new QueueProcessor(),
|
||||||
ThreadType.AUDIO_PROCESSING, new QueueProcessor(),
|
0, 40, TimeUnit.MILLISECONDS );
|
||||||
40, TimeUnit.MILLISECONDS );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,108 +132,102 @@ public class MonoAudioOutput extends AudioOutput
|
|||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
if( mProcessorTask != null && mThreadPoolManager != null )
|
|
||||||
{
|
|
||||||
mThreadPoolManager.cancel( mProcessorTask );
|
|
||||||
}
|
|
||||||
|
|
||||||
mProcessorTask = null;
|
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
||||||
if( mOutput != null )
|
if( mOutput != null )
|
||||||
{
|
{
|
||||||
mOutput.close();
|
mOutput.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutput = null;
|
|
||||||
mGainControl = null;
|
|
||||||
mMuteControl = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class QueueProcessor implements Runnable
|
public class QueueProcessor implements Runnable
|
||||||
{
|
{
|
||||||
private AtomicBoolean mProcessing = new AtomicBoolean();
|
private AtomicBoolean mProcessing = new AtomicBoolean();
|
||||||
|
|
||||||
|
public QueueProcessor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
/* The mProcessing flag ensures that only one instance of the
|
||||||
|
* processor can run at any given time */
|
||||||
|
if( mProcessing.compareAndSet( false, true ) )
|
||||||
{
|
{
|
||||||
/* The mProcessing flag ensures that only one instance of the
|
List<AudioPacket> packets = new ArrayList<AudioPacket>();
|
||||||
* processor can run at any given time */
|
|
||||||
if( mProcessing.compareAndSet( false, true ) )
|
mBuffer.drainTo( packets );
|
||||||
|
|
||||||
|
if( packets.size() > 0 )
|
||||||
{
|
{
|
||||||
List<AudioPacket> packets = new ArrayList<AudioPacket>();
|
broadcast( mAudioContinuationEvent );
|
||||||
|
|
||||||
mBuffer.drainTo( packets );
|
for( AudioPacket packet: packets )
|
||||||
|
|
||||||
if( packets.size() > 0 )
|
|
||||||
{
|
{
|
||||||
for( AudioPacket packet: packets )
|
if( mCanProcessAudio )
|
||||||
{
|
{
|
||||||
broadcast( mAudioContinuationEvent );
|
if( isSquelched() )
|
||||||
|
|
||||||
if( mCanProcessAudio )
|
|
||||||
{
|
{
|
||||||
if( packet.getType() == Type.AUDIO )
|
checkStop();
|
||||||
|
}
|
||||||
|
else if( packet.getType() == Type.AUDIO )
|
||||||
|
{
|
||||||
|
float[] samples = packet.getAudioBuffer().getSamples();
|
||||||
|
|
||||||
|
/* Little-endian byte buffer */
|
||||||
|
ByteBuffer buffer =
|
||||||
|
ByteBuffer.allocate( samples.length * 2 )
|
||||||
|
.order( ByteOrder.LITTLE_ENDIAN );
|
||||||
|
|
||||||
|
ShortBuffer shortBuffer = buffer.asShortBuffer();
|
||||||
|
|
||||||
|
for( float sample: samples )
|
||||||
{
|
{
|
||||||
float[] samples = packet.getAudioBuffer().getSamples();
|
shortBuffer.put( (short)( sample * Short.MAX_VALUE ) );
|
||||||
|
|
||||||
/* Little-endian byte buffer */
|
|
||||||
ByteBuffer buffer =
|
|
||||||
ByteBuffer.allocate( samples.length * 2 )
|
|
||||||
.order( ByteOrder.LITTLE_ENDIAN );
|
|
||||||
|
|
||||||
ShortBuffer shortBuffer = buffer.asShortBuffer();
|
|
||||||
|
|
||||||
for( float sample: samples )
|
|
||||||
{
|
|
||||||
shortBuffer.put( (short)( sample * Short.MAX_VALUE ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//This is a blocking write
|
|
||||||
mOutput.write( buffer.array(), 0, buffer.array().length );
|
|
||||||
|
|
||||||
checkStart();
|
|
||||||
|
|
||||||
broadcast( packet.getAudioMetadata() );
|
|
||||||
|
|
||||||
mLastActivity = System.currentTimeMillis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mOutput.write( buffer.array(), 0,
|
||||||
|
buffer.array().length );
|
||||||
|
|
||||||
|
checkStart();
|
||||||
|
|
||||||
|
broadcast( packet.getAudioMetadata() );
|
||||||
|
|
||||||
|
mLastActivity = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
checkStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
mProcessing.set( false );
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
catch( Exception e )
|
{
|
||||||
{
|
checkStop();
|
||||||
mLog.error( "Error while processing audio buffers", e );
|
}
|
||||||
|
|
||||||
|
mProcessing.set( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStart()
|
private void checkStart()
|
||||||
{
|
{
|
||||||
if( mCanProcessAudio &&
|
if( mCanProcessAudio && !isSquelched() &&
|
||||||
!mOutput.isRunning() && mOutput.available() <= START_THRESHOLD )
|
!mOutput.isRunning() && mOutput.available() <= START_THRESHOLD )
|
||||||
{
|
{
|
||||||
mOutput.start();
|
mOutput.start();
|
||||||
|
|
||||||
|
mAudioEventBroadcaster.broadcast( mAudioStartEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStop()
|
private void checkStop()
|
||||||
{
|
{
|
||||||
if( mCanProcessAudio && mOutput.isRunning() &&
|
if( mCanProcessAudio && mOutput.isRunning() &&
|
||||||
mOutput.available() >= STOP_THRESHOLD )
|
( mOutput.available() >= STOP_THRESHOLD || isSquelched() ) )
|
||||||
{
|
{
|
||||||
mOutput.drain();
|
mOutput.drain();
|
||||||
mOutput.stop();
|
mOutput.stop();
|
||||||
|
|
||||||
|
mAudioEventBroadcaster.broadcast( mAudioStopEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,19 +266,4 @@ public class MonoAudioOutput extends AudioOutput
|
|||||||
{
|
{
|
||||||
return mGainControl != null;
|
return mGainControl != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update( LineEvent event )
|
|
||||||
{
|
|
||||||
LineEvent.Type type = event.getType();
|
|
||||||
|
|
||||||
if( type == LineEvent.Type.START )
|
|
||||||
{
|
|
||||||
mAudioEventBroadcaster.broadcast( mAudioStartEvent );
|
|
||||||
}
|
|
||||||
else if( type == LineEvent.Type.STOP )
|
|
||||||
{
|
|
||||||
mAudioEventBroadcaster.broadcast( mAudioStopEvent );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import java.nio.ByteOrder;
|
|||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.sound.sampled.BooleanControl;
|
import javax.sound.sampled.BooleanControl;
|
||||||
import javax.sound.sampled.Control;
|
import javax.sound.sampled.Control;
|
||||||
import javax.sound.sampled.FloatControl;
|
import javax.sound.sampled.FloatControl;
|
||||||
import javax.sound.sampled.LineEvent;
|
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
import javax.sound.sampled.LineUnavailableException;
|
||||||
import javax.sound.sampled.Mixer;
|
import javax.sound.sampled.Mixer;
|
||||||
import javax.sound.sampled.SourceDataLine;
|
import javax.sound.sampled.SourceDataLine;
|
||||||
@@ -25,8 +24,7 @@ import audio.AudioEvent;
|
|||||||
import audio.AudioFormats;
|
import audio.AudioFormats;
|
||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.AudioPacket.Type;
|
import audio.AudioPacket.Type;
|
||||||
import controller.ThreadPoolManager;
|
import controller.NamingThreadFactory;
|
||||||
import controller.ThreadPoolManager.ThreadType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mono Audio output in stereo format with automatic flow control based on the
|
* Mono Audio output in stereo format with automatic flow control based on the
|
||||||
@@ -41,9 +39,9 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
private final static int BUFFER_SIZE = 96000;
|
private final static int BUFFER_SIZE = 96000;
|
||||||
|
|
||||||
/* The queue processor will run every 20 milliseconds checking for inbound
|
/* The queue processor will run every 20 milliseconds checking for inbound
|
||||||
* audio and automatically start or stop audio playback. We set the
|
* audio and automatically starting or stopping audio playback. We set the
|
||||||
* data line available space threshold to start when we're 20 ms away from
|
* data line available space threshold to start when we're 20 ms away from
|
||||||
* being full and the stop threshold when 20 ms away from being empty */
|
* being full, and the stop threshold when 20 ms away from being empty */
|
||||||
private final static int SAMPLE_SIZE_40_MS = BUFFER_SIZE / 25;
|
private final static int SAMPLE_SIZE_40_MS = BUFFER_SIZE / 25;
|
||||||
private final static int START_THRESHOLD = SAMPLE_SIZE_40_MS;
|
private final static int START_THRESHOLD = SAMPLE_SIZE_40_MS;
|
||||||
private final static int STOP_THRESHOLD = BUFFER_SIZE - SAMPLE_SIZE_40_MS;
|
private final static int STOP_THRESHOLD = BUFFER_SIZE - SAMPLE_SIZE_40_MS;
|
||||||
@@ -51,16 +49,16 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
private SourceDataLine mOutput;
|
private SourceDataLine mOutput;
|
||||||
private FloatControl mGainControl;
|
private FloatControl mGainControl;
|
||||||
private BooleanControl mMuteControl;
|
private BooleanControl mMuteControl;
|
||||||
|
|
||||||
private AudioEvent mAudioStartEvent;
|
private AudioEvent mAudioStartEvent;
|
||||||
private AudioEvent mAudioStopEvent;
|
private AudioEvent mAudioStopEvent;
|
||||||
private AudioEvent mAudioContinuationEvent;
|
private AudioEvent mAudioContinuationEvent;
|
||||||
private MixerChannel mMixerChannel;
|
|
||||||
private ScheduledFuture<?> mProcessorTask;
|
|
||||||
|
|
||||||
public StereoAudioOutput( ThreadPoolManager threadPoolManager,
|
private MixerChannel mMixerChannel;
|
||||||
Mixer mixer, MixerChannel channel )
|
|
||||||
|
public StereoAudioOutput( Mixer mixer, MixerChannel channel )
|
||||||
{
|
{
|
||||||
super( threadPoolManager );
|
super();
|
||||||
|
|
||||||
assert( channel == MixerChannel.LEFT || channel == MixerChannel.RIGHT );
|
assert( channel == MixerChannel.LEFT || channel == MixerChannel.RIGHT );
|
||||||
|
|
||||||
@@ -81,7 +79,6 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
if( mOutput != null )
|
if( mOutput != null )
|
||||||
{
|
{
|
||||||
mOutput.open( AudioFormats.PCM_SIGNED_48KHZ_16BITS_STEREO, BUFFER_SIZE );
|
mOutput.open( AudioFormats.PCM_SIGNED_48KHZ_16BITS_STEREO, BUFFER_SIZE );
|
||||||
mOutput.addLineListener( this );
|
|
||||||
mCanProcessAudio = true;
|
mCanProcessAudio = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -116,10 +113,12 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
mixer.getMixerInfo().getName() + " | " + channel.name() + "]" );
|
mixer.getMixerInfo().getName() + " | " + channel.name() + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mExecutorService = Executors.newSingleThreadScheduledExecutor(
|
||||||
|
new NamingThreadFactory( "audio (stereo) output" ) );
|
||||||
|
|
||||||
/* Run the queue processor task every 40 milliseconds */
|
/* Run the queue processor task every 40 milliseconds */
|
||||||
mProcessorTask = mThreadPoolManager.scheduleFixedRate(
|
mExecutorService.scheduleAtFixedRate( new QueueProcessor(),
|
||||||
ThreadType.AUDIO_PROCESSING, new QueueProcessor(),
|
0, 40, TimeUnit.MILLISECONDS );
|
||||||
40, TimeUnit.MILLISECONDS );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,30 +130,20 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
if( mProcessorTask != null && mThreadPoolManager != null )
|
|
||||||
{
|
|
||||||
mThreadPoolManager.cancel( mProcessorTask );
|
|
||||||
}
|
|
||||||
|
|
||||||
mProcessorTask = null;
|
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
||||||
if( mOutput != null )
|
if( mOutput != null )
|
||||||
{
|
{
|
||||||
mOutput.close();
|
mOutput.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutput = null;
|
|
||||||
mGainControl = null;
|
|
||||||
mMuteControl = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ByteBuffer convert( float[] samples )
|
private ByteBuffer convert( float[] samples )
|
||||||
{
|
{
|
||||||
/* Little-endian byte buffer */
|
/* Little-endian byte buffer */
|
||||||
ByteBuffer buffer = ByteBuffer.allocate( samples.length * 4 )
|
ByteBuffer buffer =
|
||||||
.order( ByteOrder.LITTLE_ENDIAN );
|
ByteBuffer.allocate( samples.length * 4 )
|
||||||
|
.order( ByteOrder.LITTLE_ENDIAN );
|
||||||
|
|
||||||
ShortBuffer shortBuffer = buffer.asShortBuffer();
|
ShortBuffer shortBuffer = buffer.asShortBuffer();
|
||||||
|
|
||||||
@@ -189,72 +178,72 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
try
|
/* The mProcessing flag ensures that only one instance of the
|
||||||
|
* processor can run at any given time */
|
||||||
|
if( mProcessing.compareAndSet( false, true ) )
|
||||||
{
|
{
|
||||||
/* The mProcessing flag ensures that only one instance of the
|
List<AudioPacket> packets = new ArrayList<AudioPacket>();
|
||||||
* processor can run at any given time */
|
|
||||||
if( mProcessing.compareAndSet( false, true ) )
|
mBuffer.drainTo( packets );
|
||||||
|
|
||||||
|
if( packets.size() > 0 )
|
||||||
{
|
{
|
||||||
List<AudioPacket> packets = new ArrayList<AudioPacket>();
|
broadcast( mAudioContinuationEvent );
|
||||||
|
|
||||||
mBuffer.drainTo( packets );
|
for( AudioPacket packet: packets )
|
||||||
|
|
||||||
if( packets.size() > 0 )
|
|
||||||
{
|
{
|
||||||
|
if( mCanProcessAudio )
|
||||||
for( AudioPacket packet: packets )
|
|
||||||
{
|
{
|
||||||
broadcast( mAudioContinuationEvent );
|
if( isSquelched() )
|
||||||
|
|
||||||
if( mCanProcessAudio )
|
|
||||||
{
|
{
|
||||||
if( packet.getType() == Type.AUDIO )
|
checkStop();
|
||||||
{
|
}
|
||||||
ByteBuffer buffer = convert(
|
else if( packet.getType() == Type.AUDIO )
|
||||||
packet.getAudioBuffer().getSamples() );
|
{
|
||||||
|
ByteBuffer buffer = convert(
|
||||||
mOutput.write( buffer.array(), 0,
|
packet.getAudioBuffer().getSamples() );
|
||||||
buffer.array().length );
|
|
||||||
|
mOutput.write( buffer.array(), 0,
|
||||||
checkStart();
|
buffer.array().length );
|
||||||
|
|
||||||
broadcast( packet.getAudioMetadata() );
|
checkStart();
|
||||||
|
|
||||||
mLastActivity = System.currentTimeMillis();
|
broadcast( packet.getAudioMetadata() );
|
||||||
}
|
|
||||||
|
mLastActivity = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
checkStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
mProcessing.set( false );
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
catch( Exception e )
|
{
|
||||||
{
|
checkStop();
|
||||||
mLog.error( "Error while processing audio buffers", e );
|
}
|
||||||
|
|
||||||
|
mProcessing.set( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStart()
|
private void checkStart()
|
||||||
{
|
{
|
||||||
if( mCanProcessAudio &&
|
if( mCanProcessAudio && !isSquelched() &&
|
||||||
!mOutput.isRunning() && mOutput.available() <= START_THRESHOLD )
|
!mOutput.isRunning() && mOutput.available() <= START_THRESHOLD )
|
||||||
{
|
{
|
||||||
mOutput.start();
|
mOutput.start();
|
||||||
|
|
||||||
|
mAudioEventBroadcaster.broadcast( mAudioStartEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkStop()
|
private void checkStop()
|
||||||
{
|
{
|
||||||
if( mCanProcessAudio && mOutput.isRunning() &&
|
if( mCanProcessAudio && mOutput.isRunning() &&
|
||||||
mOutput.available() >= STOP_THRESHOLD )
|
( mOutput.available() >= STOP_THRESHOLD || isSquelched() ) )
|
||||||
{
|
{
|
||||||
mOutput.drain();
|
mOutput.drain();
|
||||||
mOutput.stop();
|
mOutput.stop();
|
||||||
|
|
||||||
|
mAudioEventBroadcaster.broadcast( mAudioStopEvent );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -293,20 +282,4 @@ public class StereoAudioOutput extends AudioOutput
|
|||||||
{
|
{
|
||||||
return mGainControl != null;
|
return mGainControl != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update( LineEvent event )
|
|
||||||
{
|
|
||||||
LineEvent.Type type = event.getType();
|
|
||||||
|
|
||||||
if( type == LineEvent.Type.START )
|
|
||||||
{
|
|
||||||
mAudioEventBroadcaster.broadcast( mAudioStartEvent );
|
|
||||||
}
|
|
||||||
else if( type == LineEvent.Type.STOP )
|
|
||||||
{
|
|
||||||
mAudioEventBroadcaster.broadcast( mAudioStopEvent );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,16 +58,6 @@ public class MessageFramer implements Listener<Boolean>,
|
|||||||
mMessageLength = messageLength;
|
mMessageLength = messageLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset()
|
|
||||||
{
|
|
||||||
for( MessageAssembler assembler: mMessageAssemblers )
|
|
||||||
{
|
|
||||||
assembler.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
mMessageAssemblers.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
mBroadcaster.dispose();
|
mBroadcaster.dispose();
|
||||||
|
|||||||
@@ -36,20 +36,24 @@ public class ThreadPoolManager
|
|||||||
private HashMap<ScheduledFuture<?>,ThreadType> mTasks =
|
private HashMap<ScheduledFuture<?>,ThreadType> mTasks =
|
||||||
new HashMap<ScheduledFuture<?>,ThreadType>();
|
new HashMap<ScheduledFuture<?>,ThreadType>();
|
||||||
|
|
||||||
private ScheduledExecutorService mExecutor =
|
private ScheduledExecutorService mExecutor;
|
||||||
Executors.newScheduledThreadPool( THREAD_POOL_SIZE,
|
|
||||||
new NamingThreadFactory( "sdrtrunk" ) );
|
|
||||||
|
|
||||||
public ThreadPoolManager()
|
public ThreadPoolManager()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScheduledFuture<?> scheduleFixedRate( ThreadType type,
|
public ScheduledFuture<?> scheduleFixedRate( ThreadType type,
|
||||||
Runnable command,
|
Runnable command,
|
||||||
long period,
|
long period,
|
||||||
TimeUnit unit )
|
TimeUnit unit )
|
||||||
throws RejectedExecutionException
|
throws RejectedExecutionException
|
||||||
{
|
{
|
||||||
|
if( mExecutor == null )
|
||||||
|
{
|
||||||
|
mExecutor = Executors.newScheduledThreadPool( THREAD_POOL_SIZE,
|
||||||
|
new NamingThreadFactory( "sdrtrunk" ) );
|
||||||
|
}
|
||||||
|
|
||||||
ScheduledFuture<?> task =
|
ScheduledFuture<?> task =
|
||||||
mExecutor.scheduleAtFixedRate( command, 0, period, unit );
|
mExecutor.scheduleAtFixedRate( command, 0, period, unit );
|
||||||
|
|
||||||
@@ -61,16 +65,20 @@ public class ThreadPoolManager
|
|||||||
public void scheduleOnce( Runnable command, long delay, TimeUnit unit )
|
public void scheduleOnce( Runnable command, long delay, TimeUnit unit )
|
||||||
throws RejectedExecutionException
|
throws RejectedExecutionException
|
||||||
{
|
{
|
||||||
|
if( mExecutor == null )
|
||||||
|
{
|
||||||
|
mExecutor = Executors.newScheduledThreadPool( THREAD_POOL_SIZE,
|
||||||
|
new NamingThreadFactory( "sdrtrunk" ) );
|
||||||
|
}
|
||||||
|
|
||||||
mExecutor.schedule( command, delay, unit );
|
mExecutor.schedule( command, delay, unit );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean cancel( ScheduledFuture<?> task )
|
public void cancel( ScheduledFuture<?> task )
|
||||||
{
|
{
|
||||||
boolean success = task.cancel( true );
|
task.cancel( true );
|
||||||
|
|
||||||
mTasks.remove( task );
|
mTasks.remove( task );
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTaskCount( ThreadType type )
|
public int getTaskCount( ThreadType type )
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class SDRTrunk
|
|||||||
AliasActionManager aliasActionManager = new AliasActionManager( threadPoolManager );
|
AliasActionManager aliasActionManager = new AliasActionManager( threadPoolManager );
|
||||||
channelProcessingManager.addMessageListener( aliasActionManager );
|
channelProcessingManager.addMessageListener( aliasActionManager );
|
||||||
|
|
||||||
AudioManager audioManager = new AudioManager( threadPoolManager, sourceManager.getMixerManager() );
|
AudioManager audioManager = new AudioManager( threadPoolManager );
|
||||||
channelProcessingManager.addAudioPacketListener( audioManager );
|
channelProcessingManager.addAudioPacketListener( audioManager );
|
||||||
|
|
||||||
MapService mapService = new MapService( mSettingsManager );
|
MapService mapService = new MapService( mSettingsManager );
|
||||||
@@ -471,7 +471,7 @@ public class SDRTrunk
|
|||||||
|
|
||||||
if( version != null )
|
if( version != null )
|
||||||
{
|
{
|
||||||
sb.append( " v" );
|
sb.append( " V" );
|
||||||
sb.append( version );
|
sb.append( version );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,94 +17,52 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package message;
|
package message;
|
||||||
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import map.Plottable;
|
import map.Plottable;
|
||||||
|
import module.decode.event.MessageDetailsProvider;
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
|
|
||||||
public abstract class Message
|
public abstract class Message implements MessageDetailsProvider
|
||||||
{
|
{
|
||||||
protected long mTimeReceived;
|
protected long mTimeReceived;
|
||||||
|
protected MessageType mType;
|
||||||
|
|
||||||
public Message()
|
public Message()
|
||||||
{
|
{
|
||||||
mTimeReceived = System.currentTimeMillis();
|
this( MessageType.UN_KNWN );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Message( MessageType type )
|
||||||
|
{
|
||||||
|
mTimeReceived = System.currentTimeMillis();
|
||||||
|
mType = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract Plottable getPlottable();
|
||||||
|
|
||||||
|
public abstract String toString();
|
||||||
|
|
||||||
|
public abstract boolean isValid();
|
||||||
|
|
||||||
public long getTimeReceived()
|
public long getTimeReceived()
|
||||||
{
|
{
|
||||||
return mTimeReceived;
|
return mTimeReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Date getDateReceived()
|
||||||
* Map plottable
|
|
||||||
*/
|
|
||||||
public Plottable getPlottable()
|
|
||||||
{
|
{
|
||||||
//TODO: move this to an IPlottable interface that only gets implemented as needed
|
return new Date( mTimeReceived );
|
||||||
return null;
|
}
|
||||||
|
|
||||||
|
public MessageType getType()
|
||||||
|
{
|
||||||
|
return mType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoded textual representation of the message
|
|
||||||
*/
|
|
||||||
public abstract String toString();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the message is valid and has passed crc/integrity checks
|
|
||||||
*/
|
|
||||||
public abstract boolean isValid();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Status of the CRC check of the message
|
|
||||||
*/
|
|
||||||
public abstract String getErrorStatus();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parsed Message
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract String getMessage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Raw ( 0 & 1 ) message bits
|
|
||||||
*/
|
|
||||||
public abstract String getBinaryMessage();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decoded protocol
|
|
||||||
*/
|
|
||||||
public abstract String getProtocol();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event - call, data, idle, etc.
|
|
||||||
*/
|
|
||||||
public abstract String getEventType();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formatted from identifier
|
|
||||||
*/
|
|
||||||
public abstract String getFromID();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* From identifier alias (from AliasManager)
|
|
||||||
*/
|
|
||||||
public abstract Alias getFromIDAlias();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Formatted to identifier
|
|
||||||
*/
|
|
||||||
public abstract String getToID();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To identifier alias (from AliasManager)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public abstract Alias getToIDAlias();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a listing of aliases contained in the message.
|
* Provides a listing of aliases contained in the message.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -310,11 +310,6 @@ public abstract class CallEvent implements Comparable<CallEvent>
|
|||||||
@Override
|
@Override
|
||||||
public int compareTo( CallEvent other )
|
public int compareTo( CallEvent other )
|
||||||
{
|
{
|
||||||
if( other != null && other == this )
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Long.compare( mEventStart, other.getEventStartTime() );
|
return Long.compare( mEventStart, other.getEventStartTime() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package module.decode.event;
|
|||||||
|
|
||||||
import java.awt.EventQueue;
|
import java.awt.EventQueue;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
@@ -175,7 +174,7 @@ public class MessageActivityModel extends AbstractTableModel
|
|||||||
switch( columnIndex )
|
switch( columnIndex )
|
||||||
{
|
{
|
||||||
case sTIME:
|
case sTIME:
|
||||||
return mSDFTime.format( new Date( message.getTimeReceived() ) );
|
return mSDFTime.format( message.getDateReceived() );
|
||||||
case sPROTOCOL:
|
case sPROTOCOL:
|
||||||
return message.getProtocol();
|
return message.getProtocol();
|
||||||
case sERROR_STATUS:
|
case sERROR_STATUS:
|
||||||
|
|||||||
80
src/module/decode/event/MessageDetailsProvider.java
Normal file
80
src/module/decode/event/MessageDetailsProvider.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 module.decode.event;
|
||||||
|
|
||||||
|
import alias.Alias;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter methods to support the Message Activity Table/Model
|
||||||
|
*/
|
||||||
|
public interface MessageDetailsProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Indicates if the message is valid and has passed crc/integrity checks
|
||||||
|
*/
|
||||||
|
public abstract boolean isValid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status of the CRC check of the message
|
||||||
|
*/
|
||||||
|
public abstract String getErrorStatus();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsed Message
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract String getMessage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw ( 0 & 1 ) message bits
|
||||||
|
*/
|
||||||
|
public abstract String getBinaryMessage();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decoded protocol
|
||||||
|
*/
|
||||||
|
public abstract String getProtocol();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event - call, data, idle, etc.
|
||||||
|
*/
|
||||||
|
public abstract String getEventType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formatted from identifier
|
||||||
|
*/
|
||||||
|
public abstract String getFromID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* From identifier alias (from AliasManager)
|
||||||
|
*/
|
||||||
|
public abstract Alias getFromIDAlias();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formatted to identifier
|
||||||
|
*/
|
||||||
|
public abstract String getToID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To identifier alias (from AliasManager)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public abstract Alias getToIDAlias();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -51,16 +51,17 @@ public class LTRCallEvent extends CallEvent
|
|||||||
*/
|
*/
|
||||||
public boolean isMatchingTalkgroup( LTRNetMessage message )
|
public boolean isMatchingTalkgroup( LTRNetMessage message )
|
||||||
{
|
{
|
||||||
return isMatchingTalkgroup( message.getTalkgroupID() );
|
String talkgroup = message.getTalkgroupID();
|
||||||
|
|
||||||
|
if( talkgroup != null && getToID() != null &&
|
||||||
|
talkgroup.contentEquals( getToID() ) )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMatchingTalkgroup( String talkgroup )
|
|
||||||
{
|
|
||||||
return talkgroup != null &&
|
|
||||||
getToID() != null &&
|
|
||||||
talkgroup.contentEquals( getToID() );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Alias getAlias( String talkgroup )
|
private Alias getAlias( String talkgroup )
|
||||||
{
|
{
|
||||||
if( hasAliasList() )
|
if( hasAliasList() )
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ public class LTRNetDecoder extends Decoder
|
|||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
mLTRMessageFramer.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ public class LTRStandardDecoder extends Decoder implements IUnFilteredRealBuffer
|
|||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
mLTRMessageFramer.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014,2015 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,31 +17,21 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.ltrstandard;
|
package module.decode.ltrstandard;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
import module.decode.ltrnet.LTRCallEvent;
|
import module.decode.ltrnet.LTRCallEvent;
|
||||||
import module.decode.ltrstandard.message.CallEndMessage;
|
|
||||||
import module.decode.ltrstandard.message.CallMessage;
|
|
||||||
import module.decode.ltrstandard.message.IdleMessage;
|
|
||||||
import module.decode.ltrstandard.message.LTRStandardMessage;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderState;
|
import module.decode.state.DecoderState;
|
||||||
import module.decode.state.DecoderStateEvent;
|
import module.decode.state.DecoderStateEvent;
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
import module.decode.state.DecoderStateEvent.Event;
|
||||||
import module.decode.state.State;
|
import module.decode.state.State;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import audio.metadata.Metadata;
|
import audio.metadata.Metadata;
|
||||||
@@ -49,17 +39,15 @@ import audio.metadata.MetadataType;
|
|||||||
|
|
||||||
public class LTRStandardDecoderState extends DecoderState
|
public class LTRStandardDecoderState extends DecoderState
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private HashMap<Integer,String> mActiveCalls = new HashMap<Integer,String>();
|
||||||
LoggerFactory.getLogger( LTRStandardDecoderState.class );
|
private HashSet<String> mTalkgroupsFirstHeard = new HashSet<String>();
|
||||||
|
private TreeSet<String> mTalkgroups = new TreeSet<String>();
|
||||||
private Map<Integer,LTRCallEvent> mActiveCalls = new HashMap<>();
|
private TreeSet<Integer> mActiveLCNs = new TreeSet<Integer>();
|
||||||
private Set<String> mTalkgroupsFirstHeard = new HashSet<>();
|
|
||||||
private Set<String> mTalkgroups = new TreeSet<>();
|
|
||||||
|
|
||||||
private String mTalkgroup;
|
private String mTalkgroup;
|
||||||
private Alias mTalkgroupAlias;
|
private Alias mTalkgroupAlias;
|
||||||
|
private int mChannelNumber;
|
||||||
private long mFrequency;
|
private long mFrequency;
|
||||||
private LCNTracker mLCNTracker = new LCNTracker();
|
|
||||||
|
|
||||||
public LTRStandardDecoderState( AliasList aliasList )
|
public LTRStandardDecoderState( AliasList aliasList )
|
||||||
{
|
{
|
||||||
@@ -82,128 +70,171 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LTRCallEvent getCurrentCallEvent()
|
||||||
|
{
|
||||||
|
return (LTRCallEvent)mCurrentCallEvent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receive( Message message )
|
public void receive( Message message )
|
||||||
{
|
{
|
||||||
if( message.isValid() && message instanceof LTRStandardMessage )
|
if( message.isValid() )
|
||||||
{
|
{
|
||||||
switch( ((LTRStandardMessage)message).getMessageType() )
|
if( message instanceof LTRStandardOSWMessage )
|
||||||
{
|
{
|
||||||
case CA_STRT:
|
LTRStandardOSWMessage ltr = ((LTRStandardOSWMessage)message);
|
||||||
CallMessage start = (CallMessage)message;
|
|
||||||
|
switch( ltr.getMessageType() )
|
||||||
int channel = start.getChannel();
|
{
|
||||||
|
case CA_STRT:
|
||||||
mLCNTracker.processCallChannel( channel );
|
if( 0 < ltr.getChannel() && ltr.getChannel() <=20 )
|
||||||
|
{
|
||||||
mLCNTracker.processFreeChannel( start.getFree() );
|
/* If we haven't captured the LCN yet ... */
|
||||||
|
if( mChannelNumber == 0 )
|
||||||
|
{
|
||||||
|
mChannelNumber = ltr.getChannel();
|
||||||
|
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
||||||
|
}
|
||||||
|
|
||||||
//Only process calls on this LCN, or call detects for
|
/* If this call event is for this channel, then update
|
||||||
//talkgroups that are homed on this LCN
|
* talkgroup and alias */
|
||||||
if( mLCNTracker.isValidChannel( channel ) &&
|
if( ltr.getChannel() == mChannelNumber )
|
||||||
( mLCNTracker.isCurrentChannel( channel ) ||
|
{
|
||||||
mLCNTracker.isCurrentChannel( start.getHomeRepeater() ) ) )
|
mTalkgroup = ltr.getTalkgroupID();
|
||||||
{
|
broadcast( ChangedAttribute.TO_TALKGROUP );
|
||||||
LTRCallEvent event = mActiveCalls.get( channel );
|
|
||||||
|
mTalkgroupAlias = ltr.getTalkgroupIDAlias();
|
||||||
if( event == null ||
|
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
||||||
!event.isMatchingTalkgroup( start.getToID() ) )
|
|
||||||
{
|
LTRCallEvent current = getCurrentCallEvent();
|
||||||
//Check for different talkgroup
|
|
||||||
if( event != null )
|
|
||||||
{
|
|
||||||
event.end();
|
|
||||||
mActiveCalls.remove( channel );
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean current = mLCNTracker.isCurrentChannel( channel );
|
/* Detect when we haven't reset from the previous
|
||||||
|
* call and now have a new call coming in with
|
||||||
event = new LTRCallEvent.Builder(
|
* a different talkgroup */
|
||||||
DecoderType.LTR_STANDARD,
|
if( current != null && isDifferentTalkgroup( mTalkgroup ) )
|
||||||
current ? CallEventType.CALL : CallEventType.CALL_DETECT )
|
{
|
||||||
.to( start.getToID() )
|
mCurrentCallEvent.end();
|
||||||
.aliasList( getAliasList() )
|
broadcast( mCurrentCallEvent );
|
||||||
.channel( start.getChannelFormatted() )
|
mCurrentCallEvent = null;
|
||||||
.frequency( current ? mFrequency : 0 )
|
}
|
||||||
.build();
|
|
||||||
|
if( current == null )
|
||||||
mActiveCalls.put( channel, event );
|
{
|
||||||
|
mCurrentCallEvent =
|
||||||
broadcast( event );
|
new LTRCallEvent.Builder(
|
||||||
|
DecoderType.LTR_STANDARD, CallEventType.CALL )
|
||||||
if( mLCNTracker.isCurrentChannel( channel ) )
|
.to( ltr.getTalkgroupID() )
|
||||||
{
|
.aliasList( getAliasList() )
|
||||||
mTalkgroup = start.getToID();
|
.channel( String.valueOf( ltr.getChannel() ) )
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
.frequency( mFrequency )
|
||||||
|
.build();
|
||||||
processTalkgroup( mTalkgroup );
|
|
||||||
|
|
||||||
mTalkgroupAlias = start.getToIDAlias();
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
|
|
||||||
broadcast( new Metadata( MetadataType.TO,
|
broadcast( mCurrentCallEvent );
|
||||||
mTalkgroup, mTalkgroupAlias, true ) );
|
|
||||||
}
|
broadcast( new Metadata( MetadataType.TO,
|
||||||
}
|
mTalkgroup, mTalkgroupAlias, true ) );
|
||||||
|
|
||||||
broadcast( new DecoderStateEvent( this,
|
|
||||||
Event.CONTINUATION, State.CALL ) );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case CA_ENDD:
|
|
||||||
CallEndMessage end = (CallEndMessage)message;
|
|
||||||
|
|
||||||
//Home channel is 31 for call end -- use the free channel
|
broadcast( new DecoderStateEvent( this,
|
||||||
//as the call end channel
|
Event.START, State.CALL ) );
|
||||||
int repeater = end.getFree();
|
}
|
||||||
|
else
|
||||||
mLCNTracker.processCallChannel( repeater );
|
{
|
||||||
|
broadcast( new DecoderStateEvent( this,
|
||||||
if( mLCNTracker.isCurrentChannel( repeater ) )
|
Event.CONTINUATION, State.CALL ) );
|
||||||
{
|
}
|
||||||
mTalkgroup = end.getToID();
|
}
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
}
|
||||||
|
break;
|
||||||
processTalkgroup( mTalkgroup );
|
case CA_ENDD:
|
||||||
|
mTalkgroup = ltr.getTalkgroupID();
|
||||||
mTalkgroupAlias = end.getToIDAlias();
|
broadcast( ChangedAttribute.TO_TALKGROUP );
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
|
||||||
|
|
||||||
LTRCallEvent event = mActiveCalls.remove( repeater );
|
mTalkgroupAlias = ltr.getTalkgroupIDAlias();
|
||||||
|
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
||||||
if( event != null )
|
|
||||||
{
|
|
||||||
event.end();
|
|
||||||
broadcast( event );
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.END, State.FADE ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case SY_IDLE:
|
|
||||||
IdleMessage idle = (IdleMessage)message;
|
|
||||||
|
|
||||||
int lcn = idle.getChannel();
|
if( mCurrentCallEvent != null )
|
||||||
|
{
|
||||||
|
mCurrentCallEvent.end();
|
||||||
|
broadcast( mCurrentCallEvent );
|
||||||
|
broadcast( new DecoderStateEvent( this, Event.END, State.FADE ) );
|
||||||
|
mCurrentCallEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int home = ltr.getHomeRepeater();
|
||||||
|
|
||||||
|
if( 0 < home && home <= 20 )
|
||||||
|
{
|
||||||
|
String talkgroup = ltr.getTalkgroupID( false );
|
||||||
|
|
||||||
|
if( mTalkgroupsFirstHeard.contains( talkgroup ) )
|
||||||
|
{
|
||||||
|
mTalkgroups.add( talkgroup );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mTalkgroupsFirstHeard.add( talkgroup );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mLCNTracker.processCallChannel( lcn );
|
int channel = ltr.getChannel();
|
||||||
|
|
||||||
break;
|
if( 0 < channel && channel <= 20 )
|
||||||
case UN_KNWN:
|
{
|
||||||
default:
|
if( channel == home )
|
||||||
break;
|
{
|
||||||
|
if( mChannelNumber != channel )
|
||||||
|
{
|
||||||
|
mChannelNumber = channel;
|
||||||
|
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
||||||
|
}
|
||||||
|
|
||||||
|
mActiveLCNs.add( channel );
|
||||||
|
}
|
||||||
|
|
||||||
|
int free = ltr.getFree();
|
||||||
|
|
||||||
|
if( 0 < free && free <= 20 )
|
||||||
|
{
|
||||||
|
mActiveLCNs.add( free );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case SY_IDLE:
|
||||||
|
int idleChannel = ltr.getChannel();
|
||||||
|
|
||||||
|
if( idleChannel == ltr.getHomeRepeater() &&
|
||||||
|
idleChannel == ltr.getFree() )
|
||||||
|
{
|
||||||
|
if( mChannelNumber != idleChannel )
|
||||||
|
{
|
||||||
|
mChannelNumber = idleChannel;
|
||||||
|
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
||||||
|
}
|
||||||
|
|
||||||
|
mActiveLCNs.add( idleChannel );
|
||||||
|
}
|
||||||
|
broadcast( new DecoderStateEvent( this,
|
||||||
|
Event.CONTINUATION, State.IDLE ) );
|
||||||
|
break;
|
||||||
|
case UN_KNWN:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processTalkgroup( String talkgroup )
|
/**
|
||||||
|
* Indicates if the talkgroup is different than the talkgroup specified in
|
||||||
|
* the current call event
|
||||||
|
*/
|
||||||
|
private boolean isDifferentTalkgroup( String talkgroup )
|
||||||
{
|
{
|
||||||
if( mTalkgroupsFirstHeard.contains( talkgroup ) )
|
return talkgroup != null &&
|
||||||
{
|
mCurrentCallEvent != null &&
|
||||||
mTalkgroups.add( talkgroup );
|
mCurrentCallEvent.getToID() != null &&
|
||||||
}
|
!mCurrentCallEvent.getToID().contentEquals( talkgroup );
|
||||||
else
|
|
||||||
{
|
|
||||||
mTalkgroupsFirstHeard.add( talkgroup );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -214,7 +245,8 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
mActiveCalls.clear();
|
mActiveCalls.clear();
|
||||||
mTalkgroupsFirstHeard.clear();
|
mTalkgroupsFirstHeard.clear();
|
||||||
mTalkgroups.clear();
|
mTalkgroups.clear();
|
||||||
mLCNTracker.reset();
|
mActiveLCNs.clear();
|
||||||
|
mChannelNumber = 0;
|
||||||
|
|
||||||
resetState();
|
resetState();
|
||||||
}
|
}
|
||||||
@@ -224,20 +256,13 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
*/
|
*/
|
||||||
private void resetState()
|
private void resetState()
|
||||||
{
|
{
|
||||||
for( Integer key: mActiveCalls.keySet() )
|
if( mCurrentCallEvent != null )
|
||||||
{
|
{
|
||||||
LTRCallEvent event = mActiveCalls.get( key );
|
mCurrentCallEvent.setEnd( System.currentTimeMillis() );
|
||||||
|
broadcast( mCurrentCallEvent );
|
||||||
if( event != null )
|
mCurrentCallEvent = null;
|
||||||
{
|
|
||||||
event.end();
|
|
||||||
|
|
||||||
broadcast( event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mActiveCalls.clear();
|
|
||||||
|
|
||||||
mTalkgroup = null;
|
mTalkgroup = null;
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
broadcast( ChangedAttribute.TO_TALKGROUP );
|
||||||
|
|
||||||
@@ -257,12 +282,12 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
|
|
||||||
public boolean hasChannelNumber()
|
public boolean hasChannelNumber()
|
||||||
{
|
{
|
||||||
return mLCNTracker.getCurrentChannel() != 0;
|
return mChannelNumber != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getChannelNumber()
|
public int getChannelNumber()
|
||||||
{
|
{
|
||||||
return mLCNTracker.getCurrentChannel();
|
return mChannelNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -297,28 +322,28 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
|
|
||||||
sb.append( "Monitored LCN: " );
|
sb.append( "Monitored LCN: " );
|
||||||
|
|
||||||
if( hasChannelNumber() )
|
if( mChannelNumber > 0 )
|
||||||
{
|
{
|
||||||
sb.append( getChannelNumber() );
|
sb.append( mChannelNumber );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append( "*Insufficient Data*" );
|
sb.append( "unknown" );
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append( "\n" );
|
sb.append( "\n" );
|
||||||
|
|
||||||
sb.append( "Active LCNs:\t" );
|
Integer[] lcns = mActiveLCNs.toArray( new Integer[0] );
|
||||||
|
|
||||||
List<Integer> lcns = mLCNTracker.getActiveLCNs();
|
|
||||||
|
|
||||||
if( lcns.size() > 0 )
|
sb.append( "Active LCNs:\t" );
|
||||||
|
|
||||||
|
if( lcns.length > 0 )
|
||||||
{
|
{
|
||||||
sb.append( mLCNTracker.getActiveLCNs() );
|
sb.append( Arrays.toString( lcns ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.append( "*Insufficient Data*" );
|
sb.append( "none" );
|
||||||
}
|
}
|
||||||
sb.append( "\n\n" );
|
sb.append( "\n\n" );
|
||||||
|
|
||||||
@@ -330,15 +355,19 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for( String talkgroup: mTalkgroups )
|
Iterator<String> it = mTalkgroups.iterator();
|
||||||
|
|
||||||
|
while( it.hasNext() )
|
||||||
{
|
{
|
||||||
|
String tgid = it.next();
|
||||||
|
|
||||||
sb.append( " " );
|
sb.append( " " );
|
||||||
sb.append( talkgroup );
|
sb.append( formatTalkgroup( tgid ) );
|
||||||
sb.append( " " );
|
sb.append( " " );
|
||||||
|
|
||||||
if( hasAliasList() )
|
if( hasAliasList() )
|
||||||
{
|
{
|
||||||
Alias alias = getAliasList().getTalkgroupAlias( talkgroup );
|
Alias alias = getAliasList().getTalkgroupAlias( tgid );
|
||||||
|
|
||||||
if( alias != null )
|
if( alias != null )
|
||||||
{
|
{
|
||||||
@@ -347,147 +376,30 @@ public class LTRStandardDecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
|
|
||||||
sb.append( "\n" );
|
sb.append( "\n" );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static String formatTalkgroup( String talkgroup )
|
||||||
* Tracks the set of call and free channels for a system in order to
|
|
||||||
* dynamically determine the current LCN and minimize false triggers from
|
|
||||||
* bogus decoded LTR messages. Tracks the number of occurances of each
|
|
||||||
* LCN and uses a dynamic threshold to determine LCN validity.
|
|
||||||
*/
|
|
||||||
public class LCNTracker
|
|
||||||
{
|
{
|
||||||
private static final int DEFAULT_COUNT = 10;
|
StringBuilder sb = new StringBuilder();
|
||||||
private int[] mCallLCNCounts;
|
|
||||||
private int[] mFreeLCNCounts;
|
|
||||||
private int mCallHighestCount;
|
|
||||||
private int mFreeHighestCount;
|
|
||||||
private int mCurrentLCN;
|
|
||||||
|
|
||||||
public LCNTracker()
|
if( talkgroup.length() == 6 )
|
||||||
{
|
{
|
||||||
reset();
|
sb.append( talkgroup.substring( 0, 1 ) );
|
||||||
}
|
sb.append( "-" );
|
||||||
|
sb.append( talkgroup.substring( 1, 3 ) );
|
||||||
public void logStatistics()
|
sb.append( "-" );
|
||||||
{
|
sb.append( talkgroup.substring( 3, 6 ) );
|
||||||
for( int x = 1; x <= 20; x++ )
|
|
||||||
{
|
|
||||||
mLog.debug( "Call " + x + ": " + mCallLCNCounts[ x ] );
|
|
||||||
}
|
|
||||||
mLog.debug( "Call Highest Count: " + mCallHighestCount );
|
|
||||||
for( int x = 1; x <= 20; x++ )
|
|
||||||
{
|
|
||||||
mLog.debug( "Free " + x + ": " + mFreeLCNCounts[ x ] );
|
|
||||||
}
|
|
||||||
mLog.debug( "Free Highest Count: " + mFreeHighestCount );
|
|
||||||
|
|
||||||
mLog.debug( "Current LCN: " + mCurrentLCN );
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
public void reset()
|
|
||||||
{
|
{
|
||||||
//Dim channel arrays to 21 -- ignore the 0 index
|
return talkgroup;
|
||||||
mCallLCNCounts = new int[ 21 ];
|
|
||||||
mFreeLCNCounts = new int[ 21 ];
|
|
||||||
mCallHighestCount = 3;
|
|
||||||
mFreeHighestCount = DEFAULT_COUNT;
|
|
||||||
mCurrentLCN = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCurrentChannel( int channel )
|
|
||||||
{
|
|
||||||
if( mCurrentLCN == 0 )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return channel == mCurrentLCN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrentChannel()
|
|
||||||
{
|
|
||||||
return mCurrentLCN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the channel is valid based on the observed current and
|
|
||||||
* free channels reported by the system. Tracks the count of each
|
|
||||||
* reported free channel the highest free channel count is used as a
|
|
||||||
* threshold where a channel is valid when its count exceeds 20% of the
|
|
||||||
* highest free channel count. A channel is also valid when it is
|
|
||||||
* the currently monitored channel.
|
|
||||||
*/
|
|
||||||
public boolean isValidChannel( int channel )
|
|
||||||
{
|
|
||||||
if( isCurrentChannel( channel ) )
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int count = mFreeLCNCounts[ channel ];
|
|
||||||
|
|
||||||
int threshold = (int)( (double)mFreeHighestCount * 0.2 );
|
|
||||||
|
|
||||||
return count >= threshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processCallChannel( int channel )
|
|
||||||
{
|
|
||||||
if( 1 <= channel && channel <= 20 )
|
|
||||||
{
|
|
||||||
mCallLCNCounts[ channel ]++;
|
|
||||||
|
|
||||||
if( mCallLCNCounts[ channel ] > mCallHighestCount )
|
|
||||||
{
|
|
||||||
mCallHighestCount = mCallLCNCounts[ channel ];
|
|
||||||
mCurrentLCN = channel;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_NUMBER );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void processFreeChannel( int channel )
|
|
||||||
{
|
|
||||||
if( 1 <= channel && channel <= 20 )
|
|
||||||
{
|
|
||||||
mFreeLCNCounts[ channel ]++;
|
|
||||||
|
|
||||||
if( mFreeLCNCounts[ channel ] > mFreeHighestCount )
|
|
||||||
{
|
|
||||||
mFreeHighestCount = mFreeLCNCounts[ channel ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Integer> getActiveLCNs()
|
|
||||||
{
|
|
||||||
List<Integer> active = new ArrayList<>();
|
|
||||||
|
|
||||||
if( mFreeHighestCount > DEFAULT_COUNT )
|
|
||||||
{
|
|
||||||
for( int x = 1; x <= 20; x++ )
|
|
||||||
{
|
|
||||||
if( mCurrentLCN != 0 && isCurrentChannel( x ) )
|
|
||||||
{
|
|
||||||
active.add( x );
|
|
||||||
}
|
|
||||||
else if( isValidChannel( x ) )
|
|
||||||
{
|
|
||||||
active.add( x );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return active;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
238
src/module/decode/ltrstandard/LTRStandardISWMessage.java
Normal file
238
src/module/decode/ltrstandard/LTRStandardISWMessage.java
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 module.decode.ltrstandard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import map.Plottable;
|
||||||
|
import message.MessageDirection;
|
||||||
|
import message.MessageType;
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import bits.BinaryMessage;
|
||||||
|
|
||||||
|
public class LTRStandardISWMessage extends LTRStandardMessage
|
||||||
|
{
|
||||||
|
private static final int sCALL_END = 31;
|
||||||
|
private static final int sIDLE = 255;
|
||||||
|
|
||||||
|
public LTRStandardISWMessage( BinaryMessage message, AliasList list )
|
||||||
|
{
|
||||||
|
super( message, MessageDirection.OSW, list );
|
||||||
|
mMessageType = getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append( mDatestampFormatter.format(
|
||||||
|
new Date( System.currentTimeMillis() ) ) );
|
||||||
|
sb.append( " LTR OSW [" );
|
||||||
|
sb.append( mCRC.getAbbreviation() );
|
||||||
|
sb.append( "] " );
|
||||||
|
sb.append( getMessage() );
|
||||||
|
pad( sb, 100 );
|
||||||
|
sb.append( mMessage.toString() );
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
switch( mMessageType )
|
||||||
|
{
|
||||||
|
case SY_IDLE:
|
||||||
|
sb.append( "IDLE AREA:" );
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( " LCN:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " HOME:" );
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
sb.append( " GRP:" );
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
sb.append( " FREE:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
break;
|
||||||
|
case CA_STRT:
|
||||||
|
sb.append( "CALL LCN:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " TG [ " );
|
||||||
|
sb.append( getTalkgroupID() );
|
||||||
|
sb.append( "/" );
|
||||||
|
sb.append( getTalkgroupIDAlias() );
|
||||||
|
sb.append( " ] FREE:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
break;
|
||||||
|
case CA_ENDD:
|
||||||
|
sb.append( "END* AREA:" );
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( " LCN:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " TG [" );
|
||||||
|
sb.append( getTalkgroupID() );
|
||||||
|
sb.append( "/" );
|
||||||
|
sb.append( getTalkgroupIDAlias() );
|
||||||
|
sb.append( "] FREE:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sb.append( "UNKNOWN A:" );
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( " C:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " H:" );
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
sb.append( " G:" );
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
sb.append( " F:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTalkgroupID()
|
||||||
|
{
|
||||||
|
return getTalkgroupID( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTalkgroupID( boolean format )
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append( getArea() );
|
||||||
|
|
||||||
|
if( format )
|
||||||
|
{
|
||||||
|
sb.append( "-" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
|
||||||
|
if( format )
|
||||||
|
{
|
||||||
|
sb.append( "-" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Alias getTalkgroupIDAlias()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
|
||||||
|
return mAliasList.getTalkgroupAlias( sb.toString() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageType getType()
|
||||||
|
{
|
||||||
|
MessageType retVal = MessageType.UN_KNWN;
|
||||||
|
|
||||||
|
int group = getGroup();
|
||||||
|
|
||||||
|
if( group == sIDLE )
|
||||||
|
{
|
||||||
|
retVal = MessageType.SY_IDLE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int channel = getChannel();
|
||||||
|
|
||||||
|
if( channel == sCALL_END )
|
||||||
|
{
|
||||||
|
retVal = MessageType.CA_ENDD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retVal = MessageType.CA_STRT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFromID()
|
||||||
|
{
|
||||||
|
if( mMessageType == MessageType.CA_STRT ||
|
||||||
|
mMessageType == MessageType.CA_ENDD )
|
||||||
|
{
|
||||||
|
return getTalkgroupID();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Alias getFromIDAlias()
|
||||||
|
{
|
||||||
|
if( mMessageType == MessageType.CA_STRT ||
|
||||||
|
mMessageType == MessageType.CA_ENDD )
|
||||||
|
{
|
||||||
|
return getTalkgroupIDAlias();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
254
src/module/decode/ltrstandard/LTRStandardMessage.java
Normal file
254
src/module/decode/ltrstandard/LTRStandardMessage.java
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 module.decode.ltrstandard;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
import message.Message;
|
||||||
|
import message.MessageDirection;
|
||||||
|
import message.MessageType;
|
||||||
|
import module.decode.DecoderType;
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import bits.BinaryMessage;
|
||||||
|
import edac.CRC;
|
||||||
|
import edac.CRCLTR;
|
||||||
|
|
||||||
|
public abstract class LTRStandardMessage extends Message
|
||||||
|
{
|
||||||
|
protected static final String sUNKNOWN = "**UNKNOWN**";
|
||||||
|
protected static final int sINT_NULL_VALUE = -1;
|
||||||
|
protected static final double sDOUBLE_NULL_VALUE = -1.0D;
|
||||||
|
protected SimpleDateFormat mDatestampFormatter =
|
||||||
|
new SimpleDateFormat( "yyyyMMdd HHmmss" );
|
||||||
|
protected DecimalFormat mDecimalFormatter = new DecimalFormat("0.00000");
|
||||||
|
|
||||||
|
protected static final int[] sSYNC = { 8,7,6,5,4,3,2,1,0 };
|
||||||
|
protected static final int[] sAREA = { 9 };
|
||||||
|
protected static final int[] sCHANNEL = { 14,13,12,11,10 };
|
||||||
|
protected static final int[] sHOME_REPEATER = { 19,18,17,16,15 };
|
||||||
|
protected static final int[] sGROUP = { 27,26,25,24,23,22,21,20 };
|
||||||
|
protected static final int[] sFREE = { 32,31,30,29,28 };
|
||||||
|
protected static final int[] sCRC = { 39,38,37,36,35,34,33 };
|
||||||
|
|
||||||
|
protected BinaryMessage mMessage;
|
||||||
|
protected MessageType mMessageType;
|
||||||
|
protected CRC mCRC;
|
||||||
|
protected AliasList mAliasList;
|
||||||
|
|
||||||
|
public LTRStandardMessage( BinaryMessage message,
|
||||||
|
MessageDirection direction,
|
||||||
|
AliasList list )
|
||||||
|
{
|
||||||
|
mMessage = message;
|
||||||
|
mCRC = CRCLTR.check( message, direction );
|
||||||
|
mAliasList = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageType getMessageType()
|
||||||
|
{
|
||||||
|
return mMessageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return mCRC != CRC.FAILED_CRC && mCRC != CRC.FAILED_PARITY;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends spaces to the end of the stringbuilder to make it length long
|
||||||
|
*/
|
||||||
|
protected void pad( StringBuilder sb, int length )
|
||||||
|
{
|
||||||
|
while( sb.length() < length )
|
||||||
|
{
|
||||||
|
sb.append( " " );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBinaryMessage()
|
||||||
|
{
|
||||||
|
return mMessage.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a value formatted in hex notation.
|
||||||
|
*
|
||||||
|
* @param value - integer value
|
||||||
|
* @return - hex digits returned
|
||||||
|
*/
|
||||||
|
protected static String getHex( int value, int digits )
|
||||||
|
{
|
||||||
|
return String.format( "%0" + digits + "X", value );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String format( String val, int places )
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append( val );
|
||||||
|
|
||||||
|
while( sb.length() < places )
|
||||||
|
{
|
||||||
|
sb.append( " " );
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CRC getCRC()
|
||||||
|
{
|
||||||
|
return mCRC;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getArea()
|
||||||
|
{
|
||||||
|
return getInt( sAREA );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getChannel()
|
||||||
|
{
|
||||||
|
return getInt( sCHANNEL );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHomeRepeater()
|
||||||
|
{
|
||||||
|
return getInt( sHOME_REPEATER );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGroup()
|
||||||
|
{
|
||||||
|
return getInt( sGROUP );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTalkgroupID()
|
||||||
|
{
|
||||||
|
return getTalkgroupID( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTalkgroupID( boolean format )
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append( getArea() );
|
||||||
|
|
||||||
|
if( format )
|
||||||
|
{
|
||||||
|
sb.append( "-" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
|
||||||
|
if( format )
|
||||||
|
{
|
||||||
|
sb.append( "-" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Alias getTalkgroupIDAlias()
|
||||||
|
{
|
||||||
|
return mAliasList.getTalkgroupAlias( getTalkgroupID() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFree()
|
||||||
|
{
|
||||||
|
return getInt( sFREE );
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCRCChecksum()
|
||||||
|
{
|
||||||
|
return getInt( sCRC );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getProtocol()
|
||||||
|
{
|
||||||
|
return DecoderType.LTR_STANDARD.getDisplayString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType()
|
||||||
|
{
|
||||||
|
if( mMessageType != null )
|
||||||
|
{
|
||||||
|
return mMessageType.getDisplayText();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return MessageType.UN_KNWN.getDisplayText();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getToID()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Alias getToIDAlias()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getErrorStatus()
|
||||||
|
{
|
||||||
|
return mCRC.getDisplayText();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import message.MessageType;
|
import message.MessageType;
|
||||||
import module.decode.ltrstandard.message.LTRStandardMessage;
|
|
||||||
import filter.Filter;
|
import filter.Filter;
|
||||||
import filter.FilterElement;
|
import filter.FilterElement;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014,2015 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -19,16 +19,9 @@ package module.decode.ltrstandard;
|
|||||||
|
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
import module.decode.ltrstandard.message.CallEndMessage;
|
|
||||||
import module.decode.ltrstandard.message.CallMessage;
|
|
||||||
import module.decode.ltrstandard.message.IdleMessage;
|
|
||||||
import module.decode.ltrstandard.message.LTRStandardMessage;
|
|
||||||
import module.decode.ltrstandard.message.UnknownMessage;
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import bits.BinaryMessage;
|
import bits.BinaryMessage;
|
||||||
import edac.CRC;
|
|
||||||
import edac.CRCLTR;
|
|
||||||
|
|
||||||
public class LTRStandardMessageProcessor implements Listener<BinaryMessage>
|
public class LTRStandardMessageProcessor implements Listener<BinaryMessage>
|
||||||
{
|
{
|
||||||
@@ -36,12 +29,6 @@ public class LTRStandardMessageProcessor implements Listener<BinaryMessage>
|
|||||||
private AliasList mAliasList;
|
private AliasList mAliasList;
|
||||||
private Listener<Message> mMessageListener;
|
private Listener<Message> mMessageListener;
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes raw binary messages and converts them to the correct message class
|
|
||||||
*
|
|
||||||
* @param direction - inbound (ISW) or outbound (OSW)
|
|
||||||
* @param list - alias list
|
|
||||||
*/
|
|
||||||
public LTRStandardMessageProcessor( MessageDirection direction, AliasList list )
|
public LTRStandardMessageProcessor( MessageDirection direction, AliasList list )
|
||||||
{
|
{
|
||||||
mDirection = direction;
|
mDirection = direction;
|
||||||
@@ -49,66 +36,27 @@ public class LTRStandardMessageProcessor implements Listener<BinaryMessage>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receive( BinaryMessage binaryMessage )
|
public void receive( BinaryMessage buffer )
|
||||||
{
|
{
|
||||||
if( mMessageListener != null )
|
if( mMessageListener != null )
|
||||||
{
|
{
|
||||||
//Inbound Status Word (ISW) is a bit-flipped version of the Outbound
|
LTRStandardMessage message;
|
||||||
//(OSW), so flip the bits and process it as an OSW
|
|
||||||
if( mDirection == MessageDirection.ISW )
|
if( mDirection == MessageDirection.OSW )
|
||||||
{
|
{
|
||||||
binaryMessage.flip( 0, 40 );
|
message = new LTRStandardOSWMessage( buffer, mAliasList );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
buffer.flip( 0, 40 );
|
||||||
|
|
||||||
|
message = new LTRStandardISWMessage( buffer, mAliasList );
|
||||||
}
|
}
|
||||||
|
|
||||||
CRC crc = CRCLTR.check( binaryMessage, mDirection );
|
mMessageListener.receive( message );
|
||||||
|
|
||||||
if( crc != CRC.FAILED_CRC &&
|
|
||||||
crc != CRC.FAILED_PARITY )
|
|
||||||
{
|
|
||||||
LTRStandardMessage message;
|
|
||||||
|
|
||||||
int channel = binaryMessage.getInt( LTRStandardMessage.CHANNEL );
|
|
||||||
int home = binaryMessage.getInt( LTRStandardMessage.HOME_REPEATER );
|
|
||||||
int free = binaryMessage.getInt( LTRStandardMessage.FREE );
|
|
||||||
int group = binaryMessage.getInt( LTRStandardMessage.GROUP );
|
|
||||||
|
|
||||||
if( isValidChannel( channel ) &&
|
|
||||||
isValidChannel( home ) &&
|
|
||||||
isValidChannel( free ) )
|
|
||||||
{
|
|
||||||
if( channel == free && group == 255 )
|
|
||||||
{
|
|
||||||
message = new IdleMessage( binaryMessage, mDirection, mAliasList, crc );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message = new CallMessage( binaryMessage, mDirection, mAliasList, crc );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if( channel == 31 &&
|
|
||||||
isValidChannel( home ) &&
|
|
||||||
isValidChannel( free ) )
|
|
||||||
{
|
|
||||||
message = new CallEndMessage( binaryMessage, mDirection, mAliasList, crc );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
message = new UnknownMessage( binaryMessage, mDirection, mAliasList, crc );
|
|
||||||
}
|
|
||||||
|
|
||||||
mMessageListener.receive( message );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks the channel (LCN) number to ensure it is in the range 1 -20
|
|
||||||
*/
|
|
||||||
private boolean isValidChannel( int channel )
|
|
||||||
{
|
|
||||||
return ( 1 <= channel && channel <= 20 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessageListener( Listener<Message> listener )
|
public void setMessageListener( Listener<Message> listener )
|
||||||
{
|
{
|
||||||
mMessageListener = listener;
|
mMessageListener = listener;
|
||||||
|
|||||||
248
src/module/decode/ltrstandard/LTRStandardOSWMessage.java
Normal file
248
src/module/decode/ltrstandard/LTRStandardOSWMessage.java
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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 module.decode.ltrstandard;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import map.Plottable;
|
||||||
|
import message.MessageDirection;
|
||||||
|
import message.MessageType;
|
||||||
|
import alias.Alias;
|
||||||
|
import alias.AliasList;
|
||||||
|
import bits.BinaryMessage;
|
||||||
|
|
||||||
|
public class LTRStandardOSWMessage extends LTRStandardMessage
|
||||||
|
{
|
||||||
|
private static final int sCALL_END = 31;
|
||||||
|
private static final int sIDLE = 255;
|
||||||
|
|
||||||
|
public LTRStandardOSWMessage( BinaryMessage message, AliasList list )
|
||||||
|
{
|
||||||
|
super( message, MessageDirection.OSW, list );
|
||||||
|
mMessageType = getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append( mDatestampFormatter.format(
|
||||||
|
new Date( System.currentTimeMillis() ) ) );
|
||||||
|
sb.append( " LTR OSW [" );
|
||||||
|
sb.append( mCRC.getAbbreviation() );
|
||||||
|
sb.append( "] " );
|
||||||
|
sb.append( getMessage() );
|
||||||
|
pad( sb, 100 );
|
||||||
|
sb.append( mMessage.toString() );
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
switch( mMessageType )
|
||||||
|
{
|
||||||
|
case SY_IDLE:
|
||||||
|
sb.append( "IDLE AREA:" );
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( " LCN:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " HOME:" );
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
sb.append( " GRP:" );
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
sb.append( " FREE:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
break;
|
||||||
|
case CA_STRT:
|
||||||
|
sb.append( "CALL LCN:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " TG [ " );
|
||||||
|
sb.append( getTalkgroupID() );
|
||||||
|
sb.append( "/" );
|
||||||
|
Alias alias = getTalkgroupIDAlias();
|
||||||
|
if( alias != null )
|
||||||
|
{
|
||||||
|
sb.append( getTalkgroupIDAlias().getName() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.append( "UNKNOWN" );
|
||||||
|
}
|
||||||
|
sb.append( " ] FREE:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
break;
|
||||||
|
case CA_ENDD:
|
||||||
|
sb.append( "END* AREA:" );
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( " LCN:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " TG [" );
|
||||||
|
sb.append( getTalkgroupID() );
|
||||||
|
sb.append( "/" );
|
||||||
|
Alias endAlias = getTalkgroupIDAlias();
|
||||||
|
if( endAlias != null )
|
||||||
|
{
|
||||||
|
sb.append( getTalkgroupIDAlias().getName() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.append( "UNKNOWN" );
|
||||||
|
}
|
||||||
|
sb.append( "] FREE:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sb.append( "UNKNOWN A:" );
|
||||||
|
sb.append( getArea() );
|
||||||
|
sb.append( " C:" );
|
||||||
|
sb.append( format( getChannel(), 2 ) );
|
||||||
|
sb.append( " H:" );
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
sb.append( " G:" );
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
sb.append( " F:" );
|
||||||
|
sb.append( format( getFree(), 2 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTalkgroupID()
|
||||||
|
{
|
||||||
|
return getTalkgroupID( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTalkgroupID( boolean format )
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append( getArea() );
|
||||||
|
|
||||||
|
if( format )
|
||||||
|
{
|
||||||
|
sb.append( "-" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append( format( getHomeRepeater(), 2 ) );
|
||||||
|
|
||||||
|
if( format )
|
||||||
|
{
|
||||||
|
sb.append( "-" );
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.append( format( getGroup(), 3 ) );
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Alias getTalkgroupIDAlias()
|
||||||
|
{
|
||||||
|
return mAliasList.getTalkgroupAlias( getTalkgroupID() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageType getType()
|
||||||
|
{
|
||||||
|
MessageType retVal = MessageType.UN_KNWN;
|
||||||
|
|
||||||
|
/* Group 255 when the channel equals the free is the IDLE message */
|
||||||
|
if( getGroup() == sIDLE && getChannel() == getFree() )
|
||||||
|
{
|
||||||
|
retVal = MessageType.SY_IDLE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int channel = getChannel();
|
||||||
|
|
||||||
|
if( channel == sCALL_END )
|
||||||
|
{
|
||||||
|
retVal = MessageType.CA_ENDD;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
retVal = MessageType.CA_STRT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFromID()
|
||||||
|
{
|
||||||
|
if( mMessageType == MessageType.CA_STRT ||
|
||||||
|
mMessageType == MessageType.CA_ENDD )
|
||||||
|
{
|
||||||
|
return getTalkgroupID();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Alias getFromIDAlias()
|
||||||
|
{
|
||||||
|
if( mMessageType == MessageType.CA_STRT ||
|
||||||
|
mMessageType == MessageType.CA_ENDD )
|
||||||
|
{
|
||||||
|
return getTalkgroupIDAlias();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package module.decode.ltrstandard.message;
|
|
||||||
|
|
||||||
import message.MessageDirection;
|
|
||||||
import message.MessageType;
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
import edac.CRC;
|
|
||||||
|
|
||||||
public class CallEndMessage extends LTRStandardMessage
|
|
||||||
{
|
|
||||||
public CallEndMessage( BinaryMessage message, MessageDirection direction,
|
|
||||||
AliasList list, CRC crc )
|
|
||||||
{
|
|
||||||
super( message, direction, list, crc );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MessageType getMessageType()
|
|
||||||
{
|
|
||||||
return MessageType.CA_ENDD;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "END* AREA:" );
|
|
||||||
sb.append( getArea() );
|
|
||||||
sb.append( " LCN:" );
|
|
||||||
sb.append( getChannelFormatted() );
|
|
||||||
sb.append( " TG [" );
|
|
||||||
sb.append( getToID() );
|
|
||||||
sb.append( "/" );
|
|
||||||
Alias endAlias = getToIDAlias();
|
|
||||||
if( endAlias != null )
|
|
||||||
{
|
|
||||||
sb.append( getToIDAlias().getName() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sb.append( "UNKNOWN" );
|
|
||||||
}
|
|
||||||
sb.append( "] FREE:" );
|
|
||||||
sb.append( getFreeFormatted() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package module.decode.ltrstandard.message;
|
|
||||||
|
|
||||||
import message.MessageDirection;
|
|
||||||
import message.MessageType;
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
import edac.CRC;
|
|
||||||
|
|
||||||
public class CallMessage extends LTRStandardMessage
|
|
||||||
{
|
|
||||||
public CallMessage( BinaryMessage message, MessageDirection direction,
|
|
||||||
AliasList list, CRC crc )
|
|
||||||
{
|
|
||||||
super( message, direction, list, crc );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MessageType getMessageType()
|
|
||||||
{
|
|
||||||
return MessageType.CA_STRT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "CALL LCN:" );
|
|
||||||
sb.append( getChannelFormatted() );
|
|
||||||
sb.append( " TG [ " );
|
|
||||||
sb.append( getToID() );
|
|
||||||
sb.append( "/" );
|
|
||||||
|
|
||||||
Alias alias = getToIDAlias();
|
|
||||||
|
|
||||||
if( alias != null )
|
|
||||||
{
|
|
||||||
sb.append( getToIDAlias().getName() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sb.append( "UNKNOWN" );
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append( " ] FREE:" );
|
|
||||||
sb.append( getFreeFormatted() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package module.decode.ltrstandard.message;
|
|
||||||
|
|
||||||
import message.MessageDirection;
|
|
||||||
import message.MessageType;
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
import edac.CRC;
|
|
||||||
|
|
||||||
public class IdleMessage extends LTRStandardMessage
|
|
||||||
{
|
|
||||||
public IdleMessage( BinaryMessage message, MessageDirection direction,
|
|
||||||
AliasList list, CRC crc )
|
|
||||||
{
|
|
||||||
super( message, direction, list, crc );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MessageType getMessageType()
|
|
||||||
{
|
|
||||||
return MessageType.SY_IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "IDLE AREA:" );
|
|
||||||
sb.append( getArea() );
|
|
||||||
sb.append( " LCN:" );
|
|
||||||
sb.append( getChannelFormatted() );
|
|
||||||
sb.append( " HOME:" );
|
|
||||||
sb.append( getHomeRepeaterFormatted() );
|
|
||||||
sb.append( " GRP:" );
|
|
||||||
sb.append( getGroupFormatted() );
|
|
||||||
sb.append( " FREE:" );
|
|
||||||
sb.append( getFreeFormatted() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,213 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package module.decode.ltrstandard.message;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import message.Message;
|
|
||||||
import message.MessageDirection;
|
|
||||||
import message.MessageType;
|
|
||||||
import module.decode.DecoderType;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import alias.Alias;
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
import edac.CRC;
|
|
||||||
|
|
||||||
public abstract class LTRStandardMessage extends Message
|
|
||||||
{
|
|
||||||
protected SimpleDateFormat mDatestampFormatter =
|
|
||||||
new SimpleDateFormat( "yyyyMMdd HHmmss" );
|
|
||||||
|
|
||||||
public static final int[] SYNC = { 0,1,2,3,4,5,6,7,8 };
|
|
||||||
public static final int[] AREA = { 9 };
|
|
||||||
public static final int[] CHANNEL = { 10,11,12,13,14 };
|
|
||||||
public static final int[] HOME_REPEATER = { 15,16,17,18,19 };
|
|
||||||
public static final int[] GROUP = { 20,21,22,23,24,25,26,27 };
|
|
||||||
public static final int[] FREE = { 28,29,30,31,32 };
|
|
||||||
public static final int[] CHECKSUM = { 33,34,35,36,37,38,39 };
|
|
||||||
|
|
||||||
protected BinaryMessage mMessage;
|
|
||||||
protected MessageDirection mMessageDirection;
|
|
||||||
protected AliasList mAliasList;
|
|
||||||
protected CRC mCRC;
|
|
||||||
|
|
||||||
public LTRStandardMessage( BinaryMessage message,
|
|
||||||
MessageDirection direction,
|
|
||||||
AliasList list,
|
|
||||||
CRC crc )
|
|
||||||
{
|
|
||||||
mMessage = message;
|
|
||||||
mMessageDirection = direction;
|
|
||||||
mAliasList = list;
|
|
||||||
mCRC = crc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract MessageType getMessageType();
|
|
||||||
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return mCRC != CRC.FAILED_CRC && mCRC != CRC.FAILED_PARITY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append( mDatestampFormatter.format(
|
|
||||||
new Date( System.currentTimeMillis() ) ) );
|
|
||||||
sb.append( " LTR " );
|
|
||||||
sb.append( mMessageDirection.name() );
|
|
||||||
sb.append( " [" );
|
|
||||||
sb.append( mCRC.getAbbreviation() );
|
|
||||||
sb.append( "] " );
|
|
||||||
sb.append( getMessage() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBinaryMessage()
|
|
||||||
{
|
|
||||||
return mMessage.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CRC getCRC()
|
|
||||||
{
|
|
||||||
return mCRC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getArea()
|
|
||||||
{
|
|
||||||
return mMessage.getInt( AREA );
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getChannel()
|
|
||||||
{
|
|
||||||
return mMessage.getInt( CHANNEL );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getChannelFormatted()
|
|
||||||
{
|
|
||||||
return StringUtils.leftPad( String.valueOf( getChannel() ), 2, "0" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getHomeRepeater()
|
|
||||||
{
|
|
||||||
return mMessage.getInt( HOME_REPEATER );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHomeRepeaterFormatted()
|
|
||||||
{
|
|
||||||
return StringUtils.leftPad( String.valueOf( getHomeRepeater() ), 2, "0" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGroup()
|
|
||||||
{
|
|
||||||
return mMessage.getInt( GROUP );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGroupFormatted()
|
|
||||||
{
|
|
||||||
return StringUtils.leftPad( String.valueOf( getGroup() ), 3, "0" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFree()
|
|
||||||
{
|
|
||||||
return mMessage.getInt( FREE );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFreeFormatted()
|
|
||||||
{
|
|
||||||
return StringUtils.leftPad( String.valueOf( getFree() ), 2, "0" );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFromID()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Alias getFromIDAlias()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getToID()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( getArea() );
|
|
||||||
sb.append( "-" );
|
|
||||||
sb.append( getHomeRepeaterFormatted() );
|
|
||||||
sb.append( "-" );
|
|
||||||
sb.append( getGroupFormatted() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Alias getToIDAlias()
|
|
||||||
{
|
|
||||||
return mAliasList.getTalkgroupAlias( getToID() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Alias> getAliases()
|
|
||||||
{
|
|
||||||
List<Alias> aliases = new ArrayList<>();
|
|
||||||
|
|
||||||
Alias talkgroupAlias = getToIDAlias();
|
|
||||||
|
|
||||||
if( talkgroupAlias != null )
|
|
||||||
{
|
|
||||||
aliases.add( talkgroupAlias );
|
|
||||||
}
|
|
||||||
|
|
||||||
return aliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCRCChecksum()
|
|
||||||
{
|
|
||||||
return mMessage.getInt( CHECKSUM );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getProtocol()
|
|
||||||
{
|
|
||||||
return DecoderType.LTR_STANDARD.getDisplayString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType()
|
|
||||||
{
|
|
||||||
return getMessageType().getDisplayText();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getErrorStatus()
|
|
||||||
{
|
|
||||||
return mCRC.getDisplayText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* SDR Trunk
|
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
******************************************************************************/
|
|
||||||
package module.decode.ltrstandard.message;
|
|
||||||
|
|
||||||
import message.MessageDirection;
|
|
||||||
import message.MessageType;
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
import edac.CRC;
|
|
||||||
|
|
||||||
public class UnknownMessage extends LTRStandardMessage
|
|
||||||
{
|
|
||||||
public UnknownMessage( BinaryMessage message, MessageDirection direction,
|
|
||||||
AliasList list, CRC crc )
|
|
||||||
{
|
|
||||||
super( message, direction, list, crc );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MessageType getMessageType()
|
|
||||||
{
|
|
||||||
return MessageType.UN_KNWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "UNKNOWN AREA:" );
|
|
||||||
sb.append( getArea() );
|
|
||||||
sb.append( " LCN:" );
|
|
||||||
sb.append( getChannelFormatted() );
|
|
||||||
sb.append( " HOME:" );
|
|
||||||
sb.append( getHomeRepeaterFormatted() );
|
|
||||||
sb.append( " GRP:" );
|
|
||||||
sb.append( getGroupFormatted() );
|
|
||||||
sb.append( " FREE:" );
|
|
||||||
sb.append( getFreeFormatted() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -301,8 +301,8 @@ public class MPT1327Decoder extends Decoder
|
|||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
mControlMessageFramer.reset();
|
// TODO Auto-generated method stub
|
||||||
mTrafficMessageFramer.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -26,11 +26,9 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
import message.Message;
|
import message.Message;
|
||||||
import module.decode.DecoderType;
|
import module.decode.DecoderType;
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
import module.decode.event.CallEvent;
|
import module.decode.event.CallEvent;
|
||||||
import module.decode.event.CallEvent.CallEventType;
|
import module.decode.event.CallEvent.CallEventType;
|
||||||
import module.decode.mpt1327.MPT1327Message.IdentType;
|
import module.decode.mpt1327.MPT1327Message.IdentType;
|
||||||
import module.decode.state.ChangeChannelTimeoutEvent;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderState;
|
import module.decode.state.DecoderState;
|
||||||
import module.decode.state.DecoderStateEvent;
|
import module.decode.state.DecoderStateEvent;
|
||||||
@@ -43,8 +41,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
import alias.AliasList;
|
import alias.AliasList;
|
||||||
import audio.metadata.Metadata;
|
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import controller.channel.map.ChannelMap;
|
import controller.channel.map.ChannelMap;
|
||||||
|
|
||||||
@@ -64,18 +60,15 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
private ChannelMap mChannelMap;
|
private ChannelMap mChannelMap;
|
||||||
|
|
||||||
private long mFrequency = 0;
|
private long mFrequency = 0;
|
||||||
private long mCallTimeout;
|
|
||||||
|
|
||||||
public MPT1327DecoderState( AliasList aliasList,
|
public MPT1327DecoderState( AliasList aliasList, ChannelMap channelMap,
|
||||||
ChannelMap channelMap,
|
ChannelType channelType )
|
||||||
ChannelType channelType,
|
|
||||||
long callTimeout )
|
|
||||||
{
|
{
|
||||||
super( aliasList );
|
super( aliasList );
|
||||||
|
|
||||||
mChannelMap = channelMap;
|
mChannelMap = channelMap;
|
||||||
|
|
||||||
mChannelType = channelType;
|
mChannelType = channelType;
|
||||||
mCallTimeout = callTimeout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -259,42 +252,8 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
|
|
||||||
/* Traffic Channel Events */
|
/* Traffic Channel Events */
|
||||||
case CLEAR:
|
case CLEAR:
|
||||||
mChannelNumber = mpt.getChannel();
|
|
||||||
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.END, State.FADE ) );
|
|
||||||
break;
|
|
||||||
case MAINT:
|
case MAINT:
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
broadcast( new DecoderStateEvent( this, Event.END, State.END ) );
|
||||||
{
|
|
||||||
/**
|
|
||||||
* When we receive a MAINT message and we're configured
|
|
||||||
* as a standard channel, we need to apply the call
|
|
||||||
* timeout specified by the user. Otherwise we'll
|
|
||||||
* be using the shorter default call timeout
|
|
||||||
*/
|
|
||||||
broadcast( new ChangeChannelTimeoutEvent( this,
|
|
||||||
mChannelType, mCallTimeout ) );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent == null )
|
|
||||||
{
|
|
||||||
mCurrentCallEvent = new MPT1327CallEvent.Builder( CallEventType.CALL )
|
|
||||||
.aliasList( getAliasList() )
|
|
||||||
.channel( String.valueOf( mChannelNumber ) )
|
|
||||||
.details( "MONITORED TRAFFIC CHANNEL" )
|
|
||||||
.frequency( mFrequency )
|
|
||||||
.to( mpt.getToID() )
|
|
||||||
.build();
|
|
||||||
|
|
||||||
broadcast( mCurrentCallEvent );
|
|
||||||
}
|
|
||||||
|
|
||||||
broadcast(new Metadata(MetadataType.TO,
|
|
||||||
mpt.getToID(), mpt.getToIDAlias(), true));
|
|
||||||
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.START, State.CALL ) );
|
|
||||||
|
|
||||||
setToTalkgroup( mpt.getToID() );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -317,25 +276,6 @@ public class MPT1327DecoderState extends DecoderState
|
|||||||
|
|
||||||
mToTalkgroup = null;
|
mToTalkgroup = null;
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
broadcast( ChangedAttribute.TO_TALKGROUP );
|
||||||
|
|
||||||
/**
|
|
||||||
* If this is a standard channel, reset the fade timeout to the default
|
|
||||||
* timeout. Once processing is underway, if we get a MAINT message,
|
|
||||||
* this indicates we're processing a traffic channel as a standard
|
|
||||||
* channel, so we'll issue a different call timeout then.
|
|
||||||
*/
|
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
|
||||||
{
|
|
||||||
broadcast( new ChangeChannelTimeoutEvent( this, mChannelType,
|
|
||||||
DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS * 1000 ) );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent != null )
|
|
||||||
{
|
|
||||||
mCurrentCallEvent.end();
|
|
||||||
broadcast( mCurrentCallEvent );
|
|
||||||
mCurrentCallEvent = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSite()
|
public String getSite()
|
||||||
|
|||||||
@@ -42,8 +42,6 @@ import module.decode.p25.message.ldu.lc.TelephoneInterconnectVoiceChannelUser;
|
|||||||
import module.decode.p25.message.ldu.lc.UnitToUnitVoiceChannelUser;
|
import module.decode.p25.message.ldu.lc.UnitToUnitVoiceChannelUser;
|
||||||
import module.decode.p25.message.pdu.PDUMessage;
|
import module.decode.p25.message.pdu.PDUMessage;
|
||||||
import module.decode.p25.message.pdu.confirmed.PDUConfirmedMessage;
|
import module.decode.p25.message.pdu.confirmed.PDUConfirmedMessage;
|
||||||
import module.decode.p25.message.pdu.confirmed.PDUTypeUnknown;
|
|
||||||
import module.decode.p25.message.pdu.confirmed.PacketData;
|
|
||||||
import module.decode.p25.message.pdu.confirmed.SNDCPActivateTDSContextAccept;
|
import module.decode.p25.message.pdu.confirmed.SNDCPActivateTDSContextAccept;
|
||||||
import module.decode.p25.message.pdu.confirmed.SNDCPActivateTDSContextReject;
|
import module.decode.p25.message.pdu.confirmed.SNDCPActivateTDSContextReject;
|
||||||
import module.decode.p25.message.pdu.confirmed.SNDCPActivateTDSContextRequest;
|
import module.decode.p25.message.pdu.confirmed.SNDCPActivateTDSContextRequest;
|
||||||
@@ -120,6 +118,7 @@ import module.decode.p25.message.tsbk.osp.voice.UnitToUnitVoiceChannelGrantUpdat
|
|||||||
import module.decode.p25.reference.IPProtocol;
|
import module.decode.p25.reference.IPProtocol;
|
||||||
import module.decode.p25.reference.LinkControlOpcode;
|
import module.decode.p25.reference.LinkControlOpcode;
|
||||||
import module.decode.p25.reference.Response;
|
import module.decode.p25.reference.Response;
|
||||||
|
import module.decode.p25.reference.Service;
|
||||||
import module.decode.p25.reference.Vendor;
|
import module.decode.p25.reference.Vendor;
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderState;
|
import module.decode.state.DecoderState;
|
||||||
@@ -407,12 +406,12 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
if( hdu.isValid() )
|
if( hdu.isValid() )
|
||||||
{
|
{
|
||||||
broadcast( new DecoderStateEvent( this, Event.START, State.CALL ) );
|
State state = hdu.isEncrypted() ? State.ENCRYPTED : State.CALL;
|
||||||
|
|
||||||
|
broadcast( new DecoderStateEvent( this, Event.START, state ) );
|
||||||
|
|
||||||
String to = hdu.getToID();
|
String to = hdu.getToID();
|
||||||
|
|
||||||
updateTo( to );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent == null )
|
if( mCurrentCallEvent == null )
|
||||||
{
|
{
|
||||||
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.CALL )
|
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.CALL )
|
||||||
@@ -426,6 +425,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
broadcast( mCurrentCallEvent );
|
broadcast( mCurrentCallEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTo( to );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,7 +437,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
if( tdulc.getOpcode() == LinkControlOpcode.CALL_TERMINATION_OR_CANCELLATION )
|
if( tdulc.getOpcode() == LinkControlOpcode.CALL_TERMINATION_OR_CANCELLATION )
|
||||||
{
|
{
|
||||||
broadcast( new DecoderStateEvent( this, Event.END, State.FADE ) );
|
broadcast( new DecoderStateEvent( this, Event.END, State.END ) );
|
||||||
|
|
||||||
if( mCurrentCallEvent != null )
|
if( mCurrentCallEvent != null )
|
||||||
{
|
{
|
||||||
@@ -615,14 +615,12 @@ public class P25DecoderState extends DecoderState
|
|||||||
module.decode.p25.message.tdu.lc.GroupVoiceChannelUser gvcuser =
|
module.decode.p25.message.tdu.lc.GroupVoiceChannelUser gvcuser =
|
||||||
(module.decode.p25.message.tdu.lc.GroupVoiceChannelUser)tdulc;
|
(module.decode.p25.message.tdu.lc.GroupVoiceChannelUser)tdulc;
|
||||||
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.CALL ) );
|
broadcast( new DecoderStateEvent( this, Event.CONTINUATION,
|
||||||
|
( gvcuser.isEncrypted() ? State.ENCRYPTED : State.CALL ) ) );
|
||||||
|
|
||||||
String from = gvcuser.getSourceAddress();
|
String from = gvcuser.getSourceAddress();
|
||||||
String to = gvcuser.getGroupAddress();
|
String to = gvcuser.getGroupAddress();
|
||||||
|
|
||||||
updateFrom( from );
|
|
||||||
updateTo( to );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent == null )
|
if( mCurrentCallEvent == null )
|
||||||
{
|
{
|
||||||
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.GROUP_CALL )
|
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.GROUP_CALL )
|
||||||
@@ -638,6 +636,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast( mCurrentCallEvent );
|
broadcast( mCurrentCallEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFrom( from );
|
||||||
|
updateTo( to );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MESSAGE_UPDATE:
|
case MESSAGE_UPDATE:
|
||||||
@@ -844,8 +845,6 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
String to = tivcu.getAddress();
|
String to = tivcu.getAddress();
|
||||||
|
|
||||||
updateTo( to );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent == null )
|
if( mCurrentCallEvent == null )
|
||||||
{
|
{
|
||||||
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.TELEPHONE_INTERCONNECT )
|
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.TELEPHONE_INTERCONNECT )
|
||||||
@@ -859,6 +858,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast( mCurrentCallEvent );
|
broadcast( mCurrentCallEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTo( to );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UNIT_AUTHENTICATION_COMMAND:
|
case UNIT_AUTHENTICATION_COMMAND:
|
||||||
@@ -921,10 +922,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
(module.decode.p25.message.tdu.lc.UnitToUnitVoiceChannelUser)tdulc;
|
(module.decode.p25.message.tdu.lc.UnitToUnitVoiceChannelUser)tdulc;
|
||||||
|
|
||||||
String from = uuvcu.getSourceAddress();
|
String from = uuvcu.getSourceAddress();
|
||||||
updateFrom( from );
|
|
||||||
|
|
||||||
String to = uuvcu.getTargetAddress();
|
String to = uuvcu.getTargetAddress();
|
||||||
updateTo( to );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent != null )
|
if( mCurrentCallEvent != null )
|
||||||
{
|
{
|
||||||
@@ -938,6 +936,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
.to( to )
|
.to( to )
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFrom( from );
|
||||||
|
updateTo( to );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -949,14 +950,35 @@ public class P25DecoderState extends DecoderState
|
|||||||
* Log optional vendor format messages that we don't yet support so that we
|
* Log optional vendor format messages that we don't yet support so that we
|
||||||
* can understand those messages and eventually add support.
|
* can understand those messages and eventually add support.
|
||||||
*/
|
*/
|
||||||
private void logAlternateVendorMessage( P25Message message )
|
private void logAlternateVendorMessage( P25Message p25 )
|
||||||
{
|
{
|
||||||
// if( message.isValid() )
|
// if( p25 instanceof TDULinkControlMessage )
|
||||||
// {
|
// {
|
||||||
// mLog.info( "PLEASE NOTIFY DEVELOPER - UNRECOGNIZED P25 VENDOR FORMAT -"
|
// TDULinkControlMessage tdulc = (TDULinkControlMessage)p25;
|
||||||
// + " DUID:" + message.getDUID()
|
//
|
||||||
// + " MSG:" + message.getBinaryMessage()
|
// mLog.debug( "TDULC - VENDOR [" + tdulc.getVendor() +
|
||||||
// + " CLASS:" + message.getClass() );
|
// "] SPECIFIC FORMAT FOR " + tdulc.getVendorOpcode().getLabel() +
|
||||||
|
// " " + tdulc.getBinaryMessage() );
|
||||||
|
// }
|
||||||
|
// else if( p25 instanceof LDU1Message )
|
||||||
|
// {
|
||||||
|
// LDU1Message ldu1 = (LDU1Message)p25;
|
||||||
|
//
|
||||||
|
// mLog.debug( "LDU1 - VENDOR [" + ldu1.getVendor() +
|
||||||
|
// "] SPECIFIC FORMAT FOR " + ldu1.getVendorOpcode().getLabel() +
|
||||||
|
// " " + ldu1.getBinaryMessage() );
|
||||||
|
// }
|
||||||
|
// else if( p25 instanceof PDUMessage )
|
||||||
|
// {
|
||||||
|
// PDUMessage pdu = (PDUMessage)p25;
|
||||||
|
//
|
||||||
|
// mLog.debug( "PDU - VENDOR [" + pdu.getVendor() +
|
||||||
|
// "] SPECIFIC FORMAT FOR " + pdu.getVendorOpcode().getLabel() +
|
||||||
|
// " " + pdu.getBinaryMessage() );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// mLog.debug( "P25 - ALTERNATE VENDOR MESSAGE [" + p25.getClass() + "]" );
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -967,11 +989,15 @@ public class P25DecoderState extends DecoderState
|
|||||||
*/
|
*/
|
||||||
private void processLDU( LDUMessage ldu )
|
private void processLDU( LDUMessage ldu )
|
||||||
{
|
{
|
||||||
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.CALL ) );
|
State state = ( ldu.isValid() && ldu.isEncrypted() ) ?
|
||||||
|
State.ENCRYPTED : State.CALL;
|
||||||
|
|
||||||
|
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, state ) );
|
||||||
|
|
||||||
if( mCurrentCallEvent == null )
|
if( mCurrentCallEvent == null )
|
||||||
{
|
{
|
||||||
mCurrentCallEvent = new P25CallEvent.Builder( CallEventType.CALL )
|
mCurrentCallEvent = new P25CallEvent.Builder(
|
||||||
|
( state == State.CALL ) ? CallEventType.CALL : CallEventType.ENCRYPTED_CALL )
|
||||||
.aliasList( getAliasList() )
|
.aliasList( getAliasList() )
|
||||||
.channel( mCurrentChannel )
|
.channel( mCurrentChannel )
|
||||||
.frequency( mCurrentChannelFrequency )
|
.frequency( mCurrentChannelFrequency )
|
||||||
@@ -1031,7 +1057,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CALL_TERMINATION_OR_CANCELLATION:
|
case CALL_TERMINATION_OR_CANCELLATION:
|
||||||
broadcast( new DecoderStateEvent( this, Event.END, State.FADE ) );
|
broadcast( new DecoderStateEvent( this, Event.END, State.END ) );
|
||||||
mCurrentCallEvent = null;
|
mCurrentCallEvent = null;
|
||||||
|
|
||||||
if( !( ldu instanceof CallTermination ) )
|
if( !( ldu instanceof CallTermination ) )
|
||||||
@@ -1089,43 +1115,42 @@ public class P25DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GROUP_VOICE_CHANNEL_UPDATE:
|
case GROUP_VOICE_CHANNEL_UPDATE:
|
||||||
if( ldu instanceof module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdate )
|
if( mChannelType == ChannelType.STANDARD &&
|
||||||
|
ldu instanceof module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdate )
|
||||||
{
|
{
|
||||||
module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdate gvcu =
|
module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdate gvcu =
|
||||||
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdate)ldu;
|
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdate)ldu;
|
||||||
|
|
||||||
String userA = gvcu.getGroupAddressA();
|
String userA = gvcu.getGroupAddressA();
|
||||||
|
|
||||||
|
if( !mCallDetectTalkgroups.contains( userA ) )
|
||||||
|
{
|
||||||
|
broadcast( new P25CallEvent.Builder( CallEventType.CALL_DETECT )
|
||||||
|
.aliasList( getAliasList() )
|
||||||
|
.channel( gvcu.getChannelA() )
|
||||||
|
.details( ( gvcu.isEncrypted() ? "ENCRYPTED" : "" ) )
|
||||||
|
.frequency( gvcu.getDownlinkFrequencyA() )
|
||||||
|
.to( userA )
|
||||||
|
.build() );
|
||||||
|
|
||||||
|
mCallDetectTalkgroups.add( userA );
|
||||||
|
}
|
||||||
|
|
||||||
String userB = gvcu.getGroupAddressB();
|
String userB = gvcu.getGroupAddressB();
|
||||||
|
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
if( userB != null &&
|
||||||
|
!userB.contentEquals( "0000" ) &&
|
||||||
|
!mCallDetectTalkgroups.contains( userB ) )
|
||||||
{
|
{
|
||||||
if( !mCallDetectTalkgroups.contains( userA ) )
|
broadcast( new P25CallEvent.Builder( CallEventType.CALL_DETECT )
|
||||||
{
|
.aliasList( getAliasList() )
|
||||||
broadcast( new P25CallEvent.Builder( CallEventType.CALL_DETECT )
|
.channel( gvcu.getChannelB() )
|
||||||
.aliasList( getAliasList() )
|
.details( ( gvcu.isEncrypted() ? "ENCRYPTED" : "" ) )
|
||||||
.channel( gvcu.getChannelA() )
|
.frequency( gvcu.getDownlinkFrequencyB() )
|
||||||
.details( ( gvcu.isEncrypted() ? "ENCRYPTED" : "" ) )
|
.to( userB )
|
||||||
.frequency( gvcu.getDownlinkFrequencyA() )
|
.build() );
|
||||||
.to( userA )
|
|
||||||
.build() );
|
|
||||||
|
|
||||||
mCallDetectTalkgroups.add( userA );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( userB != null &&
|
mCallDetectTalkgroups.add( userB );
|
||||||
!userB.contentEquals( "0000" ) &&
|
|
||||||
!mCallDetectTalkgroups.contains( userB ) )
|
|
||||||
{
|
|
||||||
broadcast( new P25CallEvent.Builder( CallEventType.CALL_DETECT )
|
|
||||||
.aliasList( getAliasList() )
|
|
||||||
.channel( gvcu.getChannelB() )
|
|
||||||
.details( ( gvcu.isEncrypted() ? "ENCRYPTED" : "" ) )
|
|
||||||
.frequency( gvcu.getDownlinkFrequencyB() )
|
|
||||||
.to( userB )
|
|
||||||
.build() );
|
|
||||||
|
|
||||||
mCallDetectTalkgroups.add( userB );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1134,27 +1159,25 @@ public class P25DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GROUP_VOICE_CHANNEL_UPDATE_EXPLICIT:
|
case GROUP_VOICE_CHANNEL_UPDATE_EXPLICIT:
|
||||||
if( ldu instanceof module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdateExplicit )
|
if( mChannelType == ChannelType.STANDARD &&
|
||||||
|
ldu instanceof module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdateExplicit )
|
||||||
{
|
{
|
||||||
module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdateExplicit gvcue =
|
module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdateExplicit gvcue =
|
||||||
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdateExplicit)ldu;
|
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUpdateExplicit)ldu;
|
||||||
|
|
||||||
String group = gvcue.getGroupAddress();
|
String group = gvcue.getGroupAddress();
|
||||||
|
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
if( !mCallDetectTalkgroups.contains( group ) )
|
||||||
{
|
{
|
||||||
if( !mCallDetectTalkgroups.contains( group ) )
|
broadcast( new P25CallEvent.Builder( CallEventType.CALL_DETECT )
|
||||||
{
|
.aliasList( getAliasList() )
|
||||||
broadcast( new P25CallEvent.Builder( CallEventType.CALL_DETECT )
|
.channel( gvcue.getTransmitChannel() )
|
||||||
.aliasList( getAliasList() )
|
.details( ( gvcue.isEncrypted() ? "ENCRYPTED" : "" ) )
|
||||||
.channel( gvcue.getTransmitChannel() )
|
.frequency( gvcue.getDownlinkFrequency() )
|
||||||
.details( ( gvcue.isEncrypted() ? "ENCRYPTED" : "" ) )
|
.to( group )
|
||||||
.frequency( gvcue.getDownlinkFrequency() )
|
.build() );
|
||||||
.to( group )
|
|
||||||
.build() );
|
mCallDetectTalkgroups.add( group );
|
||||||
|
|
||||||
mCallDetectTalkgroups.add( group );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1164,32 +1187,29 @@ public class P25DecoderState extends DecoderState
|
|||||||
break;
|
break;
|
||||||
case GROUP_VOICE_CHANNEL_USER:
|
case GROUP_VOICE_CHANNEL_USER:
|
||||||
/* Indicates the current user of the current channel */
|
/* Indicates the current user of the current channel */
|
||||||
if( ldu instanceof module.decode.p25.message.ldu.lc.GroupVoiceChannelUser )
|
if( mChannelType == ChannelType.STANDARD &&
|
||||||
|
ldu instanceof module.decode.p25.message.ldu.lc.GroupVoiceChannelUser )
|
||||||
{
|
{
|
||||||
module.decode.p25.message.ldu.lc.GroupVoiceChannelUser gvcuser =
|
module.decode.p25.message.ldu.lc.GroupVoiceChannelUser gvcuser =
|
||||||
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUser)ldu;
|
(module.decode.p25.message.ldu.lc.GroupVoiceChannelUser)ldu;
|
||||||
|
|
||||||
updateFrom( gvcuser.getSourceAddress() );
|
if( mCurrentCallEvent.getCallEventType() != CallEventType.GROUP_CALL )
|
||||||
|
|
||||||
updateTo( gvcuser.getGroupAddress() );
|
|
||||||
|
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
|
||||||
{
|
{
|
||||||
if( mCurrentCallEvent.getCallEventType() != CallEventType.GROUP_CALL )
|
mCurrentCallEvent.setCallEventType( CallEventType.GROUP_CALL );
|
||||||
{
|
broadcast( mCurrentCallEvent );
|
||||||
mCurrentCallEvent.setCallEventType( CallEventType.GROUP_CALL );
|
|
||||||
broadcast( mCurrentCallEvent );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mCurrentCallEvent.getDetails() == null )
|
|
||||||
{
|
|
||||||
mCurrentCallEvent.setDetails(
|
|
||||||
( gvcuser.isEncrypted() ? "ENCRYPTED " : "" ) +
|
|
||||||
( gvcuser.isEmergency() ? "EMERGENCY " : "" ) );
|
|
||||||
|
|
||||||
broadcast( mCurrentCallEvent );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( mCurrentCallEvent.getDetails() == null )
|
||||||
|
{
|
||||||
|
mCurrentCallEvent.setDetails(
|
||||||
|
( gvcuser.isEncrypted() ? "ENCRYPTED " : "" ) +
|
||||||
|
( gvcuser.isEmergency() ? "EMERGENCY " : "" ) );
|
||||||
|
|
||||||
|
broadcast( mCurrentCallEvent );
|
||||||
|
}
|
||||||
|
|
||||||
|
updateFrom( gvcuser.getSourceAddress() );
|
||||||
|
updateTo( gvcuser.getGroupAddress() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1385,8 +1405,6 @@ public class P25DecoderState extends DecoderState
|
|||||||
TelephoneInterconnectVoiceChannelUser tivcu =
|
TelephoneInterconnectVoiceChannelUser tivcu =
|
||||||
(TelephoneInterconnectVoiceChannelUser)ldu;
|
(TelephoneInterconnectVoiceChannelUser)ldu;
|
||||||
|
|
||||||
updateTo( tivcu.getAddress() );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent.getCallEventType() != CallEventType.TELEPHONE_INTERCONNECT )
|
if( mCurrentCallEvent.getCallEventType() != CallEventType.TELEPHONE_INTERCONNECT )
|
||||||
{
|
{
|
||||||
mCurrentCallEvent.setCallEventType( CallEventType.TELEPHONE_INTERCONNECT );
|
mCurrentCallEvent.setCallEventType( CallEventType.TELEPHONE_INTERCONNECT );
|
||||||
@@ -1401,6 +1419,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast( mCurrentCallEvent );
|
broadcast( mCurrentCallEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateTo( tivcu.getAddress() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1466,10 +1486,6 @@ public class P25DecoderState extends DecoderState
|
|||||||
UnitToUnitVoiceChannelUser uuvcu =
|
UnitToUnitVoiceChannelUser uuvcu =
|
||||||
(UnitToUnitVoiceChannelUser)ldu;
|
(UnitToUnitVoiceChannelUser)ldu;
|
||||||
|
|
||||||
updateFrom( uuvcu.getSourceAddress() );
|
|
||||||
|
|
||||||
updateTo( uuvcu.getTargetAddress() );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent.getCallEventType() != CallEventType.UNIT_TO_UNIT_CALL )
|
if( mCurrentCallEvent.getCallEventType() != CallEventType.UNIT_TO_UNIT_CALL )
|
||||||
{
|
{
|
||||||
mCurrentCallEvent.setCallEventType( CallEventType.UNIT_TO_UNIT_CALL );
|
mCurrentCallEvent.setCallEventType( CallEventType.UNIT_TO_UNIT_CALL );
|
||||||
@@ -1484,6 +1500,9 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
broadcast( mCurrentCallEvent );
|
broadcast( mCurrentCallEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateFrom( uuvcu.getSourceAddress() );
|
||||||
|
updateTo( uuvcu.getTargetAddress() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1502,7 +1521,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
private void processTSBK( TSBKMessage tsbk )
|
private void processTSBK( TSBKMessage tsbk )
|
||||||
{
|
{
|
||||||
/* Trunking Signalling Block Messages - indicates Control Channel */
|
/* Trunking Signalling Block Messages - indicates Control Channel */
|
||||||
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.CONTROL ) );
|
broadcast( new DecoderStateEvent( this, Event.START, State.CONTROL ) );
|
||||||
|
|
||||||
if( tsbk.getVendor() == Vendor.STANDARD )
|
if( tsbk.getVendor() == Vendor.STANDARD )
|
||||||
{
|
{
|
||||||
@@ -1631,11 +1650,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
*/
|
*/
|
||||||
private void processPDU( PDUMessage pdu )
|
private void processPDU( PDUMessage pdu )
|
||||||
{
|
{
|
||||||
if( pdu instanceof PacketData || pdu instanceof PDUTypeUnknown )
|
if( pdu instanceof PDUConfirmedMessage )
|
||||||
{
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.DATA ) );
|
|
||||||
}
|
|
||||||
else if( pdu instanceof PDUConfirmedMessage )
|
|
||||||
{
|
{
|
||||||
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.DATA ) );
|
broadcast( new DecoderStateEvent( this, Event.CONTINUATION, State.DATA ) );
|
||||||
|
|
||||||
@@ -1643,7 +1658,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
|
|
||||||
switch( pduc.getPDUType() )
|
switch( pduc.getPDUType() )
|
||||||
{
|
{
|
||||||
case SNDCP_ACTIVATE_TDS_CONTEXT_ACCEPT:
|
case SN_ACTIVATE_TDS_CONTEXT_ACCEPT:
|
||||||
SNDCPActivateTDSContextAccept satca =
|
SNDCPActivateTDSContextAccept satca =
|
||||||
(SNDCPActivateTDSContextAccept)pduc;
|
(SNDCPActivateTDSContextAccept)pduc;
|
||||||
|
|
||||||
@@ -1655,7 +1670,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
.to( satca.getLogicalLinkID() )
|
.to( satca.getLogicalLinkID() )
|
||||||
.build() );
|
.build() );
|
||||||
break;
|
break;
|
||||||
case SNDCP_ACTIVATE_TDS_CONTEXT_REJECT:
|
case SN_ACTIVATE_TDS_CONTEXT_REJECT:
|
||||||
SNDCPActivateTDSContextReject satcr =
|
SNDCPActivateTDSContextReject satcr =
|
||||||
(SNDCPActivateTDSContextReject)pduc;
|
(SNDCPActivateTDSContextReject)pduc;
|
||||||
|
|
||||||
@@ -1680,7 +1695,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
.from( satcreq.getLogicalLinkID() )
|
.from( satcreq.getLogicalLinkID() )
|
||||||
.build() );
|
.build() );
|
||||||
break;
|
break;
|
||||||
case SNDCP_DEACTIVATE_TDS_CONTEXT_ACCEPT:
|
case SN_DEACTIVATE_TDS_CONTEXT_ACCEPT:
|
||||||
SNDCPDeactivateTDSContext sdtca =
|
SNDCPDeactivateTDSContext sdtca =
|
||||||
(SNDCPDeactivateTDSContext)pduc;
|
(SNDCPDeactivateTDSContext)pduc;
|
||||||
|
|
||||||
@@ -1692,7 +1707,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
.from( sdtca.getLogicalLinkID() )
|
.from( sdtca.getLogicalLinkID() )
|
||||||
.build() );
|
.build() );
|
||||||
break;
|
break;
|
||||||
case SNDCP_DEACTIVATE_TDS_CONTEXT_REQUEST:
|
case SN_DEACTIVATE_TDS_CONTEXT_REQUEST:
|
||||||
SNDCPDeactivateTDSContext sdtcreq =
|
SNDCPDeactivateTDSContext sdtcreq =
|
||||||
(SNDCPDeactivateTDSContext)pduc;
|
(SNDCPDeactivateTDSContext)pduc;
|
||||||
|
|
||||||
@@ -1704,7 +1719,7 @@ public class P25DecoderState extends DecoderState
|
|||||||
.from( sdtcreq.getLogicalLinkID() )
|
.from( sdtcreq.getLogicalLinkID() )
|
||||||
.build() );
|
.build() );
|
||||||
break;
|
break;
|
||||||
case SNDCP_RF_CONFIRMED_DATA:
|
case SN_RF_CONFIRMED_DATA:
|
||||||
SNDCPUserData sud = (SNDCPUserData)pduc;
|
SNDCPUserData sud = (SNDCPUserData)pduc;
|
||||||
|
|
||||||
StringBuilder sbFrom = new StringBuilder();
|
StringBuilder sbFrom = new StringBuilder();
|
||||||
@@ -1733,10 +1748,8 @@ public class P25DecoderState extends DecoderState
|
|||||||
.to( pduc.getLogicalLinkID() )
|
.to( pduc.getLogicalLinkID() )
|
||||||
.build() );
|
.build() );
|
||||||
break;
|
break;
|
||||||
case SNDCP_RF_UNCONFIRMED_DATA:
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// mLog.debug( "PDUC - Unrecognized Message: " + pduc.toString() );
|
mLog.debug( "PDUC - Unrecognized Message: " + pduc.toString() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3087,9 +3100,16 @@ public class P25DecoderState extends DecoderState
|
|||||||
if( mToTalkgroup == null || !mToTalkgroup.contentEquals( to ) )
|
if( mToTalkgroup == null || !mToTalkgroup.contentEquals( to ) )
|
||||||
{
|
{
|
||||||
mToTalkgroup = to;
|
mToTalkgroup = to;
|
||||||
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP );
|
broadcast( ChangedAttribute.TO_TALKGROUP );
|
||||||
|
|
||||||
|
if( mCurrentCallEvent != null &&
|
||||||
|
( mCurrentCallEvent.getToID() == null ||
|
||||||
|
!mCurrentCallEvent.getToID().contentEquals( to ) ) )
|
||||||
|
{
|
||||||
|
mCurrentCallEvent.setToID( to );
|
||||||
|
broadcast( mCurrentCallEvent );
|
||||||
|
}
|
||||||
|
|
||||||
if( hasAliasList() )
|
if( hasAliasList() )
|
||||||
{
|
{
|
||||||
mToAlias = getAliasList().getTalkgroupAlias( mToTalkgroup );
|
mToAlias = getAliasList().getTalkgroupAlias( mToTalkgroup );
|
||||||
@@ -3098,20 +3118,12 @@ public class P25DecoderState extends DecoderState
|
|||||||
{
|
{
|
||||||
mToAlias = null;
|
mToAlias = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
broadcast( ChangedAttribute.TO_TALKGROUP_ALIAS );
|
||||||
|
|
||||||
/* Send audio metadata update */
|
|
||||||
broadcast( new Metadata( MetadataType.TO, mToTalkgroup, mToAlias, true ) );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent != null &&
|
|
||||||
( mCurrentCallEvent.getToID() == null ||
|
|
||||||
!mCurrentCallEvent.getToID().contentEquals( to ) ) )
|
|
||||||
{
|
|
||||||
mCurrentCallEvent.setToID( to );
|
|
||||||
broadcast( mCurrentCallEvent );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send audio metadata update */
|
||||||
|
broadcast( new Metadata( MetadataType.TO, mToTalkgroup, mToAlias, true ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3127,6 +3139,14 @@ public class P25DecoderState extends DecoderState
|
|||||||
mFromTalkgroup = from;
|
mFromTalkgroup = from;
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
broadcast( ChangedAttribute.FROM_TALKGROUP );
|
||||||
|
|
||||||
|
if( mCurrentCallEvent != null &&
|
||||||
|
mCurrentCallEvent.getFromID() == null ||
|
||||||
|
!mCurrentCallEvent.getFromID().contentEquals( from ) )
|
||||||
|
{
|
||||||
|
mCurrentCallEvent.setFromID( from );
|
||||||
|
broadcast( mCurrentCallEvent );
|
||||||
|
}
|
||||||
|
|
||||||
if( hasAliasList() )
|
if( hasAliasList() )
|
||||||
{
|
{
|
||||||
mFromAlias = getAliasList().getTalkgroupAlias( mFromTalkgroup );
|
mFromAlias = getAliasList().getTalkgroupAlias( mFromTalkgroup );
|
||||||
@@ -3137,19 +3157,10 @@ public class P25DecoderState extends DecoderState
|
|||||||
}
|
}
|
||||||
|
|
||||||
broadcast( ChangedAttribute.FROM_TALKGROUP_ALIAS );
|
broadcast( ChangedAttribute.FROM_TALKGROUP_ALIAS );
|
||||||
|
|
||||||
/* Send audio metadata update */
|
|
||||||
broadcast( new Metadata( MetadataType.FROM, mFromTalkgroup, mFromAlias, true ) );
|
|
||||||
|
|
||||||
if( mCurrentCallEvent != null &&
|
|
||||||
mCurrentCallEvent.getFromID() == null ||
|
|
||||||
!mCurrentCallEvent.getFromID().contentEquals( from ) )
|
|
||||||
{
|
|
||||||
mCurrentCallEvent.setFromID( from );
|
|
||||||
broadcast( mCurrentCallEvent );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send audio metadata update */
|
||||||
|
broadcast( new Metadata( MetadataType.FROM, mFromTalkgroup, mFromAlias, true ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,6 @@ public class P25Message extends Message
|
|||||||
sb.append( " " );
|
sb.append( " " );
|
||||||
sb.append( getDUID().getLabel() );
|
sb.append( getDUID().getLabel() );
|
||||||
|
|
||||||
sb.append( " DATA UNIT ID:" + mMessage.getInt( DUID ) );
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package module.decode.p25.message.pdu;
|
package module.decode.p25.message.pdu;
|
||||||
|
|
||||||
import module.decode.p25.message.pdu.confirmed.PacketData;
|
|
||||||
import module.decode.p25.message.pdu.osp.control.AdjacentStatusBroadcastExtended;
|
import module.decode.p25.message.pdu.osp.control.AdjacentStatusBroadcastExtended;
|
||||||
import module.decode.p25.message.pdu.osp.control.CallAlertExtended;
|
import module.decode.p25.message.pdu.osp.control.CallAlertExtended;
|
||||||
import module.decode.p25.message.pdu.osp.control.GroupAffiliationQueryExtended;
|
import module.decode.p25.message.pdu.osp.control.GroupAffiliationQueryExtended;
|
||||||
@@ -122,8 +121,7 @@ public class PDUMessageFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new PDUMessage( message, duid, aliasList );
|
return new PDUMessage( message, duid, aliasList );
|
||||||
case PACKET_DATA:
|
|
||||||
return new PacketData( message, aliasList );
|
|
||||||
case UNCONFIRMED_MULTI_BLOCK_TRUNKING_CONTROL:
|
case UNCONFIRMED_MULTI_BLOCK_TRUNKING_CONTROL:
|
||||||
return new PDUMessage( message, duid, aliasList );
|
return new PDUMessage( message, duid, aliasList );
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -48,27 +48,19 @@ public class PDUConfirmedMessageFactory
|
|||||||
case UNENCRYPTED_USER_DATA:
|
case UNENCRYPTED_USER_DATA:
|
||||||
switch( message.getPDUType() )
|
switch( message.getPDUType() )
|
||||||
{
|
{
|
||||||
case SNDCP_ACTIVATE_TDS_CONTEXT_ACCEPT:
|
case SN_ACTIVATE_TDS_CONTEXT_ACCEPT:
|
||||||
return new SNDCPActivateTDSContextAccept( message );
|
return new SNDCPActivateTDSContextAccept( message );
|
||||||
case SNDCP_ACTIVATE_TDS_CONTEXT_REJECT:
|
case SN_ACTIVATE_TDS_CONTEXT_REJECT:
|
||||||
return new SNDCPActivateTDSContextReject( message );
|
return new SNDCPActivateTDSContextReject( message );
|
||||||
case SN_ACTIVATE_TDS_CONTEXT_REQUEST:
|
case SN_ACTIVATE_TDS_CONTEXT_REQUEST:
|
||||||
return new SNDCPActivateTDSContextRequest( message );
|
return new SNDCPActivateTDSContextRequest( message );
|
||||||
case SNDCP_DEACTIVATE_TDS_CONTEXT_ACCEPT:
|
case SN_DEACTIVATE_TDS_CONTEXT_ACCEPT:
|
||||||
case SNDCP_DEACTIVATE_TDS_CONTEXT_REQUEST:
|
case SN_DEACTIVATE_TDS_CONTEXT_REQUEST:
|
||||||
return new SNDCPDeactivateTDSContext( message );
|
return new SNDCPDeactivateTDSContext( message );
|
||||||
case SNDCP_RF_CONFIRMED_DATA:
|
case SN_RF_CONFIRMED_DATA:
|
||||||
return new SNDCPUserData( message );
|
return new SNDCPUserData( message );
|
||||||
case SNDCP_RF_UNCONFIRMED_DATA:
|
case SN_RF_UNCONFIRMED_DATA:
|
||||||
break;
|
break;
|
||||||
case PDU_TYPE_6:
|
|
||||||
case PDU_TYPE_7:
|
|
||||||
case PDU_TYPE_8:
|
|
||||||
case PDU_TYPE_9:
|
|
||||||
case PDU_TYPE_10:
|
|
||||||
case PDU_TYPE_11:
|
|
||||||
return new PDUTypeUnknown( message );
|
|
||||||
case UNKNOWN:
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package module.decode.p25.message.pdu.confirmed;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
public class PDUTypeUnknown extends PDUConfirmedMessage
|
|
||||||
{
|
|
||||||
public final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( PDUTypeUnknown.class );
|
|
||||||
|
|
||||||
public PDUTypeUnknown( PDUConfirmedMessage message )
|
|
||||||
{
|
|
||||||
super( message );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "NAC:" );
|
|
||||||
sb.append( getNAC() );
|
|
||||||
sb.append( " LLID:" );
|
|
||||||
sb.append( getLogicalLinkID() );
|
|
||||||
sb.append( " PACKET DATA UNIT CONFIRMED - " );
|
|
||||||
sb.append( getPDUType().getLabel() );
|
|
||||||
sb.append( " CRC[" );
|
|
||||||
sb.append( getErrorStatus() );
|
|
||||||
sb.append( "]" );
|
|
||||||
|
|
||||||
sb.append( " PACKET #" );
|
|
||||||
sb.append( getPacketSequenceNumber() );
|
|
||||||
|
|
||||||
if( isFinalFragment() && getFragmentSequenceNumber() == 0 )
|
|
||||||
{
|
|
||||||
sb.append( ".C" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sb.append( "." );
|
|
||||||
sb.append( getFragmentSequenceNumber() );
|
|
||||||
|
|
||||||
if( isFinalFragment() )
|
|
||||||
{
|
|
||||||
sb.append( "C" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append( " " );
|
|
||||||
|
|
||||||
sb.append( mMessage.toString() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
package module.decode.p25.message.pdu.confirmed;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
|
|
||||||
public class PacketData extends PDUConfirmedMessage
|
|
||||||
{
|
|
||||||
public final static Logger mLog =
|
|
||||||
LoggerFactory.getLogger( PacketData.class );
|
|
||||||
|
|
||||||
public static final int DATA_BLOCK_START = 176;
|
|
||||||
|
|
||||||
public PacketData( BinaryMessage message, AliasList aliasList )
|
|
||||||
{
|
|
||||||
super( message, aliasList );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( "NAC:" );
|
|
||||||
sb.append( getNAC() );
|
|
||||||
sb.append( " PDUC LLID:" );
|
|
||||||
sb.append( getLogicalLinkID() );
|
|
||||||
|
|
||||||
|
|
||||||
sb.append( " PACKET DATA" );
|
|
||||||
sb.append( " CRC[" );
|
|
||||||
sb.append( getErrorStatus() );
|
|
||||||
sb.append( "]" );
|
|
||||||
|
|
||||||
if( !mMessage.get( FINAL_FRAGMENT_FLAG ) )
|
|
||||||
{
|
|
||||||
sb.append( " RESENDING" );
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append( " PACKET #" );
|
|
||||||
sb.append( getPacketSequenceNumber() );
|
|
||||||
|
|
||||||
if( isFinalFragment() && getFragmentSequenceNumber() == 0 )
|
|
||||||
{
|
|
||||||
sb.append( ".C" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sb.append( "." );
|
|
||||||
sb.append( getFragmentSequenceNumber() );
|
|
||||||
|
|
||||||
if( isFinalFragment() )
|
|
||||||
{
|
|
||||||
sb.append( "C" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append( " " );
|
|
||||||
|
|
||||||
sb.append( mMessage.toString() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -49,7 +49,7 @@ public class SNDCPDeactivateTDSContext extends PDUConfirmedMessage
|
|||||||
|
|
||||||
public String getDeactivationType()
|
public String getDeactivationType()
|
||||||
{
|
{
|
||||||
if( getPDUType() == PDUType.SNDCP_DEACTIVATE_TDS_CONTEXT_REQUEST )
|
if( getPDUType() == PDUType.SN_DEACTIVATE_TDS_CONTEXT_REQUEST )
|
||||||
{
|
{
|
||||||
return mMessage.getInt( DEACTIVATION_TYPE ) == 0 ?
|
return mMessage.getInt( DEACTIVATION_TYPE ) == 0 ?
|
||||||
"ALL NSAPIS" : "THIS NSAPI";
|
"ALL NSAPIS" : "THIS NSAPI";
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package module.decode.p25.message.tsbk;
|
package module.decode.p25.message.tsbk;
|
||||||
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
import module.decode.p25.message.tsbk.motorola.ControlChannelBaseStationIdentification;
|
import module.decode.p25.message.tsbk.motorola.ControlChannelBaseStationIdentification;
|
||||||
import module.decode.p25.message.tsbk.motorola.MotorolaOpcode;
|
import module.decode.p25.message.tsbk.motorola.MotorolaOpcode;
|
||||||
import module.decode.p25.message.tsbk.motorola.MotorolaTSBKMessage;
|
import module.decode.p25.message.tsbk.motorola.MotorolaTSBKMessage;
|
||||||
@@ -21,7 +19,6 @@ import module.decode.p25.message.tsbk.osp.control.ExtendedFunctionCommand;
|
|||||||
import module.decode.p25.message.tsbk.osp.control.GroupAffiliationQuery;
|
import module.decode.p25.message.tsbk.osp.control.GroupAffiliationQuery;
|
||||||
import module.decode.p25.message.tsbk.osp.control.GroupAffiliationResponse;
|
import module.decode.p25.message.tsbk.osp.control.GroupAffiliationResponse;
|
||||||
import module.decode.p25.message.tsbk.osp.control.IdentifierUpdateNonVUHF;
|
import module.decode.p25.message.tsbk.osp.control.IdentifierUpdateNonVUHF;
|
||||||
import module.decode.p25.message.tsbk.osp.control.IdentifierUpdateTDMA;
|
|
||||||
import module.decode.p25.message.tsbk.osp.control.IdentifierUpdateVUHF;
|
import module.decode.p25.message.tsbk.osp.control.IdentifierUpdateVUHF;
|
||||||
import module.decode.p25.message.tsbk.osp.control.LocationRegistrationResponse;
|
import module.decode.p25.message.tsbk.osp.control.LocationRegistrationResponse;
|
||||||
import module.decode.p25.message.tsbk.osp.control.MessageUpdate;
|
import module.decode.p25.message.tsbk.osp.control.MessageUpdate;
|
||||||
@@ -59,6 +56,8 @@ import module.decode.p25.message.tsbk.osp.voice.UnitToUnitVoiceChannelGrantUpdat
|
|||||||
import module.decode.p25.reference.DataUnitID;
|
import module.decode.p25.reference.DataUnitID;
|
||||||
import module.decode.p25.reference.Opcode;
|
import module.decode.p25.reference.Opcode;
|
||||||
import module.decode.p25.reference.Vendor;
|
import module.decode.p25.reference.Vendor;
|
||||||
|
import alias.AliasList;
|
||||||
|
import bits.BinaryMessage;
|
||||||
|
|
||||||
public class TSBKMessageFactory
|
public class TSBKMessageFactory
|
||||||
{
|
{
|
||||||
@@ -120,8 +119,6 @@ public class TSBKMessageFactory
|
|||||||
case IDENTIFIER_UPDATE_NON_VUHF:
|
case IDENTIFIER_UPDATE_NON_VUHF:
|
||||||
return new IdentifierUpdateNonVUHF( message, duid,
|
return new IdentifierUpdateNonVUHF( message, duid,
|
||||||
aliasList );
|
aliasList );
|
||||||
case IDENTIFIER_UPDATE_TDMA:
|
|
||||||
return new IdentifierUpdateTDMA( message, duid, aliasList );
|
|
||||||
case IDENTIFIER_UPDATE_VHF_UHF_BANDS:
|
case IDENTIFIER_UPDATE_VHF_UHF_BANDS:
|
||||||
return new IdentifierUpdateVUHF( message, duid,
|
return new IdentifierUpdateVUHF( message, duid,
|
||||||
aliasList );
|
aliasList );
|
||||||
|
|||||||
@@ -1,159 +0,0 @@
|
|||||||
package module.decode.p25.message.tsbk.osp.control;
|
|
||||||
|
|
||||||
import module.decode.p25.reference.DataUnitID;
|
|
||||||
import module.decode.p25.reference.Opcode;
|
|
||||||
import alias.AliasList;
|
|
||||||
import bits.BinaryMessage;
|
|
||||||
|
|
||||||
public class IdentifierUpdateTDMA extends IdentifierUpdate
|
|
||||||
{
|
|
||||||
public static final int[] CHANNEL_TYPE = { 84,85,86,87 };
|
|
||||||
public static final int TRANSMIT_OFFSET_SIGN = 88;
|
|
||||||
public static final int[] TRANSMIT_OFFSET = { 89,90,91,92,93,94,95,96,97,98,
|
|
||||||
99,100,101 };
|
|
||||||
|
|
||||||
public IdentifierUpdateTDMA( BinaryMessage message,
|
|
||||||
DataUnitID duid,
|
|
||||||
AliasList aliasList )
|
|
||||||
{
|
|
||||||
super( message, duid, aliasList );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType()
|
|
||||||
{
|
|
||||||
return Opcode.IDENTIFIER_UPDATE_TDMA.getDescription();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append( getMessageStub() );
|
|
||||||
|
|
||||||
sb.append( " IDEN:" + getIdentifier() );
|
|
||||||
sb.append( " BASE:" + getBaseFrequency() );
|
|
||||||
sb.append( " BW:" + getBandwidth() );
|
|
||||||
sb.append( " SPACING:" + getChannelSpacing() );
|
|
||||||
sb.append( " OFFSET:" + getTransmitOffset() );
|
|
||||||
sb.append( " TYPE:" + getChannelType().toString() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChannelType getChannelType()
|
|
||||||
{
|
|
||||||
return ChannelType.fromValue( mMessage.getInt( CHANNEL_TYPE) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Channel bandwidth in hertz
|
|
||||||
*/
|
|
||||||
public int getBandwidth()
|
|
||||||
{
|
|
||||||
return getChannelType().getBandwidth();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transmit offset in hertz
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public long getTransmitOffset()
|
|
||||||
{
|
|
||||||
long offset = mMessage.getLong( TRANSMIT_OFFSET ) *
|
|
||||||
getChannelSpacing();
|
|
||||||
|
|
||||||
if( mMessage.get( TRANSMIT_OFFSET_SIGN ) )
|
|
||||||
{
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ChannelType
|
|
||||||
{
|
|
||||||
TYPE_0( AccessType.FDMA, 12500, 1, Vocoder.HALF_RATE ),
|
|
||||||
TYPE_1( AccessType.FDMA, 12500, 1, Vocoder.FULL_RATE ),
|
|
||||||
TYPE_2( AccessType.FDMA, 6250, 1, Vocoder.HALF_RATE ),
|
|
||||||
TYPE_3( AccessType.TDMA, 12500, 2, Vocoder.HALF_RATE ),
|
|
||||||
TYPE_4( AccessType.TDMA, 25000, 4, Vocoder.HALF_RATE ),
|
|
||||||
TYPE_5( AccessType.TDMA, 12500, 2, Vocoder.HALF_RATE ), //HD8PSK simulcast
|
|
||||||
UNKNOWN( AccessType.UNKNOWN, 0, 0, Vocoder.HALF_RATE );
|
|
||||||
|
|
||||||
private AccessType mAccessType;
|
|
||||||
private int mBandwidth;
|
|
||||||
private int mSlotsPerCarrier;
|
|
||||||
private Vocoder mVocoder;
|
|
||||||
|
|
||||||
private ChannelType( AccessType accessType,
|
|
||||||
int bandwidth,
|
|
||||||
int slots,
|
|
||||||
Vocoder vocoder )
|
|
||||||
{
|
|
||||||
mAccessType = accessType;
|
|
||||||
mBandwidth = bandwidth;
|
|
||||||
mSlotsPerCarrier = slots;
|
|
||||||
mVocoder = vocoder;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
if( this.equals( TYPE_5 ) )
|
|
||||||
{
|
|
||||||
sb.append("H-D8PSK SIMULCAST " );
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append( mAccessType.name() );
|
|
||||||
sb.append( " BW:" + mBandwidth );
|
|
||||||
sb.append( " SLOT/CARRIER:" + mSlotsPerCarrier );
|
|
||||||
sb.append( " VOCODER:" + mVocoder.name() );
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChannelType fromValue( int value )
|
|
||||||
{
|
|
||||||
if( 0 <= value && value <= 5 )
|
|
||||||
{
|
|
||||||
return ChannelType.values()[ value ];
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChannelType.UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccessType getAccessType()
|
|
||||||
{
|
|
||||||
return mAccessType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBandwidth()
|
|
||||||
{
|
|
||||||
return mBandwidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSlotsPerCarrier()
|
|
||||||
{
|
|
||||||
return mSlotsPerCarrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Vocoder getVocoder()
|
|
||||||
{
|
|
||||||
return mVocoder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum AccessType
|
|
||||||
{
|
|
||||||
FDMA,TDMA,UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Vocoder
|
|
||||||
{
|
|
||||||
HALF_RATE, FULL_RATE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
package module.decode.p25.message.tsbk.osp.control;
|
package module.decode.p25.message.tsbk.osp.control;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.SimpleTimeZone;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import module.decode.p25.message.tsbk.TSBKMessage;
|
import module.decode.p25.message.tsbk.TSBKMessage;
|
||||||
@@ -14,21 +12,20 @@ import alias.AliasList;
|
|||||||
import bits.BinaryMessage;
|
import bits.BinaryMessage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sync Broadcast - used to broadcast FDMA-TDMA timing synchronization
|
* Sync Broadcast - used to broadcast FDMA-TDMA synchronization timestamp so
|
||||||
* information so that a subscriber unit that is time synchronized on an FDMA
|
* that a subscriber unit that is time synchronized on an FDMA control channel
|
||||||
* control channel is also time synchronized with all TDMA traffic channels at
|
* is also synchronized with a TDMA traffic channel.
|
||||||
* the site.
|
|
||||||
*/
|
*/
|
||||||
public class SyncBroadcast extends TSBKMessage
|
public class SyncBroadcast extends TSBKMessage
|
||||||
{
|
{
|
||||||
public static final int[] RESERVED = { 80,81,82,83,84,85,86,87,88,89,90,91,92 };
|
public static final int US = 92;
|
||||||
public static final int SYSTEM_TIME_NOT_LOCKED_TO_EXTERNAL_REFERENCE = 93;
|
public static final int IST = 93;
|
||||||
public static final int MICRO_SLOTS_TO_MINUTE_ROLLOVER_UNLOCKED = 94;
|
public static final int MMU = 94;
|
||||||
public static final int[] LEAP_SECOND_CORRECTION = { 95,96 };
|
public static final int[] MC = { 95,96 };
|
||||||
public static final int LOCAL_TIME_OFFSET_VALID = 97;
|
public static final int VL = 97;
|
||||||
public static final int LOCAL_TIME_OFFSET_SIGN = 98;
|
public static final int LOCAL_TIME_OFFSET_SIGN = 98;
|
||||||
public static final int[] LOCAL_TIME_OFFSET_HOURS = { 99,100,101,102 };
|
public static final int[] LOCAL_TIME_OFFSET = { 99,100,101,102 };
|
||||||
public static final int LOCAL_TIME_OFFSET_HALF_HOUR = 103;
|
public static final int LOCAL_TIME_OFFSET_HALF = 103;
|
||||||
|
|
||||||
public static final int[] YEAR = { 104,105,106,107,108,109,110 };
|
public static final int[] YEAR = { 104,105,106,107,108,109,110 };
|
||||||
public static final int[] MONTH = { 111,112,113,114 };
|
public static final int[] MONTH = { 111,112,113,114 };
|
||||||
@@ -39,10 +36,7 @@ public class SyncBroadcast extends TSBKMessage
|
|||||||
139,140,141,142,143 };
|
139,140,141,142,143 };
|
||||||
public static final int[] TSBK_CRC = { 144,145,146,147,148,149,150,151,152,
|
public static final int[] TSBK_CRC = { 144,145,146,147,148,149,150,151,152,
|
||||||
153,154,155,156,157,158,159 };
|
153,154,155,156,157,158,159 };
|
||||||
|
|
||||||
private static final DateFormat TIME_FORMATTER = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.SSS Z" );
|
|
||||||
private static final TimeZone NO_TIME_ZONE = new SimpleTimeZone( 0, "NONE" );
|
|
||||||
|
|
||||||
public SyncBroadcast( BinaryMessage message,
|
public SyncBroadcast( BinaryMessage message,
|
||||||
DataUnitID duid,
|
DataUnitID duid,
|
||||||
AliasList aliasList )
|
AliasList aliasList )
|
||||||
@@ -62,41 +56,24 @@ public class SyncBroadcast extends TSBKMessage
|
|||||||
|
|
||||||
sb.append( getMessageStub() );
|
sb.append( getMessageStub() );
|
||||||
|
|
||||||
sb.append( " SYSTEM TIME" );
|
sb.append( " " + new Date( getTime() ).toString() );
|
||||||
|
sb.append( " TIME ZONE OFFSET:" + getTimeZone().toUpperCase() );
|
||||||
if( isSystemTimeNotLockedToExternalReference() )
|
sb.append( " US:" + isUS() );
|
||||||
{
|
sb.append( " IST:" + isIST() );
|
||||||
sb.append( " UNLOCKED" );
|
sb.append( " MMU:" + isMMU() );
|
||||||
}
|
sb.append( " VL:" + isVL() );
|
||||||
|
|
||||||
sb.append( ":" );
|
|
||||||
|
|
||||||
TIME_FORMATTER.setTimeZone( getTimeZone() );
|
|
||||||
sb.append( " " + TIME_FORMATTER.format( new Date( getSystemTime() ) ) );
|
|
||||||
|
|
||||||
sb.append( " LEAP-SECOND CORRECTION:" + getLeapSecondCorrection() + "mS" );
|
|
||||||
|
|
||||||
if( isMicroslotsLockedToMinuteRollover() )
|
|
||||||
{
|
|
||||||
sb.append( " MICROSLOT-MINUTE ROLLOVER:LOCKED" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sb.append( " MICROSLOT-MINUTE ROLLOVER:UNLOCKED" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System Time (UTC) in milliseconds since java epoch
|
* Returns the time sync in java time (ie milliseconds since epoch )
|
||||||
*/
|
*/
|
||||||
public long getSystemTime()
|
public long getTime()
|
||||||
{
|
{
|
||||||
Calendar cal = Calendar.getInstance( TimeZone.getTimeZone( "UTC" ) );
|
Calendar cal = new GregorianCalendar();
|
||||||
|
|
||||||
cal.clear();
|
cal.clear();
|
||||||
|
cal.setTimeZone( TimeZone.getTimeZone( "GMT" ) );
|
||||||
cal.set( Calendar.YEAR, getYear() );
|
cal.set( Calendar.YEAR, getYear() );
|
||||||
cal.set( Calendar.MONTH, getMonth() - 1 );
|
cal.set( Calendar.MONTH, getMonth() - 1 );
|
||||||
cal.set( Calendar.DAY_OF_MONTH, getDay() );
|
cal.set( Calendar.DAY_OF_MONTH, getDay() );
|
||||||
@@ -107,165 +84,102 @@ public class SyncBroadcast extends TSBKMessage
|
|||||||
return cal.getTimeInMillis();
|
return cal.getTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isUS()
|
||||||
* System Time not locked to external time reference indicator
|
|
||||||
*/
|
|
||||||
public boolean isSystemTimeNotLockedToExternalReference()
|
|
||||||
{
|
{
|
||||||
return mMessage.get( SYSTEM_TIME_NOT_LOCKED_TO_EXTERNAL_REFERENCE );
|
return mMessage.get( US );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Micro-slot-to-Minute rollover boundary lock indicator.
|
* Daylight Savings Time
|
||||||
*
|
|
||||||
* Note: we invert the message value so that true indicates that the micro
|
|
||||||
* slots and minute rollovers are locked, whereas the ICD uses false to
|
|
||||||
* indicate a lock.
|
|
||||||
*
|
|
||||||
* @return true if the microslots rollover at each minute interval is locked
|
|
||||||
* to the system time minute rollover.
|
|
||||||
*
|
|
||||||
* @return false if the microslots and minutes rollover are not locked. This
|
|
||||||
* indicates that the microslots minute rollover is free rolling.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public boolean isMicroslotsLockedToMinuteRollover()
|
public boolean isIST()
|
||||||
{
|
{
|
||||||
return !mMessage.get( MICRO_SLOTS_TO_MINUTE_ROLLOVER_UNLOCKED );
|
return mMessage.get( IST );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leap second correction value that should be applied to the system time.
|
* No idea ...
|
||||||
*
|
|
||||||
* The leap-second correction field indicates the number of 2.5 millisecond
|
|
||||||
* units that must be added to the system time to account for the insertion
|
|
||||||
* of leap seconds when the system time is represented as UTC universal time.
|
|
||||||
*
|
|
||||||
* @return leap-second correction value in milliseconds 0.0-10.0
|
|
||||||
*/
|
*/
|
||||||
public double getLeapSecondCorrection()
|
public boolean isMMU()
|
||||||
{
|
{
|
||||||
return (double)mMessage.getInt( LEAP_SECOND_CORRECTION ) * 2.5d;
|
return mMessage.get( MMU );
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates the local time offset fields contain valid information.
|
|
||||||
*/
|
|
||||||
public boolean isValidLocalTimeOffset()
|
|
||||||
{
|
|
||||||
return !mMessage.get( LOCAL_TIME_OFFSET_VALID );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local time zone offset from UTC universal time (zulu) when the VALID
|
* Millenium ...?
|
||||||
* LOCAL TIME OFFSET flag indicates a valid offset. Otherwise, this method
|
|
||||||
* returns a static +00:00 indicating no local time offset.
|
|
||||||
*/
|
*/
|
||||||
public TimeZone getTimeZone()
|
public int getMC()
|
||||||
{
|
{
|
||||||
if( isValidLocalTimeOffset() )
|
return mMessage.getInt( MC );
|
||||||
{
|
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
offset += mMessage.getInt( LOCAL_TIME_OFFSET_HOURS ) * 3600000;
|
|
||||||
offset += mMessage.get( LOCAL_TIME_OFFSET_HALF_HOUR ) ? 1800000 : 0;
|
|
||||||
offset = mMessage.get( LOCAL_TIME_OFFSET_SIGN ) ? -offset : offset;
|
|
||||||
|
|
||||||
return new SimpleTimeZone( offset, "LOCAL" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NO_TIME_ZONE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* System time - year.
|
* No idea ....
|
||||||
*
|
|
||||||
* @return year in range 2000-2127
|
|
||||||
*/
|
*/
|
||||||
|
public boolean isVL()
|
||||||
|
{
|
||||||
|
return mMessage.get( VL );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the time zone from the local time offset field.
|
||||||
|
*/
|
||||||
|
public String getTimeZone()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append( mMessage.get( LOCAL_TIME_OFFSET_SIGN ) ? "-" : "+" );
|
||||||
|
|
||||||
|
int hours = mMessage.getInt( LOCAL_TIME_OFFSET );
|
||||||
|
sb.append( ( hours < 10 ? "0" : "" ) + String.valueOf( hours ) );
|
||||||
|
|
||||||
|
sb.append( ":" );
|
||||||
|
|
||||||
|
sb.append( mMessage.get( LOCAL_TIME_OFFSET_HALF ) ? "30" : "00" );
|
||||||
|
|
||||||
|
if( mMessage.get( IST ) )
|
||||||
|
{
|
||||||
|
sb.append( " DST" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public int getYear()
|
public int getYear()
|
||||||
{
|
{
|
||||||
return 2000 + mMessage.getInt( YEAR );
|
return 2000 + mMessage.getInt( YEAR );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* System time - month
|
|
||||||
*
|
|
||||||
* @return month 1-12 where 1=January and 12=December
|
|
||||||
*/
|
|
||||||
public int getMonth()
|
public int getMonth()
|
||||||
{
|
{
|
||||||
return mMessage.getInt( MONTH );
|
return mMessage.getInt( MONTH );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* System time - day of month
|
|
||||||
*
|
|
||||||
* @return day of month in range 1-31
|
|
||||||
*/
|
|
||||||
public int getDay()
|
public int getDay()
|
||||||
{
|
{
|
||||||
return mMessage.getInt( DAY );
|
return mMessage.getInt( DAY );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* System time - hours
|
|
||||||
*
|
|
||||||
* @return hours in range 0 - 23
|
|
||||||
*/
|
|
||||||
public int getHours()
|
public int getHours()
|
||||||
{
|
{
|
||||||
return mMessage.getInt( HOURS );
|
return mMessage.getInt( HOURS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* System time - minutes
|
|
||||||
*
|
|
||||||
* @return minutes in range 0 - 59
|
|
||||||
*/
|
|
||||||
public int getMinutes()
|
public int getMinutes()
|
||||||
{
|
{
|
||||||
return mMessage.getInt( MINUTES );
|
return mMessage.getInt( MINUTES );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* System time - milli-seconds
|
|
||||||
*
|
|
||||||
* Note: sub-millisecond values are rounded to nearest millisecond unit to
|
|
||||||
* conform to java Date internal milli-second precision level.
|
|
||||||
*
|
|
||||||
* @return milli-seconds in range 0 - 59999;
|
|
||||||
*/
|
|
||||||
public int getMilliSeconds()
|
public int getMilliSeconds()
|
||||||
{
|
{
|
||||||
return (int)( (double)getMicroSlots() * 7.5 );
|
return (int)( (double)getMicroSlots() * 7.5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TDMA Micro Slots.
|
* Micro Slots - each uslot = 7.5 milliseconds. The value ranges 0 - 7999
|
||||||
*
|
* and represents 60,000 milliseconds ( 8000 x 7.5 ms). Superframes occur
|
||||||
* Number of 7.5 millisecond micro slots since the last minute rollover, or
|
* every 360 ms (48 micro-slots) on FDMA and Ultraframes occur every 4
|
||||||
* since the last micro-slot counter rollover when the the micro-slot to
|
* super frames on TDMA.
|
||||||
* minute rollover is unlocked.
|
|
||||||
*
|
|
||||||
* @see isMicroslotsLockedToMinuteRollover() method.
|
|
||||||
*
|
|
||||||
* This value supports mobile subscriber timing alignment with a TDMA traffic
|
|
||||||
* channel when a channel is granted from the control channels, so that when
|
|
||||||
* the mobile changes from the control channel to the traffic channel, it is
|
|
||||||
* already aligned with the traffic channel TDMA timing.
|
|
||||||
*
|
|
||||||
* Super frames occur every 360 ms (48 micro-slots) on FDMA and Ultra frames
|
|
||||||
* occur every 4 super frames on TDMA.
|
|
||||||
*
|
|
||||||
* Valid micro-slot values range 0-7999 and represent 60,000
|
|
||||||
* milliseconds ( 8000 x 7.5 ms).
|
|
||||||
*
|
|
||||||
* @return number of 7.5 mS micro-slots since last minute or micro-slot
|
|
||||||
* rollover
|
|
||||||
*/
|
*/
|
||||||
public int getMicroSlots()
|
public int getMicroSlots()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public enum Opcode
|
|||||||
TDMA_SYNC_BROADCAST( "TDMA_SYNC_BCST ", "FDMA-TDMA Sync Broadcast", 48 ),
|
TDMA_SYNC_BROADCAST( "TDMA_SYNC_BCST ", "FDMA-TDMA Sync Broadcast", 48 ),
|
||||||
RESERVED_31( "RESERVED_31 ", "Reserved", 49 ),
|
RESERVED_31( "RESERVED_31 ", "Reserved", 49 ),
|
||||||
RESERVED_32( "RESERVED_32 ", "Reserved", 50 ),
|
RESERVED_32( "RESERVED_32 ", "Reserved", 50 ),
|
||||||
IDENTIFIER_UPDATE_TDMA( "IDEN_UPDATE_TDMA", "Identifier Update for TDMA", 51 ),
|
RESERVED_33( "RESERVED_33 ", "Reserved", 51 ),
|
||||||
IDENTIFIER_UPDATE_VHF_UHF_BANDS( "IDEN_UPDATE_VUHF", "Identifier Update for VHF/UHF Bands", 52 ),
|
IDENTIFIER_UPDATE_VHF_UHF_BANDS( "IDEN_UPDATE_VUHF", "Identifier Update for VHF/UHF Bands", 52 ),
|
||||||
TIME_DATE_ANNOUNCEMENT( "TIME_DATE_ANNOUN", "Time and Date Announcement", 53 ),
|
TIME_DATE_ANNOUNCEMENT( "TIME_DATE_ANNOUN", "Time and Date Announcement", 53 ),
|
||||||
ROAMING_ADDRESS_COMMAND( "ROAM_ADDR_CMD ", "Roaming Address Command", 54 ),
|
ROAMING_ADDRESS_COMMAND( "ROAM_ADDR_CMD ", "Roaming Address Command", 54 ),
|
||||||
|
|||||||
@@ -3,18 +3,12 @@ package module.decode.p25.reference;
|
|||||||
public enum PDUType
|
public enum PDUType
|
||||||
{
|
{
|
||||||
/* Outbound */
|
/* Outbound */
|
||||||
SNDCP_ACTIVATE_TDS_CONTEXT_ACCEPT( "SNDCP-ACTIVATE TDS CONTEXT ACCEPT", 0 ),
|
SN_ACTIVATE_TDS_CONTEXT_ACCEPT( "SN-ACTIVATE TDS CONTEXT ACCEPT", 0 ),
|
||||||
SNDCP_DEACTIVATE_TDS_CONTEXT_ACCEPT( "SNDCP-DEACTIVATE TDS CONTEXT ACCEPT", 1 ),
|
SN_DEACTIVATE_TDS_CONTEXT_ACCEPT( "SN-DEACTIVATE TDS CONTEXT ACCEPT", 1 ),
|
||||||
SNDCP_DEACTIVATE_TDS_CONTEXT_REQUEST( "SNDCP-DEACTIVATE TDS CONTEXT REQUEST", 2 ),
|
SN_DEACTIVATE_TDS_CONTEXT_REQUEST( "SN-DEACTIVATE TDS CONTEXT REQUEST", 2 ),
|
||||||
SNDCP_ACTIVATE_TDS_CONTEXT_REJECT( "SNDCP-ACTIVATE TDS CONTEXT REJECT", 3 ),
|
SN_ACTIVATE_TDS_CONTEXT_REJECT( "SN-ACTIVATE TDS CONTEXT REJECT", 3 ),
|
||||||
SNDCP_RF_UNCONFIRMED_DATA( "SNDCP-RF UNCONFIRMED DATA", 4 ),
|
SN_RF_UNCONFIRMED_DATA( "SN-RF UNCONFIRMED DATA", 4 ),
|
||||||
SNDCP_RF_CONFIRMED_DATA( "SNDCP-RF CONFIRMED DATA", 5 ),
|
SN_RF_CONFIRMED_DATA( "SN-RF CONFIRMED DATA", 5 ),
|
||||||
PDU_TYPE_6( "PDU TYPE 6 UNKNOWN", 6 ),
|
|
||||||
PDU_TYPE_7( "PDU TYPE 7 UNKNOWN", 7 ),
|
|
||||||
PDU_TYPE_8( "PDU TYPE 8 UNKNOWN", 8 ),
|
|
||||||
PDU_TYPE_9( "PDU TYPE 9 UNKNOWN", 9 ),
|
|
||||||
PDU_TYPE_10( "PDU TYPE 10 UNKNOWN", 10 ),
|
|
||||||
PDU_TYPE_11( "PDU TYPE 11 UNKNOWN", 11 ),
|
|
||||||
|
|
||||||
/* Inbound */
|
/* Inbound */
|
||||||
SN_ACTIVATE_TDS_CONTEXT_REQUEST( "SN-ACTIVATE TDS CONTEXT REQUEST", 0 ),
|
SN_ACTIVATE_TDS_CONTEXT_REQUEST( "SN-ACTIVATE TDS CONTEXT REQUEST", 0 ),
|
||||||
@@ -42,7 +36,7 @@ public enum PDUType
|
|||||||
|
|
||||||
public static PDUType fromValue( int value, boolean outbound )
|
public static PDUType fromValue( int value, boolean outbound )
|
||||||
{
|
{
|
||||||
if( outbound && 0 <= value && value <= 11 )
|
if( outbound && 0 <= value && value <= 5 )
|
||||||
{
|
{
|
||||||
return values()[ value ];
|
return values()[ value ];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package module.decode.p25.reference;
|
|||||||
|
|
||||||
public enum ServiceAccessPoint
|
public enum ServiceAccessPoint
|
||||||
{
|
{
|
||||||
UNENCRYPTED_USER_DATA( "UNENCRYPTED USER DATA", 0 ),
|
UNENCRYPTED_USER_DATA( "USER DATA", 0 ),
|
||||||
ENCRYPTED_USER_DATA( "ENCRYPTED USER DATA", 1 ),
|
ENCRYPTED_USER_DATA( "ENCRYPTED USER DATA", 1 ),
|
||||||
CIRCUIT_DATA( "CIRCUIT DATA", 2 ),
|
CIRCUIT_DATA( "CIRCUIT DATA", 2 ),
|
||||||
CIRCUIT_DATA_CONTROL( "CIRCUIT DATA CONTROL", 3 ),
|
CIRCUIT_DATA_CONTROL( "CIRCUIT DATA CONTROL", 3 ),
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ public class PassportDecoder extends Decoder
|
|||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
mPassportMessageFramer.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package module.decode.state;
|
|
||||||
|
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Allows decoders to change the call timeout setting in the channel state
|
|
||||||
*/
|
|
||||||
public class ChangeChannelTimeoutEvent extends DecoderStateEvent
|
|
||||||
{
|
|
||||||
private ChannelType mChannelType;
|
|
||||||
private long mCallTimeout;
|
|
||||||
|
|
||||||
public ChangeChannelTimeoutEvent( Object source, ChannelType channelType, long timeout )
|
|
||||||
{
|
|
||||||
super( source, Event.CHANGE_CALL_TIMEOUT, State.IDLE );
|
|
||||||
mChannelType = channelType;
|
|
||||||
mCallTimeout = timeout;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChannelType getChannelType()
|
|
||||||
{
|
|
||||||
return mChannelType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getCallTimeout()
|
|
||||||
{
|
|
||||||
return mCallTimeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -136,13 +136,10 @@ public class ChannelList extends JPanel implements ChannelEventListener
|
|||||||
|
|
||||||
public void setSelectedChannel( Channel channel )
|
public void setSelectedChannel( Channel channel )
|
||||||
{
|
{
|
||||||
synchronized( mDisplayedPanels )
|
/* Send channel selection to each channel panel */
|
||||||
|
for( ChannelCollectionPanel panel: mDisplayedPanels.values() )
|
||||||
{
|
{
|
||||||
/* Send channel selection to each channel panel */
|
panel.setSelectedChannel( channel );
|
||||||
for( ChannelCollectionPanel panel: mDisplayedPanels.values() )
|
|
||||||
{
|
|
||||||
panel.setSelectedChannel( channel );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,6 +258,20 @@ public class ChannelList extends JPanel implements ChannelEventListener
|
|||||||
idleMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
idleMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE ) );
|
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE ) );
|
||||||
|
|
||||||
|
JMenu noTunerMenu = new JMenu( "No Tuner" );
|
||||||
|
channelsMenu.add( noTunerMenu );
|
||||||
|
|
||||||
|
noTunerMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||||
|
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER ) );
|
||||||
|
noTunerMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||||
|
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER ) );
|
||||||
|
noTunerMenu.add( new JSeparator() );
|
||||||
|
|
||||||
|
noTunerMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||||
|
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER ) );
|
||||||
|
noTunerMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||||
|
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER ) );
|
||||||
|
|
||||||
JMenu labelMenu = new JMenu( "Labels" );
|
JMenu labelMenu = new JMenu( "Labels" );
|
||||||
colorMenu.add( labelMenu );
|
colorMenu.add( labelMenu );
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014,2015 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -17,14 +17,20 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.state;
|
package module.decode.state;
|
||||||
|
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
import module.Module;
|
||||||
|
import module.decode.config.DecodeConfiguration;
|
||||||
|
import module.decode.event.CallEvent;
|
||||||
|
import module.decode.event.ICallEventProvider;
|
||||||
|
import module.decode.state.DecoderStateEvent.Event;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import sample.Listener;
|
||||||
import audio.metadata.IMetadataProvider;
|
import audio.metadata.IMetadataProvider;
|
||||||
import audio.metadata.Metadata;
|
import audio.metadata.Metadata;
|
||||||
import audio.metadata.MetadataReset;
|
import audio.metadata.MetadataReset;
|
||||||
@@ -34,13 +40,38 @@ import audio.squelch.SquelchState;
|
|||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import controller.ThreadPoolManager.ThreadType;
|
import controller.ThreadPoolManager.ThreadType;
|
||||||
import controller.channel.Channel.ChannelType;
|
import controller.channel.Channel.ChannelType;
|
||||||
import module.Module;
|
|
||||||
import module.decode.config.DecodeConfiguration;
|
|
||||||
import module.decode.event.CallEvent;
|
|
||||||
import module.decode.event.ICallEventProvider;
|
|
||||||
import module.decode.state.DecoderStateEvent.Event;
|
|
||||||
import sample.Listener;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Channel state tracks the overall state of all processing modules and decoders
|
||||||
|
* configured for the channel and provides squelch control events.
|
||||||
|
*
|
||||||
|
* Primary channel state provides a state machine for tracking decode events
|
||||||
|
* during a voice or data call through it's life cycle of CALL/DATA, FADE, END,
|
||||||
|
* and then back to an IDLE state. This class also provides squelch control
|
||||||
|
* to support any audio processing.
|
||||||
|
*
|
||||||
|
* State Descriptions:
|
||||||
|
* IDLE No voice or data call activity
|
||||||
|
* CALL/DATA A voice or data call has started, or is continuing
|
||||||
|
* CONTROL Control channel
|
||||||
|
* FADE The phase after a voice or data call when either an explicit
|
||||||
|
* call end has been received, or when no new signalling updates
|
||||||
|
* have been received, and the fade timer has expired. This phase
|
||||||
|
* allows for gui updates to signal to the user that the call is
|
||||||
|
* ended, while continuing to display the call details for the user
|
||||||
|
* END The phase after the voice or data call FADE, when the call is
|
||||||
|
* now over, and the gui should be reset to IDLE.
|
||||||
|
*
|
||||||
|
* When a call is started, invoke mTimerService.startFadeTimer() to start the
|
||||||
|
* call fade monitoring timer process that will automatically signal a call end
|
||||||
|
* once no more call signalling has been detected after the fade timeout has
|
||||||
|
* occurred, by invoking the fade() method.
|
||||||
|
*
|
||||||
|
* When a call ends, invoke the mTimerService.stopFadeTimer() and then invoke
|
||||||
|
* the mTimerService.startResetTimer(). Once the reset timeout occurs,
|
||||||
|
* the reset() method will be called, allowing the channel state to perform
|
||||||
|
* any reset actions, like clearing status and id labels on any view panels.
|
||||||
|
*/
|
||||||
public class ChannelState extends Module implements ICallEventProvider,
|
public class ChannelState extends Module implements ICallEventProvider,
|
||||||
IChangedAttributeProvider, IDecoderStateEventListener,
|
IChangedAttributeProvider, IDecoderStateEventListener,
|
||||||
IDecoderStateEventProvider, IMetadataProvider, ISquelchStateProvider
|
IDecoderStateEventProvider, IMetadataProvider, ISquelchStateProvider
|
||||||
@@ -52,6 +83,8 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
public static final long RESET_TIMEOUT_DELAY = 2000;
|
public static final long RESET_TIMEOUT_DELAY = 2000;
|
||||||
|
|
||||||
private State mState = State.IDLE;
|
private State mState = State.IDLE;
|
||||||
|
private long mTrafficChannelTimeout =
|
||||||
|
DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS;
|
||||||
|
|
||||||
private Listener<CallEvent> mCallEventListener;
|
private Listener<CallEvent> mCallEventListener;
|
||||||
private Listener<ChangedAttribute> mChangedAttributeListener;
|
private Listener<ChangedAttribute> mChangedAttributeListener;
|
||||||
@@ -64,15 +97,12 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
private boolean mSquelchLocked = false;
|
private boolean mSquelchLocked = false;
|
||||||
private boolean mSelected = false;
|
private boolean mSelected = false;
|
||||||
|
|
||||||
private long mStandardChannelFadeTimeout = FADE_TIMEOUT_DELAY;
|
|
||||||
private long mTrafficChannelFadeTimeout =
|
|
||||||
DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS * 1000;
|
|
||||||
private long mFadeTimeout;
|
private long mFadeTimeout;
|
||||||
private long mEndTimeout;
|
private long mResetTimeout;
|
||||||
|
|
||||||
private StateMonitor mStateMonitor = new StateMonitor();
|
private StateMonitor mStateMonitor = new StateMonitor();
|
||||||
private AtomicBoolean mMonitoring = new AtomicBoolean();
|
private AtomicBoolean mMonitoring = new AtomicBoolean();
|
||||||
private ScheduledFuture<?> mStateMonitorFuture;
|
private ScheduledFuture<?> mRunningMonitor;
|
||||||
|
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
private ChannelType mChannelType;
|
private ChannelType mChannelType;
|
||||||
@@ -80,97 +110,32 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
private TrafficChannelStatusListener mTrafficChannelStatusListener;
|
private TrafficChannelStatusListener mTrafficChannelStatusListener;
|
||||||
private CallEvent mTrafficChannelCallEvent;
|
private CallEvent mTrafficChannelCallEvent;
|
||||||
|
|
||||||
/**
|
|
||||||
* Channel state tracks the overall state of all processing modules and decoders
|
|
||||||
* configured for the channel and provides squelch control and decoder state
|
|
||||||
* reset events.
|
|
||||||
*
|
|
||||||
* Uses a state enumeration that defines allowable channel state transitions in
|
|
||||||
* order to track a call or data decode event from start to finish. Uses a
|
|
||||||
* timer to monitor for inactivity and to provide a FADE period that indicates
|
|
||||||
* to the user that the activity has stopped while continuing to provide details
|
|
||||||
* about the call, before the state is reset to IDLE.
|
|
||||||
*
|
|
||||||
* Since this class is multi-threaded between decoder events and the internal
|
|
||||||
* timer that monitors for inactivity, this class uses the mState object for
|
|
||||||
* thread synchronization.
|
|
||||||
*
|
|
||||||
* State Descriptions:
|
|
||||||
* IDLE Normal state. No voice or data call activity
|
|
||||||
* CALL/DATA/ENCRYPTED/CONTROL
|
|
||||||
* Decoding states.
|
|
||||||
* FADE The phase after a voice or data call when either an explicit
|
|
||||||
* call end has been received, or when no new signalling updates
|
|
||||||
* have been received, and the fade timer has expired. This phase
|
|
||||||
* allows for gui updates to signal to the user that the call is
|
|
||||||
* ended, while continuing to display the call details for the user
|
|
||||||
* TEARDOWN Indicates a traffic channel that will be torn down for reuse.
|
|
||||||
*/
|
|
||||||
public ChannelState( ThreadPoolManager manager, ChannelType channelType )
|
public ChannelState( ThreadPoolManager manager, ChannelType channelType )
|
||||||
{
|
{
|
||||||
mThreadPoolManager = manager;
|
mThreadPoolManager = manager;
|
||||||
mChannelType = channelType;
|
mChannelType = channelType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets this channel state and prepares it for reuse.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void reset()
|
public void reset()
|
||||||
{
|
{
|
||||||
broadcast( new DecoderStateEvent( this, Event.RESET, State.IDLE ) );
|
|
||||||
broadcast( new MetadataReset() );
|
|
||||||
|
|
||||||
mState = State.IDLE;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start()
|
public void start()
|
||||||
{
|
{
|
||||||
//Start a monitoring task to check for FADE and END event timeouts
|
|
||||||
if( mMonitoring.compareAndSet( false, true ) )
|
|
||||||
{
|
|
||||||
if( mStateMonitorFuture == null && mStateMonitor != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
mStateMonitorFuture = mThreadPoolManager.scheduleFixedRate(
|
|
||||||
ThreadType.DECODER, mStateMonitor, 20, TimeUnit.MILLISECONDS );
|
|
||||||
}
|
|
||||||
catch( RejectedExecutionException ree )
|
|
||||||
{
|
|
||||||
mLog.error( "state monitor scheduled task rejected", ree );
|
|
||||||
mMonitoring.set( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop()
|
public void stop()
|
||||||
{
|
{
|
||||||
mSquelchLocked = false;
|
mSquelchLocked = false;
|
||||||
|
|
||||||
//Shutdown the state montoring task
|
|
||||||
if( mMonitoring.compareAndSet( true, false ) )
|
|
||||||
{
|
|
||||||
if( mStateMonitorFuture != null )
|
|
||||||
{
|
|
||||||
boolean success = mThreadPoolManager.cancel( mStateMonitorFuture );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't stop monitoring scheduled future" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mStateMonitorFuture = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
|
stopMonitor();
|
||||||
|
|
||||||
mCallEventListener = null;
|
mCallEventListener = null;
|
||||||
mChangedAttributeListener = null;
|
mChangedAttributeListener = null;
|
||||||
mDecoderStateListener = null;
|
mDecoderStateListener = null;
|
||||||
@@ -179,34 +144,9 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
mStateMonitor = null;
|
mStateMonitor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStandardChannel()
|
|
||||||
{
|
|
||||||
return mChannelType == ChannelType.STANDARD;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isTrafficChannel()
|
|
||||||
{
|
|
||||||
return mChannelType == ChannelType.TRAFFIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStandardChannelTimeout( long milliseconds )
|
|
||||||
{
|
|
||||||
mStandardChannelFadeTimeout = milliseconds;
|
|
||||||
|
|
||||||
if( mChannelType == ChannelType.STANDARD )
|
|
||||||
{
|
|
||||||
mFadeTimeout = mStandardChannelFadeTimeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTrafficChannelTimeout( long milliseconds )
|
public void setTrafficChannelTimeout( long milliseconds )
|
||||||
{
|
{
|
||||||
mTrafficChannelFadeTimeout = milliseconds;
|
mTrafficChannelTimeout = milliseconds;
|
||||||
|
|
||||||
if( mChannelType == ChannelType.TRAFFIC )
|
|
||||||
{
|
|
||||||
mFadeTimeout = mTrafficChannelFadeTimeout;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelected( boolean selected )
|
public void setSelected( boolean selected )
|
||||||
@@ -224,18 +164,71 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
return mState;
|
return mState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isIdleOrEndingState()
|
||||||
|
{
|
||||||
|
return mState == State.FADE ||
|
||||||
|
mState == State.END ||
|
||||||
|
mState == State.IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the state monitor running when we're not in IDLE state. Calls to
|
||||||
|
* start an already started monitor are ignored.
|
||||||
|
*/
|
||||||
|
private void startMonitor()
|
||||||
|
{
|
||||||
|
if( mMonitoring.compareAndSet( false, true ) )
|
||||||
|
{
|
||||||
|
if( mRunningMonitor == null && mStateMonitor != null )
|
||||||
|
{
|
||||||
|
mRunningMonitor = mThreadPoolManager.scheduleFixedRate(
|
||||||
|
ThreadType.DECODER, mStateMonitor, 20, TimeUnit.MILLISECONDS );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new RuntimeException( "Channel state monitor's scheduled "
|
||||||
|
+ "future pointer was not null" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the state monitor when we're in an IDLE state. Calls to stop an
|
||||||
|
* already stopped monitor are ignored.
|
||||||
|
*/
|
||||||
|
private void stopMonitor()
|
||||||
|
{
|
||||||
|
if( mMonitoring.compareAndSet( true, false ) )
|
||||||
|
{
|
||||||
|
if( mRunningMonitor != null )
|
||||||
|
{
|
||||||
|
mThreadPoolManager.cancel( mRunningMonitor );
|
||||||
|
}
|
||||||
|
|
||||||
|
mRunningMonitor = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the fade timeout threshold to the current time plus delay
|
* Updates the fade timeout threshold to the current time plus delay
|
||||||
*/
|
*/
|
||||||
private void updateFadeTimeout()
|
private void updateFadeTimeout()
|
||||||
{
|
{
|
||||||
if( isTrafficChannel() )
|
/* Standard channel uses the FADE_TIMEOUT_DELAY and traffic channels
|
||||||
|
* use the TRAFFIC_FADE_TIMEOUT_DELAY. Some traffic channels (e.g. MPT)
|
||||||
|
* don't have signaling on the traffic channel that can be used to
|
||||||
|
* update the fade timeout, so we set the timeout value larger to ensure
|
||||||
|
* the channel doesn't fade before the end of the call. */
|
||||||
|
long current = System.currentTimeMillis();
|
||||||
|
|
||||||
|
long timeout = current +
|
||||||
|
( mChannelType == ChannelType.STANDARD ? FADE_TIMEOUT_DELAY :
|
||||||
|
mTrafficChannelTimeout );
|
||||||
|
|
||||||
|
if( timeout > mFadeTimeout )
|
||||||
{
|
{
|
||||||
mFadeTimeout = System.currentTimeMillis() + mTrafficChannelFadeTimeout;
|
mFadeTimeout = timeout;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mFadeTimeout = System.currentTimeMillis() + mStandardChannelFadeTimeout;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,13 +237,13 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
*/
|
*/
|
||||||
private void updateResetTimeout()
|
private void updateResetTimeout()
|
||||||
{
|
{
|
||||||
if( isTrafficChannel() )
|
if( mChannelType == ChannelType.TRAFFIC )
|
||||||
{
|
{
|
||||||
mEndTimeout = System.currentTimeMillis();
|
mResetTimeout = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mEndTimeout = System.currentTimeMillis() + RESET_TIMEOUT_DELAY;
|
mResetTimeout = System.currentTimeMillis() + RESET_TIMEOUT_DELAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,120 +285,120 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
*/
|
*/
|
||||||
protected void setState( State state )
|
protected void setState( State state )
|
||||||
{
|
{
|
||||||
synchronized( mState )
|
if( mState == state )
|
||||||
{
|
{
|
||||||
if( state == mState )
|
switch( state )
|
||||||
{
|
{
|
||||||
if( State.CALL_STATES.contains( state ) )
|
case CALL:
|
||||||
{
|
case CONTROL:
|
||||||
|
case DATA:
|
||||||
|
case ENCRYPTED:
|
||||||
updateFadeTimeout();
|
updateFadeTimeout();
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if( state != mState && mState.canChangeTo( state ) )
|
}
|
||||||
|
else if( mState.canChangeTo( state ) )
|
||||||
|
{
|
||||||
|
switch( state )
|
||||||
{
|
{
|
||||||
switch( state )
|
case CONTROL:
|
||||||
{
|
//Don't allow traffic channels to be control channels,
|
||||||
case CONTROL:
|
//otherwise they won't get call tear down
|
||||||
//Don't allow traffic channels to be control channels,
|
if( mChannelType != ChannelType.TRAFFIC )
|
||||||
//otherwise they can't transition to call tear down
|
{
|
||||||
if( isStandardChannel() )
|
|
||||||
{
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
updateFadeTimeout();
|
|
||||||
mState = state;
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DATA:
|
|
||||||
case ENCRYPTED:
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
broadcast( SquelchState.SQUELCH );
|
||||||
updateFadeTimeout();
|
updateFadeTimeout();
|
||||||
|
startMonitor();
|
||||||
mState = state;
|
mState = state;
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||||
break;
|
}
|
||||||
case CALL:
|
break;
|
||||||
broadcast( SquelchState.UNSQUELCH );
|
case DATA:
|
||||||
updateFadeTimeout();
|
case ENCRYPTED:
|
||||||
mState = state;
|
broadcast( SquelchState.SQUELCH );
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
updateFadeTimeout();
|
||||||
break;
|
startMonitor();
|
||||||
case FADE:
|
mState = state;
|
||||||
processFadeState();
|
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||||
break;
|
break;
|
||||||
case IDLE:
|
case CALL:
|
||||||
processIdleState();
|
broadcast( SquelchState.UNSQUELCH );
|
||||||
break;
|
updateFadeTimeout();
|
||||||
case TEARDOWN:
|
startMonitor();
|
||||||
processTeardownState();
|
mState = state;
|
||||||
break;
|
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||||
case RESET:
|
break;
|
||||||
mState = State.IDLE;
|
case FADE:
|
||||||
break;
|
broadcast( SquelchState.SQUELCH );
|
||||||
default:
|
updateResetTimeout();
|
||||||
break;
|
startMonitor();
|
||||||
|
mState = state;
|
||||||
|
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||||
|
break;
|
||||||
|
case END:
|
||||||
|
broadcast( SquelchState.SQUELCH );
|
||||||
|
broadcast( new DecoderStateEvent( this, Event.RESET, State.IDLE ) );
|
||||||
|
broadcast( new MetadataReset() );
|
||||||
|
mState = state;
|
||||||
|
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||||
|
break;
|
||||||
|
case IDLE:
|
||||||
|
broadcast( SquelchState.SQUELCH );
|
||||||
|
stopMonitor();
|
||||||
|
|
||||||
|
if( mChannelType == ChannelType.TRAFFIC )
|
||||||
|
{
|
||||||
|
if( mTrafficChannelStatusListener != null )
|
||||||
|
{
|
||||||
|
mTrafficChannelStatusListener.callEnd();
|
||||||
|
mTrafficChannelStatusListener = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( mTrafficChannelCallEvent != null )
|
||||||
|
{
|
||||||
|
mTrafficChannelCallEvent.end();
|
||||||
|
|
||||||
|
broadcast( mTrafficChannelCallEvent );
|
||||||
|
mTrafficChannelCallEvent = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mState = state;
|
||||||
|
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StateMonitor implements Runnable
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if( getState() == State.FADE )
|
||||||
|
{
|
||||||
|
if( mResetTimeout <= System.currentTimeMillis() )
|
||||||
|
{
|
||||||
|
setState( State.END );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( getState() == State.END )
|
||||||
|
{
|
||||||
|
setState( State.IDLE );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// mLog.debug( "Can't change from [" + mState + "] to [" + state + "]" );
|
if( mFadeTimeout <= System.currentTimeMillis() )
|
||||||
|
{
|
||||||
|
setState( State.FADE );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the state and processes related actions
|
|
||||||
*/
|
|
||||||
private void processFadeState()
|
|
||||||
{
|
|
||||||
updateResetTimeout();
|
|
||||||
mState = State.FADE;
|
|
||||||
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processIdleState()
|
|
||||||
{
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
|
|
||||||
if( mState == State.FADE )
|
|
||||||
{
|
|
||||||
broadcast( new DecoderStateEvent( this, Event.RESET, State.IDLE ) );
|
|
||||||
broadcast( new MetadataReset() );
|
|
||||||
}
|
|
||||||
|
|
||||||
mState = State.IDLE;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
}
|
|
||||||
|
|
||||||
private void processTeardownState()
|
|
||||||
{
|
|
||||||
broadcast( SquelchState.SQUELCH );
|
|
||||||
|
|
||||||
mState = State.TEARDOWN;
|
|
||||||
|
|
||||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
|
||||||
|
|
||||||
if( mTrafficChannelCallEvent != null )
|
|
||||||
{
|
|
||||||
mTrafficChannelCallEvent.end();
|
|
||||||
|
|
||||||
broadcast( mTrafficChannelCallEvent );
|
|
||||||
mTrafficChannelCallEvent = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mTrafficChannelStatusListener != null )
|
|
||||||
{
|
|
||||||
mTrafficChannelStatusListener.callEnd();
|
|
||||||
mTrafficChannelStatusListener = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mLog.error( "Traffic channel status listener was null - couldn't "
|
|
||||||
+ "teardown the channel");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcasts the call event to the registered listener
|
* Broadcasts the call event to the registered listener
|
||||||
@@ -597,95 +590,35 @@ public class ChannelState extends Module implements ICallEventProvider,
|
|||||||
broadcast( SquelchState.UNSQUELCH );
|
broadcast( SquelchState.UNSQUELCH );
|
||||||
mSquelchLocked = true;
|
mSquelchLocked = true;
|
||||||
break;
|
break;
|
||||||
case CHANGE_CALL_TIMEOUT:
|
|
||||||
if( event instanceof ChangeChannelTimeoutEvent )
|
|
||||||
{
|
|
||||||
ChangeChannelTimeoutEvent timeout = (ChangeChannelTimeoutEvent)event;
|
|
||||||
|
|
||||||
if( timeout.getChannelType() == ChannelType.STANDARD )
|
|
||||||
{
|
|
||||||
setStandardChannelTimeout( timeout.getCallTimeout() );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setTrafficChannelTimeout( timeout.getCallTimeout() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case CONTINUATION:
|
case CONTINUATION:
|
||||||
|
if( isIdleOrEndingState() )
|
||||||
|
{
|
||||||
|
setState( event.getState() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
updateFadeTimeout();
|
||||||
|
}
|
||||||
|
break;
|
||||||
case DECODE:
|
case DECODE:
|
||||||
case START:
|
if( getState() == State.IDLE )
|
||||||
if( State.CALL_STATES.contains( event.getState() ) )
|
|
||||||
{
|
{
|
||||||
setState( event.getState() );
|
setState( event.getState() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case END:
|
case END:
|
||||||
if( isTrafficChannel() )
|
setState( State.FADE );
|
||||||
{
|
|
||||||
setState( State.TEARDOWN );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setState( State.FADE );
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case RESET:
|
case RESET:
|
||||||
/* Channel State does not respond to reset events */
|
/* Channel State does not respond to reset events */
|
||||||
break;
|
break;
|
||||||
|
case START:
|
||||||
|
setState( event.getState() );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Monitors decoder state events to automatically transition the channel
|
|
||||||
* state to IDLE (standard channel) or to TEARDOWN (traffic channel) when
|
|
||||||
* decoding stops or the monitored channel returns to a no signal state.
|
|
||||||
*
|
|
||||||
* Provides a FADE transition state to allow for momentary decoding dropouts
|
|
||||||
* and to allow the user access to call details for a fade period upon
|
|
||||||
* call end.
|
|
||||||
*/
|
|
||||||
public class StateMonitor implements Runnable
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
synchronized( mState )
|
|
||||||
{
|
|
||||||
if( State.CALL_STATES.contains( mState ) &&
|
|
||||||
mFadeTimeout <= System.currentTimeMillis() )
|
|
||||||
{
|
|
||||||
mState = State.FADE;
|
|
||||||
processFadeState();
|
|
||||||
}
|
|
||||||
else if( mState == State.FADE &&
|
|
||||||
mEndTimeout <= System.currentTimeMillis() )
|
|
||||||
{
|
|
||||||
if( isTrafficChannel() )
|
|
||||||
{
|
|
||||||
processTeardownState();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
processIdleState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
mLog.error( "Exception thrown while state monitor is running " +
|
|
||||||
"- state [" + getState() +
|
|
||||||
"] current [" + System.currentTimeMillis() +
|
|
||||||
"] mResetTimeout [" + mEndTimeout +
|
|
||||||
"] mFadeTimeout [" + mFadeTimeout +
|
|
||||||
"]", e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ public class DecoderStateEvent
|
|||||||
public enum Event
|
public enum Event
|
||||||
{
|
{
|
||||||
ALWAYS_UNSQUELCH,
|
ALWAYS_UNSQUELCH,
|
||||||
CHANGE_CALL_TIMEOUT,
|
|
||||||
CONTINUATION,
|
CONTINUATION,
|
||||||
DECODE,
|
DECODE,
|
||||||
END,
|
END,
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
package module.decode.state;
|
package module.decode.state;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Details the set of states for a channel and the allowable transition states
|
|
||||||
*/
|
|
||||||
public enum State
|
public enum State
|
||||||
{
|
{
|
||||||
IDLE( "IDLE" )
|
IDLE( "IDLE" )
|
||||||
@@ -12,8 +7,7 @@ public enum State
|
|||||||
@Override
|
@Override
|
||||||
public boolean canChangeTo( State state )
|
public boolean canChangeTo( State state )
|
||||||
{
|
{
|
||||||
return state != TEARDOWN &&
|
return true;
|
||||||
state != RESET;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CALL( "CALL" )
|
CALL( "CALL" )
|
||||||
@@ -21,11 +15,11 @@ public enum State
|
|||||||
@Override
|
@Override
|
||||||
public boolean canChangeTo( State state )
|
public boolean canChangeTo( State state )
|
||||||
{
|
{
|
||||||
return state == CONTROL ||
|
return state == CALL ||
|
||||||
|
state == CONTROL ||
|
||||||
state == DATA ||
|
state == DATA ||
|
||||||
state == ENCRYPTED ||
|
state == ENCRYPTED ||
|
||||||
state == FADE ||
|
state == FADE;
|
||||||
state == TEARDOWN;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DATA( "DATA" )
|
DATA( "DATA" )
|
||||||
@@ -35,9 +29,9 @@ public enum State
|
|||||||
{
|
{
|
||||||
return state == CALL ||
|
return state == CALL ||
|
||||||
state == CONTROL ||
|
state == CONTROL ||
|
||||||
state == ENCRYPTED ||
|
state == DATA ||
|
||||||
state == FADE ||
|
state == State.ENCRYPTED ||
|
||||||
state == TEARDOWN;
|
state == FADE;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ENCRYPTED( "ENCRYPTED" )
|
ENCRYPTED( "ENCRYPTED" )
|
||||||
@@ -45,7 +39,7 @@ public enum State
|
|||||||
@Override
|
@Override
|
||||||
public boolean canChangeTo( State state )
|
public boolean canChangeTo( State state )
|
||||||
{
|
{
|
||||||
return state == FADE || state == TEARDOWN;
|
return state == FADE;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CONTROL( "CONTROL" )
|
CONTROL( "CONTROL" )
|
||||||
@@ -53,8 +47,7 @@ public enum State
|
|||||||
@Override
|
@Override
|
||||||
public boolean canChangeTo( State state )
|
public boolean canChangeTo( State state )
|
||||||
{
|
{
|
||||||
return state == IDLE ||
|
return true;
|
||||||
state == FADE;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FADE( "FADE" )
|
FADE( "FADE" )
|
||||||
@@ -62,36 +55,20 @@ public enum State
|
|||||||
@Override
|
@Override
|
||||||
public boolean canChangeTo( State state )
|
public boolean canChangeTo( State state )
|
||||||
{
|
{
|
||||||
return state != FADE &&
|
return state != FADE; //All states except fade allowed
|
||||||
state != RESET;
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
RESET( "RESET" )
|
END( "END" )
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean canChangeTo(State state)
|
public boolean canChangeTo( State state )
|
||||||
{
|
{
|
||||||
return state == IDLE;
|
return state != FADE; //Fade is only disallowed state
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
TEARDOWN( "TEARDOWN" )
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public boolean canChangeTo(State state)
|
|
||||||
{
|
|
||||||
return state == RESET;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private String mDisplayValue;
|
private String mDisplayValue;
|
||||||
|
|
||||||
public static final EnumSet<State> CALL_STATES =
|
|
||||||
EnumSet.of( CALL, CONTROL, DATA, ENCRYPTED );
|
|
||||||
|
|
||||||
public static final EnumSet<State> IDLE_STATES =
|
|
||||||
EnumSet.of( IDLE, FADE );
|
|
||||||
|
|
||||||
private State( String displayValue )
|
private State( String displayValue )
|
||||||
{
|
{
|
||||||
mDisplayValue = displayValue;
|
mDisplayValue = displayValue;
|
||||||
|
|||||||
@@ -22,9 +22,10 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.beans.DesignMode;
|
import java.beans.DesignMode;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||||
@@ -125,13 +126,13 @@ public class JXMapViewer extends JPanel implements DesignMode
|
|||||||
// make a dummy loading image
|
// make a dummy loading image
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ImageIcon imageIcon = new ImageIcon( "images/loading.png" );
|
URL url = JXMapViewer.class.getResource("mapviewer/resources/loading.png");
|
||||||
this.setLoadingImage( imageIcon.getImage() );
|
this.setLoadingImage(ImageIO.read(url));
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
mLog.error( "could not load 'loading.png'" );
|
mLog.error( "JXMapViewer could not load 'loading.png'" );
|
||||||
|
|
||||||
BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||||
Graphics2D g2 = img.createGraphics();
|
Graphics2D g2 = img.createGraphics();
|
||||||
|
|||||||
@@ -82,13 +82,18 @@ public class SystemProperties
|
|||||||
{
|
{
|
||||||
out = new FileOutputStream( propsPath.toString() );
|
out = new FileOutputStream( propsPath.toString() );
|
||||||
|
|
||||||
String comments = "SDRTrunk - SDR Trunking Decoder Application Settings";
|
String comments =
|
||||||
|
"SDRTrunk - SDR Trunking Decoder Application Settings";
|
||||||
|
|
||||||
mProperties.store( out, comments );
|
mProperties.store( out, comments );
|
||||||
|
|
||||||
|
mLog.info( "SystemProperties - saved current properties [" +
|
||||||
|
propsPath.toString() + "]" );
|
||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
mLog.error( "exception while saving application properties", e );
|
mLog.error( "SystemProperties - exception while saving " +
|
||||||
|
"application properties", e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -141,7 +146,8 @@ public class SystemProperties
|
|||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
mLog.error( "exception while creating app folder [" + folder + "]", e );
|
mLog.error( "SystemProperties - exception while creating " +
|
||||||
|
"app folder [" + folder + "]", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,11 +158,11 @@ public class SystemProperties
|
|||||||
{
|
{
|
||||||
if( mPropertiesPath == null )
|
if( mPropertiesPath == null )
|
||||||
{
|
{
|
||||||
mLog.info( "no properties file loaded - using defaults" );
|
mLog.info( "SystemProperties - no properties file loaded - using defaults" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.info( "application properties loaded [" + mPropertiesPath.toString() + "]" );
|
mLog.info( "SystemProperties - application properties loaded [" + mPropertiesPath.toString() + "]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +184,7 @@ public class SystemProperties
|
|||||||
}
|
}
|
||||||
catch ( FileNotFoundException e )
|
catch ( FileNotFoundException e )
|
||||||
{
|
{
|
||||||
mLog.error( "exception while opening inputstream on " +
|
mLog.error( "SDRTrunk - exception while opening inputstream on " +
|
||||||
"application properties file", e );
|
"application properties file", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +196,7 @@ public class SystemProperties
|
|||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
mLog.error( "exception while loading properties " +
|
mLog.error( "SDRTrunk - exception while loading properties " +
|
||||||
"inputstream into SystemProperties", e );
|
"inputstream into SystemProperties", e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -206,7 +212,8 @@ public class SystemProperties
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mLog.info( "loaded [" + propertiesPath.toString() + "]" );
|
mLog.info( "SystemProperties - loaded [" +
|
||||||
|
propertiesPath.toString() + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ public class ColorSetting extends Setting
|
|||||||
"Control Gradient Middle", "Channel Control State Gradient Middle" ),
|
"Control Gradient Middle", "Channel Control State Gradient Middle" ),
|
||||||
CHANNEL_STATE_GRADIENT_TOP_DATA( Color.BLACK,
|
CHANNEL_STATE_GRADIENT_TOP_DATA( Color.BLACK,
|
||||||
"Data Gradient Top", "Channel Data State Gradient Top" ),
|
"Data Gradient Top", "Channel Data State Gradient Top" ),
|
||||||
CHANNEL_STATE_GRADIENT_MIDDLE_DATA( new Color( 0xCC00CC ),
|
CHANNEL_STATE_GRADIENT_MIDDLE_DATA( Color.BLUE,
|
||||||
"Data Gradient Middle", "Channel Data State Gradient Middle" ),
|
"Data Gradient Middle", "Channel Data State Gradient Middle" ),
|
||||||
CHANNEL_STATE_GRADIENT_TOP_FADE( Color.BLACK,
|
CHANNEL_STATE_GRADIENT_TOP_FADE( Color.BLACK,
|
||||||
"Fade Gradient Top", "Channel Fade State Gradient Top" ),
|
"Fade Gradient Top", "Channel Fade State Gradient Top" ),
|
||||||
|
|||||||
@@ -437,7 +437,8 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Something happened ... the above should always return an icon */
|
/* Something happened ... the above should always return an icon */
|
||||||
mLog.error( "couldn't return an icon named [" + name + "] of heigh [" + height + "]" );
|
mLog.error( "SettingsManager - couldn't return an icon named [" +
|
||||||
|
name + "] of heigh [" + height + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -635,7 +636,8 @@ public class SettingsManager
|
|||||||
|
|
||||||
return r820TConfig;
|
return r820TConfig;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException( "tuner type is unrecognized [" +
|
throw new IllegalArgumentException( "TunerConfiguration"
|
||||||
|
+ "Directory - tuner type is unrecognized [" +
|
||||||
type.toString() + "]" );
|
type.toString() + "]" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -709,7 +711,8 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
catch( Exception e )
|
catch( Exception e )
|
||||||
{
|
{
|
||||||
mLog.error( "couldn't create file to save settings [" + filePath.toString() + "]", e );
|
mLog.error( "SettingsManager - couldn't create file to save "
|
||||||
|
+ "settings [" + filePath.toString() + "]", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputStream out = null;
|
OutputStream out = null;
|
||||||
@@ -730,12 +733,14 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
catch ( JAXBException e )
|
catch ( JAXBException e )
|
||||||
{
|
{
|
||||||
mLog.error( "jaxb exception while saving settings", e );
|
mLog.error( "SettingsManager - jaxb exception while saving " +
|
||||||
|
"settings", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
mLog.error( "couldn't open outputstream to save settings [" + filePath.toString() + "]" );
|
mLog.error( "SettingsManager - coulcn't open outputstream to " +
|
||||||
|
"save settings [" + filePath.toString() + "]" );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -761,7 +766,8 @@ public class SettingsManager
|
|||||||
{
|
{
|
||||||
if( Files.exists( settingsPath ) )
|
if( Files.exists( settingsPath ) )
|
||||||
{
|
{
|
||||||
mLog.info( "loading settings file [" + settingsPath.toString() + "]" );
|
mLog.info( "SettingsManager - loading settings file [" +
|
||||||
|
settingsPath.toString() + "]" );
|
||||||
|
|
||||||
JAXBContext context = null;
|
JAXBContext context = null;
|
||||||
|
|
||||||
@@ -781,13 +787,13 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
catch ( JAXBException e )
|
catch ( JAXBException e )
|
||||||
{
|
{
|
||||||
mLog.error( "jaxb exception while loading " +
|
mLog.error( "SettingsManager - jaxb exception while loading " +
|
||||||
"settings", e );
|
"settings", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( Exception e )
|
catch ( Exception e )
|
||||||
{
|
{
|
||||||
mLog.error( "coulcn't open inputstream to " +
|
mLog.error( "SettingsManager - coulcn't open inputstream to " +
|
||||||
"load settings [" + settingsPath.toString() + "]", e );
|
"load settings [" + settingsPath.toString() + "]", e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
@@ -800,7 +806,7 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
catch ( IOException e )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
mLog.error( "exception while closing " +
|
mLog.error( "SettingsManager - exception while closing " +
|
||||||
"the settings file inputstream reader", e );
|
"the settings file inputstream reader", e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -808,7 +814,8 @@ public class SettingsManager
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLog.info( "settings does not exist [" + settingsPath.toString() + "]" );
|
mLog.info( "SettingsManager - settings does not exist [" +
|
||||||
|
settingsPath.toString() + "]" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mSettings == null )
|
if( mSettings == null )
|
||||||
|
|||||||
@@ -23,14 +23,6 @@ public class MixerChannelConfiguration
|
|||||||
return mMixerChannel;
|
return mMixerChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches( String mixer, String channels )
|
|
||||||
{
|
|
||||||
return mixer != null &&
|
|
||||||
channels != null &&
|
|
||||||
mMixer.getMixerInfo().getName().contentEquals( mixer ) &&
|
|
||||||
mMixerChannel.name().contentEquals( channels );
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|||||||
@@ -97,13 +97,9 @@ public class TunerChannel implements Comparable<TunerChannel>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo( TunerChannel otherTunerChannel )
|
public int compareTo( TunerChannel otherLock )
|
||||||
{
|
{
|
||||||
if( this.equals( otherTunerChannel ) )
|
if( mFrequency < otherLock.getFrequency() )
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if( mFrequency < otherTunerChannel.getFrequency() )
|
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import org.jtransforms.fft.FloatFFT_1D;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import properties.SystemProperties;
|
|
||||||
import sample.Buffer;
|
import sample.Buffer;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
@@ -62,8 +61,6 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
|||||||
private ScheduledExecutorService mScheduler = Executors
|
private ScheduledExecutorService mScheduler = Executors
|
||||||
.newScheduledThreadPool( 1, new NamingThreadFactory( "spectrum dft" ) );
|
.newScheduledThreadPool( 1, new NamingThreadFactory( "spectrum dft" ) );
|
||||||
|
|
||||||
public static final String FRAME_RATE_PROPERTY = "spectral.display.frame.rate";
|
|
||||||
|
|
||||||
private DFTSize mDFTSize = DFTSize.FFT04096;
|
private DFTSize mDFTSize = DFTSize.FFT04096;
|
||||||
private DFTSize mNewDFTSize = DFTSize.FFT04096;
|
private DFTSize mNewDFTSize = DFTSize.FFT04096;
|
||||||
|
|
||||||
@@ -92,16 +89,7 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
|||||||
public DFTProcessor( SampleType sampleType )
|
public DFTProcessor( SampleType sampleType )
|
||||||
{
|
{
|
||||||
setSampleType( sampleType );
|
setSampleType( sampleType );
|
||||||
|
setFrameRate( 20 );
|
||||||
loadSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadSettings()
|
|
||||||
{
|
|
||||||
int frameRate = SystemProperties.getInstance()
|
|
||||||
.get( DFTProcessor.FRAME_RATE_PROPERTY, 20 );
|
|
||||||
|
|
||||||
setFrameRate( frameRate );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
@@ -183,10 +171,6 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
|||||||
|
|
||||||
mFrameRate = framesPerSecond;
|
mFrameRate = framesPerSecond;
|
||||||
|
|
||||||
SystemProperties properties = SystemProperties.getInstance();
|
|
||||||
properties.set( FRAME_RATE_PROPERTY, String.valueOf( mFrameRate ) );
|
|
||||||
properties.save();
|
|
||||||
|
|
||||||
calculateConsumptionRate();
|
calculateConsumptionRate();
|
||||||
|
|
||||||
restart();
|
restart();
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import playlist.PlaylistManager;
|
import playlist.PlaylistManager;
|
||||||
import properties.SystemProperties;
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import sample.SampleType;
|
import sample.SampleType;
|
||||||
import sample.complex.ComplexBuffer;
|
import sample.complex.ComplexBuffer;
|
||||||
@@ -100,10 +99,8 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
|
|
||||||
private static DecimalFormat sCURSOR_FORMAT = new DecimalFormat( "000.00000" );
|
private static DecimalFormat sCURSOR_FORMAT = new DecimalFormat( "000.00000" );
|
||||||
|
|
||||||
public static final String FFT_SIZE_PROPERTY = "spectral.display.dft.size";
|
|
||||||
public static final int NO_ZOOM = 0;
|
public static final int NO_ZOOM = 0;
|
||||||
public static final int MAX_ZOOM = 6;
|
public static final int MAX_ZOOM = 6;
|
||||||
|
|
||||||
|
|
||||||
private DFTSize mDFTSize = DFTSize.FFT04096;
|
private DFTSize mDFTSize = DFTSize.FFT04096;
|
||||||
private int mZoom = 0;
|
private int mZoom = 0;
|
||||||
@@ -158,36 +155,6 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
loadSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadSettings()
|
|
||||||
{
|
|
||||||
SystemProperties properties = SystemProperties.getInstance();
|
|
||||||
|
|
||||||
String rawSize = properties.get( FFT_SIZE_PROPERTY, DFTSize.FFT04096.name() );
|
|
||||||
|
|
||||||
DFTSize size = null;
|
|
||||||
|
|
||||||
if( rawSize != null )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
size = DFTSize.valueOf( rawSize );
|
|
||||||
}
|
|
||||||
catch( Exception e )
|
|
||||||
{
|
|
||||||
//Do nothing, we couldn't parse the stored value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( size == null )
|
|
||||||
{
|
|
||||||
size = DFTSize.FFT04096;
|
|
||||||
}
|
|
||||||
|
|
||||||
setDFTSize( size );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
@@ -232,10 +199,6 @@ public class SpectralDisplayPanel extends JPanel
|
|||||||
mDFTProcessor.setDFTSize( size );
|
mDFTProcessor.setDFTSize( size );
|
||||||
mOverlayPanel.setDFTSize( size );
|
mOverlayPanel.setDFTSize( size );
|
||||||
mDFTSize = size;
|
mDFTSize = size;
|
||||||
|
|
||||||
SystemProperties properties = SystemProperties.getInstance();
|
|
||||||
properties.set( FFT_SIZE_PROPERTY, size.name() );
|
|
||||||
properties.save();
|
|
||||||
|
|
||||||
setZoom( 0, 0, 0 );
|
setZoom( 0, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,8 +121,6 @@ public class WaterfallPanel extends JPanel implements DFTResultsListener,
|
|||||||
mMemoryImageSource.setAnimated( true );
|
mMemoryImageSource.setAnimated( true );
|
||||||
|
|
||||||
mWaterfallImage = createImage( mMemoryImageSource );
|
mWaterfallImage = createImage( mMemoryImageSource );
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user