mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
wip #34 - testing and validating changes and testing decoding.
This commit is contained in:
@@ -121,6 +121,7 @@ import module.decode.p25.reference.LinkControlOpcode;
|
||||
import module.decode.p25.reference.Response;
|
||||
import module.decode.p25.reference.Service;
|
||||
import module.decode.p25.reference.Vendor;
|
||||
import module.decode.state.ChangeChannelTimeoutEvent;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderState;
|
||||
import module.decode.state.DecoderStateEvent;
|
||||
@@ -207,6 +208,10 @@ public class P25DecoderState extends DecoderState
|
||||
@Override
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
if( mChannelType == ChannelType.TRAFFIC )
|
||||
{
|
||||
broadcast( new ChangeChannelTimeoutEvent( this, ChannelType.TRAFFIC, 1000 ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2819,8 +2824,7 @@ public class P25DecoderState extends DecoderState
|
||||
broadcast( event );
|
||||
}
|
||||
|
||||
broadcast( new TrafficChannelAllocationEvent( this,
|
||||
mChannelCallMap.get( channel ) ) );
|
||||
broadcast( new TrafficChannelAllocationEvent( this, mChannelCallMap.get( channel ) ) );
|
||||
|
||||
if( gvcgu.hasChannelNumber2() )
|
||||
{
|
||||
|
||||
@@ -21,30 +21,27 @@ import java.util.concurrent.RejectedExecutionException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
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.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import audio.metadata.IMetadataProvider;
|
||||
import audio.metadata.Metadata;
|
||||
import audio.metadata.MetadataReset;
|
||||
import audio.metadata.MetadataType;
|
||||
import audio.squelch.ISquelchStateProvider;
|
||||
import audio.squelch.SquelchState;
|
||||
import controller.ThreadPoolManager;
|
||||
import controller.ThreadPoolManager.ThreadType;
|
||||
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;
|
||||
|
||||
public class ChannelState extends Module implements ICallEventProvider,
|
||||
IChangedAttributeProvider, IDecoderStateEventListener,
|
||||
IDecoderStateEventProvider, IMetadataProvider, ISquelchStateProvider
|
||||
public class ChannelState extends Module implements ICallEventProvider, IChangedAttributeProvider,
|
||||
IDecoderStateEventListener, IDecoderStateEventProvider, IMetadataProvider, ISquelchStateProvider
|
||||
{
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( ChannelState.class );
|
||||
@@ -66,18 +63,16 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
private boolean mSelected = false;
|
||||
|
||||
private long mStandardChannelFadeTimeout = FADE_TIMEOUT_DELAY;
|
||||
private long mTrafficChannelFadeTimeout =
|
||||
DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS * 1000;
|
||||
private long mTrafficChannelFadeTimeout = DecodeConfiguration.DEFAULT_CALL_TIMEOUT_SECONDS * 1000;
|
||||
private long mFadeTimeout;
|
||||
private long mEndTimeout;
|
||||
|
||||
private StateMonitor mStateMonitor = new StateMonitor();
|
||||
private AtomicBoolean mMonitoring = new AtomicBoolean();
|
||||
private ScheduledFuture<?> mStateMonitorFuture;
|
||||
|
||||
private ChannelType mChannelType;
|
||||
|
||||
private TrafficChannelStatusListener mTrafficChannelStatusListener;
|
||||
private TrafficChannelManager mTrafficChannelEndListener;
|
||||
private CallEvent mTrafficChannelCallEvent;
|
||||
|
||||
/**
|
||||
@@ -127,21 +122,20 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
@Override
|
||||
public void start( ScheduledExecutorService executor )
|
||||
{
|
||||
//Start a monitoring task to check for FADE and END event timeouts
|
||||
if( mMonitoring.compareAndSet( false, true ) )
|
||||
if( mStateMonitorFuture == null && mStateMonitor != null )
|
||||
{
|
||||
if( mStateMonitorFuture == null && mStateMonitor != null )
|
||||
if( mTrafficChannelEndListener != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
mStateMonitorFuture = executor.scheduleAtFixedRate(
|
||||
mStateMonitor, 0, 20, TimeUnit.MILLISECONDS );
|
||||
}
|
||||
catch( RejectedExecutionException ree )
|
||||
{
|
||||
mLog.error( "state monitor scheduled task rejected", ree );
|
||||
mMonitoring.set( false );
|
||||
}
|
||||
setState( State.CALL );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
mStateMonitorFuture = executor.scheduleAtFixedRate( mStateMonitor, 0, 20, TimeUnit.MILLISECONDS );
|
||||
}
|
||||
catch( RejectedExecutionException ree )
|
||||
{
|
||||
mLog.error( "state monitor scheduled task rejected", ree );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,23 +143,29 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
mSquelchLocked = false;
|
||||
|
||||
//Shutdown the state montoring task
|
||||
if( mMonitoring.compareAndSet( true, false ) )
|
||||
if( mStateMonitorFuture != null )
|
||||
{
|
||||
if( mStateMonitorFuture != null )
|
||||
{
|
||||
boolean success = mStateMonitorFuture.cancel( true );
|
||||
|
||||
if( !success )
|
||||
{
|
||||
mLog.error("Couldn't stop monitoring scheduled future" );
|
||||
}
|
||||
}
|
||||
boolean success = mStateMonitorFuture.cancel( true );
|
||||
|
||||
mStateMonitorFuture = null;
|
||||
if( !success )
|
||||
{
|
||||
mLog.error("Couldn't stop monitoring scheduled future" );
|
||||
}
|
||||
}
|
||||
|
||||
mTrafficChannelEndListener = null;
|
||||
|
||||
if( mTrafficChannelCallEvent != null )
|
||||
{
|
||||
mTrafficChannelCallEvent.end();
|
||||
broadcast( mTrafficChannelCallEvent );
|
||||
}
|
||||
|
||||
mTrafficChannelCallEvent = null;
|
||||
|
||||
mStateMonitorFuture = null;
|
||||
|
||||
mSquelchLocked = false;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
@@ -203,7 +203,7 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
|
||||
if( mChannelType == ChannelType.TRAFFIC )
|
||||
{
|
||||
mFadeTimeout = mTrafficChannelFadeTimeout;
|
||||
mFadeTimeout = System.currentTimeMillis() + mTrafficChannelFadeTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +235,7 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
{
|
||||
mFadeTimeout = System.currentTimeMillis() + mStandardChannelFadeTimeout;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,23 +388,9 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
|
||||
broadcast( ChangedAttribute.CHANNEL_STATE );
|
||||
|
||||
if( mTrafficChannelCallEvent != null )
|
||||
if( mTrafficChannelEndListener != 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");
|
||||
mTrafficChannelEndListener.callEnd( mTrafficChannelCallEvent.getChannel() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,11 +515,11 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
* Registers a listener to be notified when a traffic channel call event is
|
||||
* completed, so that the listener can perform call tear-down
|
||||
*/
|
||||
public void configureAsTrafficChannel( TrafficChannelStatusListener listener,
|
||||
TrafficChannelAllocationEvent allocationEvent )
|
||||
public void configureAsTrafficChannel( TrafficChannelManager manager, CallEvent callEvent )
|
||||
{
|
||||
mTrafficChannelStatusListener = listener;
|
||||
mTrafficChannelCallEvent = allocationEvent.getCallEvent();
|
||||
mTrafficChannelEndListener = manager;
|
||||
|
||||
mTrafficChannelCallEvent = callEvent;
|
||||
|
||||
/* Broadcast the call event details as metadata for the audio manager */
|
||||
String channel = mTrafficChannelCallEvent.getChannel();
|
||||
@@ -541,9 +528,9 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
{
|
||||
broadcast( new Metadata( MetadataType.CHANNEL_NUMBER, channel, true ) );
|
||||
}
|
||||
|
||||
|
||||
broadcast( new Metadata( MetadataType.PROTOCOL,
|
||||
mTrafficChannelCallEvent.getDecoderType().getDisplayString(), true ) );
|
||||
mTrafficChannelCallEvent.getDecoderType().getDisplayString(), true ) );
|
||||
|
||||
String details = mTrafficChannelCallEvent.getDetails();
|
||||
|
||||
@@ -572,13 +559,12 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
|
||||
if( frequency > 0 )
|
||||
{
|
||||
broadcast( new Metadata( MetadataType.FREQUENCY,
|
||||
String.valueOf( frequency ), true ) );
|
||||
broadcast( new Metadata( MetadataType.FREQUENCY, String.valueOf( frequency ), true ) );
|
||||
}
|
||||
|
||||
/* Rebroadcast the allocation event so that the internal decoder states
|
||||
* can self-configure with the call event details */
|
||||
broadcast( allocationEvent );
|
||||
broadcast( mTrafficChannelCallEvent );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -660,7 +646,6 @@ public class ChannelState extends Module implements ICallEventProvider,
|
||||
if( State.CALL_STATES.contains( mState ) &&
|
||||
mFadeTimeout <= System.currentTimeMillis() )
|
||||
{
|
||||
mState = State.FADE;
|
||||
processFadeState();
|
||||
}
|
||||
else if( mState == State.FADE &&
|
||||
|
||||
@@ -103,11 +103,8 @@ public enum State
|
||||
|
||||
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 );
|
||||
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 )
|
||||
{
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import module.Module;
|
||||
import module.ProcessingChain;
|
||||
import module.decode.config.DecodeConfiguration;
|
||||
import module.decode.event.CallEvent;
|
||||
import module.decode.event.CallEvent.CallEventType;
|
||||
@@ -29,6 +28,7 @@ import controller.channel.ChannelEvent;
|
||||
import controller.channel.ChannelEvent.Event;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.TrafficChannelEvent;
|
||||
|
||||
public class TrafficChannelManager extends Module
|
||||
implements ICallEventProvider, IDecoderStateEventListener
|
||||
@@ -148,7 +148,7 @@ public class TrafficChannelManager extends Module
|
||||
mTrafficChannelPool.add( channel );
|
||||
}
|
||||
|
||||
/* If we have a configured channel, start it and track it */
|
||||
/* If we have a configured channel, update metadata */
|
||||
if( channel != null )
|
||||
{
|
||||
channel.setSourceConfiguration( new SourceConfigTuner( tunerChannel ) );
|
||||
@@ -156,11 +156,7 @@ public class TrafficChannelManager extends Module
|
||||
channel.setSite( mSite );
|
||||
channel.setName( channelNumber );
|
||||
|
||||
mChannelModel.broadcast( new ChannelEvent( channel,
|
||||
Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
|
||||
|
||||
mChannelModel.broadcast( new ChannelEvent( channel,
|
||||
Event.REQUEST_ENABLE ) );
|
||||
mChannelModel.broadcast( new ChannelEvent( channel, Event.NOTIFICATION_CONFIGURATION_CHANGE ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,35 +197,25 @@ public class TrafficChannelManager extends Module
|
||||
}
|
||||
else if( frequency > 0 )
|
||||
{
|
||||
Channel channel = getChannel( callEvent.getChannel(),
|
||||
new TunerChannel( Type.TRAFFIC, frequency,
|
||||
mDecodeConfiguration.getDecoderType()
|
||||
.getChannelBandwidth() ) );
|
||||
Channel channel = getChannel( callEvent.getChannel(), new TunerChannel( Type.TRAFFIC,
|
||||
frequency, mDecodeConfiguration.getDecoderType().getChannelBandwidth() ) );
|
||||
|
||||
if( channel != null )
|
||||
{
|
||||
TrafficChannelEvent trafficChannelEvent =
|
||||
new TrafficChannelEvent( this, channel, Event.REQUEST_ENABLE, callEvent );
|
||||
|
||||
//Request to enable the channel
|
||||
mChannelModel.broadcast( trafficChannelEvent );
|
||||
|
||||
if( channel.getEnabled() )
|
||||
{
|
||||
ProcessingChain chain = mChannelProcessingManager
|
||||
.getProcessingChain( channel );
|
||||
|
||||
if( chain != null )
|
||||
{
|
||||
ChannelState state = chain.getChannelState();
|
||||
|
||||
/* Register as a listener to be notified when the call
|
||||
* is completed */
|
||||
state.configureAsTrafficChannel(
|
||||
new TrafficChannelStatusListener( this,
|
||||
callEvent.getChannel() ), event );
|
||||
|
||||
/* Set state to call so that audio squelch state is correct */
|
||||
state.setState( State.CALL );
|
||||
}
|
||||
mTrafficChannelsInUse.put( callEvent.getChannel(), channel );
|
||||
}
|
||||
else
|
||||
{
|
||||
callEvent.setCallEventType( CallEventType.CALL_DETECT );
|
||||
callEvent.setDetails( "CHANNEL START REJECTED" );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -394,7 +380,7 @@ public class TrafficChannelManager extends Module
|
||||
if( channelNumber != null && mTrafficChannelsInUse.containsKey( channelNumber ) )
|
||||
{
|
||||
Channel channel = mTrafficChannelsInUse.get( channelNumber );
|
||||
|
||||
|
||||
mChannelModel.broadcast( new ChannelEvent( channel, Event.REQUEST_DISABLE ) );
|
||||
|
||||
mTrafficChannelsInUse.remove( channelNumber );
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package module.decode.state;
|
||||
|
||||
public class TrafficChannelStatusListener
|
||||
{
|
||||
private TrafficChannelManager mTrafficChannelManager;
|
||||
private String mChannelNumber;
|
||||
|
||||
public TrafficChannelStatusListener( TrafficChannelManager manager, String channelNumber )
|
||||
{
|
||||
mTrafficChannelManager = manager;
|
||||
mChannelNumber = channelNumber;
|
||||
}
|
||||
|
||||
public void callEnd()
|
||||
{
|
||||
if( mTrafficChannelManager != null )
|
||||
{
|
||||
mTrafficChannelManager.callEnd( mChannelNumber );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user