mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
wip #34 - final edits to R820T tuner configuration editor and introduced
frequency correction to the airspy tuner configuration.
This commit is contained in:
@@ -38,7 +38,7 @@ public class Recording implements Comparable<Recording>,
|
||||
public void setAlias( String alias )
|
||||
{
|
||||
mConfiguration.setAlias( alias );
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
|
||||
public void setRecordingFile( File file ) throws SourceException
|
||||
@@ -51,7 +51,7 @@ public class Recording implements Comparable<Recording>,
|
||||
}
|
||||
|
||||
mConfiguration.setFilePath( file.getAbsolutePath() );
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +96,7 @@ public class Recording implements Comparable<Recording>,
|
||||
|
||||
mConfiguration.setCenterFrequency( frequency );
|
||||
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
|
||||
mCenterFrequency = frequency;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
@@ -43,8 +44,9 @@ public class TunerEditor extends Editor<Tuner>
|
||||
private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" );
|
||||
private JButton mNewConfigurationButton = new JButton( "New" );
|
||||
private JButton mDeleteConfigurationButton = new JButton( "Delete" );
|
||||
private JButton mAssignConfigurationButton = new JButton( "Assign" );
|
||||
private JScrollPane mEditorScroller;
|
||||
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>();
|
||||
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>( "a tuner" );
|
||||
private JideSplitPane mEditorSplitPane = new JideSplitPane();
|
||||
|
||||
public TunerEditor( TunerConfigurationModel tunerConfigurationModel )
|
||||
@@ -58,7 +60,7 @@ public class TunerEditor extends Editor<Tuner>
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]" ) );
|
||||
|
||||
JPanel listPanel = new JPanel();
|
||||
listPanel.setLayout( new MigLayout( "fill,wrap 2", "[grow,fill]", "[][][][grow,fill][]" ) );
|
||||
listPanel.setLayout( new MigLayout( "fill,wrap 3", "[grow,fill]", "[][][][grow,fill][]" ) );
|
||||
|
||||
listPanel.add( mSelectedTunerType, "span" );
|
||||
|
||||
@@ -84,7 +86,7 @@ public class TunerEditor extends Editor<Tuner>
|
||||
|
||||
if( modelRow >= 0 )
|
||||
{
|
||||
setConfigurationEditor( mTunerConfigurationModel.getTunerConfiguration( modelRow ) );
|
||||
setTunerConfiguration( mTunerConfigurationModel.getTunerConfiguration( modelRow ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,8 +120,39 @@ public class TunerEditor extends Editor<Tuner>
|
||||
listPanel.add( mNewConfigurationButton );
|
||||
|
||||
mDeleteConfigurationButton.setEnabled( false );
|
||||
mDeleteConfigurationButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog( TunerEditor.this,
|
||||
"Do you want to delete this tuner configuration?",
|
||||
"Delete Tuner Configuration?", JOptionPane.YES_NO_OPTION );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
TunerConfiguration selected = getSelectedTunerConfiguration();
|
||||
|
||||
mTunerConfigurationModel.removeTunerConfiguration( selected );
|
||||
}
|
||||
}
|
||||
} );
|
||||
listPanel.add( mDeleteConfigurationButton );
|
||||
|
||||
mAssignConfigurationButton.setEnabled( false );
|
||||
mAssignConfigurationButton.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
TunerConfiguration selected = getSelectedTunerConfiguration();
|
||||
|
||||
mTunerConfigurationModel.assignTunerConfiguration( selected );
|
||||
setTunerConfiguration( getSelectedTunerConfiguration() );
|
||||
}
|
||||
} );
|
||||
listPanel.add( mAssignConfigurationButton );
|
||||
|
||||
//Set preferred size on both scrollers to same width, so they split the space
|
||||
listPanel.setPreferredSize( new Dimension( 100, 80 ) );
|
||||
JScrollPane listScroller = new JScrollPane( listPanel );
|
||||
@@ -135,6 +168,23 @@ public class TunerEditor extends Editor<Tuner>
|
||||
add( mEditorSplitPane );
|
||||
}
|
||||
|
||||
private TunerConfiguration getSelectedTunerConfiguration()
|
||||
{
|
||||
int tableRow = mTunerConfigurationTable.getSelectedRow();
|
||||
|
||||
if( tableRow >= 0 )
|
||||
{
|
||||
int modelRow = mTunerConfigurationTable.convertRowIndexToModel( tableRow );
|
||||
|
||||
if( modelRow >= 0 )
|
||||
{
|
||||
return mTunerConfigurationModel.getTunerConfiguration( modelRow );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
@@ -161,8 +211,11 @@ public class TunerEditor extends Editor<Tuner>
|
||||
mTunerConfigurationTable.setEnabled( true );
|
||||
mNewConfigurationButton.setEnabled( true );
|
||||
|
||||
mRowSorter.setRowFilter( new ConfigurationRowFilter(
|
||||
tuner.getTunerType(), tuner.getUniqueID() ) );
|
||||
//Change to an editor for this config's tuner type
|
||||
mEditor = TunerConfigurationFactory.getEditor( getItem(), mTunerConfigurationModel );
|
||||
|
||||
mRowSorter.setRowFilter( new ConfigurationRowFilter( tuner.getTunerType(),
|
||||
tuner.getUniqueID() ) );
|
||||
|
||||
TunerConfiguration assigned = mTunerConfigurationModel
|
||||
.getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
|
||||
@@ -190,9 +243,6 @@ public class TunerEditor extends Editor<Tuner>
|
||||
//Set the displayed frequency without adjusting the tuner's frequency
|
||||
mFrequencyControl.setFrequency(
|
||||
tuner.getTunerController().getFrequency(), false );
|
||||
|
||||
mEditor = TunerConfigurationFactory
|
||||
.getEditor( getItem(), mTunerConfigurationModel );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -212,13 +262,32 @@ public class TunerEditor extends Editor<Tuner>
|
||||
mEditorSplitPane.setDividerLocation( 0, split );
|
||||
}
|
||||
|
||||
private void setConfigurationEditor( TunerConfiguration config )
|
||||
private void setTunerConfiguration( TunerConfiguration config )
|
||||
{
|
||||
if( config != null )
|
||||
{
|
||||
if( !mDeleteConfigurationButton.isEnabled() )
|
||||
if( !config.isAssigned() )
|
||||
{
|
||||
mDeleteConfigurationButton.setEnabled( true );
|
||||
if( !mAssignConfigurationButton.isEnabled() )
|
||||
{
|
||||
mAssignConfigurationButton.setEnabled( true );
|
||||
}
|
||||
if( !mDeleteConfigurationButton.isEnabled() )
|
||||
{
|
||||
mDeleteConfigurationButton.setEnabled( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( mAssignConfigurationButton.isEnabled() )
|
||||
{
|
||||
mAssignConfigurationButton.setEnabled( false );
|
||||
}
|
||||
|
||||
if( mDeleteConfigurationButton.isEnabled() )
|
||||
{
|
||||
mDeleteConfigurationButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -227,6 +296,11 @@ public class TunerEditor extends Editor<Tuner>
|
||||
{
|
||||
mDeleteConfigurationButton.setEnabled( false );
|
||||
}
|
||||
|
||||
if( mAssignConfigurationButton.isEnabled() )
|
||||
{
|
||||
mAssignConfigurationButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
|
||||
mEditor.setItem( config );
|
||||
|
||||
@@ -30,6 +30,7 @@ public class AirspyTunerConfiguration extends TunerConfiguration
|
||||
private int mIFGain = AirspyTunerController.IF_GAIN_DEFAULT;
|
||||
private int mMixerGain = AirspyTunerController.MIXER_GAIN_DEFAULT;
|
||||
private int mLNAGain = AirspyTunerController.LNA_GAIN_DEFAULT;
|
||||
private double mFrequencyCorrection = 0.0d;
|
||||
|
||||
private boolean mMixerAGC = false;
|
||||
private boolean mLNAAGC = false;
|
||||
@@ -128,4 +129,16 @@ public class AirspyTunerConfiguration extends TunerConfiguration
|
||||
{
|
||||
mLNAAGC = enabled;
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "frequency_correction" )
|
||||
public double getFrequencyCorrection()
|
||||
{
|
||||
return mFrequencyCorrection;
|
||||
}
|
||||
|
||||
public void setFrequencyCorrection( double value )
|
||||
{
|
||||
mFrequencyCorrection = value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
@@ -47,11 +46,8 @@ import org.usb4java.LibUsbException;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.SourceException;
|
||||
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
|
||||
{
|
||||
@@ -119,7 +115,7 @@ public class AirspyTunerConfigurationPanel extends JPanel
|
||||
mComboConfigurations.setModel( getModel() );
|
||||
|
||||
/* Determine which tuner configuration should be selected/displayed */
|
||||
TunerConfigurationAssignment savedConfig = null;
|
||||
// TunerConfigurationAssignment savedConfig = null;
|
||||
String serial = null;
|
||||
|
||||
serial = mController.getDeviceInfo().getSerialNumber();
|
||||
@@ -130,11 +126,11 @@ public class AirspyTunerConfigurationPanel extends JPanel
|
||||
// TunerType.AIRSPY_R820T, serial );
|
||||
}
|
||||
|
||||
if( savedConfig != null )
|
||||
{
|
||||
mSelectedConfig = getNamedConfiguration(
|
||||
savedConfig.getTunerConfigurationName() );
|
||||
}
|
||||
// if( savedConfig != null )
|
||||
// {
|
||||
// mSelectedConfig = getNamedConfiguration(
|
||||
// savedConfig.getTunerConfigurationName() );
|
||||
// }
|
||||
|
||||
/* If we couldn't determine the saved/selected config, use the first one */
|
||||
if( mSelectedConfig == null )
|
||||
@@ -694,6 +690,6 @@ public class AirspyTunerConfigurationPanel extends JPanel
|
||||
*/
|
||||
private void save()
|
||||
{
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +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.configuration;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
import source.tuner.TunerType;
|
||||
|
||||
public class TunerConfigurationAssignment
|
||||
{
|
||||
private TunerType mTunerType;
|
||||
private String mUniqueID;
|
||||
private String mTunerConfigurationName;
|
||||
|
||||
public TunerConfigurationAssignment()
|
||||
{
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "type" )
|
||||
public TunerType getTunerType()
|
||||
{
|
||||
return mTunerType;
|
||||
}
|
||||
|
||||
public void setTunerType( TunerType tunerType )
|
||||
{
|
||||
mTunerType = tunerType;
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "id" )
|
||||
public String getUniqueID()
|
||||
{
|
||||
return mUniqueID;
|
||||
}
|
||||
|
||||
public void setUniqueID( String uniqueID )
|
||||
{
|
||||
mUniqueID = uniqueID;
|
||||
}
|
||||
|
||||
@XmlAttribute( name = "configuration_name" )
|
||||
public String getTunerConfigurationName()
|
||||
{
|
||||
return mTunerConfigurationName;
|
||||
}
|
||||
|
||||
public void setTunerConfigurationName( String tunerConfigurationName )
|
||||
{
|
||||
mTunerConfigurationName = tunerConfigurationName;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,6 @@ public class TunerConfigurationFactory
|
||||
break;
|
||||
}
|
||||
|
||||
return new EmptyEditor<TunerConfiguration>();
|
||||
return new EmptyEditor<TunerConfiguration>( "a tuner" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,12 +23,13 @@ public class TunerConfigurationModel extends AbstractTableModel
|
||||
private static final int ASSIGNED = 2;
|
||||
private static final String[] COLUMN_HEADERS = { "Tuner Type", "Name", "Assigned" };
|
||||
|
||||
private List<Listener<TunerConfigurationEvent>> mConfigurationListeners = new ArrayList<>();
|
||||
private List<Listener<TunerConfigurationEvent>> mConfigurationChangeListeners =
|
||||
new ArrayList<>();
|
||||
private List<TunerConfiguration> mTunerConfigurations = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Table model for managing tuner configurations and tuner configuration
|
||||
* assignments. Provides tuner configuration events to registered listeners
|
||||
* Table model for managing tuner configurations. Provides tuner configuration events to
|
||||
* registered listeners
|
||||
*/
|
||||
public TunerConfigurationModel()
|
||||
{
|
||||
@@ -115,7 +116,7 @@ public class TunerConfigurationModel extends AbstractTableModel
|
||||
*/
|
||||
public void addListener( Listener<TunerConfigurationEvent> listener )
|
||||
{
|
||||
mConfigurationListeners.add( listener );
|
||||
mConfigurationChangeListeners.add( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -123,7 +124,7 @@ public class TunerConfigurationModel extends AbstractTableModel
|
||||
*/
|
||||
public void removeListener( Listener<TunerConfigurationEvent> listener )
|
||||
{
|
||||
mConfigurationListeners.remove( listener );
|
||||
mConfigurationChangeListeners.remove( listener );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,12 +132,44 @@ public class TunerConfigurationModel extends AbstractTableModel
|
||||
*/
|
||||
public void broadcast( TunerConfigurationEvent event )
|
||||
{
|
||||
for( Listener<TunerConfigurationEvent> listener: mConfigurationListeners )
|
||||
for( Listener<TunerConfigurationEvent> listener: mConfigurationChangeListeners )
|
||||
{
|
||||
listener.receive( event );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Designates the configuration argument as the currently assigned configuration and unassigns
|
||||
* any other configurations with the same tuner type and unique ID.
|
||||
*/
|
||||
public void assignTunerConfiguration( TunerConfiguration configToAssign )
|
||||
{
|
||||
if( configToAssign != null )
|
||||
{
|
||||
List<TunerConfiguration> configs =
|
||||
getTunerConfigurations( configToAssign.getTunerType(), configToAssign.getUniqueID() );
|
||||
|
||||
for( TunerConfiguration config: configs )
|
||||
{
|
||||
if( config.isAssigned() )
|
||||
{
|
||||
mLog.debug( "Unassigning: " + config.getName() );
|
||||
config.setAssigned( false );
|
||||
|
||||
int index = mTunerConfigurations.indexOf( config );
|
||||
fireTableCellUpdated( index, ASSIGNED );
|
||||
broadcast( new TunerConfigurationEvent( config, Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
|
||||
mLog.debug( "Assigning: " + configToAssign.getName() );
|
||||
configToAssign.setAssigned( true );
|
||||
int index = mTunerConfigurations.indexOf( configToAssign );
|
||||
fireTableCellUpdated( index, ASSIGNED );
|
||||
broadcast( new TunerConfigurationEvent( configToAssign, Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tuner configuration that is assigned to the tuner with the
|
||||
* tuner type and uniqueID, or selects the first existing configuration that
|
||||
|
||||
@@ -557,7 +557,7 @@ public class FCD1TunerConfigurationPanel extends JPanel
|
||||
|
||||
private void save()
|
||||
{
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
|
||||
public enum Correction { GAIN, PHASE, DC_INPHASE, DC_QUADRATURE };
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
@@ -48,9 +47,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.SourceException;
|
||||
import source.tuner.TunerType;
|
||||
import source.tuner.configuration.TunerConfiguration;
|
||||
import source.tuner.configuration.TunerConfigurationAssignment;
|
||||
|
||||
public class FCD2TunerConfigurationPanel extends JPanel
|
||||
{
|
||||
@@ -375,6 +371,6 @@ public class FCD2TunerConfigurationPanel extends JPanel
|
||||
|
||||
private void save()
|
||||
{
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ComboBoxModel;
|
||||
@@ -50,9 +49,6 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.SourceException;
|
||||
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;
|
||||
@@ -105,7 +101,7 @@ public class HackRFTunerConfigurationPanel extends JPanel
|
||||
mComboConfigurations.setModel( getModel() );
|
||||
|
||||
/* Determine which tuner configuration should be selected/displayed */
|
||||
TunerConfigurationAssignment savedConfig = null;
|
||||
// TunerConfigurationAssignment savedConfig = null;
|
||||
String serial = null;
|
||||
|
||||
try
|
||||
@@ -122,12 +118,12 @@ public class HackRFTunerConfigurationPanel extends JPanel
|
||||
// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
|
||||
// TunerType.HACKRF, serial );
|
||||
// }
|
||||
|
||||
if( savedConfig != null )
|
||||
{
|
||||
mSelectedConfig = getNamedConfiguration(
|
||||
savedConfig.getTunerConfigurationName() );
|
||||
}
|
||||
//
|
||||
// if( savedConfig != null )
|
||||
// {
|
||||
// mSelectedConfig = getNamedConfiguration(
|
||||
// savedConfig.getTunerConfigurationName() );
|
||||
// }
|
||||
|
||||
/* If we couldn't determine the saved/selected config, use the first one */
|
||||
if( mSelectedConfig == null )
|
||||
@@ -556,6 +552,6 @@ public class HackRFTunerConfigurationPanel extends JPanel
|
||||
*/
|
||||
private void save()
|
||||
{
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ComboBoxModel;
|
||||
@@ -50,9 +49,6 @@ import org.usb4java.LibUsbException;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.SourceException;
|
||||
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;
|
||||
@@ -686,6 +682,6 @@ public class E4KTunerConfigurationPanel extends JPanel
|
||||
*/
|
||||
private void save()
|
||||
{
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.FocusEvent;
|
||||
import java.awt.event.FocusListener;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ComboBoxModel;
|
||||
@@ -50,9 +49,6 @@ import org.usb4java.LibUsbException;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import source.SourceException;
|
||||
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;
|
||||
@@ -694,6 +690,6 @@ public class R820TTunerConfigurationEditorOld extends JPanel
|
||||
*/
|
||||
private void save()
|
||||
{
|
||||
mSettingsManager.save();
|
||||
// mSettingsManager.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,18 +17,15 @@
|
||||
******************************************************************************/
|
||||
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.JSeparator;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.JTextField;
|
||||
@@ -76,6 +73,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
private JComboBox<R820TLNAGain> mComboLNAGain;
|
||||
private JComboBox<R820TVGAGain> mComboVGAGain;
|
||||
private JComboBox<SampleRate> mComboSampleRate;
|
||||
private boolean mLoading;
|
||||
|
||||
public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel,
|
||||
RTL2832Tuner tuner )
|
||||
@@ -95,7 +93,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() )
|
||||
if( hasItem() && !mLoading )
|
||||
{
|
||||
R820TTunerConfiguration config = getConfiguration();
|
||||
|
||||
@@ -133,14 +131,73 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
{
|
||||
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() );
|
||||
//Toggle loading so that we don't fire a change event and schedule a settings file save
|
||||
mLoading = true;
|
||||
|
||||
if( item.isAssigned() )
|
||||
{
|
||||
setControlsEnabled( true );
|
||||
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() );
|
||||
}
|
||||
else
|
||||
{
|
||||
setControlsEnabled( false );
|
||||
mConfigurationName.setText( config.getName() );
|
||||
}
|
||||
|
||||
mLoading = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
setControlsEnabled( false );
|
||||
mConfigurationName.setText( "" );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sets each of the tuner configuration controls to the enabled argument state
|
||||
*/
|
||||
private void setControlsEnabled( boolean enabled )
|
||||
{
|
||||
if( mConfigurationName.isEnabled() != enabled )
|
||||
{
|
||||
mConfigurationName.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mFrequencyCorrection.isEnabled() != enabled )
|
||||
{
|
||||
mFrequencyCorrection.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mComboSampleRate.isEnabled() != enabled )
|
||||
{
|
||||
mComboSampleRate.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mComboMasterGain.isEnabled() != enabled )
|
||||
{
|
||||
mComboMasterGain.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mComboMixerGain.isEnabled() != enabled )
|
||||
{
|
||||
mComboMixerGain.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mComboLNAGain.isEnabled() != enabled )
|
||||
{
|
||||
mComboLNAGain.setEnabled( enabled );
|
||||
}
|
||||
|
||||
if( mComboVGAGain.isEnabled() != enabled )
|
||||
{
|
||||
mComboVGAGain.setEnabled( enabled );
|
||||
}
|
||||
}
|
||||
|
||||
private R820TTunerConfiguration getConfiguration()
|
||||
@@ -164,6 +221,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
* Tuner Configuration Name
|
||||
*/
|
||||
mConfigurationName = new JTextField();
|
||||
mConfigurationName.setEnabled( false );
|
||||
mConfigurationName.addFocusListener( new FocusListener()
|
||||
{
|
||||
@Override
|
||||
@@ -179,6 +237,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
add( mConfigurationName, "span,grow" );
|
||||
|
||||
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
||||
mComboSampleRate.setEnabled( false );
|
||||
mComboSampleRate.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -219,6 +278,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
0.1 ); //step
|
||||
|
||||
mFrequencyCorrection = new JSpinner( model );
|
||||
mFrequencyCorrection.setEnabled( false );
|
||||
|
||||
JSpinner.NumberEditor editor =
|
||||
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
||||
@@ -258,7 +318,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
*/
|
||||
/* Master Gain Control */
|
||||
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
||||
|
||||
mComboMasterGain.setEnabled( false );
|
||||
mComboMasterGain.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -292,7 +352,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
mComboVGAGain.setEnabled( false );
|
||||
mComboVGAGain.setSelectedItem( gain.getVGAGain() );
|
||||
}
|
||||
|
||||
|
||||
save();
|
||||
}
|
||||
catch ( UsbException e )
|
||||
@@ -317,54 +377,49 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
|
||||
/* Mixer Gain Control */
|
||||
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
|
||||
mComboMixerGain.setEnabled( false );
|
||||
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 );
|
||||
}
|
||||
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 );
|
||||
}
|
||||
}
|
||||
} );
|
||||
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 );
|
||||
|
||||
add( new JLabel( "Mixer:" ) );
|
||||
add( mComboMixerGain );
|
||||
|
||||
/* LNA Gain Control */
|
||||
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
|
||||
mComboLNAGain.setEnabled( false );
|
||||
mComboLNAGain.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -400,12 +455,13 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
} );
|
||||
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
|
||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
||||
mComboLNAGain.setEnabled( false );
|
||||
|
||||
add( new JLabel( "LNA:" ) );
|
||||
add( mComboLNAGain );
|
||||
|
||||
/* VGA Gain Control */
|
||||
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
|
||||
mComboVGAGain.setEnabled( false );
|
||||
mComboVGAGain.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
@@ -441,7 +497,6 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
||||
} );
|
||||
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
|
||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
||||
mComboVGAGain.setEnabled( false );
|
||||
add( new JLabel( "VGA:" ) );
|
||||
add( mComboVGAGain );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user