Resolved issue with channel label display in spectrum overlay panel

when a new tuner is added.

Cleanup of debugging messages.
This commit is contained in:
denny
2015-11-22 14:25:37 -05:00
parent 547da54340
commit f04a6727b0
18 changed files with 64 additions and 171 deletions

View File

@@ -48,7 +48,7 @@ public class ClipAction extends RecurringAction
} }
catch( Exception e ) catch( Exception e )
{ {
mLog.debug( "Couldn't play audio clip", e ); mLog.error( "Couldn't play audio clip", e );
} }
} }

View File

@@ -40,7 +40,7 @@ public class ScriptAction extends RecurringAction
} }
catch( Exception e ) catch( Exception e )
{ {
mLog.debug( "Couldn't execute script [" + mScript + "]", e ); mLog.error( "Couldn't execute script [" + mScript + "]", e );
} }
} }

View File

@@ -124,7 +124,10 @@ public class AudioModule extends Module implements IAudioPacketProvider,
AudioPacket packet = new AudioPacket( audio, mAudioMetadata.copyOf() ); AudioPacket packet = new AudioPacket( audio, mAudioMetadata.copyOf() );
mAudioPacketListener.receive( packet ); if( mAudioPacketListener != null )
{
mAudioPacketListener.receive( packet );
}
} }
} }

View File

@@ -165,7 +165,7 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
} }
catch( AudioException e ) catch( AudioException e )
{ {
mLog.debug( "Error while detecting current mixer " mLog.error( "Error while detecting current mixer "
+ "channel configuration", e ); + "channel configuration", e );
} }

View File

@@ -740,7 +740,6 @@ public class Channel extends Configuration
public void setup() throws SourceException public void setup() throws SourceException
{ {
setupProcessingChain(); setupProcessingChain();
setupSource(); setupSource();
} }

View File

@@ -1,6 +1,6 @@
/******************************************************************************* /*******************************************************************************
* SDR Trunk * SDR Trunk
* Copyright (C) 2014 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
@@ -18,6 +18,7 @@
package controller.channel; package controller.channel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import message.Message; import message.Message;
@@ -32,12 +33,9 @@ public class ChannelManager implements ChannelEventListener
{ {
private final static Logger mLog = LoggerFactory.getLogger( ChannelManager.class ); private final static Logger mLog = LoggerFactory.getLogger( ChannelManager.class );
private ArrayList<Channel> mChannels = new ArrayList<Channel>(); private List<Channel> mChannels = new ArrayList<>();
private List<ChannelEventListener> mChannelListeners = new ArrayList<>();
private ArrayList<ChannelEventListener> mChannelListeners = private List<Listener<Message>> mMessageListeners = new ArrayList<>();
new ArrayList<ChannelEventListener>();
private ArrayList<Listener<Message>> mMessageListeners =
new ArrayList<Listener<Message>>();
private AliasActionManager mAliasActionManager; private AliasActionManager mAliasActionManager;
@@ -62,13 +60,13 @@ public class ChannelManager implements ChannelEventListener
{ {
switch( event.getEvent() ) switch( event.getEvent() )
{ {
case CHANNEL_ENABLED: case CHANNEL_ADDED:
if( !mChannels.contains( event.getChannel() ) ) if( !mChannels.contains( event.getChannel() ) )
{ {
mChannels.add( event.getChannel() ); mChannels.add( event.getChannel() );
} }
break; break;
case CHANNEL_DISABLED: case CHANNEL_DELETED:
mChannels.remove( event.getChannel() ); mChannels.remove( event.getChannel() );
break; break;
} }
@@ -89,6 +87,11 @@ public class ChannelManager implements ChannelEventListener
} }
} }
public List<Channel> getChannels()
{
return mChannels;
}
/** /**
* Removes a channel listener from being automatically added to all channels * Removes a channel listener from being automatically added to all channels
* to receive channel change events. * to receive channel change events.
@@ -107,7 +110,7 @@ public class ChannelManager implements ChannelEventListener
* Returns the list of channel change listeners that will be automatically * Returns the list of channel change listeners that will be automatically
* added to all channels to receive channel change events * added to all channels to receive channel change events
*/ */
public ArrayList<ChannelEventListener> getChannelListeners() public List<ChannelEventListener> getChannelListeners()
{ {
return mChannelListeners; return mChannelListeners;
} }
@@ -116,7 +119,7 @@ public class ChannelManager implements ChannelEventListener
* Returns the list of channel change listeners that will be automatically * Returns the list of channel change listeners that will be automatically
* added to all channels to receive channel change events * added to all channels to receive channel change events
*/ */
public ArrayList<Listener<Message>> getMessageListeners() public List<Listener<Message>> getMessageListeners()
{ {
return mMessageListeners; return mMessageListeners;
} }

View File

@@ -19,9 +19,7 @@ package module;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import message.IMessageListener; import message.IMessageListener;
@@ -64,7 +62,6 @@ import audio.squelch.ISquelchStateListener;
import audio.squelch.ISquelchStateProvider; import audio.squelch.ISquelchStateProvider;
import audio.squelch.SquelchState; import audio.squelch.SquelchState;
import controller.ThreadPoolManager; import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
import controller.channel.ChannelEvent; import controller.channel.ChannelEvent;
import controller.channel.IChannelEventListener; import controller.channel.IChannelEventListener;
import controller.channel.IChannelEventProvider; import controller.channel.IChannelEventProvider;
@@ -92,9 +89,6 @@ public class ProcessingChain implements IChannelEventListener
private final static Logger mLog = private final static Logger mLog =
LoggerFactory.getLogger( ProcessingChain.class ); LoggerFactory.getLogger( ProcessingChain.class );
private BufferReceiver<ComplexBuffer> mComplexReceiver = new BufferReceiver<>( 5 );
private BufferReceiver<RealBuffer> mRealReceiver = new BufferReceiver<>( 5 );
private Broadcaster<AudioPacket> mAudioPacketBroadcaster = new Broadcaster<>(); private Broadcaster<AudioPacket> mAudioPacketBroadcaster = new Broadcaster<>();
private Broadcaster<Metadata> mMetadataBroadcaster = new Broadcaster<>(); private Broadcaster<Metadata> mMetadataBroadcaster = new Broadcaster<>();
private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>(); private Broadcaster<CallEvent> mCallEventBroadcaster = new Broadcaster<>();
@@ -134,11 +128,11 @@ public class ProcessingChain implements IChannelEventListener
mModules.clear(); mModules.clear();
mComplexReceiver.dispose(); // mComplexReceiver.dispose();
mComplexReceiver = null; // mComplexReceiver = null;
//
mRealReceiver.dispose(); // mRealReceiver.dispose();
mRealReceiver = null; // mRealReceiver = null;
mThreadPoolManager = null; mThreadPoolManager = null;
mBufferProcessingTask = null; mBufferProcessingTask = null;
@@ -429,9 +423,6 @@ public class ProcessingChain implements IChannelEventListener
/* Register with the source to receive sample data. Setup a /* Register with the source to receive sample data. Setup a
* timer task to process the buffer queues 50 times a second * timer task to process the buffer queues 50 times a second
* (every 20 ms) */ * (every 20 ms) */
mBufferProcessingTask = mThreadPoolManager.scheduleFixedRate(
ThreadType.DECODER, new BufferProcessor(), 20, TimeUnit.MILLISECONDS );
switch( mSource.getSampleType() ) switch( mSource.getSampleType() )
{ {
case COMPLEX: case COMPLEX:
@@ -463,6 +454,10 @@ public class ProcessingChain implements IChannelEventListener
} }
} }
} }
else
{
mLog.debug( "Source is null on start()" );
}
} }
} }
@@ -612,91 +607,6 @@ public class ProcessingChain implements IChannelEventListener
mRealBufferBroadcaster.removeListener( listener ); mRealBufferBroadcaster.removeListener( listener );
} }
/**
* Processes complex and real sample buffers and broadcasts buffers to any
* registered listeners.
*/
private class BufferProcessor implements Runnable
{
private AtomicBoolean mProcessing = new AtomicBoolean();
@Override
public void run()
{
/* Allow only one instance of this processor to run to ensure
* correct serial processing of incoming buffers. Overlapping
* invocations of this processor by the timer service will end
* immediately without doing anything for cases where a single
* iteration runs longer than the scheduled processing interval */
if( mProcessing.compareAndSet( false, true ) )
{
try
{
for( ComplexBuffer buffer: mComplexReceiver.get() )
{
mComplexBufferBroadcaster.broadcast( buffer );
}
}
catch( Exception e )
{
mLog.error( "Error processing complex sample buffers", e );
}
try
{
for( RealBuffer buffer: mRealReceiver.get() )
{
mRealBufferBroadcaster.broadcast( buffer );
}
}
catch( Exception e )
{
mLog.error( "Error processing real sample buffers", e );
}
mProcessing.set( false );
}
}
}
/**
* Buffer receiver - non-blocking receiver to allow calling thread to return
* without blocking on any internal processing. This ensures that we don't
* impair any receiver sample processing.
*/
private class BufferReceiver<T> implements Listener<T>
{
private LinkedTransferQueue<T> mQueue = new LinkedTransferQueue<>();
private int mMaxFetchSize;
public BufferReceiver( int maxFetchSize )
{
mMaxFetchSize = maxFetchSize;
}
@Override
public void receive( T t )
{
mQueue.add( t );
}
public List<T> get()
{
List<T> buffers = new ArrayList<>();
mQueue.drainTo( buffers, mMaxFetchSize );
return buffers;
}
public void dispose()
{
mQueue.clear();
mQueue = null;
}
}
@Override @Override
public Listener<ChannelEvent> getChannelEventListener() public Listener<ChannelEvent> getChannelEventListener()
{ {

View File

@@ -255,9 +255,9 @@ public class C4FMSymbolFilter implements FrequencyCorrectionResetListener,
{ {
mFrequencyCorrectionControl.adjust( mFrequencyAdjustmentRequested ); mFrequencyCorrectionControl.adjust( mFrequencyAdjustmentRequested );
mLog.debug( "Adjusting frequency [" + mFrequencyAdjustmentRequested + // mLog.debug( "Adjusting frequency [" + mFrequencyAdjustmentRequested +
"] correction is now: " + mFrequencyCorrectionControl // "] correction is now: " + mFrequencyCorrectionControl
.getErrorCorrection() ); // .getErrorCorrection() );
mFrequencyAdjustmentRequested = 0; mFrequencyAdjustmentRequested = 0;

View File

@@ -137,25 +137,4 @@ public class P25Interleave
return message; return message;
} }
public static void main( String[] args )
{
int start = 0;
int end = 144;
int set = 50;
String interleaved = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
BinaryMessage b = BinaryMessage.load( interleaved );
b.set( set );
mLog.debug( "INT:" + b.toString() );
P25Interleave.deinterleaveVoice( b, start, end );
mLog.debug( "DEI:" + b.toString() );
mLog.debug( "In: " + set + " Out:" + b.nextSetBit( 0 ) );
}
} }

View File

@@ -165,7 +165,7 @@ public class P25AudioModule extends Module implements Listener<Message>,
} }
else else
{ {
mLog.debug( "JMBE library version 0.3.1 or higher is required - found: " + library.getVersion() ); mLog.warn( "JMBE library version 0.3.1 or higher is required - found: " + library.getVersion() );
} }
} }
catch ( ClassNotFoundException e1 ) catch ( ClassNotFoundException e1 )

View File

@@ -229,16 +229,4 @@ public class LDU2Message extends LDUMessage
{ {
return mMessage.getInt( KEY_ID ); return mMessage.getInt( KEY_ID );
} }
public static void main( String[] args )
{
String msg = "001010100000101010011010001001001001010011000111000111110111001100000010000101001011110111111000001100111100110000000010001110011011001101101101101101110011110011010000101111001111000011000010110010011110110010000100101101101001100000100000100001011100000000001110011111011000100100000000011011100000111111111101111010110111000111100011010111111110111000000000000000000000000000000000000000000100100001110110101111011000011010010100011001000101001011100101111011000001101100010101111001000100001111011111011001111110100111001100110110000000000000000000000000000000000000000000000101000001011110111010110010000100010110001100001101001110111001000111100100111011011011110101011111011000010100110111001000101000010011101010000000000000000000000000000000000000000001001000001000011011110110011110011001111100100000111000101001110111011110101001000101001100001110001100000000110000110000001011110000000101100110000011100000000000000000000000000000000111011001010000111111111111110000110110011000100101011000001111110000101000101111010101010101000100110111000100100111110010101010000100111010111010111010001011010010001011011001001001011100000101000010010010111100000110010000101010000110101100101111100110111100010001011011110101001011010100010000111000010000001001001001101000100110101011110100111100011111110101100000011011011001000001010100011001010100110000111100101011100110110011111100011011111110100111011101011111100001111011000101100011101000110001101000000000000000000000000000000000010001101101011101111010101010000111011011101001011111001110111001000010101011010000001011010111010000011011001100010110001010001000010001101101";
BinaryMessage message = BinaryMessage.load( msg );
LDU2Message ldu2 = new LDU2Message( message, DataUnitID.LDU2, null );
mLog.debug( ldu2.getMessage() );
mLog.debug( "CRC: " + CRC.format( ldu2.getCRCResults() ));
}
} }

View File

@@ -129,6 +129,7 @@ public class ChannelState extends Module implements ICallEventProvider,
@Override @Override
public void stop() public void stop()
{ {
mSquelchLocked = false;
} }
public void dispose() public void dispose()

View File

@@ -19,11 +19,19 @@ package sample;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import module.decode.state.ChannelState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Broadcasts a received float sample to multiple listeners * Broadcasts a received float sample to multiple listeners
*/ */
public class Broadcaster<T> implements Listener<T> public class Broadcaster<T> implements Listener<T>
{ {
private final static Logger mLog =
LoggerFactory.getLogger( Broadcaster.class );
private CopyOnWriteArrayList<Listener<T>> mListeners = private CopyOnWriteArrayList<Listener<T>> mListeners =
new CopyOnWriteArrayList<Listener<T>>(); new CopyOnWriteArrayList<Listener<T>>();

View File

@@ -109,7 +109,7 @@ public class AirspyTuner extends Tuner
} }
catch ( SourceException e ) catch ( SourceException e )
{ {
mLog.debug( "Error while getting sample rate from controller", e ); mLog.error( "Error while getting sample rate from controller", e );
} }
return rate; return rate;

View File

@@ -597,7 +597,7 @@ public class AirspyTunerController extends TunerController
{ {
int count = EndianUtils.readSwappedInteger( rawCount, 0 ); int count = EndianUtils.readSwappedInteger( rawCount, 0 );
mLog.debug( "There are [" + count + "] sample rates available" ); mLog.info( "There are [" + count + "] sample rates available" );
byte[] rawRates = readArray( Command.GET_SAMPLE_RATES, 0, byte[] rawRates = readArray( Command.GET_SAMPLE_RATES, 0,
count, ( count * 4 ) ); count, ( count * 4 ) );

View File

@@ -927,7 +927,7 @@ public class HackRFTunerController extends TunerController
{ {
if( mRunning.compareAndSet( false, true ) ) if( mRunning.compareAndSet( false, true ) )
{ {
mLog.debug( "starting sample fetch thread" ); mLog.info( "starting HackRF sample fetch thread" );
prepareTransfers(); prepareTransfers();
@@ -969,7 +969,7 @@ public class HackRFTunerController extends TunerController
{ {
if( mRunning.compareAndSet( true, false ) ) if( mRunning.compareAndSet( true, false ) )
{ {
mLog.debug( "stopping sample fetch thread" ); mLog.info( "stopping HackRF sample fetch thread" );
cancel(); cancel();

View File

@@ -207,8 +207,9 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
} }
catch ( InterruptedException e ) catch ( InterruptedException e )
{ {
mLog.error( "DFTProcessor - exception while awaiting shutdown of " /* Do nothing ... we're shutting down */
+ "calculation scheduler for reset", e ); // mLog.error( "DFTProcessor - exception while awaiting shutdown of "
// + "calculation scheduler for reset", e );
} }
} }

View File

@@ -32,6 +32,7 @@ import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.JPanel; import javax.swing.JPanel;
@@ -96,9 +97,9 @@ public class OverlayPanel extends JPanel
private Color mColorSpectrumCursor; private Color mColorSpectrumCursor;
private Color mColorSpectrumLine; private Color mColorSpectrumLine;
//All channels // //All channels
private ArrayList<Channel> mChannels = new ArrayList<Channel>(); // private List<Channel> mChannels = new ArrayList<Channel>();
//
//Currently visible/displayable channels //Currently visible/displayable channels
private CopyOnWriteArrayList<Channel> mVisibleChannels = private CopyOnWriteArrayList<Channel> mVisibleChannels =
new CopyOnWriteArrayList<Channel>(); new CopyOnWriteArrayList<Channel>();
@@ -151,7 +152,7 @@ public class OverlayPanel extends JPanel
mChannelManager = null; mChannelManager = null;
mChannels.clear(); // mChannels.clear();
mVisibleChannels.clear(); mVisibleChannels.clear();
if( mSettingsManager != null ) if( mSettingsManager != null )
@@ -678,7 +679,7 @@ public class OverlayPanel extends JPanel
long minimum = getMinFrequency(); long minimum = getMinFrequency();
long maximum = getMaxFrequency(); long maximum = getMaxFrequency();
for( Channel channel: mChannels ) for( Channel channel: mChannelManager.getChannels() )
{ {
if( channel.isWithin( minimum, maximum ) ) if( channel.isWithin( minimum, maximum ) )
{ {
@@ -698,12 +699,12 @@ public class OverlayPanel extends JPanel
switch( event.getEvent() ) switch( event.getEvent() )
{ {
case CHANNEL_ADDED: // case CHANNEL_ADDED:
case CHANNEL_ENABLED: case CHANNEL_ENABLED:
if( !mChannels.contains( channel ) ) // if( !mChannels.contains( channel ) )
{ // {
mChannels.add( channel ); // mChannels.add( channel );
} // }
if( channel.isWithin( getMinFrequency(), getMaxFrequency() ) && if( channel.isWithin( getMinFrequency(), getMaxFrequency() ) &&
!mVisibleChannels.contains( channel ) ) !mVisibleChannels.contains( channel ) )
@@ -712,13 +713,13 @@ public class OverlayPanel extends JPanel
} }
break; break;
case CHANNEL_DELETED: case CHANNEL_DELETED:
mChannels.remove( channel ); // mChannels.remove( channel );
mVisibleChannels.remove( channel ); mVisibleChannels.remove( channel );
break; break;
case CHANNEL_PROCESSING_STOPPED: case CHANNEL_PROCESSING_STOPPED:
if( channel.getChannelType() == ChannelType.TRAFFIC ) if( channel.getChannelType() == ChannelType.TRAFFIC )
{ {
mChannels.remove( channel ); // mChannels.remove( channel );
mVisibleChannels.remove( channel ); mVisibleChannels.remove( channel );
} }
break; break;