mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
Work in progress.
-Started work on new channel editor channel viewer/controller -Removed a number of unused buffer package classes -Moved automatic frequency control to be a module and removed special handling -Added IUnfilteredRealBufferListener & Provider interfaces -Completely removed the ResourceManager class
This commit is contained in:
@@ -6,7 +6,6 @@ import java.awt.event.ComponentListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import javax.swing.JLayeredPane;
|
||||
@@ -16,15 +15,16 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import module.ProcessingChain;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import sample.Listener;
|
||||
import sample.SampleType;
|
||||
import sample.complex.ComplexBuffer;
|
||||
import sample.real.RealBuffer;
|
||||
import sample.real.RealSampleListener;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.ColorSettingMenuItem;
|
||||
import settings.Setting;
|
||||
@@ -40,15 +40,13 @@ import spectrum.menu.FFTWindowTypeItem;
|
||||
import spectrum.menu.FrameRateItem;
|
||||
import spectrum.menu.SmoothingItem;
|
||||
import spectrum.menu.SmoothingTypeItem;
|
||||
import controller.ResourceManager;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEvent;
|
||||
import controller.channel.ChannelEventListener;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import dsp.filter.Filters;
|
||||
import dsp.filter.FloatHalfBandFilter;
|
||||
import dsp.filter.Window.WindowType;
|
||||
import dsp.filter.halfband.real.HalfBandFilter_RB_RB;
|
||||
import dsp.filter.hilbert.HilbertTransform;
|
||||
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
|
||||
|
||||
public class ChannelSpectrumPanel extends JPanel
|
||||
@@ -61,7 +59,6 @@ public class ChannelSpectrumPanel extends JPanel
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// private ResourceManager mResourceManager;
|
||||
private DFTProcessor mDFTProcessor = new DFTProcessor( SampleType.REAL );
|
||||
private DFTResultsConverter mDFTConverter = new RealDecibelConverter();
|
||||
private JLayeredPane mLayeredPane;
|
||||
@@ -80,10 +77,13 @@ public class ChannelSpectrumPanel extends JPanel
|
||||
private AtomicBoolean mEnabled = new AtomicBoolean();
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
|
||||
public ChannelSpectrumPanel( SettingsManager settingsManager )
|
||||
public ChannelSpectrumPanel( SettingsManager settingsManager,
|
||||
ChannelProcessingManager channelProcessingManager )
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
|
||||
if( mSettingsManager != null )
|
||||
{
|
||||
@@ -99,7 +99,7 @@ public class ChannelSpectrumPanel extends JPanel
|
||||
|
||||
/* Set the DFTProcessor to the decimated 24kHz sample rate */
|
||||
mDFTProcessor.frequencyChanged(
|
||||
new FrequencyChangeEvent( Event.SAMPLE_RATE_CHANGE_NOTIFICATION, 24000 ) );
|
||||
new FrequencyChangeEvent( Event.NOTIFICATION_SAMPLE_RATE_CHANGE, 24000 ) );
|
||||
|
||||
initGui();
|
||||
}
|
||||
@@ -167,14 +167,17 @@ public class ChannelSpectrumPanel extends JPanel
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case NOTIFICATION_SELECTION_CHANGE:
|
||||
if( !event.getChannel().isSelected() )
|
||||
//ChannelSelectionManager ensures that only 1 channel can be
|
||||
//selected and any previously selected channel will be first
|
||||
//deselected before we get a new selection event
|
||||
if( event.getChannel().isSelected() )
|
||||
{
|
||||
stop();
|
||||
if( mCurrentChannel != null )
|
||||
{
|
||||
stop();
|
||||
mCurrentChannel = null;
|
||||
}
|
||||
|
||||
mCurrentChannel = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
mCurrentChannel = event.getChannel();
|
||||
|
||||
if( mEnabled.get() )
|
||||
@@ -182,17 +185,13 @@ public class ChannelSpectrumPanel extends JPanel
|
||||
start();
|
||||
}
|
||||
}
|
||||
if( event.getChannel().isSelected() &&
|
||||
mCurrentChannel != event.getChannel() )
|
||||
else
|
||||
{
|
||||
stop();
|
||||
|
||||
mCurrentChannel = event.getChannel();
|
||||
|
||||
start();
|
||||
mCurrentChannel = null;
|
||||
}
|
||||
break;
|
||||
case REQUEST_DISABLE:
|
||||
case NOTIFICATION_PROCESSING_STOP:
|
||||
if( event.getChannel() == mCurrentChannel )
|
||||
{
|
||||
if( mEnabled.get() )
|
||||
@@ -203,32 +202,36 @@ public class ChannelSpectrumPanel extends JPanel
|
||||
mCurrentChannel = null;
|
||||
}
|
||||
break;
|
||||
case REQUEST_ENABLE:
|
||||
if( event.getChannel() == mCurrentChannel &&
|
||||
!event.getChannel().isProcessing() )
|
||||
{
|
||||
stop();
|
||||
mCurrentChannel = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void start()
|
||||
{
|
||||
if( mEnabled.get() && mCurrentChannel != null && mCurrentChannel.isProcessing() )
|
||||
if( mEnabled.get() && mCurrentChannel != null && mCurrentChannel.getEnabled() )
|
||||
{
|
||||
mCurrentChannel.getProcessingChain().addRealBufferListener( this );
|
||||
mDFTProcessor.start();
|
||||
ProcessingChain processingChain = mChannelProcessingManager
|
||||
.getProcessingChain( mCurrentChannel );
|
||||
|
||||
if( processingChain != null )
|
||||
{
|
||||
processingChain.addRealBufferListener( this );
|
||||
|
||||
mDFTProcessor.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void stop()
|
||||
{
|
||||
|
||||
if( mCurrentChannel != null && mCurrentChannel.isProcessing() )
|
||||
if( mCurrentChannel != null && mCurrentChannel.getEnabled() )
|
||||
{
|
||||
mCurrentChannel.getProcessingChain().removeRealBufferListener( this );
|
||||
ProcessingChain processingChain = mChannelProcessingManager
|
||||
.getProcessingChain( mCurrentChannel );
|
||||
|
||||
if( processingChain != null )
|
||||
{
|
||||
processingChain.removeRealBufferListener( this );
|
||||
}
|
||||
}
|
||||
|
||||
mDFTProcessor.stop();
|
||||
|
||||
@@ -36,7 +36,7 @@ import sample.Listener;
|
||||
import sample.SampleType;
|
||||
import sample.complex.ComplexBuffer;
|
||||
import source.tuner.frequency.FrequencyChangeEvent;
|
||||
import source.tuner.frequency.FrequencyChangeListener;
|
||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||
import spectrum.converter.DFTResultsConverter;
|
||||
import controller.NamingThreadFactory;
|
||||
import dsp.filter.Window;
|
||||
@@ -47,7 +47,7 @@ import dsp.filter.Window.WindowType;
|
||||
* of DFT results, using configurable fft size and output dispatch timelines.
|
||||
*/
|
||||
public class DFTProcessor implements Listener<ComplexBuffer>,
|
||||
FrequencyChangeListener,
|
||||
IFrequencyChangeProcessor,
|
||||
IDFTWidthChangeProcessor
|
||||
{
|
||||
private final static Logger mLog =
|
||||
@@ -494,7 +494,7 @@ public class DFTProcessor implements Listener<ComplexBuffer>,
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case SAMPLE_RATE_CHANGE_NOTIFICATION:
|
||||
case NOTIFICATION_SAMPLE_RATE_CHANGE:
|
||||
mSampleRate = event.getValue().intValue();
|
||||
calculateConsumptionRate();
|
||||
break;
|
||||
|
||||
@@ -46,7 +46,7 @@ import settings.SettingChangeListener;
|
||||
import settings.SettingsManager;
|
||||
import source.tuner.TunerChannel;
|
||||
import source.tuner.frequency.FrequencyChangeEvent;
|
||||
import source.tuner.frequency.FrequencyChangeListener;
|
||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
import controller.channel.ChannelEvent;
|
||||
@@ -55,7 +55,7 @@ import controller.channel.ChannelModel;
|
||||
|
||||
public class OverlayPanel extends JPanel
|
||||
implements ChannelEventListener,
|
||||
FrequencyChangeListener,
|
||||
IFrequencyChangeProcessor,
|
||||
SettingChangeListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -528,14 +528,14 @@ public class OverlayPanel extends JPanel
|
||||
{
|
||||
if( mChannelDisplay == ChannelDisplay.ALL ||
|
||||
( mChannelDisplay == ChannelDisplay.ENABLED &&
|
||||
channel.isProcessing() ) )
|
||||
channel.getEnabled() ) )
|
||||
{
|
||||
//Choose the correct background color to use
|
||||
if( channel.isSelected() )
|
||||
{
|
||||
graphics.setColor( mColorChannelConfigSelected );
|
||||
}
|
||||
else if( channel.isProcessing() )
|
||||
else if( channel.getEnabled() )
|
||||
{
|
||||
graphics.setColor( mColorChannelConfigProcessing );
|
||||
}
|
||||
@@ -613,9 +613,11 @@ public class OverlayPanel extends JPanel
|
||||
drawChannelCenterLine( graphics, frequencyAxis );
|
||||
|
||||
/* Draw Automatic Frequency Control line */
|
||||
if( channel.hasFrequencyControl() )
|
||||
int correction = channel.getChannelFrequencyCorrection();
|
||||
|
||||
if( correction != 0 )
|
||||
{
|
||||
long error = frequency + channel.getFrequencyCorrection();
|
||||
long error = frequency + correction;
|
||||
|
||||
drawAFC( graphics, frequencyAxis, getAxisFromFrequency( error ) );
|
||||
}
|
||||
@@ -674,11 +676,11 @@ public class OverlayPanel extends JPanel
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case SAMPLE_RATE_CHANGE_NOTIFICATION:
|
||||
case NOTIFICATION_SAMPLE_RATE_CHANGE:
|
||||
mBandwidth = event.getValue().intValue();
|
||||
mLabelSizeMonitor.update();
|
||||
break;
|
||||
case FREQUENCY_CHANGE_NOTIFICATION:
|
||||
case NOTIFICATION_FREQUENCY_CHANGE:
|
||||
mFrequency = event.getValue().longValue();
|
||||
mLabelSizeMonitor.update();
|
||||
break;
|
||||
|
||||
@@ -66,7 +66,7 @@ import source.tuner.Tuner;
|
||||
import source.tuner.TunerSelectionListener;
|
||||
import source.tuner.frequency.FrequencyChangeEvent;
|
||||
import source.tuner.frequency.FrequencyChangeEvent.Event;
|
||||
import source.tuner.frequency.FrequencyChangeListener;
|
||||
import source.tuner.frequency.IFrequencyChangeProcessor;
|
||||
import spectrum.OverlayPanel.ChannelDisplay;
|
||||
import spectrum.converter.ComplexDecibelConverter;
|
||||
import spectrum.converter.DFTResultsConverter;
|
||||
@@ -82,13 +82,14 @@ import com.jidesoft.swing.JideSplitPane;
|
||||
import controller.ConfigurationControllerModel;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.ChannelUtils;
|
||||
import dsp.filter.Window.WindowType;
|
||||
import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
|
||||
|
||||
public class SpectralDisplayPanel extends JPanel
|
||||
implements Listener<ComplexBuffer>,
|
||||
FrequencyChangeListener,
|
||||
IFrequencyChangeProcessor,
|
||||
IDFTWidthChangeProcessor,
|
||||
TunerSelectionListener
|
||||
{
|
||||
@@ -115,9 +116,11 @@ public class SpectralDisplayPanel extends JPanel
|
||||
private OverlayPanel mOverlayPanel;
|
||||
private DFTProcessor mDFTProcessor;
|
||||
private DFTResultsConverter mDFTConverter;
|
||||
private ConfigurationControllerModel mControllerModel;
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
private PlaylistManager mPlaylistManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private ConfigurationControllerModel mController;
|
||||
private Tuner mTuner;
|
||||
|
||||
/**
|
||||
@@ -132,23 +135,26 @@ public class SpectralDisplayPanel extends JPanel
|
||||
* the DFT is translated to decibels for display in the spectrum and
|
||||
* waterfall components.
|
||||
*/
|
||||
public SpectralDisplayPanel( ChannelModel channelModel,
|
||||
ConfigurationControllerModel controller,
|
||||
public SpectralDisplayPanel( ConfigurationControllerModel controllerModel,
|
||||
ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
PlaylistManager playlistManager,
|
||||
SettingsManager settingsManager )
|
||||
{
|
||||
mController = controller;
|
||||
mControllerModel = controllerModel;
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mPlaylistManager = playlistManager;
|
||||
mSettingsManager = settingsManager;
|
||||
|
||||
mSpectrumPanel = new SpectrumPanel( mSettingsManager );
|
||||
mOverlayPanel = new OverlayPanel( mSettingsManager, channelModel );
|
||||
mOverlayPanel = new OverlayPanel( mSettingsManager, mChannelModel );
|
||||
mWaterfallPanel = new WaterfallPanel( mSettingsManager );
|
||||
|
||||
//Register to receive tuner selection events
|
||||
if( mController != null )
|
||||
if( mControllerModel != null )
|
||||
{
|
||||
mController.addListener( (TunerSelectionListener)this );
|
||||
mControllerModel.addListener( (TunerSelectionListener)this );
|
||||
}
|
||||
|
||||
init();
|
||||
@@ -189,12 +195,12 @@ public class SpectralDisplayPanel extends JPanel
|
||||
/* De-register from receiving samples when the window closes */
|
||||
clearTuner();
|
||||
|
||||
if( mController != null )
|
||||
if( mControllerModel != null )
|
||||
{
|
||||
mController.removeListener( (TunerSelectionListener)this );
|
||||
mControllerModel.removeListener( (TunerSelectionListener)this );
|
||||
}
|
||||
|
||||
mController = null;
|
||||
mControllerModel = null;
|
||||
mPlaylistManager = null;
|
||||
mSettingsManager = null;
|
||||
|
||||
@@ -426,7 +432,6 @@ public class SpectralDisplayPanel extends JPanel
|
||||
/**
|
||||
* Receives frequency change events -- primarily from tuner components.
|
||||
*/
|
||||
@Override
|
||||
public void frequencyChanged( FrequencyChangeEvent event )
|
||||
{
|
||||
mOverlayPanel.frequencyChanged( event );
|
||||
@@ -458,7 +463,7 @@ public class SpectralDisplayPanel extends JPanel
|
||||
if( mTuner != null )
|
||||
{
|
||||
//Register to receive frequency change events
|
||||
mTuner.addListener( (FrequencyChangeListener)this );
|
||||
mTuner.addFrequencyChangeProcessor( this );
|
||||
|
||||
//Register the dft processor to receive samples from the tuner
|
||||
mTuner.addListener( (Listener<ComplexBuffer>)mDFTProcessor );
|
||||
@@ -470,10 +475,10 @@ public class SpectralDisplayPanel extends JPanel
|
||||
try
|
||||
{
|
||||
frequencyChanged( new FrequencyChangeEvent(
|
||||
Event.FREQUENCY_CHANGE_NOTIFICATION, mTuner.getFrequency() ) );
|
||||
Event.NOTIFICATION_FREQUENCY_CHANGE, mTuner.getFrequency() ) );
|
||||
|
||||
frequencyChanged( new FrequencyChangeEvent(
|
||||
Event.SAMPLE_RATE_CHANGE_NOTIFICATION, mTuner.getSampleRate() ) );
|
||||
Event.NOTIFICATION_SAMPLE_RATE_CHANGE, mTuner.getSampleRate() ) );
|
||||
}
|
||||
catch ( SourceException e )
|
||||
{
|
||||
@@ -491,7 +496,7 @@ public class SpectralDisplayPanel extends JPanel
|
||||
if( mTuner != null )
|
||||
{
|
||||
//Deregister for frequency change events from the tuner
|
||||
mTuner.removeListener( (FrequencyChangeListener)this );
|
||||
mTuner.removeFrequencyChangeProcessor( this );
|
||||
|
||||
//Deregister the dft processor from receiving samples
|
||||
mTuner.removeListener( (Listener<ComplexBuffer>)mDFTProcessor );
|
||||
@@ -652,8 +657,9 @@ public class SpectralDisplayPanel extends JPanel
|
||||
|
||||
for( Channel channel: channels )
|
||||
{
|
||||
JMenu channelMenu = ChannelUtils.getContextMenu(
|
||||
mPlaylistManager, channel, SpectralDisplayPanel.this );
|
||||
JMenu channelMenu = ChannelUtils.getContextMenu( mChannelModel,
|
||||
mChannelProcessingManager, mPlaylistManager, channel,
|
||||
SpectralDisplayPanel.this );
|
||||
|
||||
if( channelMenu != null )
|
||||
{
|
||||
@@ -675,10 +681,7 @@ public class SpectralDisplayPanel extends JPanel
|
||||
|
||||
for( DecoderType type: DecoderType.getPrimaryDecoders() )
|
||||
{
|
||||
decoderMenu.add( new DecoderItem( mController,
|
||||
frequency,
|
||||
type ) );
|
||||
|
||||
decoderMenu.add( new DecoderItem( type, frequency ) );
|
||||
}
|
||||
|
||||
frequencyMenu.add( decoderMenu );
|
||||
@@ -957,17 +960,14 @@ public class SpectralDisplayPanel extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ConfigurationControllerModel mController;
|
||||
private ChannelModel mChannelModel;
|
||||
private long mFrequency;
|
||||
private DecoderType mDecoder;
|
||||
|
||||
public DecoderItem( ConfigurationControllerModel controller,
|
||||
long frequency,
|
||||
DecoderType type )
|
||||
public DecoderItem( DecoderType type, long frequency )
|
||||
{
|
||||
super( type.getDisplayString() );
|
||||
|
||||
mController = controller;
|
||||
mFrequency = frequency;
|
||||
mDecoder = type;
|
||||
|
||||
@@ -976,7 +976,7 @@ public class SpectralDisplayPanel extends JPanel
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
mController.createChannel( mFrequency, mDecoder );
|
||||
mChannelModel.createChannel( mDecoder, mFrequency );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@@ -28,18 +28,18 @@ import playlist.PlaylistManager;
|
||||
import settings.SettingsManager;
|
||||
import source.tuner.Tuner;
|
||||
import controller.ConfigurationControllerModel;
|
||||
import controller.ResourceManager;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
|
||||
public class SpectrumFrame extends JFrame implements WindowListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ResourceManager mResourceManager;
|
||||
private SpectralDisplayPanel mSpectralDisplayPanel;
|
||||
|
||||
public SpectrumFrame( ChannelModel channelModel,
|
||||
ConfigurationControllerModel controller,
|
||||
public SpectrumFrame( ConfigurationControllerModel controllerModel,
|
||||
ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
PlaylistManager playlistManager,
|
||||
SettingsManager settingsManager,
|
||||
Tuner tuner )
|
||||
@@ -50,8 +50,8 @@ public class SpectrumFrame extends JFrame implements WindowListener
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow]", "[grow]") );
|
||||
|
||||
mSpectralDisplayPanel = new SpectralDisplayPanel( channelModel,
|
||||
controller, playlistManager, settingsManager );
|
||||
mSpectralDisplayPanel = new SpectralDisplayPanel( controllerModel,
|
||||
channelModel, channelProcessingManager, playlistManager, settingsManager );
|
||||
|
||||
mSpectralDisplayPanel.tunerSelected( tuner );
|
||||
add( mSpectralDisplayPanel, "grow" );
|
||||
|
||||
Reference in New Issue
Block a user