();
-
- public ControllerTreeCellRenderer()
- {
- }
-
- @Override
- public Component getTreeCellRendererComponent( JTree tree,
- Object value, boolean selected, boolean expanded, boolean isLeaf,
- int row, boolean focused )
- {
- Component c = super.getTreeCellRendererComponent( tree, value, selected,
- expanded, isLeaf, row, focused );
-
- if( value instanceof BaseNode )
- {
- BaseNode node = (BaseNode)value;
-
- ImageIcon icon = getIcon( node );
-
- setIcon( icon );
-
- Color background = node.getBackgroundColor();
-
- if( background != null )
- {
- setBackground( background );
- setOpaque( true );
-
- if( selected )
- {
- if( background == Color.CYAN )
- {
- setForeground( Color.ORANGE );
- }
- else if( background == Color.GREEN )
- {
- setForeground( Color.MAGENTA );
- }
- else if( background == Color.RED )
- {
- setForeground( Color.YELLOW );
- }
- }
- }
- else
- {
- setOpaque( false );
- }
- }
-
- return c;
- }
-
- private ImageIcon getIcon( BaseNode node )
- {
- ImageIcon icon = null;
-
- String filepath = node.getIconPath();
-
- if( filepath != null )
- {
- if( mIcons.containsKey( filepath ) )
- {
- icon = mIcons.get( filepath );
- }
- else
- {
- icon = new ImageIcon( filepath );
-
- if( icon.getIconHeight() > MAX_ICON_HEIGHT )
- {
- Image image = icon.getImage();
-
- double scale = (double)icon.getIconHeight() / (double)MAX_ICON_HEIGHT;
-
- int scaledWidth = (int)( (double)icon.getIconWidth() / scale );
-
- Image scaledImage = image.getScaledInstance( scaledWidth,
- MAX_ICON_HEIGHT, java.awt.Image.SCALE_SMOOTH );
-
- mIcons.put( filepath, new ImageIcon( scaledImage ) );
- }
- else
- {
- mIcons.put( filepath, icon );
- }
-
- }
- }
-
- return icon;
- }
-}
diff --git a/src/controller/EmptyEditor.java b/src/controller/EmptyEditor.java
deleted file mode 100644
index 83f21de3..00000000
--- a/src/controller/EmptyEditor.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package controller;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-public class EmptyEditor extends JPanel
-{
- private static final long serialVersionUID = 1L;
-
- public EmptyEditor()
- {
- setLayout( new BorderLayout() );
- setPreferredSize( new Dimension( 200, (int)getPreferredSize().getHeight() ) );
-
- String text = ""
- + "SDR Trunk
"
- + "
"
- + "Use the tree structure to the left to configure SDRTrunk"
- + " to use multiple SDR tuners and sound card sources to"
- + " decode multiple trunked and digital radio channels.
"
- + "
"
- + "Each tree branch can be accessed by clicking on the branch"
- + " and a configuration editor will appear here.
"
- + "
"
- + "Many of the branches contain context sensitive menus that "
- + " you can access by right-clicking on the node.
"
- + "
"
- + "To begin, right-click on the 'Systems' branch under 'Playlist'"
- + "and create a new 'System'. Right-click the 'System' node to create "
- + "a new 'Site'. Right-click on the 'Site' node to create a new Channel.
"
- + "
"
- + "In the new channel, select a channel source and decoder "
- + "and select event logging and recording options. Check 'Enabled'"
- + " and hit the 'Save' button to begin decoding.
"
- + "";
-
- add( new JLabel( text ), BorderLayout.NORTH );
- }
-}
diff --git a/src/controller/OldConfigurationEditor.java b/src/controller/OldConfigurationEditor.java
deleted file mode 100644
index 29d504ee..00000000
--- a/src/controller/OldConfigurationEditor.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package controller;
-
-
-import java.awt.BorderLayout;
-
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTree;
-import javax.swing.event.TreeSelectionEvent;
-import javax.swing.event.TreeSelectionListener;
-
-public class OldConfigurationEditor extends JPanel
- implements TreeSelectionListener
-{
- private static final long serialVersionUID = 1L;
-
- /**
- * Host for configuration editor display panels
- */
- public OldConfigurationEditor()
- {
- init();
- }
-
- public void init()
- {
- setPanel( new EmptyEditor() );
- }
-
- public void setPanel( JPanel display )
- {
- removeAll();
-
- setLayout( new BorderLayout() );
-
- JScrollPane scroll = new JScrollPane( display );
-
- add( scroll, BorderLayout.CENTER );
-
- revalidate();
- repaint();
- }
-
- @Override
- public void valueChanged( TreeSelectionEvent e )
- {
- JTree tree = (JTree)e.getSource();
-
- BaseNode node =
- (BaseNode)tree.getLastSelectedPathComponent();
-
- if( node != null )
- {
- setPanel( node.getEditor() );
- }
- }
-}
diff --git a/src/gui/SDRTrunk.java b/src/gui/SDRTrunk.java
index 16658a8f..dc84bb70 100644
--- a/src/gui/SDRTrunk.java
+++ b/src/gui/SDRTrunk.java
@@ -54,11 +54,12 @@ import org.slf4j.LoggerFactory;
import playlist.PlaylistManager;
import properties.SystemProperties;
import record.RecorderManager;
+import sample.Listener;
import settings.SettingsManager;
import source.SourceManager;
-import source.TunerModel;
-import source.tuner.Tuner;
-import source.tuner.TunerSelectionListener;
+import source.tuner.TunerEvent;
+import source.tuner.TunerModel;
+import source.tuner.configuration.TunerConfigurationModel;
import spectrum.SpectralDisplayPanel;
import util.TimeStamp;
import alias.AliasModel;
@@ -67,7 +68,6 @@ import audio.AudioManager;
import com.jidesoft.swing.JideSplitPane;
-import controller.ConfigurationControllerModel;
import controller.ControllerPanel;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
@@ -77,7 +77,7 @@ import controller.channel.ChannelProcessingManager;
import controller.channel.ChannelSelectionManager;
import controller.channel.map.ChannelMapModel;
-public class SDRTrunk
+public class SDRTrunk implements Listener
{
private final static Logger mLog = LoggerFactory.getLogger( SDRTrunk.class );
@@ -115,7 +115,10 @@ public class SDRTrunk
//Log current properties setting
SystemProperties.getInstance().logCurrentSettings();
- mSettingsManager = new SettingsManager();
+ TunerConfigurationModel tunerConfigurationModel = new TunerConfigurationModel();
+ TunerModel tunerModel = new TunerModel( tunerConfigurationModel );
+
+ mSettingsManager = new SettingsManager( tunerConfigurationModel );
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
@@ -129,12 +132,9 @@ public class SDRTrunk
RecorderManager recorderManager = new RecorderManager( threadPoolManager );
- SourceManager sourceManager = new SourceManager( mSettingsManager,
- threadPoolManager );
+ SourceManager sourceManager = new SourceManager( tunerModel,
+ mSettingsManager, threadPoolManager );
- TunerModel tunerModel = new TunerModel();
- tunerModel.addTuners( sourceManager.getTunerManager().getTuners() );
-
ChannelProcessingManager channelProcessingManager =
new ChannelProcessingManager( channelModel, channelMapModel,
aliasModel, eventLogManager, recorderManager,
@@ -156,18 +156,15 @@ public class SDRTrunk
MapService mapService = new MapService( mSettingsManager );
channelProcessingManager.addMessageListener( mapService );
- ConfigurationControllerModel configurationControllerModel =
- new ConfigurationControllerModel( channelModel, channelProcessingManager,
- mSettingsManager, sourceManager );
-
- mControllerPanel = new ControllerPanel( audioManager, configurationControllerModel,
- aliasModel, channelModel, channelMapModel, channelProcessingManager,
+ mControllerPanel = new ControllerPanel( audioManager, aliasModel,
+ channelModel, channelMapModel, channelProcessingManager,
mapService, mSettingsManager, sourceManager, tunerModel );
- mSpectralPanel = new SpectralDisplayPanel( configurationControllerModel,
- channelModel, channelProcessingManager, mSettingsManager );
-
- mTitle = getTitle();
+ mSpectralPanel = new SpectralDisplayPanel( channelModel,
+ channelProcessingManager, mSettingsManager );
+
+ tunerModel.addListener( mSpectralPanel.getTunerEventListener() );
+ tunerModel.addListener( this );
PlaylistManager playlistManager = new PlaylistManager( threadPoolManager,
aliasModel, channelModel, channelMapModel );
@@ -186,6 +183,8 @@ public class SDRTrunk
//Initialize the GUI
initGUI();
+
+ tunerModel.requestFirstTunerDisplay();
//Start the gui
EventQueue.invokeLater( new Runnable()
@@ -221,36 +220,17 @@ public class SDRTrunk
"[grow,fill]",
"[grow,fill]") );
- //init() the controller to load tuners and playlists
- mControllerPanel.getController().init();
-
/**
* Setup main JFrame window
*/
+ mTitle = getTitle();
mMainGui.setTitle( mTitle );
mMainGui.setBounds( 100, 100, 1280, 800 );
mMainGui.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
-
- mControllerPanel.getController().addListener( new TunerSelectionListener()
- {
- @Override
- public void tunerSelected( Tuner tuner )
- {
- if( tuner != null )
- {
- mMainGui.setTitle( mTitle + " - " + tuner.getName() );
- }
- else
- {
- mMainGui.setTitle( mTitle );
- }
- }
- } );
- //Fire first tuner selection so it is displayed in the spectrum/waterfall
- mControllerPanel.getController().fireFirstTunerSelected();
-
- mSpectralPanel.setPreferredSize( new Dimension( 1280, 400 ) );
+ //Set preferred sizes to influence the split
+ mSpectralPanel.setPreferredSize( new Dimension( 1280, 300 ) );
+ mControllerPanel.setPreferredSize( new Dimension( 1280, 500 ) );
JideSplitPane splitPane = new JideSplitPane( JideSplitPane.VERTICAL_SPLIT );
splitPane.setDividerSize( 5 );
@@ -487,5 +467,13 @@ public class SDRTrunk
return sb.toString();
}
-
+
+ @Override
+ public void receive( TunerEvent event )
+ {
+ if( event.getEvent() == TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY )
+ {
+ mMainGui.setTitle( mTitle + " - " + event.getTuner().getName() );
+ }
+ }
}
diff --git a/src/gui/editor/EmptyEditor.java b/src/gui/editor/EmptyEditor.java
index 4578df0b..128407fc 100644
--- a/src/gui/editor/EmptyEditor.java
+++ b/src/gui/editor/EmptyEditor.java
@@ -10,7 +10,7 @@ public class EmptyEditor extends Editor
public EmptyEditor()
{
- setLayout( new MigLayout( "", "[center]", "[grow]" ) );
+ setLayout( new MigLayout( "insets 0 0 0 0", "[center]", "[grow]" ) );
add( new JLabel( "Please select an item" ), "wrap" );
}
diff --git a/src/module/decode/p25/P25DecodeEditor.java b/src/module/decode/p25/P25DecodeEditor.java
index c87d1e7c..ccdfb281 100644
--- a/src/module/decode/p25/P25DecodeEditor.java
+++ b/src/module/decode/p25/P25DecodeEditor.java
@@ -33,7 +33,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import source.SourceEditor;
-import source.tuner.TunerEditor;
+import source.tuner.TunerEditorOld;
import controller.channel.ChannelConfigurationEditor;
import controller.channel.ConfigurationValidationException;
diff --git a/src/settings/Settings.java b/src/settings/Settings.java
index 464e4d46..1166592a 100644
--- a/src/settings/Settings.java
+++ b/src/settings/Settings.java
@@ -28,10 +28,10 @@ import map.DefaultIcon;
import map.MapIcon;
import settings.ColorSetting.ColorSettingName;
import source.recording.RecordingConfiguration;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerConfiguration;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import source.tuner.hackrf.HackRFTunerConfiguration;
@@ -60,15 +60,15 @@ import source.tuner.rtl.r820t.R820TTunerConfiguration;
@XmlRootElement( name = "SDRTrunk_settings" )
public class Settings
{
- private ArrayList mSettings = new ArrayList();
+ private List mSettings = new ArrayList();
- private ArrayList mTunerConfiguration =
+ private List mTunerConfiguration =
new ArrayList();
- private ArrayList mConfigurationAssignments =
+ private List mConfigurationAssignments =
new ArrayList();
- private ArrayList mRecordingConfigurations =
+ private List mRecordingConfigurations =
new ArrayList();
public Settings()
@@ -76,7 +76,7 @@ public class Settings
}
@XmlElement( name="recording_configuration" )
- public ArrayList getRecordingConfigurations()
+ public List getRecordingConfigurations()
{
return mRecordingConfigurations;
}
@@ -98,12 +98,12 @@ public class Settings
}
@XmlElement( name="tuner_configuration" )
- public ArrayList getTunerConfigurations()
+ public List getTunerConfigurations()
{
return mTunerConfiguration;
}
- public void setTunerConfigurations( ArrayList configs )
+ public void setTunerConfigurations( List configs )
{
mTunerConfiguration = configs;
}
@@ -136,7 +136,7 @@ public class Settings
}
@XmlElement( name="setting" )
- public ArrayList getSettings()
+ public List getSettings()
{
return mSettings;
}
@@ -255,12 +255,12 @@ public class Settings
}
@XmlElement( name="tuner_configuration_assignment" )
- public ArrayList getSelectedTunerConfiguration()
+ public List getSelectedTunerConfiguration()
{
return mConfigurationAssignments;
}
- public void setSelectedTunerConfiguration( ArrayList configs )
+ public void setSelectedTunerConfiguration( List configs )
{
mConfigurationAssignments = configs;
}
diff --git a/src/settings/SettingsManager.java b/src/settings/SettingsManager.java
index 3cac8abe..9529c9f6 100644
--- a/src/settings/SettingsManager.java
+++ b/src/settings/SettingsManager.java
@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
- * Copyright (C) 2014 Dennis Sheirer
+ * 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
@@ -30,6 +30,7 @@ import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import javax.swing.ImageIcon;
import javax.xml.bind.JAXBContext;
@@ -45,19 +46,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import properties.SystemProperties;
+import sample.Listener;
import settings.ColorSetting.ColorSettingName;
import source.recording.RecordingConfiguration;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
-import source.tuner.TunerType;
-import source.tuner.airspy.AirspyTunerConfiguration;
-import source.tuner.fcd.proV1.FCD1TunerConfiguration;
-import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
-import source.tuner.hackrf.HackRFTunerConfiguration;
-import source.tuner.rtl.e4k.E4KTunerConfiguration;
-import source.tuner.rtl.r820t.R820TTunerConfiguration;
+import source.tuner.configuration.TunerConfigurationEvent;
+import source.tuner.configuration.TunerConfigurationModel;
-public class SettingsManager
+public class SettingsManager implements Listener
{
private final static Logger mLog =
LoggerFactory.getLogger( SettingsManager.class );
@@ -76,8 +71,20 @@ public class SettingsManager
private HashMap mResizedIcons =
new HashMap();
- public SettingsManager()
+ private TunerConfigurationModel mTunerConfigurationModel;
+ private boolean mLoading = false;
+
+ public SettingsManager( TunerConfigurationModel tunerConfigurationModel )
{
+ //TODO: move settings and icons into a SettingsModel and an IconModel
+ //and update this class to only provide loading, saving, and model
+ //change detection producing a save.
+
+ mTunerConfigurationModel = tunerConfigurationModel;
+
+ //Register for tuner config events so that we can save the settings
+ mTunerConfigurationModel.addListener( this );
+
init();
}
@@ -101,6 +108,15 @@ public class SettingsManager
refreshIcons();
}
+
+ @Override
+ public void receive( TunerConfigurationEvent t )
+ {
+ if( !mLoading )
+ {
+ save();
+ }
+ }
/**
* Reloads the icon hash map, and sets up the default iconology. If the
@@ -542,7 +558,7 @@ public class SettingsManager
broadcastSettingChange( setting );
}
- public ArrayList getRecordingConfigurations()
+ public List getRecordingConfigurations()
{
return mSettings.getRecordingConfigurations();
}
@@ -559,98 +575,6 @@ public class SettingsManager
save();
}
- public ArrayList getTunerConfigurations( TunerType type )
- {
- ArrayList configs = getSettings()
- .getTunerConfigurations( type );
-
- return configs;
- }
-
- public void deleteTunerConfiguration( TunerConfiguration config )
- {
- getSettings().removeTunerConfiguration( config );
- save();
- }
-
- public TunerConfiguration addNewTunerConfiguration( TunerType type,
- String name )
- {
- switch( type )
- {
- case AIRSPY_R820T:
- AirspyTunerConfiguration airspyConfig =
- new AirspyTunerConfiguration( name );
-
- getSettings().addTunerConfiguration( airspyConfig );
-
- save();
- return airspyConfig;
- case ELONICS_E4000:
- E4KTunerConfiguration e4KConfig =
- new E4KTunerConfiguration( name );
-
- getSettings().addTunerConfiguration( e4KConfig );
-
- save();
- return e4KConfig;
- case FUNCUBE_DONGLE_PRO:
- FCD1TunerConfiguration config =
- new FCD1TunerConfiguration( name );
-
- getSettings().addTunerConfiguration( config );
-
- save();
-
- return config;
- case FUNCUBE_DONGLE_PRO_PLUS:
- FCD2TunerConfiguration configPlus =
- new FCD2TunerConfiguration( name );
-
- getSettings().addTunerConfiguration( configPlus );
-
- save();
-
- return configPlus;
- case HACKRF:
- HackRFTunerConfiguration hackConfig =
- new HackRFTunerConfiguration( name );
-
- getSettings().addTunerConfiguration( hackConfig );
-
- save();
-
- return hackConfig;
- case RAFAELMICRO_R820T:
- R820TTunerConfiguration r820TConfig =
- new R820TTunerConfiguration( name );
-
- getSettings().addTunerConfiguration( r820TConfig );
-
- save();
-
- return r820TConfig;
- default:
- throw new IllegalArgumentException( "TunerConfiguration"
- + "Directory - tuner type is unrecognized [" +
- type.toString() + "]" );
- }
- }
-
- public TunerConfigurationAssignment getSelectedTunerConfiguration(
- TunerType type, String address )
- {
- return mSettings.getConfigurationAssignment( type, address );
- }
-
- public void setSelectedTunerConfiguration( TunerType type,
- String address, TunerConfiguration config )
- {
- mSettings.setConfigurationAssignment( type, address, config.getName() );
-
- save();
- }
-
public MapViewSetting getMapViewSetting( String name, GeoPosition position, int zoom )
{
MapViewSetting loc = mSettings.getMapViewSetting( name );
@@ -681,6 +605,8 @@ public class SettingsManager
public void save()
{
+ saveTunerConfigurationModel();
+
JAXBContext context = null;
SystemProperties props = SystemProperties.getInstance();
@@ -759,6 +685,8 @@ public class SettingsManager
*/
public void load( Path settingsPath )
{
+ mLoading = true;
+
if( Files.exists( settingsPath ) )
{
mLog.info( "SettingsManager - loading settings file [" +
@@ -817,6 +745,36 @@ public class SettingsManager
{
mSettings = new Settings();
}
+
+ loadTunerConfigurationModel();
+
+ mLoading = false;
+ }
+
+ private void loadTunerConfigurationModel()
+ {
+ if( mSettings != null )
+ {
+ mTunerConfigurationModel.clear();
+
+ mTunerConfigurationModel.addTunerConfigurations(
+ mSettings.getTunerConfigurations() );
+
+ mTunerConfigurationModel.addTunerConfigurationAssignments(
+ mSettings.getSelectedTunerConfiguration() );
+ }
+ }
+
+ private void saveTunerConfigurationModel()
+ {
+ if( mSettings != null )
+ {
+ mSettings.setTunerConfigurations(
+ mTunerConfigurationModel.getTunerConfigurations() );
+
+ mSettings.setSelectedTunerConfiguration(
+ mTunerConfigurationModel.getTunerConfigurationAssignments() );
+ }
}
public void broadcastSettingChange( Setting setting )
diff --git a/src/source/SourceManager.java b/src/source/SourceManager.java
index c4a06e19..450a8b53 100644
--- a/src/source/SourceManager.java
+++ b/src/source/SourceManager.java
@@ -18,13 +18,15 @@
package source;
import settings.SettingsManager;
+import source.config.SourceConfigTuner;
import source.config.SourceConfiguration;
import source.mixer.MixerEditor;
import source.mixer.MixerManager;
import source.recording.RecordingEditor;
import source.recording.RecordingSourceManager;
-import source.tuner.TunerEditor;
+import source.tuner.TunerEditorOld;
import source.tuner.TunerManager;
+import source.tuner.TunerModel;
import controller.ThreadPoolManager;
public class SourceManager
@@ -32,13 +34,19 @@ public class SourceManager
private MixerManager mMixerManager;
private RecordingSourceManager mRecordingSourceManager;
private TunerManager mTunerManager;
+ private TunerModel mTunerModel;
- public SourceManager( SettingsManager settingsManager,
+ public SourceManager( TunerModel tunerModel,
+ SettingsManager settingsManager,
ThreadPoolManager threadPoolManager )
{
+ mTunerModel = tunerModel;
mMixerManager = new MixerManager();
mRecordingSourceManager = new RecordingSourceManager( settingsManager );
- mTunerManager = new TunerManager( mMixerManager, settingsManager, threadPoolManager );
+ mTunerManager = new TunerManager( mMixerManager, tunerModel, threadPoolManager );
+
+ //TODO: change mixer & recording managers to be models and hand them
+ //in via the constructor. Perform loading outside of this class.
}
public MixerManager getMixerManager()
@@ -67,7 +75,7 @@ public class SourceManager
retVal = mMixerManager.getSource( config );
break;
case TUNER:
- retVal = mTunerManager.getSource( config, bandwidth );
+ retVal = mTunerModel.getSource( (SourceConfigTuner)config, bandwidth );
break;
case RECORDING:
retVal = mRecordingSourceManager.getSource( config, bandwidth );
@@ -89,7 +97,7 @@ public class SourceManager
configuredPanel = new MixerEditor( this, config );
break;
case TUNER:
- configuredPanel = new TunerEditor( this, config );
+ configuredPanel = new TunerEditorOld( this, config );
break;
case RECORDING:
configuredPanel = new RecordingEditor( this, config );
diff --git a/src/source/TunerModel.java b/src/source/TunerModel.java
deleted file mode 100644
index 4e5655a4..00000000
--- a/src/source/TunerModel.java
+++ /dev/null
@@ -1,184 +0,0 @@
-package source;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-import sample.Listener;
-import source.tuner.Tuner;
-import source.tuner.TunerChangeEvent;
-
-public class TunerModel extends AbstractTableModel
- implements Listener
-{
- private static final long serialVersionUID = 1L;
-
- private static final int TUNER_CLASS = 0;
- private static final int TUNER_TYPE = 1;
- private static final int SAMPLE_RATE = 2;
- private static final int FREQUENCY = 3;
- private static final int CHANNEL_COUNT = 4;
- private static final int SPECTRAL_DISPLAY = 5;
-
- private static final String MHZ = " MHz";
- private static final String[] COLUMNS =
- { "Class", "Type", "Sample Rate", "Frequency", "Channels", "Spectrum" };
-
- private List mTuners = new ArrayList<>();
- private DecimalFormat mFrequencyFormat = new DecimalFormat( "0.00000" );
- private DecimalFormat mSampleRateFormat = new DecimalFormat( "0.000" );
-
- public TunerModel()
- {
- }
-
- /**
- * List of Tuners currently in the model
- */
- public List getTuners()
- {
- return mTuners;
- }
-
- public Tuner getTuner( int index )
- {
- if( index < mTuners.size() )
- {
- return mTuners.get( index );
- }
-
- return null;
- }
-
- public void addTuners( List Tuners )
- {
- for( Tuner tuner: Tuners )
- {
- addTuner( tuner );
- }
- }
-
- /**
- * Adds the Tuner to this model
- */
- public void addTuner( Tuner tuner )
- {
- if( !mTuners.contains( tuner ) )
- {
- mTuners.add( tuner );
-
- int index = mTuners.indexOf( tuner );
-
- fireTableRowsInserted( index, index );
-
- tuner.addTunerChangeListener( this );
- }
- }
-
- /**
- * Removes the Tuner from this model
- */
- public void removeTuner( Tuner tuner )
- {
- if( mTuners.contains( tuner ) )
- {
- tuner.removeTunerChangeListener( this );
-
- int index = mTuners.indexOf( tuner );
-
- mTuners.remove( tuner );
-
- fireTableRowsDeleted( index, index );
- }
- }
-
-
- @Override
- public void receive( TunerChangeEvent event )
- {
- if( event.getTuner() != null )
- {
- int index = mTuners.indexOf( event.getTuner() );
-
- if( index >= 0 )
- {
- switch( event.getEvent() )
- {
- case CHANNEL_COUNT:
- fireTableCellUpdated( index, CHANNEL_COUNT );
- break;
- case FREQUENCY:
- fireTableCellUpdated( index, FREQUENCY );
- break;
- case SAMPLE_RATE:
- fireTableCellUpdated( index, SAMPLE_RATE );
- break;
- case SPECTRAL_DISPLAY:
- fireTableCellUpdated( index, SPECTRAL_DISPLAY );
- default:
- break;
- }
- }
- }
- }
-
- @Override
- public int getRowCount()
- {
- return mTuners.size();
- }
-
- @Override
- public int getColumnCount()
- {
- return 6;
- }
-
- @Override
- public Object getValueAt( int rowIndex, int columnIndex )
- {
- if( rowIndex < mTuners.size() )
- {
- Tuner tuner = mTuners.get( rowIndex );
-
- switch( columnIndex )
- {
- case TUNER_CLASS:
- return tuner.getTunerClass().getVendorDescription();
- case TUNER_TYPE:
- return tuner.getTunerType().getLabel();
- case SAMPLE_RATE:
- int sampleRate = tuner.getSampleRate();
-
- return mSampleRateFormat.format( sampleRate / 1E6D ) + MHZ;
- case FREQUENCY:
- try
- {
- long frequency = tuner.getFrequency();
-
- return mFrequencyFormat.format( frequency / 1E6D ) + MHZ;
- }
- catch( Exception e )
- {
- return 0;
- }
- case CHANNEL_COUNT:
- return tuner.getChannelCount();
- case SPECTRAL_DISPLAY:
- return "TBD";
- default:
- break;
- }
- }
-
- return null;
- }
-
- @Override
- public String getColumnName( int columnIndex )
- {
- return COLUMNS[ columnIndex ];
- }
-}
diff --git a/src/source/recording/RecordingEditorPanel.java b/src/source/recording/RecordingEditorPanel.java
deleted file mode 100644
index 408538d5..00000000
--- a/src/source/recording/RecordingEditorPanel.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package source.recording;
-
-import gui.control.JFrequencyControl;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
-import java.io.File;
-
-import javax.swing.JButton;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-
-import net.miginfocom.swing.MigLayout;
-
-public class RecordingEditorPanel extends JPanel
-{
- private static final long serialVersionUID = 1L;
-
- private RecordingNode mRecordingNode;
-
- private JTextField mRecordingAlias;
- private JLabel mFilePathLabel;
-
- public RecordingEditorPanel( RecordingNode recordingNode )
- {
- mRecordingNode = recordingNode;
-
- initGUI();
- }
-
- private void initGUI()
- {
- setLayout( new MigLayout( "fill,wrap 2", "[right,grow][grow]", "[][][][][][grow]" ) );
-
- add( new JLabel( "I/Q Recording" ), "span,align left" );
-
- add( new JLabel( "Alias:" ) );
-
- mRecordingAlias = new JTextField( mRecordingNode.getRecording()
- .getRecordingConfiguration().getAlias() );
-
- mRecordingAlias.addFocusListener( new FocusListener()
- {
- @Override
- public void focusLost( FocusEvent arg0 )
- {
- String alias = mRecordingAlias.getText();
-
- if( alias != null )
- {
- mRecordingNode.getRecording().setAlias( alias );
- }
- }
-
- @Override
- public void focusGained( FocusEvent arg0 ) {}
- } );
-
- add( mRecordingAlias, "wrap" );
-
- JButton mFileSelectionButton = new JButton( "File ..." );
- mFileSelectionButton.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent arg0 )
- {
- if( mRecordingNode.getRecording().hasChannels() )
- {
- JOptionPane.showMessageDialog( RecordingEditorPanel.this,
- "This recording is currently in replay. Please "
- + "disable any channels that are using this "
- + "recording before changing the recording file." );
- }
- else
- {
- final JFileChooser fc = new JFileChooser();
-
- int returnVal = fc.showOpenDialog( RecordingEditorPanel.this );
-
- if ( returnVal == JFileChooser.APPROVE_OPTION )
- {
- File file = fc.getSelectedFile();
-
- if( file != null && file.exists() )
- {
- mRecordingNode.getRecording()
- .getRecordingConfiguration()
- .setFilePath( file.getAbsolutePath() );
-
- if( mFilePathLabel != null )
- {
- mFilePathLabel.setText( file.getName() );
- }
- }
- }
- }
- }
- } );
- add( mFileSelectionButton );
-
- String filePath = mRecordingNode.getRecording()
- .getRecordingConfiguration().getFilePath();
-
- if( filePath != null )
- {
- mFilePathLabel = new JLabel( filePath );
- }
- else
- {
- mFilePathLabel = new JLabel( "Please select a recording" );
- }
-
- add( mFilePathLabel, "wrap" );
-
- add( new JLabel( "Center Frequency:" ), "span,align left" );
-
- JFrequencyControl frequencyControl = new JFrequencyControl(
- mRecordingNode.getRecording().getRecordingConfiguration()
- .getCenterFrequency() );
-
- frequencyControl.addListener( mRecordingNode.getRecording() );
-
- add( frequencyControl, "span,align left" );
- }
-}
diff --git a/src/source/recording/RecordingGroupNode.java b/src/source/recording/RecordingGroupNode.java
deleted file mode 100644
index 3e9d4631..00000000
--- a/src/source/recording/RecordingGroupNode.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package source.recording;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.List;
-
-import javax.swing.JMenuItem;
-import javax.swing.JPopupMenu;
-
-import settings.SettingsManager;
-import source.SourceManager;
-import controller.BaseNode;
-
-public class RecordingGroupNode extends BaseNode
-{
- private static final long serialVersionUID = 1L;
-
- private SettingsManager mSettingsManager;
-
- public RecordingGroupNode( SourceManager sourceManager, SettingsManager settingsManager )
- {
- super( sourceManager );
-
- mSettingsManager = settingsManager;
- }
-
- private SourceManager getSourceManager()
- {
- return (SourceManager)getUserObject();
- }
-
- public String toString()
- {
- return "Recordings [" + this.getChildCount() + "]";
- }
-
- public JPopupMenu getContextMenu()
- {
- JPopupMenu menu = new JPopupMenu();
-
- JMenuItem addRecordingItem = new JMenuItem( "Add Recording" );
-
- addRecordingItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- RecordingConfiguration config = new RecordingConfiguration();
-
- mSettingsManager.addRecordingConfiguration( config );
-
- Recording recording = getSourceManager()
- .getRecordingSourceManager().addRecording( config );
-
- RecordingNode node = new RecordingNode( getSourceManager(), recording );
-
- getModel().addNode( node, RecordingGroupNode.this, 0 );
-
- sort();
-
- node.show();
- }
- } );
-
- menu.add( addRecordingItem );
-
- return menu;
- }
-
- public void loadRecordings()
- {
- List recordings = getSourceManager()
- .getRecordingSourceManager().getRecordings();
-
- for( Recording recording: recordings )
- {
- RecordingNode node = new RecordingNode( getSourceManager(), recording );
-
- getModel().addNode( node, this, 0 );
- }
-
- sort();
- }
-}
diff --git a/src/source/recording/RecordingNode.java b/src/source/recording/RecordingNode.java
deleted file mode 100644
index 920602e3..00000000
--- a/src/source/recording/RecordingNode.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package source.recording;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-
-import source.SourceManager;
-import controller.BaseNode;
-
-public class RecordingNode extends BaseNode
-{
- private static final long serialVersionUID = 1L;
-
- private JPanel mEditor;
-
- private SourceManager mSourceManager;
-
- public RecordingNode( SourceManager sourceManager, Recording recording )
- {
- super( recording );
- }
-
- public Recording getRecording()
- {
- return (Recording)getUserObject();
- }
-
- public String toString()
- {
- return getRecording().toString();
- }
-
- @Override
- public JPanel getEditor()
- {
- if( mEditor == null )
- {
- mEditor = new RecordingEditorPanel( this );
- }
-
- return mEditor;
- }
-
- public JPopupMenu getContextMenu()
- {
- JPopupMenu menu = new JPopupMenu();
-
- JMenuItem deleteItem = new JMenuItem( "Delete" );
-
- deleteItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- if( getRecording().hasChannels() )
- {
- JOptionPane.showMessageDialog( getModel().getTree(),
- "Can't delete recording - currently in use. Please"
- + " disable any channel(s) that are using this "
- + "recording before deleting it",
- "Can't delete recording",
- JOptionPane.ERROR_MESSAGE );
- }
- else
- {
- mSourceManager.getRecordingSourceManager()
- .removeRecording( getRecording() );
-
- getModel().removeNodeFromParent( RecordingNode.this );
- }
- }
- } );
-
- menu.add( deleteItem );
-
- return menu;
- }
-}
diff --git a/src/source/recording/RecordingSourceManager.java b/src/source/recording/RecordingSourceManager.java
index a047b170..fa0ae8b7 100644
--- a/src/source/recording/RecordingSourceManager.java
+++ b/src/source/recording/RecordingSourceManager.java
@@ -131,7 +131,7 @@ public class RecordingSourceManager
private void loadRecordings()
{
- ArrayList recordingConfigurations =
+ List recordingConfigurations =
mSettingsManager.getRecordingConfigurations();
mLog.info( "RecordingSourceManager - discovered [" +
diff --git a/src/source/tuner/Tuner.java b/src/source/tuner/Tuner.java
index cc4a8195..0a0215f2 100644
--- a/src/source/tuner/Tuner.java
+++ b/src/source/tuner/Tuner.java
@@ -31,6 +31,7 @@ import sample.Listener;
import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
@@ -55,7 +56,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
protected List mFrequencyChangeProcessors =
new CopyOnWriteArrayList<>();
- protected List> mTunerChangeListeners =
+ protected List> mTunerChangeListeners =
new ArrayList<>();
public Tuner( String name )
@@ -79,12 +80,6 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
mName = name;
}
- /**
- * Return an editor panel for the tuner
- */
- public abstract JPanel getEditor( SettingsManager settingsManager );
-
-
/**
* Applies the settings from a saved tuner configuration setting object
*/
@@ -223,7 +218,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
/**
* Registers the listener
*/
- public void addTunerChangeListener( Listener listener )
+ public void addTunerChangeListener( Listener listener )
{
mTunerChangeListeners.add( listener );
}
@@ -231,7 +226,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
/**
* Removes the registered listener
*/
- public void removeTunerChangeListener( Listener listener )
+ public void removeTunerChangeListener( Listener listener )
{
mTunerChangeListeners.remove( listener );
}
@@ -239,9 +234,9 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
/**
* Broadcasts the tuner change event
*/
- public void broadcast( TunerChangeEvent event )
+ public void broadcast( TunerEvent event )
{
- for( Listener listener: mTunerChangeListeners )
+ for( Listener listener: mTunerChangeListeners )
{
listener.receive( event );
}
@@ -277,11 +272,11 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
{
- broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.FREQUENCY ) );
+ broadcast( new TunerEvent( this, TunerEvent.Event.FREQUENCY ) );
}
else if( event.getEvent() == Event.NOTIFICATION_SAMPLE_RATE_CHANGE )
{
- broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.SAMPLE_RATE ) );
+ broadcast( new TunerEvent( this, TunerEvent.Event.SAMPLE_RATE ) );
}
}
diff --git a/src/source/tuner/TunerController.java b/src/source/tuner/TunerController.java
index 65a6d859..832b4b2f 100644
--- a/src/source/tuner/TunerController.java
+++ b/src/source/tuner/TunerController.java
@@ -25,6 +25,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import source.SourceException;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.frequency.FrequencyController;
import source.tuner.frequency.FrequencyController.Tunable;
import source.tuner.frequency.IFrequencyChangeProcessor;
diff --git a/src/source/tuner/TunerEditor.java b/src/source/tuner/TunerEditor.java
index 2be792a1..18799074 100644
--- a/src/source/tuner/TunerEditor.java
+++ b/src/source/tuner/TunerEditor.java
@@ -1,75 +1,168 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
package source.tuner;
-import controller.channel.Channel;
-import controller.channel.ConfigurationValidationException;
import gui.control.JFrequencyControl;
-import source.SourceEditor;
-import source.SourceManager;
-import source.config.SourceConfigTuner;
-import source.config.SourceConfiguration;
+import gui.editor.Editor;
+import gui.editor.EmptyEditor;
-public class TunerEditor extends SourceEditor
+import java.awt.Dimension;
+
+import javax.swing.JButton;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTable;
+import javax.swing.RowFilter;
+import javax.swing.table.TableRowSorter;
+
+import net.miginfocom.swing.MigLayout;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationModel;
+
+import com.jidesoft.swing.JideSplitPane;
+
+public class TunerEditor extends Editor
{
- private static final long serialVersionUID = 1L;
- private JFrequencyControl mFrequencyControl;
-
- public TunerEditor( SourceManager sourceManager,
- SourceConfiguration config )
- {
- super( sourceManager, config );
-
- initGUI();
- }
+ private static final long serialVersionUID = 1L;
- public void reset()
+ private final static Logger mLog = LoggerFactory.getLogger( TunerEditor.class );
+
+ private TunerConfigurationModel mTunerConfigurationModel;
+ private JTable mTunerConfigurationTable;
+ private TableRowSorter mRowSorter;
+ private ConfigurationRowFilter mRowFilter = new ConfigurationRowFilter();
+ private JFrequencyControl mFrequencyControl = new JFrequencyControl();
+
+ public TunerEditor( TunerConfigurationModel tunerConfigurationModel )
{
- mFrequencyControl.setFrequency(
- ((SourceConfigTuner)mConfig).getFrequency(), false );
+ mTunerConfigurationModel = tunerConfigurationModel;
+ init();
}
+ public void init()
+ {
+ setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]" ) );
+
+ JPanel listPanel = new JPanel();
+ listPanel.setLayout( new MigLayout( "fill,wrap 1",
+ "[grow,fill]", "[][][grow,fill][]" ) );
+ listPanel.add( mFrequencyControl );
+
+// mFrequencyControl.addListener( this );
+// /* Add frequency control as frequency change listener. */
+// mController.addListener( mFrequencyControl );
+// mFrequencyControl.setFrequency( mController.getFrequency(), false );
+
+ mTunerConfigurationTable = new JTable( mTunerConfigurationModel );
+ mRowSorter = new TableRowSorter<>( mTunerConfigurationModel );
+ mRowSorter.setRowFilter( mRowFilter );
+ mTunerConfigurationTable.setRowSorter( mRowSorter );
+
+ listPanel.add( new JLabel( "Tuner Configurations" ) );
+ listPanel.add( mTunerConfigurationTable );
+
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout( new MigLayout( "insets 0 0 0 0",
+ "[grow,fill][grow,fill]", "[grow,fill]" ) );
+
+ JButton newButton = new JButton( "New" );
+ buttonPanel.add( newButton );
+
+ JButton deleteButton = new JButton( "Delete" );
+ buttonPanel.add( deleteButton );
+
+ listPanel.add( buttonPanel );
+
+ //Set preferred size on both scrollers to same width, so they split the space
+ JScrollPane listScroller = new JScrollPane( listPanel );
+ listScroller.setPreferredSize( new Dimension( 200, 80 ) );
+
+ JPanel editorPanel = new EmptyEditor();
+ JScrollPane editorScroller = new JScrollPane( editorPanel );
+ editorScroller.setPreferredSize( new Dimension( 200, 80 ) );
+
+ JideSplitPane splitPane =
+ new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
+ splitPane.add( listScroller );
+ splitPane.add( editorScroller );
+
+ add( splitPane );
+ }
+
+ @Override
public void save()
{
- ((SourceConfigTuner)mConfig).setFrequency( mFrequencyControl.getFrequency() );
+ }
+
+ @Override
+ public void setItem( Tuner tuner )
+ {
+ super.setItem( tuner );
+
+ if( hasItem() )
+ {
+ mRowFilter.setTunerType( tuner.getTunerType() );
+
+ TunerConfiguration assigned = mTunerConfigurationModel
+ .getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
+
+ int modelIndex = mTunerConfigurationModel.getRowIndex( assigned );
+
+ if( modelIndex >= 0 )
+ {
+ int viewIndex = mTunerConfigurationTable.convertRowIndexToView( modelIndex );
+
+ if( viewIndex >= 0 )
+ {
+ mTunerConfigurationTable.setRowSelectionInterval( viewIndex, viewIndex );
+ }
+ }
+ }
+ else
+ {
+ mRowFilter.setTunerType( null );
+ }
+
+ mRowSorter.setRowFilter( mRowFilter );
}
- private void initGUI()
+ public class ConfigurationRowFilter extends RowFilter
{
- mFrequencyControl = new JFrequencyControl();
+ private TunerType mTunerType;
- mFrequencyControl.setFrequency(
- ((SourceConfigTuner)mConfig).getFrequency(), false );
-
- add( mFrequencyControl );
- }
-
- @Override
- public void setConfiguration( Channel channel )
- {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void validateConfiguration() throws ConfigurationValidationException
- {
- // TODO Auto-generated method stub
+ public ConfigurationRowFilter()
+ {
+ }
+ public void setTunerType( TunerType type )
+ {
+ mTunerType = type;
+ }
+
+ @Override
+ public boolean include( javax.swing.RowFilter.Entry extends TunerConfigurationModel,
+ ? extends Integer> entry )
+ {
+ if( mTunerType == null )
+ {
+ return true;
+ }
+ else
+ {
+ TunerConfigurationModel model = entry.getModel();
+ TunerConfiguration config = model.getTunerConfiguration( entry.getIdentifier() );
+
+ if( config != null )
+ {
+ return config.getTunerType() == mTunerType;
+ }
+ }
+
+ return false;
+ }
}
+
}
diff --git a/src/source/tuner/TunerEditorOld.java b/src/source/tuner/TunerEditorOld.java
new file mode 100644
index 00000000..b17339e0
--- /dev/null
+++ b/src/source/tuner/TunerEditorOld.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+package source.tuner;
+
+import controller.channel.Channel;
+import controller.channel.ConfigurationValidationException;
+import gui.control.JFrequencyControl;
+import source.SourceEditor;
+import source.SourceManager;
+import source.config.SourceConfigTuner;
+import source.config.SourceConfiguration;
+
+public class TunerEditorOld extends SourceEditor
+{
+ private static final long serialVersionUID = 1L;
+ private JFrequencyControl mFrequencyControl;
+
+ public TunerEditorOld( SourceManager sourceManager,
+ SourceConfiguration config )
+ {
+ super( sourceManager, config );
+
+ initGUI();
+ }
+
+ public void reset()
+ {
+ mFrequencyControl.setFrequency(
+ ((SourceConfigTuner)mConfig).getFrequency(), false );
+ }
+
+ public void save()
+ {
+ ((SourceConfigTuner)mConfig).setFrequency( mFrequencyControl.getFrequency() );
+ }
+
+ private void initGUI()
+ {
+ mFrequencyControl = new JFrequencyControl();
+
+ mFrequencyControl.setFrequency(
+ ((SourceConfigTuner)mConfig).getFrequency(), false );
+
+ add( mFrequencyControl );
+ }
+
+ @Override
+ public void setConfiguration( Channel channel )
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void validateConfiguration() throws ConfigurationValidationException
+ {
+ // TODO Auto-generated method stub
+
+ }
+}
diff --git a/src/source/tuner/TunerChangeEvent.java b/src/source/tuner/TunerEvent.java
similarity index 68%
rename from src/source/tuner/TunerChangeEvent.java
rename to src/source/tuner/TunerEvent.java
index 72bf366c..cccdc8fa 100644
--- a/src/source/tuner/TunerChangeEvent.java
+++ b/src/source/tuner/TunerEvent.java
@@ -1,11 +1,11 @@
package source.tuner;
-public class TunerChangeEvent
+public class TunerEvent
{
private Tuner mTuner;
private Event mEvent;
- public TunerChangeEvent( Tuner tuner, Event event )
+ public TunerEvent( Tuner tuner, Event event )
{
mTuner = tuner;
mEvent = event;
@@ -28,6 +28,7 @@ public class TunerChangeEvent
CHANNEL_COUNT,
FREQUENCY,
SAMPLE_RATE,
- SPECTRAL_DISPLAY;
+ REQUEST_MAIN_SPECTRAL_DISPLAY,
+ REQUEST_SECONDARY_SPECTRAL_DISPLAY;
}
}
diff --git a/src/source/tuner/TunerGroupNode.java b/src/source/tuner/TunerGroupNode.java
deleted file mode 100644
index 4a3c8247..00000000
--- a/src/source/tuner/TunerGroupNode.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package source.tuner;
-
-import controller.BaseNode;
-
-public class TunerGroupNode extends BaseNode
-{
- private static final long serialVersionUID = 1L;
-
- public TunerGroupNode()
- {
- super( null );
- }
-
- public String toString()
- {
- return "Tuners [" + this.getChildCount() + "]";
- }
-}
diff --git a/src/source/tuner/TunerManager.java b/src/source/tuner/TunerManager.java
index 38b10e0a..d423d860 100644
--- a/src/source/tuner/TunerManager.java
+++ b/src/source/tuner/TunerManager.java
@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
- * Copyright (C) 2014,2015 Dennis Sheirer
+ * 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
@@ -17,15 +17,7 @@
******************************************************************************/
package source.tuner;
-import gui.editor.EmptyEditor;
-
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.RejectedExecutionException;
-
-import javax.swing.JPanel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -34,15 +26,10 @@ import org.usb4java.DeviceDescriptor;
import org.usb4java.DeviceList;
import org.usb4java.LibUsb;
-import settings.SettingsManager;
-import source.Source;
import source.SourceException;
-import source.config.SourceConfigTuner;
-import source.config.SourceConfiguration;
import source.mixer.MixerManager;
import source.tuner.airspy.AirspyTuner;
import source.tuner.airspy.AirspyTunerController;
-import source.tuner.airspy.AirspyTunerEditorPanel;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.proV1.FCD1TunerController;
import source.tuner.fcd.proplusV2.FCD2TunerController;
@@ -51,7 +38,6 @@ import source.tuner.hackrf.HackRFTunerController;
import source.tuner.rtl.RTL2832Tuner;
import source.tuner.rtl.RTL2832TunerController;
import source.tuner.rtl.e4k.E4KTunerController;
-import source.tuner.rtl.e4k.E4KTunerEditorPanel;
import source.tuner.rtl.r820t.R820TTunerController;
import controller.ThreadPoolManager;
@@ -60,17 +46,15 @@ public class TunerManager
private final static Logger mLog =
LoggerFactory.getLogger( TunerManager.class );
- private ArrayList mTuners = new ArrayList();
-
private MixerManager mMixerManager;
- private SettingsManager mSettingsManager;
+ private TunerModel mTunerModel;
private ThreadPoolManager mThreadPoolManager;
public TunerManager( MixerManager mixerManager,
- SettingsManager settingsManager,
+ TunerModel tunerModel,
ThreadPoolManager threadPoolManager )
{
- mSettingsManager = settingsManager;
+ mTunerModel = tunerModel;
mThreadPoolManager = threadPoolManager;
initTuners();
@@ -84,57 +68,6 @@ public class TunerManager
LibUsb.exit( null );
}
- /**
- * Iterates current tuners to get a tuner channel source for the frequency
- * specified in the channel config's source config object
- */
- public Source getSource( SourceConfiguration config, int bandwidth )
- {
- TunerChannelSource retVal = null;
-
- if( config instanceof SourceConfigTuner )
- {
- SourceConfigTuner tunerConfig = (SourceConfigTuner)config;
-
- TunerChannel tunerChannel = tunerConfig.getTunerChannel();
-
- tunerChannel.setBandwidth( bandwidth );
-
- Iterator it = mTuners.iterator();
-
- Tuner tuner;
-
- while( it.hasNext() && retVal == null )
- {
- tuner = it.next();
-
- try
- {
- retVal = tuner.getChannel( tunerChannel );
- }
- catch ( RejectedExecutionException ree )
- {
- mLog.error( "couldn't provide tuner channel source", ree );
- }
- catch ( SourceException e )
- {
- mLog.error( "error obtaining channel from tuner [" +
- tuner.getName() + "]", e );
- }
- }
- }
-
- return retVal;
- }
-
- /**
- * Get list of current tuners
- */
- public List getTuners()
- {
- return mTuners;
- }
-
/**
* Loads all USB tuners and USB/Mixer tuner devices
*/
@@ -192,9 +125,19 @@ public class TunerManager
if( status.isLoaded() )
{
Tuner tuner = status.getTuner();
- sb.append( "] LOADED: " );
- sb.append( tuner.toString() );
- mTuners.add( tuner );
+
+ try
+ {
+ mTunerModel.addTuner( tuner );
+ sb.append( "] LOADED: " );
+ sb.append( tuner.toString() );
+ }
+ catch( Exception e )
+ {
+ sb.append( "] NOT LOADED: " );
+ sb.append( status.getInfo() );
+ sb.append( " Error:" + e.getMessage() );
+ }
}
else
{
@@ -276,13 +219,6 @@ public class TunerManager
AirspyTuner tuner = new AirspyTuner( airspyController );
- TunerConfiguration config = getTunerConfiguration( tuner );
-
- if( config != null )
- {
- tuner.apply( config );
- }
-
return new TunerInitStatus( tuner, "LOADED" );
}
catch( SourceException se )
@@ -301,11 +237,6 @@ public class TunerManager
{
return new TunerInitStatus( null, "Ettus B100 tuner not currently "
+ "supported" );
-// case ETTUS_USRP_B100:
-// mTuners.add( new B100Tuner( device ) );
-// status = sLOADED;
-// reason = null;
-// break;
}
private TunerInitStatus initFuncubeProTuner( Device device,
@@ -328,13 +259,6 @@ public class TunerManager
FCDTuner tuner =
new FCDTuner( dataline, controller );
- TunerConfiguration config = getTunerConfiguration( tuner );
-
- if( config != null )
- {
- tuner.apply( config );
- }
-
return new TunerInitStatus( tuner, "LOADED" );
}
catch ( SourceException e )
@@ -373,13 +297,6 @@ public class TunerManager
FCDTuner tuner =
new FCDTuner( dataline, controller );
- TunerConfiguration config = getTunerConfiguration( tuner );
-
- if( config != null )
- {
- tuner.apply( config );
- }
-
return new TunerInitStatus( tuner, "LOADED" );
}
catch ( SourceException e )
@@ -412,13 +329,6 @@ public class TunerManager
HackRFTuner tuner = new HackRFTuner( hackRFController );
- TunerConfiguration config = getTunerConfiguration( tuner );
-
- if( config != null )
- {
- tuner.apply( config );
- }
-
return new TunerInitStatus( tuner, "LOADED" );
}
catch( SourceException se )
@@ -465,14 +375,6 @@ public class TunerManager
RTL2832Tuner rtlTuner =
new RTL2832Tuner( tunerClass, controller );
- TunerConfiguration config =
- getTunerConfiguration( rtlTuner );
-
- if( config != null )
- {
- rtlTuner.apply( config );
- }
-
return new TunerInitStatus( rtlTuner, "LOADED" );
}
catch( SourceException se )
@@ -492,14 +394,6 @@ public class TunerManager
RTL2832Tuner rtlTuner =
new RTL2832Tuner( tunerClass, controller );
- TunerConfiguration config =
- getTunerConfiguration( rtlTuner );
-
- if( config != null )
- {
- rtlTuner.apply( config );
- }
-
return new TunerInitStatus( rtlTuner, "LOADED" );
}
catch( SourceException se )
@@ -522,54 +416,6 @@ public class TunerManager
return new TunerInitStatus( null, reason );
}
-
- /**
- * Get a stored tuner configuration or create a default tuner configuration
- * for the tuner type, connected at the address.
- *
- * Note: a named tuner configuration will be stored for for each tuner type
- * and address combination.
- * @param type - tuner type
- * @param address - current usb address/port
- * @return - stored tuner configuration or default configuration
- */
- private TunerConfiguration getTunerConfiguration( Tuner tuner )
- {
- TunerConfigurationAssignment selected = mSettingsManager
- .getSelectedTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
-
- ArrayList configs = mSettingsManager
- .getTunerConfigurations( tuner.getTunerType() );
-
- TunerConfiguration config = null;
-
- if( selected != null )
- {
- for( TunerConfiguration tunerConfig: configs )
- {
- if( tunerConfig.getName().contentEquals( selected.getTunerConfigurationName() ) )
- {
- config = tunerConfig;
- }
- }
- }
-
- //If we're still null at this point, create a default config
- if( config == null )
- {
- String name = "Default-" + tuner.getUniqueID();
-
- config = mSettingsManager.addNewTunerConfiguration(
- tuner.getTunerType(), name );
- }
-
- //Persist the config as the selected tuner configuration. The method
- //auto-saves the setting
- mSettingsManager.setSelectedTunerConfiguration(
- tuner.getTunerType(), tuner.getUniqueID(), config );
-
- return config;
- }
/**
* Gets the first tuner mixer dataline that corresponds to the tuner class.
@@ -625,15 +471,4 @@ public class TunerManager
}
}
- public static JPanel getEditor( SettingsManager settingsManager, Tuner tuner )
- {
- JPanel editor = tuner.getEditor( settingsManager );
-
- if( editor != null )
- {
- return editor;
- }
-
- return new EmptyEditor();
- }
}
diff --git a/src/source/tuner/TunerModel.java b/src/source/tuner/TunerModel.java
new file mode 100644
index 00000000..14ca0a3d
--- /dev/null
+++ b/src/source/tuner/TunerModel.java
@@ -0,0 +1,294 @@
+package source.tuner;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.RejectedExecutionException;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import sample.Listener;
+import source.Source;
+import source.SourceException;
+import source.config.SourceConfigTuner;
+import source.tuner.TunerEvent.Event;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationModel;
+
+public class TunerModel extends AbstractTableModel implements Listener
+{
+ private static final long serialVersionUID = 1L;
+
+ private final static Logger mLog = LoggerFactory.getLogger( TunerModel.class );
+
+ private static final int TUNER_CLASS = 0;
+ private static final int TUNER_TYPE = 1;
+ private static final int SAMPLE_RATE = 2;
+ private static final int FREQUENCY = 3;
+ private static final int CHANNEL_COUNT = 4;
+ private static final int SPECTRAL_DISPLAY = 5;
+
+ private static final String MHZ = " MHz";
+ private static final String[] COLUMNS =
+ { "Class", "Type", "Sample Rate", "Frequency", "Channels", "Spectrum" };
+
+ private List mTuners = new ArrayList<>();
+ private List> mTunerEventListeners = new ArrayList<>();
+ private DecimalFormat mFrequencyFormat = new DecimalFormat( "0.00000" );
+ private DecimalFormat mSampleRateFormat = new DecimalFormat( "0.000" );
+
+ private TunerConfigurationModel mTunerConfigurationModel;
+
+ public TunerModel( TunerConfigurationModel tunerConfigurationModel )
+ {
+ mTunerConfigurationModel = tunerConfigurationModel;
+ }
+
+ public TunerConfigurationModel getTunerConfigurationModel()
+ {
+ return mTunerConfigurationModel;
+ }
+
+ /**
+ * List of Tuners currently in the model
+ */
+ public List getTuners()
+ {
+ return mTuners;
+ }
+
+ public Tuner getTuner( int index )
+ {
+ if( index < mTuners.size() )
+ {
+ return mTuners.get( index );
+ }
+
+ return null;
+ }
+
+ public void addTuners( List Tuners )
+ {
+ for( Tuner tuner: Tuners )
+ {
+ addTuner( tuner );
+ }
+ }
+
+ /**
+ * Adds the Tuner to this model
+ */
+ public void addTuner( Tuner tuner )
+ {
+ if( !mTuners.contains( tuner ) )
+ {
+ //Get the tuner configuration and apply it to the tuner - this
+ //call should always produce a tuner configuration
+ TunerConfiguration config = mTunerConfigurationModel
+ .getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
+
+ try
+ {
+ tuner.apply( config );
+
+ mTuners.add( tuner );
+
+ int index = mTuners.indexOf( tuner );
+
+ fireTableRowsInserted( index, index );
+
+ tuner.addTunerChangeListener( this );
+ }
+ catch( SourceException se )
+ {
+ mLog.error( "Couldn't apply tuner configuration to tuner - ["
+ + tuner.getTunerType().name() + "] with id ["
+ + tuner.getUniqueID() + "] - tuner will not be included" );
+ }
+
+ }
+ }
+
+ /**
+ * Removes the Tuner from this model
+ */
+ public void removeTuner( Tuner tuner )
+ {
+ if( mTuners.contains( tuner ) )
+ {
+ tuner.removeTunerChangeListener( this );
+
+ int index = mTuners.indexOf( tuner );
+
+ mTuners.remove( tuner );
+
+ fireTableRowsDeleted( index, index );
+ }
+ }
+
+ public void addListener( Listener listener )
+ {
+ mTunerEventListeners.add( listener );
+ }
+
+ public void removeListener( Listener listener )
+ {
+ mTunerEventListeners.remove( listener );
+ }
+
+ public void broadcast( TunerEvent event )
+ {
+ for( Listener listener: mTunerEventListeners )
+ {
+ listener.receive( event );
+ }
+ }
+
+ /**
+ * Requests to display the first tuner in this model. Invoke this method
+ * after all listeners have registered and tuners have been added to this
+ * model, in order to inform the primary display to use the first tuner.
+ */
+ public void requestFirstTunerDisplay()
+ {
+ if( mTuners.size() > 0 )
+ {
+ broadcast( new TunerEvent( mTuners.get( 0 ),
+ Event.REQUEST_MAIN_SPECTRAL_DISPLAY ) );
+ }
+ }
+
+ @Override
+ public void receive( TunerEvent event )
+ {
+ if( event.getTuner() != null )
+ {
+ int index = mTuners.indexOf( event.getTuner() );
+
+ if( index >= 0 )
+ {
+ switch( event.getEvent() )
+ {
+ case CHANNEL_COUNT:
+ fireTableCellUpdated( index, CHANNEL_COUNT );
+ break;
+ case FREQUENCY:
+ fireTableCellUpdated( index, FREQUENCY );
+ break;
+ case SAMPLE_RATE:
+ fireTableCellUpdated( index, SAMPLE_RATE );
+ break;
+ case REQUEST_MAIN_SPECTRAL_DISPLAY:
+ fireTableCellUpdated( index, SPECTRAL_DISPLAY );
+ default:
+ break;
+ }
+ }
+ }
+
+ broadcast( event );
+ }
+
+ @Override
+ public int getRowCount()
+ {
+ return mTuners.size();
+ }
+
+ @Override
+ public int getColumnCount()
+ {
+ return 6;
+ }
+
+ @Override
+ public Object getValueAt( int rowIndex, int columnIndex )
+ {
+ if( rowIndex < mTuners.size() )
+ {
+ Tuner tuner = mTuners.get( rowIndex );
+
+ switch( columnIndex )
+ {
+ case TUNER_CLASS:
+ return tuner.getTunerClass().getVendorDescription();
+ case TUNER_TYPE:
+ return tuner.getTunerType().getLabel();
+ case SAMPLE_RATE:
+ int sampleRate = tuner.getSampleRate();
+
+ return mSampleRateFormat.format( sampleRate / 1E6D ) + MHZ;
+ case FREQUENCY:
+ try
+ {
+ long frequency = tuner.getFrequency();
+
+ return mFrequencyFormat.format( frequency / 1E6D ) + MHZ;
+ }
+ catch( Exception e )
+ {
+ return 0;
+ }
+ case CHANNEL_COUNT:
+ return tuner.getChannelCount();
+ case SPECTRAL_DISPLAY:
+ return "TBD";
+ default:
+ break;
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public String getColumnName( int columnIndex )
+ {
+ return COLUMNS[ columnIndex ];
+ }
+
+ /**
+ * Iterates current tuners to get a tuner channel source for the frequency
+ * specified in the channel config's source config object.
+ *
+ * Returns null if no tuner can source the channel
+ */
+ public Source getSource( SourceConfigTuner config, int bandwidth )
+ {
+ TunerChannelSource retVal = null;
+
+ TunerChannel tunerChannel = config.getTunerChannel();
+
+ tunerChannel.setBandwidth( bandwidth );
+
+ Iterator it = mTuners.iterator();
+
+ Tuner tuner;
+
+ while( it.hasNext() && retVal == null )
+ {
+ tuner = it.next();
+
+ try
+ {
+ retVal = tuner.getChannel( tunerChannel );
+ }
+ catch ( RejectedExecutionException ree )
+ {
+ mLog.error( "couldn't provide tuner channel source", ree );
+ }
+ catch ( SourceException e )
+ {
+ mLog.error( "error obtaining channel from tuner [" +
+ tuner.getName() + "]", e );
+ }
+ }
+
+ return retVal;
+ }
+
+}
diff --git a/src/source/tuner/TunerNode.java b/src/source/tuner/TunerNode.java
deleted file mode 100644
index fdba9a08..00000000
--- a/src/source/tuner/TunerNode.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package source.tuner;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.text.DecimalFormat;
-
-import javax.swing.JMenuItem;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import playlist.PlaylistManager;
-import settings.SettingsManager;
-import source.SourceException;
-import source.tuner.frequency.FrequencyChangeEvent;
-import source.tuner.frequency.IFrequencyChangeProcessor;
-import spectrum.SpectrumFrame;
-import controller.BaseNode;
-import controller.channel.ChannelModel;
-import controller.channel.ChannelProcessingManager;
-
-public class TunerNode extends BaseNode implements IFrequencyChangeProcessor
-{
- private final static Logger mLog =
- LoggerFactory.getLogger( TunerNode.class );
-
- private static final long serialVersionUID = 1L;
- private static DecimalFormat FREQUENCY_FORMAT = new DecimalFormat( "0.00000" );
- private static DecimalFormat SAMPLE_RATE_FORMAT = new DecimalFormat( "0.000" );
-
- private long mFrequency;
- private int mSampleRate;
- private ChannelModel mChannelModel;
- private ChannelProcessingManager mChannelProcessingManager;
- private SettingsManager mSettingsManager;
-
- public TunerNode( ChannelModel channelModel,
- ChannelProcessingManager channelProcessingManager,
- SettingsManager settingsManager,
- Tuner tuner )
- {
- super( tuner ); //does this make it a super tuner?
-
- mChannelModel = channelModel;
- mChannelProcessingManager = channelProcessingManager;
- mSettingsManager = settingsManager;
-
- tuner.addFrequencyChangeProcessor( this );
-
- try
- {
- mFrequency = tuner.getFrequency();
- mSampleRate = tuner.getSampleRate();
- }
- catch ( SourceException e )
- {
- mLog.error( "TunerNode - error reading frequency and sample rate "
- + "from tuner", e );
- }
- }
-
- @Override
- public JPanel getEditor()
- {
- return getTuner().getEditor( mSettingsManager );
- }
-
- public Tuner getTuner()
- {
- return (Tuner)getUserObject();
- }
-
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( getTuner().getName() );
-
- sb.append( " " );
- sb.append( FREQUENCY_FORMAT.format( (double)mFrequency / 1E6d ) );
- sb.append( " [" );
- sb.append( SAMPLE_RATE_FORMAT.format( (double)mSampleRate / 1E6d ) );
- sb.append( "] MHz" );
-
- return sb.toString();
- }
-
- public JPopupMenu getContextMenu()
- {
- JPopupMenu retVal = new JPopupMenu();
-
- JMenuItem showSpectrumItem = new JMenuItem( "Show in Main Spectrum" );
- showSpectrumItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- getModel().fireTunerSelectedEvent( getTuner() );
- }
- } );
-
- retVal.add( showSpectrumItem );
-
- JMenuItem newSpectrumItem = new JMenuItem( "New Spectrum Window" );
- newSpectrumItem.addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- SpectrumFrame frame = new SpectrumFrame( getModel(), mChannelModel,
- mChannelProcessingManager, mSettingsManager, getTuner() );
- }
- } );
-
- retVal.add( newSpectrumItem );
-
- return retVal;
- }
-
- @Override
- public void frequencyChanged( FrequencyChangeEvent event )
- {
- switch( event.getEvent() )
- {
- case NOTIFICATION_FREQUENCY_CHANGE:
- long frequency = event.getValue().longValue();
-
- if( mFrequency != frequency )
- {
- mFrequency = frequency;
- getModel().nodeChanged( TunerNode.this );
- }
- break;
- case NOTIFICATION_SAMPLE_RATE_CHANGE:
- int sampleRate = event.getValue().intValue();
-
- if( mSampleRate != sampleRate )
- {
- mSampleRate = sampleRate;
- getModel().nodeChanged( TunerNode.this );
- }
- break;
- default:
- break;
- }
- }
-}
diff --git a/src/source/tuner/TunerSelectionListener.java b/src/source/tuner/TunerSelectionListener.java
deleted file mode 100644
index 52ebff6d..00000000
--- a/src/source/tuner/TunerSelectionListener.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package source.tuner;
-
-public interface TunerSelectionListener
-{
- public void tunerSelected( Tuner tuner );
-}
diff --git a/src/source/tuner/TunerType.java b/src/source/tuner/TunerType.java
index 75dc06ca..65b293f3 100644
--- a/src/source/tuner/TunerType.java
+++ b/src/source/tuner/TunerType.java
@@ -19,7 +19,7 @@ package source.tuner;
public enum TunerType
{
- AIRSPY_R820T( "R820T/R820T2" ),
+ AIRSPY_R820T( "Airspy R820T" ),
ELONICS_E4000( "E4000" ),
ETTUS_WBX( "WBX" ),
ETTUS_VARIOUS( "Ettus Tuner" ),
diff --git a/src/source/TunerViewPanel.java b/src/source/tuner/TunerViewPanel.java
similarity index 61%
rename from src/source/TunerViewPanel.java
rename to src/source/tuner/TunerViewPanel.java
index 5b577bfb..c6a5879d 100644
--- a/src/source/TunerViewPanel.java
+++ b/src/source/tuner/TunerViewPanel.java
@@ -1,8 +1,5 @@
-package source;
+package source.tuner;
-import gui.editor.EmptyEditor;
-
-import java.awt.Component;
import java.awt.Dimension;
import javax.swing.JPanel;
@@ -17,10 +14,6 @@ import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import settings.SettingsManager;
-import source.tuner.Tuner;
-import source.tuner.TunerManager;
-
import com.jidesoft.swing.JideSplitPane;
public class TunerViewPanel extends JPanel
@@ -29,21 +22,22 @@ public class TunerViewPanel extends JPanel
private final static Logger mLog = LoggerFactory.getLogger( TunerViewPanel.class );
private TunerModel mTunerModel;
- private SettingsManager mSettingsManager;
- private JideSplitPane mSplitPane;
private JTable mTunerTable;
+
+ private JideSplitPane mSplitPane;
+ private TunerEditor mTunerEditor;
- public TunerViewPanel( TunerModel tunerModel, SettingsManager settingsManager )
+ public TunerViewPanel( TunerModel tunerModel )
{
mTunerModel = tunerModel;
- mSettingsManager = settingsManager;
+ mTunerEditor = new TunerEditor( mTunerModel.getTunerConfigurationModel() );
init();
}
private void init()
{
- setLayout( new MigLayout( "insets 1 1 1 1", "[fill,grow]", "[fill,grow]" ) );
+ setLayout( new MigLayout( "insets 0 0 0 0", "[fill,grow]", "[fill,grow]" ) );
mTunerTable = new JTable( mTunerModel );
mTunerTable.setSelectionMode( ListSelectionModel.SINGLE_SELECTION );
@@ -56,29 +50,8 @@ public class TunerViewPanel extends JPanel
{
int row = mTunerTable.getSelectedRow();
int modelRow = mTunerTable.convertRowIndexToModel( row );
-
- Tuner selected = mTunerModel.getTuner( modelRow );
-
- Component component = null;
-
- if( selected != null )
- {
- JPanel tunerEditor = TunerManager
- .getEditor( mSettingsManager, selected );
-
- component = new JScrollPane( tunerEditor );
- }
- else
- {
- component = new EmptyEditor();
- }
- int split = mSplitPane.getDividerLocation( 0 );
-
- mSplitPane.remove( 2 );
- mSplitPane.add( component );
- mSplitPane.setDividerLocation( 0, split );
- validate();
+ mTunerEditor.setItem( mTunerModel.getTuner( modelRow ) );
}
}
} );
@@ -86,7 +59,7 @@ public class TunerViewPanel extends JPanel
JScrollPane listScroller = new JScrollPane( mTunerTable );
listScroller.setPreferredSize( new Dimension( 400, 20 ) );
- JScrollPane editorScroller = new JScrollPane( new EmptyEditor() );
+ JScrollPane editorScroller = new JScrollPane( mTunerEditor );
editorScroller.setPreferredSize( new Dimension( 400, 80 ) );
mSplitPane = new JideSplitPane();
@@ -96,4 +69,6 @@ public class TunerViewPanel extends JPanel
add( mSplitPane );
}
+
+
}
diff --git a/src/source/tuner/airspy/AirspyTuner.java b/src/source/tuner/airspy/AirspyTuner.java
index 4637bfc8..3d1406f3 100644
--- a/src/source/tuner/airspy/AirspyTuner.java
+++ b/src/source/tuner/airspy/AirspyTuner.java
@@ -29,13 +29,13 @@ import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
-import source.tuner.TunerChangeEvent;
+import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerController.BoardID;
+import source.tuner.configuration.TunerConfiguration;
public class AirspyTuner extends Tuner
{
@@ -54,12 +54,6 @@ public class AirspyTuner extends Tuner
mController.addListener( this );
}
- @Override
- public JPanel getEditor( SettingsManager settingsManager )
- {
- return new AirspyTunerEditorPanel( this, settingsManager );
- }
-
public AirspyTunerController getController()
{
return mController;
@@ -142,7 +136,7 @@ public class AirspyTuner extends Tuner
if( source != null )
{
- broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
+ broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
return source;
diff --git a/src/source/tuner/airspy/AirspyTunerConfiguration.java b/src/source/tuner/airspy/AirspyTunerConfiguration.java
index 52a3a818..5b50c348 100644
--- a/src/source/tuner/airspy/AirspyTunerConfiguration.java
+++ b/src/source/tuner/airspy/AirspyTunerConfiguration.java
@@ -19,9 +19,9 @@ package source.tuner.airspy;
import javax.xml.bind.annotation.XmlAttribute;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerController.Gain;
+import source.tuner.configuration.TunerConfiguration;
public class AirspyTunerConfiguration extends TunerConfiguration
{
diff --git a/src/source/tuner/airspy/AirspyTunerConfigurationPanel.java b/src/source/tuner/airspy/AirspyTunerConfigurationPanel.java
index 937a63f8..781c52e2 100644
--- a/src/source/tuner/airspy/AirspyTunerConfigurationPanel.java
+++ b/src/source/tuner/airspy/AirspyTunerConfigurationPanel.java
@@ -47,11 +47,11 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTunerController.Gain;
import source.tuner.airspy.AirspyTunerController.GainMode;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationAssignment;
public class AirspyTunerConfigurationPanel extends JPanel
{
@@ -126,8 +126,8 @@ public class AirspyTunerConfigurationPanel extends JPanel
if( serial != null )
{
- savedConfig = mSettingsManager.getSelectedTunerConfiguration(
- TunerType.AIRSPY_R820T, serial );
+// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
+// TunerType.AIRSPY_R820T, serial );
}
if( savedConfig != null )
@@ -145,8 +145,8 @@ public class AirspyTunerConfigurationPanel extends JPanel
if( serial != null )
{
- mSettingsManager.setSelectedTunerConfiguration( TunerType.AIRSPY_R820T,
- serial, mSelectedConfig );
+// mSettingsManager.setSelectedTunerConfiguration( TunerType.AIRSPY_R820T,
+// serial, mSelectedConfig );
}
}
@@ -515,16 +515,16 @@ public class AirspyTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
- TunerConfiguration config =
- mSettingsManager.addNewTunerConfiguration(
- TunerType.AIRSPY_R820T,
- "New Configuration" );
-
- mComboConfigurations.setModel( getModel() );
-
- mComboConfigurations.setSelectedItem( config );
-
- repaint();
+// TunerConfiguration config =
+// mSettingsManager.addNewTunerConfiguration(
+// TunerType.AIRSPY_R820T,
+// "New Configuration" );
+//
+// mComboConfigurations.setModel( getModel() );
+//
+// mComboConfigurations.setSelectedItem( config );
+//
+// repaint();
}
} );
@@ -555,7 +555,7 @@ public class AirspyTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
- mSettingsManager.deleteTunerConfiguration( selected );
+// mSettingsManager.deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -631,8 +631,8 @@ public class AirspyTunerConfigurationPanel extends JPanel
mGainModeCombo.setSelectedItem( Gain.getGainMode( gain ) );
mGain.setValue( gain.getValue() );
- mSettingsManager.setSelectedTunerConfiguration(
- TunerType.AIRSPY_R820T, mController.getDeviceInfo().getSerialNumber(), config );
+// mSettingsManager.setSelectedTunerConfiguration(
+// TunerType.AIRSPY_R820T, mController.getDeviceInfo().getSerialNumber(), config );
save();
}
@@ -656,16 +656,16 @@ public class AirspyTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel getModel()
{
- ArrayList configs =
- mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
+// ArrayList configs =
+// mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
DefaultComboBoxModel model =
new DefaultComboBoxModel();
- for( TunerConfiguration config: configs )
- {
- model.addElement( (AirspyTunerConfiguration)config );
- }
+// for( TunerConfiguration config: configs )
+// {
+// model.addElement( (AirspyTunerConfiguration)config );
+// }
return model;
}
@@ -675,16 +675,16 @@ public class AirspyTunerConfigurationPanel extends JPanel
*/
private AirspyTunerConfiguration getNamedConfiguration( String name )
{
- ArrayList configs =
- mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
+// ArrayList configs =
+// mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
- for( TunerConfiguration config: configs )
- {
- if( config.getName().contentEquals( name ) )
- {
- return (AirspyTunerConfiguration)config;
- }
- }
+// for( TunerConfiguration config: configs )
+// {
+// if( config.getName().contentEquals( name ) )
+// {
+// return (AirspyTunerConfiguration)config;
+// }
+// }
return null;
}
diff --git a/src/source/tuner/airspy/AirspyTunerController.java b/src/source/tuner/airspy/AirspyTunerController.java
index fb82784d..e132e59e 100644
--- a/src/source/tuner/airspy/AirspyTunerController.java
+++ b/src/source/tuner/airspy/AirspyTunerController.java
@@ -28,8 +28,8 @@ import sample.Broadcaster;
import sample.Listener;
import sample.complex.ComplexBuffer;
import source.SourceException;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerController;
+import source.tuner.configuration.TunerConfiguration;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
import dsp.filter.dc.DCRemovalFilter_RB;
diff --git a/src/source/tuner/TunerConfiguration.java b/src/source/tuner/configuration/TunerConfiguration.java
similarity index 96%
rename from src/source/tuner/TunerConfiguration.java
rename to src/source/tuner/configuration/TunerConfiguration.java
index d82977da..eee31f3f 100644
--- a/src/source/tuner/TunerConfiguration.java
+++ b/src/source/tuner/configuration/TunerConfiguration.java
@@ -15,11 +15,13 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
******************************************************************************/
-package source.tuner;
+package source.tuner.configuration;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
+import source.tuner.TunerType;
+
/**
* Abstract class to hold a named configuration for a specific type of tuner
*/
diff --git a/src/source/tuner/TunerConfigurationAssignment.java b/src/source/tuner/configuration/TunerConfigurationAssignment.java
similarity index 96%
rename from src/source/tuner/TunerConfigurationAssignment.java
rename to src/source/tuner/configuration/TunerConfigurationAssignment.java
index 0cb450bf..3e3fcf2e 100644
--- a/src/source/tuner/TunerConfigurationAssignment.java
+++ b/src/source/tuner/configuration/TunerConfigurationAssignment.java
@@ -15,10 +15,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
******************************************************************************/
-package source.tuner;
+package source.tuner.configuration;
import javax.xml.bind.annotation.XmlAttribute;
+import source.tuner.TunerType;
+
public class TunerConfigurationAssignment
{
private TunerType mTunerType;
diff --git a/src/source/tuner/configuration/TunerConfigurationEditor.java b/src/source/tuner/configuration/TunerConfigurationEditor.java
new file mode 100644
index 00000000..1c02f4b0
--- /dev/null
+++ b/src/source/tuner/configuration/TunerConfigurationEditor.java
@@ -0,0 +1,20 @@
+package source.tuner.configuration;
+
+import gui.editor.Editor;
+
+public abstract class TunerConfigurationEditor extends Editor
+{
+ private static final long serialVersionUID = 1L;
+
+ private TunerConfigurationModel mTunerConfigurationModel;
+
+ public TunerConfigurationEditor( TunerConfigurationModel model )
+ {
+ mTunerConfigurationModel = model;
+ }
+
+ public TunerConfigurationModel getTunerConfigurationModel()
+ {
+ return mTunerConfigurationModel;
+ }
+}
diff --git a/src/source/tuner/configuration/TunerConfigurationEvent.java b/src/source/tuner/configuration/TunerConfigurationEvent.java
new file mode 100644
index 00000000..3815c7b7
--- /dev/null
+++ b/src/source/tuner/configuration/TunerConfigurationEvent.java
@@ -0,0 +1,45 @@
+package source.tuner.configuration;
+
+public class TunerConfigurationEvent
+{
+ private TunerConfiguration mTunerConfiguration;
+ private TunerConfigurationAssignment mTunerConfigurationAssignment;
+ private Event mEvent;
+
+ public TunerConfigurationEvent( TunerConfiguration configuration, Event event )
+ {
+ mTunerConfiguration = configuration;
+ mEvent = event;
+ }
+
+ public TunerConfigurationEvent( TunerConfigurationAssignment assignment, Event event )
+ {
+ mTunerConfigurationAssignment = assignment;
+ mEvent = event;
+ }
+
+ public TunerConfiguration getConfiguration()
+ {
+ return mTunerConfiguration;
+ }
+
+ public TunerConfigurationAssignment getAssignment()
+ {
+ return mTunerConfigurationAssignment;
+ }
+
+ public Event getEvent()
+ {
+ return mEvent;
+ }
+
+ public enum Event
+ {
+ CONFIGURATION_ADD,
+ CONFIGURATION_REMOVE,
+ CONFIGURATION_CHANGE,
+ ASSIGNMENT_ADD,
+ ASSIGNMENT_REMOVE,
+ ASSIGNMENT_CHANGE;
+ }
+}
diff --git a/src/source/tuner/configuration/TunerConfigurationFactory.java b/src/source/tuner/configuration/TunerConfigurationFactory.java
new file mode 100644
index 00000000..2af4a4eb
--- /dev/null
+++ b/src/source/tuner/configuration/TunerConfigurationFactory.java
@@ -0,0 +1,64 @@
+package source.tuner.configuration;
+
+import source.tuner.Tuner;
+import source.tuner.TunerType;
+import source.tuner.airspy.AirspyTunerConfiguration;
+import source.tuner.fcd.proV1.FCD1TunerConfiguration;
+import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
+import source.tuner.hackrf.HackRFTunerConfiguration;
+import source.tuner.rtl.RTL2832Tuner;
+import source.tuner.rtl.e4k.E4KTunerConfiguration;
+import source.tuner.rtl.r820t.R820TTunerConfiguration;
+import source.tuner.rtl.r820t.R820TTunerEditor;
+
+public class TunerConfigurationFactory
+{
+ public static TunerConfiguration getTunerConfiguration( TunerType type, String name )
+ {
+ switch( type )
+ {
+ case AIRSPY_R820T:
+ return new AirspyTunerConfiguration( name );
+ case ELONICS_E4000:
+ return new E4KTunerConfiguration( name );
+ case FUNCUBE_DONGLE_PRO:
+ return new FCD1TunerConfiguration( name );
+ case FUNCUBE_DONGLE_PRO_PLUS:
+ return new FCD2TunerConfiguration( name );
+ case HACKRF:
+ return new HackRFTunerConfiguration( name );
+ case RAFAELMICRO_R820T:
+ return new R820TTunerConfiguration( name );
+ default:
+ throw new IllegalArgumentException( "Unrecognized tuner type ["
+ + type.name() + "] - can't create named [" + name + "] tuner"
+ + " configuration" );
+ }
+ }
+
+ public static TunerConfigurationEditor getEditor( Tuner tuner,
+ TunerConfigurationModel model )
+ {
+ switch( tuner.getTunerType() )
+ {
+ case AIRSPY_R820T:
+ break;
+ case ELONICS_E4000:
+ break;
+ case FUNCUBE_DONGLE_PRO:
+ break;
+ case FUNCUBE_DONGLE_PRO_PLUS:
+ break;
+ case HACKRF:
+ break;
+ case RAFAELMICRO_R820T:
+ return new R820TTunerEditor( model, (RTL2832Tuner)tuner );
+ case UNKNOWN:
+ default:
+ break;
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/source/tuner/configuration/TunerConfigurationModel.java b/src/source/tuner/configuration/TunerConfigurationModel.java
new file mode 100644
index 00000000..d41bd7c7
--- /dev/null
+++ b/src/source/tuner/configuration/TunerConfigurationModel.java
@@ -0,0 +1,370 @@
+package source.tuner.configuration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.RowFilter;
+import javax.swing.table.AbstractTableModel;
+import javax.swing.table.TableRowSorter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import sample.Listener;
+import source.tuner.TunerType;
+import source.tuner.TunerViewPanel;
+import source.tuner.configuration.TunerConfigurationEvent.Event;
+
+public class TunerConfigurationModel extends AbstractTableModel
+{
+ private static final long serialVersionUID = 1L;
+ private final static Logger mLog =
+ LoggerFactory.getLogger( TunerConfigurationModel.class );
+
+ private static final int TUNER_TYPE = 0;
+ private static final int CONFIGURATION_NAME = 1;
+ private static final String[] COLUMN_HEADERS = { "Tuner Type", "Name" };
+
+ private List> mConfigurationListeners = new ArrayList<>();
+ private List mTunerConfigurations = new ArrayList<>();
+ private List mTunerConfigurationAssignments = new ArrayList<>();
+
+ /**
+ * Table model for managing tuner configurations and tuner configuration
+ * assignments. Provides tuner configuration events to registered listeners
+ */
+ public TunerConfigurationModel()
+ {
+ }
+
+ /**
+ * Adds the list of tuner configurations to the model
+ */
+ public void addTunerConfigurations( List configs )
+ {
+ for( TunerConfiguration config: configs )
+ {
+ addTunerConfiguration( config );
+ }
+ }
+
+ /**
+ * Returns of list of tuner configurations from the model
+ */
+ public List getTunerConfigurations()
+ {
+ return mTunerConfigurations;
+ }
+
+ /**
+ * Adds the tuner configuration to the model firing a table model row add
+ * event and broadcasting a tuner configuration event.
+ */
+ public void addTunerConfiguration( TunerConfiguration config )
+ {
+ if( !mTunerConfigurations.contains( config ) )
+ {
+ mTunerConfigurations.add( config );
+
+ int index = mTunerConfigurations.indexOf( config );
+
+ fireTableRowsInserted( index, index );
+
+ broadcast( new TunerConfigurationEvent( config, Event.CONFIGURATION_ADD ) );
+ }
+ }
+
+ /**
+ * Removes the tuner configuration from the model firing a table model row
+ * delete event and broadcasting a tuner configuration event.
+ */
+ public void removeTunerConfiguration( TunerConfiguration config )
+ {
+ if( mTunerConfigurations.contains( config ) )
+ {
+ int index = mTunerConfigurations.indexOf( config );
+
+ mTunerConfigurations.remove( config );
+
+ fireTableRowsDeleted( index, index );
+
+ broadcast( new TunerConfigurationEvent( config, Event.CONFIGURATION_REMOVE ) );
+ }
+ }
+
+ /**
+ * Removes all tuner configurations and assignments from the model and
+ * fires a table clear event and broadcasts a tuner configuration event for
+ * each row removed.
+ */
+ public void clear()
+ {
+ for( TunerConfiguration config: mTunerConfigurations )
+ {
+ broadcast( new TunerConfigurationEvent( config, Event.CONFIGURATION_REMOVE ) );
+ }
+
+ int size = mTunerConfigurations.size();
+
+ mTunerConfigurations.clear();
+
+ fireTableRowsDeleted( 0, size - 1 );
+
+ for( TunerConfigurationAssignment assignment: mTunerConfigurationAssignments )
+ {
+ broadcast( new TunerConfigurationEvent( assignment, Event.ASSIGNMENT_REMOVE ) );
+ }
+
+ mTunerConfigurationAssignments.clear();
+ }
+
+ /**
+ * Registers a tuner configuration event listener
+ */
+ public void addListener( Listener listener )
+ {
+ mConfigurationListeners.add( listener );
+ }
+
+ /**
+ * Removes the tuner configuration event listener
+ */
+ public void removeListener( Listener listener )
+ {
+ mConfigurationListeners.remove( listener );
+ }
+
+ /**
+ * Broadcasts a tuner configuration event
+ */
+ public void broadcast( TunerConfigurationEvent event )
+ {
+ for( Listener listener: mConfigurationListeners )
+ {
+ listener.receive( event );
+ }
+ }
+
+ /**
+ * Adds a list of tuner configuration assignments to the model
+ */
+ public void addTunerConfigurationAssignments( List assignments )
+ {
+ for( TunerConfigurationAssignment assigment: assignments )
+ {
+ addTunerConfigurationAssignment( assigment );
+ }
+ }
+
+ /**
+ * Returns of list of tuner configurations from the model
+ */
+ public List getTunerConfigurationAssignments()
+ {
+ return mTunerConfigurationAssignments;
+ }
+
+ /**
+ * Adds a tuner configuration assigment to the model
+ */
+ public void addTunerConfigurationAssignment( TunerConfigurationAssignment assignment )
+ {
+ mTunerConfigurationAssignments.add( assignment );
+
+ broadcast( new TunerConfigurationEvent( assignment, Event.ASSIGNMENT_ADD ) );
+ }
+
+ /**
+ * Removes a tuner configuration assignment from the model
+ */
+ public void removeTunerConfigurationAssignment( TunerConfigurationAssignment assignment )
+ {
+ mTunerConfigurationAssignments.remove( assignment );
+
+ broadcast( new TunerConfigurationEvent( assignment, Event.ASSIGNMENT_REMOVE ) );
+ }
+
+ /**
+ * Returns the tuner configuration that is assigned to the tuner with the
+ * tuner type and uniqueID, or creates a new tuner configuration and tuner
+ * configuration assignment for the tuner.
+ */
+ public TunerConfiguration getTunerConfiguration( TunerType type, String uniqueID )
+ {
+ String configurationName = null;
+
+ TunerConfigurationAssignment assignment = getTunerConfigurationAssignment( type, uniqueID );
+
+ if( assignment != null )
+ {
+ configurationName = assignment.getTunerConfigurationName();
+ }
+
+ if( configurationName == null )
+ {
+ configurationName = "Default-" + uniqueID;
+ }
+
+ List configs = getTunerConfigurations( type );
+
+ for( TunerConfiguration config: configs )
+ {
+ if( config.getName().contentEquals( configurationName ) )
+ {
+ if( assignment == null )
+ {
+ assignTunerConfiguration( config, configurationName );
+ }
+
+ return config;
+ }
+ }
+
+ //We didn't find the config so create a new one and assign it
+ TunerConfiguration config = TunerConfigurationFactory
+ .getTunerConfiguration( type, configurationName );
+
+ addTunerConfiguration( config );
+ assignTunerConfiguration( config, configurationName );
+
+ return config;
+ }
+
+ /**
+ * Assigns the tuner configuration to the tuner identified by the uniqueID
+ */
+ public void assignTunerConfiguration( TunerConfiguration config, String uniqueID )
+ {
+ TunerConfigurationAssignment assignment =
+ getTunerConfigurationAssignment( config.getTunerType(), uniqueID );
+
+ Event event = Event.ASSIGNMENT_CHANGE;
+
+ if( assignment == null )
+ {
+ assignment = new TunerConfigurationAssignment();
+ assignment.setUniqueID( uniqueID );
+
+ addTunerConfigurationAssignment( assignment );
+
+ event = Event.ASSIGNMENT_ADD;
+ }
+
+ assignment.setTunerConfigurationName( config.getName() );
+
+ broadcast( new TunerConfigurationEvent( assignment, event ) );
+ }
+
+ /**
+ * Returns the tuner configuration assiged to the tuner type and unique id
+ */
+ private TunerConfigurationAssignment getTunerConfigurationAssignment( TunerType type, String uniqueID )
+ {
+ for( TunerConfigurationAssignment assignment: mTunerConfigurationAssignments )
+ {
+ if( assignment.getTunerType() == type &&
+ assignment.getUniqueID().contentEquals( uniqueID ) )
+ {
+ return assignment;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns all tuner configurations for the specified tuner type
+ */
+ public List getTunerConfigurations( TunerType type )
+ {
+ List configs = new ArrayList<>();
+
+ for( TunerConfiguration config: mTunerConfigurations )
+ {
+ if( config.getTunerType() == type )
+ {
+ configs.add( config );
+ }
+ }
+
+ return configs;
+ }
+
+ /**
+ * Column names for the table model
+ */
+ @Override
+ public String getColumnName( int column )
+ {
+ return COLUMN_HEADERS[ column ];
+ }
+
+ /**
+ * Tuner configuration model row count
+ */
+ @Override
+ public int getRowCount()
+ {
+ return mTunerConfigurations.size();
+ }
+
+ /**
+ * Tuner configuration model column count
+ */
+ @Override
+ public int getColumnCount()
+ {
+ return COLUMN_HEADERS.length;
+ }
+
+ /**
+ * Returns the row index for the specified configuration or -1
+ */
+ public int getRowIndex( TunerConfiguration configuration )
+ {
+ if( mTunerConfigurations.contains( configuration ) )
+ {
+ return mTunerConfigurations.indexOf( configuration );
+ }
+
+ return -1;
+ }
+
+ /**
+ * Returns the configuration at the specified index or null
+ */
+ public TunerConfiguration getTunerConfiguration( int index )
+ {
+ if( index >= 0 && index < mTunerConfigurations.size() )
+ {
+ return mTunerConfigurations.get( index );
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the value at the indicated table cell
+ */
+ @Override
+ public Object getValueAt( int row, int column )
+ {
+ if( row >= 0 && row < mTunerConfigurations.size() )
+ {
+ TunerConfiguration config = mTunerConfigurations.get( row );
+
+ switch( column )
+ {
+ case TUNER_TYPE:
+ return config.getTunerType().getLabel();
+ case CONFIGURATION_NAME:
+ return config.getName();
+ default:
+ break;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/source/tuner/ettus/B100Tuner.java b/src/source/tuner/ettus/B100Tuner.java
index b14e0e77..40e4c6b8 100644
--- a/src/source/tuner/ettus/B100Tuner.java
+++ b/src/source/tuner/ettus/B100Tuner.java
@@ -30,8 +30,8 @@ import source.tuner.Tuner;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.usb.USBTunerDevice;
import controller.ThreadPoolManager;
@@ -68,12 +68,6 @@ public class B100Tuner extends Tuner
return TunerType.ETTUS_WBX;
}
- @Override
- public JPanel getEditor( SettingsManager settingsManager )
- {
- return new B100TunerEditorPanel( this, settingsManager );
- }
-
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
diff --git a/src/source/tuner/fcd/FCDTuner.java b/src/source/tuner/fcd/FCDTuner.java
index e2a1bcfa..9ce5087b 100644
--- a/src/source/tuner/fcd/FCDTuner.java
+++ b/src/source/tuner/fcd/FCDTuner.java
@@ -28,12 +28,12 @@ import settings.SettingsManager;
import source.SourceException;
import source.tuner.MixerTuner;
import source.tuner.MixerTunerDataLine;
-import source.tuner.TunerChangeEvent;
+import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
public class FCDTuner extends MixerTuner
{
@@ -80,12 +80,6 @@ public class FCDTuner extends MixerTuner
return mController.getUSBAddress();
}
- @Override
- public JPanel getEditor( SettingsManager settingsManager )
- {
- return mController.getEditor( this, settingsManager );
- }
-
@Override
public void apply( TunerConfiguration config )throws SourceException
{
@@ -118,7 +112,7 @@ public class FCDTuner extends MixerTuner
if( source != null )
{
- broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
+ broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
return source;
diff --git a/src/source/tuner/fcd/FCDTunerController.java b/src/source/tuner/fcd/FCDTunerController.java
index ca602ed2..d1fdfd62 100644
--- a/src/source/tuner/fcd/FCDTunerController.java
+++ b/src/source/tuner/fcd/FCDTunerController.java
@@ -36,9 +36,9 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerController;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerController.Block;
public abstract class FCDTunerController extends TunerController
diff --git a/src/source/tuner/fcd/proV1/FCD1TunerConfiguration.java b/src/source/tuner/fcd/proV1/FCD1TunerConfiguration.java
index 29a7b0f4..43152221 100644
--- a/src/source/tuner/fcd/proV1/FCD1TunerConfiguration.java
+++ b/src/source/tuner/fcd/proV1/FCD1TunerConfiguration.java
@@ -19,8 +19,8 @@ package source.tuner.fcd.proV1;
import javax.xml.bind.annotation.XmlAttribute;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
import source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
import source.tuner.fcd.proV1.FCD1TunerController.MixerGain;
diff --git a/src/source/tuner/fcd/proV1/FCD1TunerConfigurationPanel.java b/src/source/tuner/fcd/proV1/FCD1TunerConfigurationPanel.java
index b54bef0b..051d597f 100644
--- a/src/source/tuner/fcd/proV1/FCD1TunerConfigurationPanel.java
+++ b/src/source/tuner/fcd/proV1/FCD1TunerConfigurationPanel.java
@@ -49,8 +49,8 @@ import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
import source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
import source.tuner.fcd.proV1.FCD1TunerController.MixerGain;
@@ -426,14 +426,14 @@ public class FCD1TunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
- TunerConfiguration config =
- mSettingsManager.addNewTunerConfiguration(
- TunerType.FUNCUBE_DONGLE_PRO,
- "New Configuration" );
+// TunerConfiguration config =
+// mSettingsManager.addNewTunerConfiguration(
+// TunerType.FUNCUBE_DONGLE_PRO,
+// "New Configuration" );
mComboConfigurations.setModel( getModel() );
- mComboConfigurations.setSelectedItem( config );
+// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -470,7 +470,7 @@ public class FCD1TunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
- mSettingsManager.deleteTunerConfiguration( selected );
+// mSettingsManager.deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -505,9 +505,9 @@ public class FCD1TunerConfigurationPanel extends JPanel
mCorrectionGain.setValue( config.getGainCorrection() );
mCorrectionPhase.setValue( config.getPhaseCorrection() );
- mSettingsManager.setSelectedTunerConfiguration(
- TunerType.FUNCUBE_DONGLE_PRO,
- mController.getUSBAddress(), config );
+// mSettingsManager.setSelectedTunerConfiguration(
+// TunerType.FUNCUBE_DONGLE_PRO,
+// mController.getUSBAddress(), config );
}
catch ( SourceException e1 )
{
@@ -524,16 +524,16 @@ public class FCD1TunerConfigurationPanel extends JPanel
private ComboBoxModel getModel()
{
- ArrayList configs =
- mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
+// ArrayList configs =
+// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
DefaultComboBoxModel model =
new DefaultComboBoxModel();
- for( TunerConfiguration config: configs )
- {
- model.addElement( (FCD1TunerConfiguration)config );
- }
+// for( TunerConfiguration config: configs )
+// {
+// model.addElement( (FCD1TunerConfiguration)config );
+// }
return model;
}
@@ -541,16 +541,16 @@ public class FCD1TunerConfigurationPanel extends JPanel
@SuppressWarnings( "unused" )
private FCD1TunerConfiguration getNamedConfiguration( String name )
{
- ArrayList configs =
- mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
+// ArrayList configs =
+// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
- for( TunerConfiguration config: configs )
- {
- if( config.getName().contentEquals( name ) )
- {
- return (FCD1TunerConfiguration)config;
- }
- }
+// for( TunerConfiguration config: configs )
+// {
+// if( config.getName().contentEquals( name ) )
+// {
+// return (FCD1TunerConfiguration)config;
+// }
+// }
return null;
}
diff --git a/src/source/tuner/fcd/proV1/FCD1TunerController.java b/src/source/tuner/fcd/proV1/FCD1TunerController.java
index 8de3053c..005950b1 100644
--- a/src/source/tuner/fcd/proV1/FCD1TunerController.java
+++ b/src/source/tuner/fcd/proV1/FCD1TunerController.java
@@ -32,8 +32,8 @@ import org.usb4java.DeviceDescriptor;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.FCDCommand;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerController;
diff --git a/src/source/tuner/fcd/proplusV2/FCD2TunerConfiguration.java b/src/source/tuner/fcd/proplusV2/FCD2TunerConfiguration.java
index 06a4de4d..b2955570 100644
--- a/src/source/tuner/fcd/proplusV2/FCD2TunerConfiguration.java
+++ b/src/source/tuner/fcd/proplusV2/FCD2TunerConfiguration.java
@@ -19,8 +19,8 @@ package source.tuner.fcd.proplusV2;
import javax.xml.bind.annotation.XmlAttribute;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
public class FCD2TunerConfiguration extends TunerConfiguration
{
diff --git a/src/source/tuner/fcd/proplusV2/FCD2TunerConfigurationPanel.java b/src/source/tuner/fcd/proplusV2/FCD2TunerConfigurationPanel.java
index 8bd20ac9..991d0b11 100644
--- a/src/source/tuner/fcd/proplusV2/FCD2TunerConfigurationPanel.java
+++ b/src/source/tuner/fcd/proplusV2/FCD2TunerConfigurationPanel.java
@@ -48,9 +48,9 @@ import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationAssignment;
public class FCD2TunerConfigurationPanel extends JPanel
{
@@ -218,26 +218,26 @@ public class FCD2TunerConfigurationPanel extends JPanel
* Lookup the save config and apply that config to update all of the
* controls
*/
- TunerConfigurationAssignment savedConfig = mSettingsManager
- .getSelectedTunerConfiguration(
- TunerType.FUNCUBE_DONGLE_PRO_PLUS,
- mController.getUSBAddress() );
-
- if( savedConfig != null )
- {
- mSelectedConfig = getNamedConfiguration(
- savedConfig.getTunerConfigurationName() );
- }
+// TunerConfigurationAssignment savedConfig = mSettingsManager
+// .getSelectedTunerConfiguration(
+// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
+// mController.getUSBAddress() );
+//
+// if( savedConfig != null )
+// {
+// mSelectedConfig = getNamedConfiguration(
+// savedConfig.getTunerConfigurationName() );
+// }
if( mSelectedConfig == null )
{
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
- //Store this config as the default for this tuner at this address
- mSettingsManager
- .setSelectedTunerConfiguration(
- TunerType.FUNCUBE_DONGLE_PRO_PLUS,
- mController.getUSBAddress(), mSelectedConfig );
+// //Store this config as the default for this tuner at this address
+// mSettingsManager
+// .setSelectedTunerConfiguration(
+// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
+// mController.getUSBAddress(), mSelectedConfig );
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -252,15 +252,15 @@ public class FCD2TunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
- TunerConfiguration config =
- mSettingsManager
- .addNewTunerConfiguration(
- TunerType.FUNCUBE_DONGLE_PRO_PLUS,
- "New Configuration" );
+// TunerConfiguration config =
+// mSettingsManager
+// .addNewTunerConfiguration(
+// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
+// "New Configuration" );
mComboConfigurations.setModel( getModel() );
- mComboConfigurations.setSelectedItem( config );
+// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -293,8 +293,8 @@ public class FCD2TunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
- mSettingsManager
- .deleteTunerConfiguration( selected );
+// mSettingsManager
+// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -322,9 +322,9 @@ public class FCD2TunerConfigurationPanel extends JPanel
mMixerGain.setSelected( config.getGainMixer() );
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
- mSettingsManager.setSelectedTunerConfiguration(
- TunerType.FUNCUBE_DONGLE_PRO_PLUS,
- mController.getUSBAddress(), config );
+// mSettingsManager.setSelectedTunerConfiguration(
+// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
+// mController.getUSBAddress(), config );
}
catch ( SourceException e1 )
{
@@ -341,34 +341,34 @@ public class FCD2TunerConfigurationPanel extends JPanel
private ComboBoxModel getModel()
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
DefaultComboBoxModel model =
new DefaultComboBoxModel();
- for( TunerConfiguration config: configs )
- {
- model.addElement( (FCD2TunerConfiguration)config );
- }
+// for( TunerConfiguration config: configs )
+// {
+// model.addElement( (FCD2TunerConfiguration)config );
+// }
return model;
}
private FCD2TunerConfiguration getNamedConfiguration( String name )
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
- for( TunerConfiguration config: configs )
- {
- if( config.getName().contentEquals( name ) )
- {
- return (FCD2TunerConfiguration)config;
- }
- }
+// for( TunerConfiguration config: configs )
+// {
+// if( config.getName().contentEquals( name ) )
+// {
+// return (FCD2TunerConfiguration)config;
+// }
+// }
return null;
}
diff --git a/src/source/tuner/fcd/proplusV2/FCD2TunerController.java b/src/source/tuner/fcd/proplusV2/FCD2TunerController.java
index 96a31b85..da7520c1 100644
--- a/src/source/tuner/fcd/proplusV2/FCD2TunerController.java
+++ b/src/source/tuner/fcd/proplusV2/FCD2TunerController.java
@@ -30,8 +30,8 @@ import org.usb4java.DeviceDescriptor;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.fcd.FCDCommand;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerController;
diff --git a/src/source/tuner/hackrf/HackRFTuner.java b/src/source/tuner/hackrf/HackRFTuner.java
index aee8570b..a0a52613 100644
--- a/src/source/tuner/hackrf/HackRFTuner.java
+++ b/src/source/tuner/hackrf/HackRFTuner.java
@@ -29,12 +29,12 @@ import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
-import source.tuner.TunerChangeEvent;
+import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.hackrf.HackRFTunerController.BoardID;
public class HackRFTuner extends Tuner
@@ -75,12 +75,6 @@ public class HackRFTuner extends Tuner
return TunerType.HACKRF;
}
- @Override
- public JPanel getEditor( SettingsManager settingsManager )
- {
- return new HackRFTunerEditorPanel( this, settingsManager );
- }
-
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
@@ -113,7 +107,7 @@ public class HackRFTuner extends Tuner
if( source != null )
{
- broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
+ broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
return source;
diff --git a/src/source/tuner/hackrf/HackRFTunerConfiguration.java b/src/source/tuner/hackrf/HackRFTunerConfiguration.java
index 66d85e25..33356fc0 100644
--- a/src/source/tuner/hackrf/HackRFTunerConfiguration.java
+++ b/src/source/tuner/hackrf/HackRFTunerConfiguration.java
@@ -20,8 +20,8 @@ package source.tuner.hackrf;
import javax.xml.bind.annotation.XmlAttribute;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
diff --git a/src/source/tuner/hackrf/HackRFTunerConfigurationPanel.java b/src/source/tuner/hackrf/HackRFTunerConfigurationPanel.java
index 1acd7269..88aa95d6 100644
--- a/src/source/tuner/hackrf/HackRFTunerConfigurationPanel.java
+++ b/src/source/tuner/hackrf/HackRFTunerConfigurationPanel.java
@@ -50,9 +50,9 @@ import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
@@ -117,11 +117,11 @@ public class HackRFTunerConfigurationPanel extends JPanel
mLog.error( "couldn't read hackrf serial number", e2 );
}
- if( serial != null )
- {
- savedConfig = mSettingsManager.getSelectedTunerConfiguration(
- TunerType.HACKRF, serial );
- }
+// if( serial != null )
+// {
+// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
+// TunerType.HACKRF, serial );
+// }
if( savedConfig != null )
{
@@ -136,12 +136,12 @@ public class HackRFTunerConfigurationPanel extends JPanel
//Store this config as the default for this tuner at this address
- if( serial != null )
- {
- mSettingsManager
- .setSelectedTunerConfiguration( TunerType.HACKRF,
- serial, mSelectedConfig );
- }
+// if( serial != null )
+// {
+// mSettingsManager
+// .setSelectedTunerConfiguration( TunerType.HACKRF,
+// serial, mSelectedConfig );
+// }
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -416,15 +416,15 @@ public class HackRFTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
- TunerConfiguration config =
- mSettingsManager
- .addNewTunerConfiguration(
- TunerType.HACKRF,
- "New Configuration" );
+// TunerConfiguration config =
+// mSettingsManager
+// .addNewTunerConfiguration(
+// TunerType.HACKRF,
+// "New Configuration" );
mComboConfigurations.setModel( getModel() );
- mComboConfigurations.setSelectedItem( config );
+// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -457,8 +457,8 @@ public class HackRFTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
- mSettingsManager
- .deleteTunerConfiguration( selected );
+// mSettingsManager
+// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -493,10 +493,10 @@ public class HackRFTunerConfigurationPanel extends JPanel
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
- mSettingsManager.setSelectedTunerConfiguration(
- TunerType.HACKRF, mController.getSerial().getSerialNumber(), config );
+// mSettingsManager.setSelectedTunerConfiguration(
+// TunerType.HACKRF, mController.getSerial().getSerialNumber(), config );
}
- catch ( UsbException | SourceException e1 )
+ catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
HackRFTunerConfigurationPanel.this,
@@ -516,17 +516,17 @@ public class HackRFTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel getModel()
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.HACKRF );
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.HACKRF );
DefaultComboBoxModel model =
new DefaultComboBoxModel();
- for( TunerConfiguration config: configs )
- {
- model.addElement( (HackRFTunerConfiguration)config );
- }
+// for( TunerConfiguration config: configs )
+// {
+// model.addElement( (HackRFTunerConfiguration)config );
+// }
return model;
}
@@ -536,17 +536,17 @@ public class HackRFTunerConfigurationPanel extends JPanel
*/
private HackRFTunerConfiguration getNamedConfiguration( String name )
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.HACKRF );
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.HACKRF );
- for( TunerConfiguration config: configs )
- {
- if( config.getName().contentEquals( name ) )
- {
- return (HackRFTunerConfiguration)config;
- }
- }
+// for( TunerConfiguration config: configs )
+// {
+// if( config.getName().contentEquals( name ) )
+// {
+// return (HackRFTunerConfiguration)config;
+// }
+// }
return null;
}
diff --git a/src/source/tuner/hackrf/HackRFTunerController.java b/src/source/tuner/hackrf/HackRFTunerController.java
index cf4146d1..a4545dc2 100644
--- a/src/source/tuner/hackrf/HackRFTunerController.java
+++ b/src/source/tuner/hackrf/HackRFTunerController.java
@@ -81,8 +81,8 @@ import sample.Listener;
import sample.adapter.ByteSampleAdapter;
import sample.complex.ComplexBuffer;
import source.SourceException;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerController;
+import source.tuner.configuration.TunerConfiguration;
import controller.ThreadPoolManager;
import controller.ThreadPoolManager.ThreadType;
diff --git a/src/source/tuner/rtl/RTL2832Tuner.java b/src/source/tuner/rtl/RTL2832Tuner.java
index 55c7dfed..1cbbd6ce 100644
--- a/src/source/tuner/rtl/RTL2832Tuner.java
+++ b/src/source/tuner/rtl/RTL2832Tuner.java
@@ -30,12 +30,12 @@ import sample.complex.ComplexBuffer;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
-import source.tuner.TunerChangeEvent;
+import source.tuner.TunerEvent;
import source.tuner.TunerChannel;
import source.tuner.TunerChannelSource;
import source.tuner.TunerClass;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.frequency.IFrequencyChangeListener;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import controller.ThreadPoolManager;
@@ -89,12 +89,6 @@ public class RTL2832Tuner extends Tuner
return mController.getTunerType();
}
- @Override
- public JPanel getEditor( SettingsManager settingsManager )
- {
- return mController.getEditor( settingsManager );
- }
-
@Override
public void apply( TunerConfiguration config ) throws SourceException
{
@@ -161,7 +155,7 @@ public class RTL2832Tuner extends Tuner
if( source != null )
{
- broadcast( new TunerChangeEvent( this, TunerChangeEvent.Event.CHANNEL_COUNT ) );
+ broadcast( new TunerEvent( this, TunerEvent.Event.CHANNEL_COUNT ) );
}
}
catch( Exception e )
diff --git a/src/source/tuner/rtl/RTL2832TunerController.java b/src/source/tuner/rtl/RTL2832TunerController.java
index 802bd15b..5efa45d4 100644
--- a/src/source/tuner/rtl/RTL2832TunerController.java
+++ b/src/source/tuner/rtl/RTL2832TunerController.java
@@ -363,8 +363,6 @@ public abstract class RTL2832TunerController extends TunerController
}
}
- public abstract JPanel getEditor( SettingsManager settingsManager );
-
public abstract void setSampleRateFilters( int sampleRate )
throws SourceException;
diff --git a/src/source/tuner/rtl/e4k/E4KTunerConfiguration.java b/src/source/tuner/rtl/e4k/E4KTunerConfiguration.java
index d7d82a62..5c699d4d 100644
--- a/src/source/tuner/rtl/e4k/E4KTunerConfiguration.java
+++ b/src/source/tuner/rtl/e4k/E4KTunerConfiguration.java
@@ -19,8 +19,8 @@ package source.tuner.rtl.e4k;
import javax.xml.bind.annotation.XmlAttribute;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;
diff --git a/src/source/tuner/rtl/e4k/E4KTunerConfigurationPanel.java b/src/source/tuner/rtl/e4k/E4KTunerConfigurationPanel.java
index ed3a4ac7..b411ff5e 100644
--- a/src/source/tuner/rtl/e4k/E4KTunerConfigurationPanel.java
+++ b/src/source/tuner/rtl/e4k/E4KTunerConfigurationPanel.java
@@ -50,9 +50,9 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;
@@ -108,15 +108,15 @@ public class E4KTunerConfigurationPanel extends JPanel
mComboConfigurations.setModel( getModel() );
/* Determine which tuner configuration should be selected/displayed */
- TunerConfigurationAssignment savedConfig = mSettingsManager
- .getSelectedTunerConfiguration(
- TunerType.ELONICS_E4000, mController.getUniqueID() );
-
- if( savedConfig != null )
- {
- mSelectedConfig = getNamedConfiguration(
- savedConfig.getTunerConfigurationName() );
- }
+// TunerConfigurationAssignment savedConfig = mSettingsManager
+// .getSelectedTunerConfiguration(
+// TunerType.ELONICS_E4000, mController.getUniqueID() );
+//
+// if( savedConfig != null )
+// {
+// mSelectedConfig = getNamedConfiguration(
+// savedConfig.getTunerConfigurationName() );
+// }
/* If we couldn't determine the saved/selected config, use the first one */
if( mSelectedConfig == null )
@@ -124,10 +124,10 @@ public class E4KTunerConfigurationPanel extends JPanel
mSelectedConfig = mComboConfigurations.getItemAt( 0 );
//Store this config as the default for this tuner at this address
- mSettingsManager
- .setSelectedTunerConfiguration(
- TunerType.ELONICS_E4000,
- mController.getUniqueID(), mSelectedConfig );
+// mSettingsManager
+// .setSelectedTunerConfiguration(
+// TunerType.ELONICS_E4000,
+// mController.getUniqueID(), mSelectedConfig );
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -168,10 +168,10 @@ public class E4KTunerConfigurationPanel extends JPanel
/* Reset this named config as the assigned config for this
* tuner */
- mSettingsManager
- .setSelectedTunerConfiguration(
- TunerType.ELONICS_E4000,
- mController.getUniqueID(), mSelectedConfig );
+// mSettingsManager
+// .setSelectedTunerConfiguration(
+// TunerType.ELONICS_E4000,
+// mController.getUniqueID(), mSelectedConfig );
save();
}
@@ -541,15 +541,15 @@ public class E4KTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
- TunerConfiguration config =
- mSettingsManager
- .addNewTunerConfiguration(
- TunerType.ELONICS_E4000,
- "New Configuration" );
+// TunerConfiguration config =
+// mSettingsManager
+// .addNewTunerConfiguration(
+// TunerType.ELONICS_E4000,
+// "New Configuration" );
mComboConfigurations.setModel( getModel() );
- mComboConfigurations.setSelectedItem( config );
+// mComboConfigurations.setSelectedItem( config );
repaint();
}
@@ -582,8 +582,8 @@ public class E4KTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
- mSettingsManager
- .deleteTunerConfiguration( selected );
+// mSettingsManager
+// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -623,8 +623,8 @@ public class E4KTunerConfigurationPanel extends JPanel
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
- mSettingsManager.setSelectedTunerConfiguration(
- TunerType.ELONICS_E4000, mController.getUniqueID(), config );
+// mSettingsManager.setSelectedTunerConfiguration(
+// TunerType.ELONICS_E4000, mController.getUniqueID(), config );
}
catch ( SourceException e1 )
{
@@ -646,17 +646,17 @@ public class E4KTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel getModel()
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.ELONICS_E4000 );
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.ELONICS_E4000 );
DefaultComboBoxModel model =
new DefaultComboBoxModel();
- for( TunerConfiguration config: configs )
- {
- model.addElement( (E4KTunerConfiguration)config );
- }
+// for( TunerConfiguration config: configs )
+// {
+// model.addElement( (E4KTunerConfiguration)config );
+// }
return model;
}
@@ -666,17 +666,17 @@ public class E4KTunerConfigurationPanel extends JPanel
*/
private E4KTunerConfiguration getNamedConfiguration( String name )
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.ELONICS_E4000 );
-
- for( TunerConfiguration config: configs )
- {
- if( config.getName().contentEquals( name ) )
- {
- return (E4KTunerConfiguration)config;
- }
- }
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.ELONICS_E4000 );
+//
+// for( TunerConfiguration config: configs )
+// {
+// if( config.getName().contentEquals( name ) )
+// {
+// return (E4KTunerConfiguration)config;
+// }
+// }
return null;
}
diff --git a/src/source/tuner/rtl/e4k/E4KTunerController.java b/src/source/tuner/rtl/e4k/E4KTunerController.java
index b727fa74..6f4df48c 100644
--- a/src/source/tuner/rtl/e4k/E4KTunerController.java
+++ b/src/source/tuner/rtl/e4k/E4KTunerController.java
@@ -32,8 +32,8 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController;
import controller.ThreadPoolManager;
diff --git a/src/source/tuner/rtl/r820t/R820TTunerConfiguration.java b/src/source/tuner/rtl/r820t/R820TTunerConfiguration.java
index 8ecc7795..95686f66 100644
--- a/src/source/tuner/rtl/r820t/R820TTunerConfiguration.java
+++ b/src/source/tuner/rtl/r820t/R820TTunerConfiguration.java
@@ -19,8 +19,8 @@ package source.tuner.rtl.r820t;
import javax.xml.bind.annotation.XmlAttribute;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
diff --git a/src/source/tuner/rtl/r820t/R820TTunerConfigurationPanel.java b/src/source/tuner/rtl/r820t/R820TTunerConfigurationEditorOld.java
similarity index 88%
rename from src/source/tuner/rtl/r820t/R820TTunerConfigurationPanel.java
rename to src/source/tuner/rtl/r820t/R820TTunerConfigurationEditorOld.java
index 413dc8ea..1a310ba1 100644
--- a/src/source/tuner/rtl/r820t/R820TTunerConfigurationPanel.java
+++ b/src/source/tuner/rtl/r820t/R820TTunerConfigurationEditorOld.java
@@ -50,21 +50,22 @@ import org.usb4java.LibUsbException;
import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
-import source.tuner.TunerConfigurationAssignment;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationAssignment;
import source.tuner.rtl.RTL2832TunerController.SampleRate;
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
-public class R820TTunerConfigurationPanel extends JPanel
+public class R820TTunerConfigurationEditorOld extends JPanel
{
- private final static Logger mLog =
- LoggerFactory.getLogger( R820TTunerConfigurationPanel.class );
-
private static final long serialVersionUID = 1L;
+
+ private final static Logger mLog =
+ LoggerFactory.getLogger( R820TTunerConfigurationEditorOld.class );
+
private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
private SettingsManager mSettingsManager;
@@ -86,7 +87,7 @@ public class R820TTunerConfigurationPanel extends JPanel
private JComboBox mComboSampleRate;
- public R820TTunerConfigurationPanel( SettingsManager settingsManager,
+ public R820TTunerConfigurationEditorOld( SettingsManager settingsManager,
R820TTunerController controller )
{
mSettingsManager = settingsManager;
@@ -110,27 +111,27 @@ public class R820TTunerConfigurationPanel extends JPanel
mComboConfigurations.setModel( getModel() );
/* Determine which tuner configuration should be selected/displayed */
- TunerConfigurationAssignment savedConfig = mSettingsManager
- .getSelectedTunerConfiguration(
- TunerType.RAFAELMICRO_R820T, mController.getUniqueID() );
-
- if( savedConfig != null )
- {
- mSelectedConfig = getNamedConfiguration(
- savedConfig.getTunerConfigurationName() );
- }
+// TunerConfigurationAssignment savedConfig = mSettingsManager
+// .getSelectedTunerConfiguration(
+// TunerType.RAFAELMICRO_R820T, mController.getUniqueID() );
+//
+// if( savedConfig != null )
+// {
+// mSelectedConfig = getNamedConfiguration(
+// savedConfig.getTunerConfigurationName() );
+// }
/* If we couldn't determine the saved/selected config, use the first one */
- if( mSelectedConfig == null )
- {
- mSelectedConfig = mComboConfigurations.getItemAt( 0 );
-
- //Store this config as the default for this tuner at this address
- mSettingsManager
- .setSelectedTunerConfiguration(
- TunerType.RAFAELMICRO_R820T,
- mController.getUniqueID(), mSelectedConfig );
- }
+// if( mSelectedConfig == null )
+// {
+// mSelectedConfig = mComboConfigurations.getItemAt( 0 );
+//
+// //Store this config as the default for this tuner at this address
+// mSettingsManager
+// .setSelectedTunerConfiguration(
+// TunerType.RAFAELMICRO_R820T,
+// mController.getUniqueID(), mSelectedConfig );
+// }
mComboConfigurations.setSelectedItem( mSelectedConfig );
@@ -217,7 +218,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply "
+ "frequency correction value: " + value +
e1.getLocalizedMessage() );
@@ -256,7 +257,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( SourceException | LibUsbException eSampleRate )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the sample "
+ "rate setting [" + sampleRate.getLabel() + "] " +
eSampleRate.getLocalizedMessage() );
@@ -380,7 +381,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the gain "
+ "setting - " + e.getLocalizedMessage() );
@@ -431,7 +432,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the mixer "
+ "gain setting - " + e.getLocalizedMessage() );
@@ -477,7 +478,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the LNA "
+ "gain setting - " + e.getLocalizedMessage() );
@@ -521,7 +522,7 @@ public class R820TTunerConfigurationPanel extends JPanel
catch ( UsbException e )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't apply the VGA "
+ "gain setting - " + e.getLocalizedMessage() );
@@ -548,17 +549,17 @@ public class R820TTunerConfigurationPanel extends JPanel
@Override
public void actionPerformed( ActionEvent e )
{
- TunerConfiguration config =
- mSettingsManager
- .addNewTunerConfiguration(
- TunerType.RAFAELMICRO_R820T,
- "New Configuration" );
-
- mComboConfigurations.setModel( getModel() );
-
- mComboConfigurations.setSelectedItem( config );
-
- repaint();
+// TunerConfiguration config =
+// mSettingsManager
+// .addNewTunerConfiguration(
+// TunerType.RAFAELMICRO_R820T,
+// "New Configuration" );
+//
+// mComboConfigurations.setModel( getModel() );
+//
+// mComboConfigurations.setSelectedItem( config );
+//
+// repaint();
}
} );
@@ -581,7 +582,7 @@ public class R820TTunerConfigurationPanel extends JPanel
if( selected != null )
{
int n = JOptionPane.showConfirmDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"Are you sure you want to delete '"
+ selected.getName() + "'?",
"Are you sure?",
@@ -589,8 +590,8 @@ public class R820TTunerConfigurationPanel extends JPanel
if( n == JOptionPane.YES_OPTION )
{
- mSettingsManager
- .deleteTunerConfiguration( selected );
+// mSettingsManager
+// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
@@ -630,13 +631,13 @@ public class R820TTunerConfigurationPanel extends JPanel
mComboSampleRate.setSelectedItem( mSelectedConfig.getSampleRate() );
- mSettingsManager.setSelectedTunerConfiguration(
- TunerType.RAFAELMICRO_R820T, mController.getUniqueID(), config );
+// mSettingsManager.setSelectedTunerConfiguration(
+// TunerType.RAFAELMICRO_R820T, mController.getUniqueID(), config );
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
- R820TTunerConfigurationPanel.this,
+ R820TTunerConfigurationEditorOld.this,
"R820T Tuner Controller - couldn't "
+ "apply the tuner configuration settings - " +
e1.getLocalizedMessage() );
@@ -653,17 +654,17 @@ public class R820TTunerConfigurationPanel extends JPanel
*/
private ComboBoxModel getModel()
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
DefaultComboBoxModel model =
new DefaultComboBoxModel();
- for( TunerConfiguration config: configs )
- {
- model.addElement( (R820TTunerConfiguration)config );
- }
+// for( TunerConfiguration config: configs )
+// {
+// model.addElement( (R820TTunerConfiguration)config );
+// }
return model;
}
@@ -673,17 +674,17 @@ public class R820TTunerConfigurationPanel extends JPanel
*/
private R820TTunerConfiguration getNamedConfiguration( String name )
{
- ArrayList configs =
- mSettingsManager
- .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
-
- for( TunerConfiguration config: configs )
- {
- if( config.getName().contentEquals( name ) )
- {
- return (R820TTunerConfiguration)config;
- }
- }
+// ArrayList configs =
+// mSettingsManager
+// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
+//
+// for( TunerConfiguration config: configs )
+// {
+// if( config.getName().contentEquals( name ) )
+// {
+// return (R820TTunerConfiguration)config;
+// }
+// }
return null;
}
diff --git a/src/source/tuner/rtl/r820t/R820TTunerController.java b/src/source/tuner/rtl/r820t/R820TTunerController.java
index 109458e2..766c1091 100644
--- a/src/source/tuner/rtl/r820t/R820TTunerController.java
+++ b/src/source/tuner/rtl/r820t/R820TTunerController.java
@@ -1,6 +1,6 @@
/*******************************************************************************
* SDR Trunk
- * Copyright (C) 2014 Dennis Sheirer
+ * Copyright (C) 2014-2016 Dennis Sheirer
*
* Java port of librtlsdr
*
@@ -33,10 +33,9 @@ import org.usb4java.Device;
import org.usb4java.DeviceDescriptor;
import org.usb4java.LibUsbException;
-import settings.SettingsManager;
import source.SourceException;
-import source.tuner.TunerConfiguration;
import source.tuner.TunerType;
+import source.tuner.configuration.TunerConfiguration;
import source.tuner.rtl.RTL2832TunerController;
import controller.ThreadPoolManager;
@@ -136,19 +135,6 @@ public class R820TTunerController extends RTL2832TunerController
}
}
- /**
- * Controller gui editor component for this tuner
- */
- public JPanel getEditor( SettingsManager settingsManager )
- {
- if( mEditor == null )
- {
- mEditor = new R820TTunerEditorPanel( this, settingsManager );
- }
-
- return mEditor;
- }
-
/**
* Not implemented.
*/
diff --git a/src/source/tuner/rtl/r820t/R820TTunerEditor.java b/src/source/tuner/rtl/r820t/R820TTunerEditor.java
new file mode 100644
index 00000000..0d106f8a
--- /dev/null
+++ b/src/source/tuner/rtl/r820t/R820TTunerEditor.java
@@ -0,0 +1,446 @@
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+package source.tuner.rtl.r820t;
+
+import java.awt.EventQueue;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.text.DecimalFormat;
+
+import javax.swing.BorderFactory;
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JSpinner;
+import javax.swing.JTextField;
+import javax.swing.SpinnerModel;
+import javax.swing.SpinnerNumberModel;
+import javax.swing.SwingConstants;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import javax.usb.UsbException;
+
+import net.miginfocom.swing.MigLayout;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.usb4java.LibUsbException;
+
+import source.SourceException;
+import source.tuner.configuration.TunerConfiguration;
+import source.tuner.configuration.TunerConfigurationEditor;
+import source.tuner.configuration.TunerConfigurationEvent;
+import source.tuner.configuration.TunerConfigurationEvent.Event;
+import source.tuner.configuration.TunerConfigurationModel;
+import source.tuner.rtl.RTL2832Tuner;
+import source.tuner.rtl.RTL2832TunerController.SampleRate;
+import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
+import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
+import source.tuner.rtl.r820t.R820TTunerController.R820TMixerGain;
+import source.tuner.rtl.r820t.R820TTunerController.R820TVGAGain;
+
+public class R820TTunerEditor extends TunerConfigurationEditor
+{
+ private final static Logger mLog =
+ LoggerFactory.getLogger( R820TTunerEditor.class );
+
+ private static final long serialVersionUID = 1L;
+ private static final R820TGain DEFAULT_GAIN = R820TGain.GAIN_279;
+
+ private R820TTunerController mController;
+
+ private JTextField mConfigurationName;
+ private JSpinner mFrequencyCorrection;
+ private JComboBox mComboMasterGain;
+ private JComboBox mComboMixerGain;
+ private JComboBox mComboLNAGain;
+ private JComboBox mComboVGAGain;
+ private JComboBox mComboSampleRate;
+
+ public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel,
+ RTL2832Tuner tuner )
+ {
+ super( tunerConfigurationModel );
+ mController = (R820TTunerController)tuner.getController();
+
+ init();
+ }
+
+ @Override
+ public void save()
+ {
+ if( hasItem() )
+ {
+ R820TTunerConfiguration config = getConfiguration();
+
+ config.setName( mConfigurationName.getText() );
+
+ double value = ((SpinnerNumberModel)mFrequencyCorrection
+ .getModel()).getNumber().doubleValue();
+ config.setFrequencyCorrection( value );
+
+ config.setSampleRate( (SampleRate)mComboSampleRate.getSelectedItem() );
+
+ R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
+ config.setMasterGain( gain );
+
+ R820TMixerGain mixerGain = (R820TMixerGain)mComboMixerGain.getSelectedItem();
+ config.setMixerGain( mixerGain );
+
+ R820TLNAGain lnaGain = (R820TLNAGain)mComboLNAGain.getSelectedItem();
+ config.setLNAGain( lnaGain );
+
+ R820TVGAGain vgaGain = (R820TVGAGain)mComboVGAGain.getSelectedItem();
+ config.setVGAGain( vgaGain );
+
+ getTunerConfigurationModel().broadcast(
+ new TunerConfigurationEvent( getConfiguration(), Event.CONFIGURATION_CHANGE ) );
+ }
+ }
+
+ @Override
+ public void setItem( TunerConfiguration item )
+ {
+ super.setItem( item );
+
+ if( hasItem() )
+ {
+ R820TTunerConfiguration config = getConfiguration();
+
+ mConfigurationName.setText( config.getName() );
+ mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
+ mComboSampleRate.setSelectedItem( config.getSampleRate() );
+ mComboMasterGain.setSelectedItem( config.getMasterGain() );
+ mComboMixerGain.setSelectedItem( config.getMixerGain() );
+ mComboLNAGain.setSelectedItem( config.getLNAGain() );
+ mComboVGAGain.setSelectedItem( config.getVGAGain() );
+ }
+ }
+
+ private R820TTunerConfiguration getConfiguration()
+ {
+ if( hasItem() )
+ {
+ return (R820TTunerConfiguration)getItem();
+ }
+
+ return null;
+ }
+
+ private void init()
+ {
+ setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow]" ) );
+
+ add( new JLabel( "R820T Tuner" ), "span, align center" );
+
+ /**
+ * Tuner Configuration Name
+ */
+ mConfigurationName = new JTextField();
+ mConfigurationName.addFocusListener( new FocusListener()
+ {
+ @Override
+ public void focusLost( FocusEvent e )
+ {
+ save();
+ }
+ @Override
+ public void focusGained( FocusEvent e ) {}
+ } );
+
+ add( new JLabel( "Configuration:" ) );
+ add( mConfigurationName, "growx,push" );
+
+ /**
+ * Frequency Correction
+ */
+ SpinnerModel model =
+ new SpinnerNumberModel( 0.0, //initial value
+ -1000.0, //min
+ 1000.0, //max
+ 0.1 ); //step
+
+ mFrequencyCorrection = new JSpinner( model );
+
+ JSpinner.NumberEditor editor =
+ (JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
+
+ DecimalFormat format = editor.getFormat();
+ format.setMinimumFractionDigits( 1 );
+ editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
+
+ mFrequencyCorrection.addChangeListener( new ChangeListener()
+ {
+ @Override
+ public void stateChanged( ChangeEvent e )
+ {
+ final double value = ((SpinnerNumberModel)mFrequencyCorrection
+ .getModel()).getNumber().doubleValue();
+
+ try
+ {
+ mController.setFrequencyCorrection( value );
+ }
+ catch ( SourceException e1 )
+ {
+ mLog.error( "Error setting frequency correction value", e1 );
+ }
+
+ save();
+ }
+ } );
+
+ add( new JLabel( "Correction PPM:" ) );
+ add( mFrequencyCorrection, "growx,push" );
+
+ /**
+ * Sample Rate
+ */
+ mComboSampleRate = new JComboBox<>( SampleRate.values() );
+ mComboSampleRate.addActionListener( new ActionListener()
+ {
+ @Override
+ public void actionPerformed( ActionEvent e )
+ {
+ SampleRate sampleRate =
+ (SampleRate)mComboSampleRate.getSelectedItem();
+ try
+ {
+
+ mController.setSampleRate( sampleRate );
+ save();
+ }
+ catch ( SourceException | LibUsbException eSampleRate )
+ {
+ JOptionPane.showMessageDialog(
+ R820TTunerEditor.this,
+ "R820T Tuner Controller - couldn't apply the sample "
+ + "rate setting [" + sampleRate.getLabel() + "] " +
+ eSampleRate.getLocalizedMessage() );
+
+ mLog.error( "R820T Tuner Controller - couldn't apply sample "
+ + "rate setting [" + sampleRate.getLabel() + "]",
+ eSampleRate );
+ }
+ }
+ } );
+ add( new JLabel( "Sample Rate:" ) );
+ add( mComboSampleRate, "growx,push" );
+
+ /**
+ * Gain Controls
+ */
+ JPanel gainPanel = new JPanel();
+ gainPanel.setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
+ gainPanel.setBorder( BorderFactory.createTitledBorder( "Gain" ) );
+
+ /* Master Gain Control */
+ mComboMasterGain = new JComboBox( R820TGain.values() );
+
+ mComboMasterGain.addActionListener( new ActionListener()
+ {
+ @Override
+ public void actionPerformed( ActionEvent arg0 )
+ {
+ try
+ {
+ R820TGain gain = (R820TGain)mComboMasterGain.getSelectedItem();
+
+ mController.setGain( (R820TGain)mComboMasterGain.getSelectedItem(), true );
+
+ if( gain == R820TGain.MANUAL )
+ {
+ mComboMixerGain.setSelectedItem( gain.getMixerGain() );
+ mComboMixerGain.setEnabled( true );
+
+ mComboLNAGain.setSelectedItem( gain.getLNAGain() );
+ mComboLNAGain.setEnabled( true );
+
+ mComboVGAGain.setSelectedItem( gain.getVGAGain() );
+ mComboVGAGain.setEnabled( true );
+ }
+ else
+ {
+ mComboMixerGain.setEnabled( false );
+ mComboMixerGain.setSelectedItem( gain.getMixerGain() );
+
+ mComboLNAGain.setEnabled( false );
+ mComboLNAGain.setSelectedItem( gain.getLNAGain() );
+
+ mComboVGAGain.setEnabled( false );
+ mComboVGAGain.setSelectedItem( gain.getVGAGain() );
+ }
+
+ save();
+ }
+ catch ( UsbException e )
+ {
+ JOptionPane.showMessageDialog(
+ R820TTunerEditor.this,
+ "R820T Tuner Controller - couldn't apply the gain "
+ + "setting - " + e.getLocalizedMessage() );
+
+ mLog.error( "R820T Tuner Controller - couldn't apply "
+ + "gain setting - ", e );
+ }
+ }
+ } );
+ mComboMasterGain.setToolTipText( "Select AUTOMATIC for auto "
+ + "gain, MANUAL to enable
independent control of "
+ + "Mixer, LNA and Enhance gain
"
+ + "settings, or one of the individual gain settings for
"
+ + "semi-manual gain control" );
+ gainPanel.add( new JLabel( "Master" ) );
+ gainPanel.add( mComboMasterGain );
+
+ /* Mixer Gain Control */
+ mComboMixerGain = new JComboBox( R820TMixerGain.values() );
+ mComboMixerGain.addActionListener( new ActionListener()
+ {
+ @Override
+ public void actionPerformed( ActionEvent arg0 )
+ {
+ EventQueue.invokeLater( new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ try
+ {
+ R820TMixerGain mixerGain =
+ (R820TMixerGain)mComboMixerGain.getSelectedItem();
+
+ if( mixerGain == null )
+ {
+ mixerGain = DEFAULT_GAIN.getMixerGain();
+ }
+
+ if( mComboMixerGain.isEnabled() )
+ {
+ mController.setMixerGain( mixerGain, true );
+ }
+
+ save();
+ }
+ catch ( UsbException e )
+ {
+ JOptionPane.showMessageDialog( R820TTunerEditor.this,
+ "R820T Tuner Controller - couldn't apply the mixer "
+ + "gain setting - " + e.getLocalizedMessage() );
+
+ mLog.error( "R820T Tuner Controller - couldn't apply mixer "
+ + "gain setting - ", e );
+ }
+ }
+ } );
+ }
+ } );
+ mComboMixerGain.setToolTipText( "Mixer Gain. Set master gain "
+ + "to MASTER to enable adjustment" );
+ mComboMixerGain.setEnabled( false );
+ gainPanel.add( new JLabel( "Mixer" ) );
+ gainPanel.add( mComboMixerGain, "wrap" );
+
+ /* LNA Gain Control */
+ mComboLNAGain = new JComboBox( R820TLNAGain.values() );
+ mComboLNAGain.addActionListener( new ActionListener()
+ {
+ @Override
+ public void actionPerformed( ActionEvent arg0 )
+ {
+ try
+ {
+ R820TLNAGain lnaGain =
+ (R820TLNAGain)mComboLNAGain.getSelectedItem();
+
+ if ( lnaGain == null )
+ {
+ lnaGain = DEFAULT_GAIN.getLNAGain();
+ }
+
+ if( mComboLNAGain.isEnabled() )
+ {
+ mController.setLNAGain( lnaGain, true );
+ }
+
+ save();
+ }
+ catch ( UsbException e )
+ {
+ JOptionPane.showMessageDialog( R820TTunerEditor.this,
+ "R820T Tuner Controller - couldn't apply the LNA "
+ + "gain setting - " + e.getLocalizedMessage() );
+
+ mLog.error( "R820T Tuner Controller - couldn't apply LNA "
+ + "gain setting - ", e );
+ }
+ }
+ } );
+ mComboLNAGain.setToolTipText( "LNA Gain. Set master gain "
+ + "to MANUAL to enable adjustment" );
+ mComboLNAGain.setEnabled( false );
+ gainPanel.add( new JLabel( "LNA" ) );
+ gainPanel.add( mComboLNAGain );
+
+ /* VGA Gain Control */
+ mComboVGAGain = new JComboBox( R820TVGAGain.values() );
+ mComboVGAGain.addActionListener( new ActionListener()
+ {
+ @Override
+ public void actionPerformed( ActionEvent arg0 )
+ {
+ try
+ {
+ R820TVGAGain vgaGain =
+ (R820TVGAGain)mComboVGAGain.getSelectedItem();
+
+ if( vgaGain == null )
+ {
+ vgaGain = DEFAULT_GAIN.getVGAGain();
+ }
+
+ if( mComboVGAGain.isEnabled() )
+ {
+ mController.setVGAGain( vgaGain, true );
+ }
+
+ save();
+ }
+ catch ( UsbException e )
+ {
+ JOptionPane.showMessageDialog( R820TTunerEditor.this,
+ "R820T Tuner Controller - couldn't apply the VGA "
+ + "gain setting - " + e.getLocalizedMessage() );
+
+ mLog.error( "R820T Tuner Controller - couldn't apply VGA "
+ + "gain setting", e );
+ }
+ }
+ } );
+ mComboVGAGain.setToolTipText( "VGA Gain. Set master gain "
+ + "to MANUAL to enable adjustment" );
+ mComboVGAGain.setEnabled( false );
+ gainPanel.add( new JLabel( "VGA" ) );
+ gainPanel.add( mComboVGAGain, "wrap" );
+
+ add( gainPanel, "span" );
+ }
+}
diff --git a/src/source/tuner/rtl/r820t/R820TTunerEditorPanel.java b/src/source/tuner/rtl/r820t/R820TTunerEditorPanel.java
deleted file mode 100644
index c761a07a..00000000
--- a/src/source/tuner/rtl/r820t/R820TTunerEditorPanel.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * 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
- ******************************************************************************/
-package source.tuner.rtl.r820t;
-
-import gui.control.JFrequencyControl;
-
-import java.awt.Color;
-import java.awt.EventQueue;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-import net.miginfocom.swing.MigLayout;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import settings.SettingsManager;
-import source.SourceException;
-import source.tuner.frequency.FrequencyChangeEvent;
-import source.tuner.frequency.FrequencyChangeEvent.Event;
-import source.tuner.frequency.IFrequencyChangeProcessor;
-import source.tuner.rtl.RTL2832InfoPanel;
-
-import com.jidesoft.swing.JideTabbedPane;
-
-public class R820TTunerEditorPanel extends JPanel implements IFrequencyChangeProcessor
-{
- private final static Logger mLog =
- LoggerFactory.getLogger( R820TTunerEditorPanel.class );
-
- private static final long serialVersionUID = 1L;
-
- private R820TTunerController mController;
- private SettingsManager mSettingsManager;
-
- private JFrequencyControl mFrequencyControl;
-
- public R820TTunerEditorPanel( R820TTunerController controller,
- SettingsManager settingsManager )
- {
- mController = controller;
- mSettingsManager = settingsManager;
-
- initGUI();
- }
-
- private void initGUI()
- {
- setLayout( new MigLayout( "fill,wrap 2", "[right][grow]", "[][][grow]" ) );
-
- add( new JLabel( "RTL2832 with R820T Tuner" ), "span 2, align center, wrap" );
-
- mFrequencyControl = new JFrequencyControl();
-
- mFrequencyControl.addListener( this );
-
- /* Add frequency control as frequency change listener. */
- mController.addListener( mFrequencyControl );
-
- mFrequencyControl.setFrequency( mController.getFrequency(), false );
-
- add( mFrequencyControl, "span 2, align center, wrap" );
-
- JideTabbedPane tabs = new JideTabbedPane();
- tabs.setFont( this.getFont() );
- tabs.setForeground( Color.BLACK );
-
- tabs.addTab( "Configuration",
- new R820TTunerConfigurationPanel( mSettingsManager, mController ) );
-
- tabs.addTab( "Info", new RTL2832InfoPanel( mController ) );
-
- add( tabs, "grow,push,span" );
- }
-
- /**
- * Frequency change listener for the frequency control gui component to
- * apply end-user requested frequency changes against the tuner
- */
- @Override
- public void frequencyChanged( FrequencyChangeEvent event )
- {
- if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
- {
- final long frequency = event.getValue().longValue();
-
- EventQueue.invokeLater( new Runnable()
- {
- @Override
- public void run()
- {
- try
- {
- mController.setFrequency( frequency );
- }
- catch ( SourceException e )
- {
- mLog.error( "R820T Tuner Controller - error setting frequency [" +
- frequency + "]", e );
- }
- }
- } );
- }
- }
-}
diff --git a/src/spectrum/SpectralDisplayPanel.java b/src/spectrum/SpectralDisplayPanel.java
index 0ef337c0..c3b27325 100644
--- a/src/spectrum/SpectralDisplayPanel.java
+++ b/src/spectrum/SpectralDisplayPanel.java
@@ -62,7 +62,7 @@ import settings.ColorSettingMenuItem;
import settings.SettingsManager;
import source.SourceException;
import source.tuner.Tuner;
-import source.tuner.TunerSelectionListener;
+import source.tuner.TunerEvent;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
@@ -78,7 +78,6 @@ import spectrum.menu.SmoothingTypeItem;
import com.jidesoft.swing.JideSplitPane;
-import controller.ConfigurationControllerModel;
import controller.channel.Channel;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
@@ -89,8 +88,7 @@ import dsp.filter.smoothing.SmoothingFilter.SmoothingType;
public class SpectralDisplayPanel extends JPanel
implements Listener,
IFrequencyChangeProcessor,
- IDFTWidthChangeProcessor,
- TunerSelectionListener
+ IDFTWidthChangeProcessor
{
private static final long serialVersionUID = 1L;
@@ -114,7 +112,6 @@ public class SpectralDisplayPanel extends JPanel
private OverlayPanel mOverlayPanel;
private DFTProcessor mDFTProcessor;
private DFTResultsConverter mDFTConverter;
- private ConfigurationControllerModel mControllerModel;
private ChannelModel mChannelModel;
private ChannelProcessingManager mChannelProcessingManager;
private SettingsManager mSettingsManager;
@@ -132,12 +129,10 @@ public class SpectralDisplayPanel extends JPanel
* the DFT is translated to decibels for display in the spectrum and
* waterfall components.
*/
- public SpectralDisplayPanel( ConfigurationControllerModel controllerModel,
- ChannelModel channelModel,
+ public SpectralDisplayPanel( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager )
{
- mControllerModel = controllerModel;
mChannelModel = channelModel;
mChannelProcessingManager = channelProcessingManager;
mSettingsManager = settingsManager;
@@ -146,12 +141,6 @@ public class SpectralDisplayPanel extends JPanel
mOverlayPanel = new OverlayPanel( mSettingsManager, mChannelModel );
mWaterfallPanel = new WaterfallPanel( mSettingsManager );
- //Register to receive tuner selection events
- if( mControllerModel != null )
- {
- mControllerModel.addListener( (TunerSelectionListener)this );
- }
-
init();
loadSettings();
@@ -190,12 +179,6 @@ public class SpectralDisplayPanel extends JPanel
/* De-register from receiving samples when the window closes */
clearTuner();
- if( mControllerModel != null )
- {
- mControllerModel.removeListener( (TunerSelectionListener)this );
- }
-
- mControllerModel = null;
mSettingsManager = null;
mDFTProcessor.dispose();
@@ -217,6 +200,11 @@ public class SpectralDisplayPanel extends JPanel
mTuner = null;
}
+ public Listener getTunerEventListener()
+ {
+ return new TunerSelectionListener( this );
+ }
+
/**
* Queues an FFT size change request. The scheduled executor will apply
* the change when it runs.
@@ -442,11 +430,10 @@ public class SpectralDisplayPanel extends JPanel
}
/**
- * Responds to tuner selection event by deregistering from the current
+ * Responds to tuner event by deregistering from the current
* complex sample buffer source and registering with the tuner argument.
*/
- @Override
- public void tunerSelected( Tuner tuner )
+ public void showTuner( Tuner tuner )
{
clearTuner();
@@ -975,4 +962,26 @@ public class SpectralDisplayPanel extends JPanel
} );
}
}
+
+ /**
+ * Provides tuner event listener interface for showing tuners in this display
+ */
+ public class TunerSelectionListener implements Listener
+ {
+ private SpectralDisplayPanel mSpectralDisplayPanel;
+
+ public TunerSelectionListener( SpectralDisplayPanel spectralDisplayPanel )
+ {
+ mSpectralDisplayPanel = spectralDisplayPanel;
+ }
+
+ @Override
+ public void receive( TunerEvent event )
+ {
+ if( event.getEvent() == TunerEvent.Event.REQUEST_MAIN_SPECTRAL_DISPLAY )
+ {
+ mSpectralDisplayPanel.showTuner( event.getTuner() );
+ }
+ }
+ }
}
diff --git a/src/spectrum/SpectrumFrame.java b/src/spectrum/SpectrumFrame.java
index a094be24..a3e1e5d1 100644
--- a/src/spectrum/SpectrumFrame.java
+++ b/src/spectrum/SpectrumFrame.java
@@ -26,7 +26,6 @@ import javax.swing.JFrame;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
import source.tuner.Tuner;
-import controller.ConfigurationControllerModel;
import controller.channel.ChannelModel;
import controller.channel.ChannelProcessingManager;
@@ -36,8 +35,7 @@ public class SpectrumFrame extends JFrame implements WindowListener
private SpectralDisplayPanel mSpectralDisplayPanel;
- public SpectrumFrame( ConfigurationControllerModel controllerModel,
- ChannelModel channelModel,
+ public SpectrumFrame( ChannelModel channelModel,
ChannelProcessingManager channelProcessingManager,
SettingsManager settingsManager,
Tuner tuner )
@@ -48,10 +46,10 @@ public class SpectrumFrame extends JFrame implements WindowListener
setLayout( new MigLayout( "insets 0 0 0 0", "[grow]", "[grow]") );
- mSpectralDisplayPanel = new SpectralDisplayPanel( controllerModel,
- channelModel, channelProcessingManager, settingsManager );
-
- mSpectralDisplayPanel.tunerSelected( tuner );
+ mSpectralDisplayPanel = new SpectralDisplayPanel( channelModel,
+ channelProcessingManager, settingsManager );
+
+ mSpectralDisplayPanel.showTuner( tuner );
add( mSpectralDisplayPanel, "grow" );
/* Register a shutdown listener */