mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
WIP #34 - more work on tuner model and view. Includes new tuner
configuration and tuner configuration assignment editors. Beginning of tuner editor panel rework. Removes most of the remaining JTree configuration pieces. Updates the settings manager to load and save tuners and refactors all of the tuner configuration management out into the tuner configuration model.
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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<TunerChangeEvent>
|
||||
{
|
||||
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<Tuner> 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<Tuner> getTuners()
|
||||
{
|
||||
return mTuners;
|
||||
}
|
||||
|
||||
public Tuner getTuner( int index )
|
||||
{
|
||||
if( index < mTuners.size() )
|
||||
{
|
||||
return mTuners.get( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addTuners( List<Tuner> 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 ];
|
||||
}
|
||||
}
|
||||
@@ -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" );
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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<Recording> recordings = getSourceManager()
|
||||
.getRecordingSourceManager().getRecordings();
|
||||
|
||||
for( Recording recording: recordings )
|
||||
{
|
||||
RecordingNode node = new RecordingNode( getSourceManager(), recording );
|
||||
|
||||
getModel().addNode( node, this, 0 );
|
||||
}
|
||||
|
||||
sort();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class RecordingSourceManager
|
||||
|
||||
private void loadRecordings()
|
||||
{
|
||||
ArrayList<RecordingConfiguration> recordingConfigurations =
|
||||
List<RecordingConfiguration> recordingConfigurations =
|
||||
mSettingsManager.getRecordingConfigurations();
|
||||
|
||||
mLog.info( "RecordingSourceManager - discovered [" +
|
||||
|
||||
@@ -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<IFrequencyChangeProcessor> mFrequencyChangeProcessors =
|
||||
new CopyOnWriteArrayList<>();
|
||||
|
||||
protected List<Listener<TunerChangeEvent>> mTunerChangeListeners =
|
||||
protected List<Listener<TunerEvent>> 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<TunerChangeEvent> listener )
|
||||
public void addTunerChangeListener( Listener<TunerEvent> listener )
|
||||
{
|
||||
mTunerChangeListeners.add( listener );
|
||||
}
|
||||
@@ -231,7 +226,7 @@ public abstract class Tuner implements IFrequencyChangeProcessor,
|
||||
/**
|
||||
* Removes the registered listener
|
||||
*/
|
||||
public void removeTunerChangeListener( Listener<TunerChangeEvent> listener )
|
||||
public void removeTunerChangeListener( Listener<TunerEvent> 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<TunerChangeEvent> listener: mTunerChangeListeners )
|
||||
for( Listener<TunerEvent> 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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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<Tuner>
|
||||
{
|
||||
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<TunerConfigurationModel> 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<TunerConfiguration>();
|
||||
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<TunerConfigurationModel,Integer>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
75
src/source/tuner/TunerEditorOld.java
Normal file
75
src/source/tuner/TunerEditorOld.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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() + "]";
|
||||
}
|
||||
}
|
||||
@@ -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<Tuner> mTuners = new ArrayList<Tuner>();
|
||||
|
||||
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<Tuner> 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<Tuner> 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<TunerConfiguration> 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<Tuner>();
|
||||
}
|
||||
}
|
||||
|
||||
294
src/source/tuner/TunerModel.java
Normal file
294
src/source/tuner/TunerModel.java
Normal file
@@ -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<TunerEvent>
|
||||
{
|
||||
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<Tuner> mTuners = new ArrayList<>();
|
||||
private List<Listener<TunerEvent>> 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<Tuner> getTuners()
|
||||
{
|
||||
return mTuners;
|
||||
}
|
||||
|
||||
public Tuner getTuner( int index )
|
||||
{
|
||||
if( index < mTuners.size() )
|
||||
{
|
||||
return mTuners.get( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addTuners( List<Tuner> 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<TunerEvent> listener )
|
||||
{
|
||||
mTunerEventListeners.add( listener );
|
||||
}
|
||||
|
||||
public void removeListener( Listener<TunerEvent> listener )
|
||||
{
|
||||
mTunerEventListeners.remove( listener );
|
||||
}
|
||||
|
||||
public void broadcast( TunerEvent event )
|
||||
{
|
||||
for( Listener<TunerEvent> 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<Tuner> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package source.tuner;
|
||||
|
||||
public interface TunerSelectionListener
|
||||
{
|
||||
public void tunerSelected( Tuner tuner );
|
||||
}
|
||||
@@ -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" ),
|
||||
|
||||
@@ -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<Tuner>();
|
||||
}
|
||||
|
||||
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<Tuner>() );
|
||||
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 );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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<AirspyTunerConfiguration> getModel()
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
|
||||
|
||||
DefaultComboBoxModel<AirspyTunerConfiguration> model =
|
||||
new DefaultComboBoxModel<AirspyTunerConfiguration>();
|
||||
|
||||
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<TunerConfiguration> configs =
|
||||
mSettingsManager.getTunerConfigurations( TunerType.AIRSPY_R820T );
|
||||
// ArrayList<TunerConfiguration> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package 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
|
||||
*/
|
||||
@@ -15,10 +15,12 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package source.tuner;
|
||||
package source.tuner.configuration;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import source.tuner.TunerType;
|
||||
|
||||
public class TunerConfigurationAssignment
|
||||
{
|
||||
private TunerType mTunerType;
|
||||
20
src/source/tuner/configuration/TunerConfigurationEditor.java
Normal file
20
src/source/tuner/configuration/TunerConfigurationEditor.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package source.tuner.configuration;
|
||||
|
||||
import gui.editor.Editor;
|
||||
|
||||
public abstract class TunerConfigurationEditor extends Editor<TunerConfiguration>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private TunerConfigurationModel mTunerConfigurationModel;
|
||||
|
||||
public TunerConfigurationEditor( TunerConfigurationModel model )
|
||||
{
|
||||
mTunerConfigurationModel = model;
|
||||
}
|
||||
|
||||
public TunerConfigurationModel getTunerConfigurationModel()
|
||||
{
|
||||
return mTunerConfigurationModel;
|
||||
}
|
||||
}
|
||||
45
src/source/tuner/configuration/TunerConfigurationEvent.java
Normal file
45
src/source/tuner/configuration/TunerConfigurationEvent.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
370
src/source/tuner/configuration/TunerConfigurationModel.java
Normal file
370
src/source/tuner/configuration/TunerConfigurationModel.java
Normal file
@@ -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<Listener<TunerConfigurationEvent>> mConfigurationListeners = new ArrayList<>();
|
||||
private List<TunerConfiguration> mTunerConfigurations = new ArrayList<>();
|
||||
private List<TunerConfigurationAssignment> 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<TunerConfiguration> configs )
|
||||
{
|
||||
for( TunerConfiguration config: configs )
|
||||
{
|
||||
addTunerConfiguration( config );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns of list of tuner configurations from the model
|
||||
*/
|
||||
public List<TunerConfiguration> 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<TunerConfigurationEvent> listener )
|
||||
{
|
||||
mConfigurationListeners.add( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the tuner configuration event listener
|
||||
*/
|
||||
public void removeListener( Listener<TunerConfigurationEvent> listener )
|
||||
{
|
||||
mConfigurationListeners.remove( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts a tuner configuration event
|
||||
*/
|
||||
public void broadcast( TunerConfigurationEvent event )
|
||||
{
|
||||
for( Listener<TunerConfigurationEvent> listener: mConfigurationListeners )
|
||||
{
|
||||
listener.receive( event );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a list of tuner configuration assignments to the model
|
||||
*/
|
||||
public void addTunerConfigurationAssignments( List<TunerConfigurationAssignment> assignments )
|
||||
{
|
||||
for( TunerConfigurationAssignment assigment: assignments )
|
||||
{
|
||||
addTunerConfigurationAssignment( assigment );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns of list of tuner configurations from the model
|
||||
*/
|
||||
public List<TunerConfigurationAssignment> 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<TunerConfiguration> 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<TunerConfiguration> getTunerConfigurations( TunerType type )
|
||||
{
|
||||
List<TunerConfiguration> 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<FCD1TunerConfiguration> getModel()
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
|
||||
|
||||
DefaultComboBoxModel<FCD1TunerConfiguration> model =
|
||||
new DefaultComboBoxModel<FCD1TunerConfiguration>();
|
||||
|
||||
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<TunerConfiguration> configs =
|
||||
mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
|
||||
// ArrayList<TunerConfiguration> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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<FCD2TunerConfiguration> getModel()
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager
|
||||
// .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
|
||||
|
||||
DefaultComboBoxModel<FCD2TunerConfiguration> model =
|
||||
new DefaultComboBoxModel<FCD2TunerConfiguration>();
|
||||
|
||||
for( TunerConfiguration config: configs )
|
||||
{
|
||||
model.addElement( (FCD2TunerConfiguration)config );
|
||||
}
|
||||
// for( TunerConfiguration config: configs )
|
||||
// {
|
||||
// model.addElement( (FCD2TunerConfiguration)config );
|
||||
// }
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private FCD2TunerConfiguration getNamedConfiguration( String name )
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
|
||||
// ArrayList<TunerConfiguration> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<HackRFTunerConfiguration> getModel()
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.HACKRF );
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager
|
||||
// .getTunerConfigurations( TunerType.HACKRF );
|
||||
|
||||
DefaultComboBoxModel<HackRFTunerConfiguration> model =
|
||||
new DefaultComboBoxModel<HackRFTunerConfiguration>();
|
||||
|
||||
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<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.HACKRF );
|
||||
// ArrayList<TunerConfiguration> 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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -363,8 +363,6 @@ public abstract class RTL2832TunerController extends TunerController
|
||||
}
|
||||
}
|
||||
|
||||
public abstract JPanel getEditor( SettingsManager settingsManager );
|
||||
|
||||
public abstract void setSampleRateFilters( int sampleRate )
|
||||
throws SourceException;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<E4KTunerConfiguration> getModel()
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.ELONICS_E4000 );
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager
|
||||
// .getTunerConfigurations( TunerType.ELONICS_E4000 );
|
||||
|
||||
DefaultComboBoxModel<E4KTunerConfiguration> model =
|
||||
new DefaultComboBoxModel<E4KTunerConfiguration>();
|
||||
|
||||
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<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.ELONICS_E4000 );
|
||||
|
||||
for( TunerConfiguration config: configs )
|
||||
{
|
||||
if( config.getName().contentEquals( name ) )
|
||||
{
|
||||
return (E4KTunerConfiguration)config;
|
||||
}
|
||||
}
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager
|
||||
// .getTunerConfigurations( TunerType.ELONICS_E4000 );
|
||||
//
|
||||
// for( TunerConfiguration config: configs )
|
||||
// {
|
||||
// if( config.getName().contentEquals( name ) )
|
||||
// {
|
||||
// return (E4KTunerConfiguration)config;
|
||||
// }
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<SampleRate> 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<R820TTunerConfiguration> getModel()
|
||||
{
|
||||
ArrayList<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager
|
||||
// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
|
||||
|
||||
DefaultComboBoxModel<R820TTunerConfiguration> model =
|
||||
new DefaultComboBoxModel<R820TTunerConfiguration>();
|
||||
|
||||
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<TunerConfiguration> configs =
|
||||
mSettingsManager
|
||||
.getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
|
||||
|
||||
for( TunerConfiguration config: configs )
|
||||
{
|
||||
if( config.getName().contentEquals( name ) )
|
||||
{
|
||||
return (R820TTunerConfiguration)config;
|
||||
}
|
||||
}
|
||||
// ArrayList<TunerConfiguration> configs =
|
||||
// mSettingsManager
|
||||
// .getTunerConfigurations( TunerType.RAFAELMICRO_R820T );
|
||||
//
|
||||
// for( TunerConfiguration config: configs )
|
||||
// {
|
||||
// if( config.getName().contentEquals( name ) )
|
||||
// {
|
||||
// return (R820TTunerConfiguration)config;
|
||||
// }
|
||||
// }
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||
*
|
||||
* Java port of librtlsdr <https://github.com/steve-m/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.
|
||||
*/
|
||||
|
||||
446
src/source/tuner/rtl/r820t/R820TTunerEditor.java
Normal file
446
src/source/tuner/rtl/r820t/R820TTunerEditor.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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<R820TGain> mComboMasterGain;
|
||||
private JComboBox<R820TMixerGain> mComboMixerGain;
|
||||
private JComboBox<R820TLNAGain> mComboLNAGain;
|
||||
private JComboBox<R820TVGAGain> mComboVGAGain;
|
||||
private JComboBox<SampleRate> 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>( 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( "<html>Select <b>AUTOMATIC</b> for auto "
|
||||
+ "gain, <b>MANUAL</b> to enable<br> independent control of "
|
||||
+ "<i>Mixer</i>, <i>LNA</i> and <i>Enhance</i> gain<br>"
|
||||
+ "settings, or one of the individual gain settings for<br>"
|
||||
+ "semi-manual gain control</html>" );
|
||||
gainPanel.add( new JLabel( "Master" ) );
|
||||
gainPanel.add( mComboMasterGain );
|
||||
|
||||
/* Mixer Gain Control */
|
||||
mComboMixerGain = new JComboBox<R820TMixerGain>( 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( "<html>Mixer Gain. Set master gain "
|
||||
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
||||
mComboMixerGain.setEnabled( false );
|
||||
gainPanel.add( new JLabel( "Mixer" ) );
|
||||
gainPanel.add( mComboMixerGain, "wrap" );
|
||||
|
||||
/* LNA Gain Control */
|
||||
mComboLNAGain = new JComboBox<R820TLNAGain>( 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( "<html>LNA Gain. Set master gain "
|
||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
||||
mComboLNAGain.setEnabled( false );
|
||||
gainPanel.add( new JLabel( "LNA" ) );
|
||||
gainPanel.add( mComboLNAGain );
|
||||
|
||||
/* VGA Gain Control */
|
||||
mComboVGAGain = new JComboBox<R820TVGAGain>( 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( "<html>VGA Gain. Set master gain "
|
||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
||||
mComboVGAGain.setEnabled( false );
|
||||
gainPanel.add( new JLabel( "VGA" ) );
|
||||
gainPanel.add( mComboVGAGain, "wrap" );
|
||||
|
||||
add( gainPanel, "span" );
|
||||
}
|
||||
}
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
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 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user