wip #34 - updates FCD Pro tuner and completes work on tuners, tuner

configurations and tuner editors.
This commit is contained in:
denny
2016-03-20 08:13:28 -04:00
parent 13617e8fe2
commit f32c520cab
9 changed files with 537 additions and 1200 deletions

View File

@@ -158,6 +158,7 @@ public class TunerEditor extends Editor<Tuner>
TunerConfiguration selected = getSelectedTunerConfiguration();
mTunerConfigurationModel.removeTunerConfiguration( selected );
mTunerConfigurationTable.setRowSelectionInterval( 0, 0 );
}
}
} );

View File

@@ -19,7 +19,6 @@
package source.tuner.configuration;
import gui.editor.Editor;
import gui.editor.EmptyEditor;
import source.tuner.Tuner;
import source.tuner.TunerType;
import source.tuner.airspy.AirspyTuner;
@@ -27,6 +26,7 @@ import source.tuner.airspy.AirspyTunerConfiguration;
import source.tuner.airspy.AirspyTunerEditor;
import source.tuner.fcd.FCDTuner;
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
import source.tuner.fcd.proV1.FCD1TunerEditor;
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
import source.tuner.fcd.proplusV2.FCD2TunerEditor;
import source.tuner.hackrf.HackRFTuner;
@@ -43,8 +43,8 @@ public class TunerConfigurationFactory
/**
* Creates a tuner configuration for the specified tuner type, unique ID and name
*/
public static TunerConfiguration getTunerConfiguration( TunerType type,
String uniqueID, String name )
public static TunerConfiguration getTunerConfiguration( TunerType type, String uniqueID,
String name )
{
switch( type )
{
@@ -70,8 +70,7 @@ public class TunerConfigurationFactory
/**
* Creates a tuner editor gui for the specified tuner
*/
public static Editor<TunerConfiguration> getEditor( Tuner tuner,
TunerConfigurationModel model )
public static Editor<TunerConfiguration> getEditor( Tuner tuner, TunerConfigurationModel model )
{
switch( tuner.getTunerType() )
{
@@ -80,7 +79,7 @@ public class TunerConfigurationFactory
case ELONICS_E4000:
return new E4KTunerEditor( model, (RTL2832Tuner)tuner );
case FUNCUBE_DONGLE_PRO:
return new EmptyEditor<TunerConfiguration>( "a tuner" );
return new FCD1TunerEditor( model, (FCDTuner)tuner );
case FUNCUBE_DONGLE_PRO_PLUS:
return new FCD2TunerEditor( model, (FCDTuner)tuner );
case HACKRF:

View File

@@ -1,49 +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.fcd;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.miginfocom.swing.MigLayout;
public class FCDTunerDetailsPanel extends JPanel
{
private static final long serialVersionUID = 1L;
public FCDTunerDetailsPanel( FCDTunerController controller )
{
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
add( new JLabel( "USB ID:" ) );
add( new JLabel( controller.getUSBID() ) );
add( new JLabel( "USB Address:" ) );
add( new JLabel( controller.getUSBAddress() ) );
add( new JLabel( "USB Speed:" ) );
add( new JLabel( controller.getUSBSpeed() ) );
add( new JLabel( "Cellular Band:" ) );
add( new JLabel( controller.getConfiguration().getBandBlocking()
.getLabel() ) );
add( new JLabel( "Firmware:" ) );
add( new JLabel( controller.getConfiguration().getFirmware() ) );
}
}

View File

@@ -55,6 +55,7 @@ public class FCD1TunerConfiguration extends TunerConfiguration
return TunerType.FUNCUBE_DONGLE_PRO;
}
@XmlAttribute( name = "lna_gain" )
public LNAGain getLNAGain()
{
return mLNAGain;
@@ -65,12 +66,12 @@ public class FCD1TunerConfiguration extends TunerConfiguration
mLNAGain = gain;
}
@XmlAttribute( name = "lna_gain" )
public LNAEnhance getLNAEnhance()
{
return mLNAEnhance;
}
@XmlAttribute( name = "lna_enhance" )
public void setLNAEnhance( LNAEnhance enhance )
{
mLNAEnhance = enhance;

View File

@@ -1,657 +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.fcd.proV1;
import java.awt.Color;
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 java.util.ArrayList;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
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.UsbClaimException;
import javax.usb.UsbException;
import net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
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;
import com.jidesoft.swing.JideTabbedPane;
public class FCD1TunerConfigurationPanel extends JPanel
{
private final static Logger mLog =
LoggerFactory.getLogger( FCD1TunerConfigurationPanel.class );
private static final long serialVersionUID = 1L;
private SettingsManager mSettingsManager;
private FCD1TunerController mController;
private FCD1TunerConfiguration mSelectedConfig;
private JButton mNewConfiguration;
private JButton mDeleteConfiguration;
private JComboBox<FCD1TunerConfiguration> mComboConfigurations;
private JComboBox<LNAGain> mComboLNAGain;
private JComboBox<LNAEnhance> mComboLNAEnhance;
private JComboBox<MixerGain> mComboMixerGain;
private JTextField mName;
private JSpinner mCorrectionFrequency;
private CorrectionSpinner mCorrectionDCI;
private CorrectionSpinner mCorrectionDCQ;
private CorrectionSpinner mCorrectionGain;
private CorrectionSpinner mCorrectionPhase;
public FCD1TunerConfigurationPanel( SettingsManager settingsManager,
FCD1TunerController controller )
{
mSettingsManager = settingsManager;
mController = controller;
mSelectedConfig = controller.getTunerConfiguration();
init();
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][grow]" ) );
/**
* Tuner configurations combo
*/
mComboConfigurations = new JComboBox<FCD1TunerConfiguration>();
mComboConfigurations.setToolTipText( "Select a tuner configuration. "
+ "Create a separate tuner configuration for each of your "
+ "funcube dongles by using the NEW button and typing a "
+ "descriptive name" );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedItem( mSelectedConfig );
mComboConfigurations.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
FCD1TunerConfiguration selected =
(FCD1TunerConfiguration)mComboConfigurations
.getItemAt( mComboConfigurations.getSelectedIndex() );
if( selected != null )
{
update( selected );
}
}
});
add( new JLabel( "Config:" ) );
add( mComboConfigurations, "growx,push" );
/**
* Tuner Configuration - Name
*/
mName = new JTextField( mSelectedConfig.getName() );
mName.setToolTipText( "Name for the selected tuner configuration" );
mName.addFocusListener( new FocusListener()
{
@Override
public void focusLost( FocusEvent e )
{
mSelectedConfig.setName( mName.getText() );
save();
}
@Override
public void focusGained( FocusEvent e ) {}
} );
add( new JLabel( "Name:" ) );
add( mName, "growx,push" );
JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
add( tabs, "span,grow,push" );
JPanel gainPanel = new JPanel();
gainPanel.setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][grow]" ) );
/**
* LNA Gain
*/
mComboLNAGain = new JComboBox<LNAGain>( LNAGain.values() );
mComboLNAGain.setToolTipText( "Adjust the low noise amplifier gain "
+ "setting. Default value is 20db" );
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
mComboLNAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
LNAGain gain = (LNAGain)mComboLNAGain.getSelectedItem();
mSelectedConfig.setLNAGain( gain );
try
{
mController.setLNAGain( gain );
}
catch ( UsbClaimException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - cannot claim FCD "
+ "Controller to apply LNA gain [" + gain.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - usb claim "
+ "exception while applying LNA gain value [" +
gain.toString() + "]", e1 );
}
catch ( UsbException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - FCD Controller "
+ "cannot apply LNA gain [" + gain.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - "
+ "exception while applying LNA gain value [" +
gain.toString() + "]", e1 );
}
save();
}
} );
gainPanel.add( new JLabel( "LNA:" ) );
gainPanel.add( mComboLNAGain, "growx,push" );
/**
* LNA Enhance
*/
mComboLNAEnhance = new JComboBox<LNAEnhance>( LNAEnhance.values() );
mComboLNAEnhance.setToolTipText( "Adjust the LNA enhance setting. "
+ "Default value is OFF" );
mComboLNAEnhance.setSelectedItem( mSelectedConfig.getLNAEnhance() );
mComboLNAEnhance.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
LNAEnhance enhance = (LNAEnhance)mComboLNAEnhance.getSelectedItem();
mSelectedConfig.setLNAEnhance( enhance );
try
{
mController.setLNAEnhance( enhance );
}
catch ( UsbClaimException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - cannot claim FCD "
+ "Controller to apply LNA enhance [" + enhance.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - usb claim "
+ "exception while applying LNA enhance value [" +
enhance.toString() + "]", e1 );
}
catch ( UsbException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - FCD Controller "
+ "cannot apply LNA enhance [" + enhance.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - "
+ "exception while applying LNA enhance value [" +
enhance.toString() + "]", e1 );
}
save();
}
} );
gainPanel.add( new JLabel( "LNA Enhance:" ) );
gainPanel.add( mComboLNAEnhance, "growx,push" );
/**
* Mixer Gain
*/
mComboMixerGain = new JComboBox<MixerGain>( MixerGain.values() );
mComboMixerGain.setToolTipText( "Adjust mixer gain setting" );
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
mComboMixerGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
MixerGain gain = (MixerGain)mComboMixerGain.getSelectedItem();
mSelectedConfig.setMixerGain( gain );
try
{
mController.setMixerGain( gain );
}
catch ( UsbClaimException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - cannot claim FCD "
+ "Controller to apply Mixer gain [" + gain.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - usb claim "
+ "exception while applying Mixer gain value [" +
gain.toString() + "]", e1 );
}
catch ( UsbException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - FCD Controller "
+ "cannot apply Mixer gain [" + gain.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - "
+ "exception while applying Mixer gain value [" +
gain.toString() + "]", e1 );
}
save();
}
} );
gainPanel.add( new JLabel( "Mixer:" ) );
gainPanel.add( mComboMixerGain, "growx,push" );
tabs.add( "Gain", gainPanel );
JPanel correctionPanel = new JPanel();
correctionPanel.setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
/**
* Frequency Correction
*/
SpinnerModel model =
new SpinnerNumberModel( 0.0, -1000.0, 1000.0, 0.1 ); //initial,min,max,step
mCorrectionFrequency = new JSpinner( model );
mCorrectionFrequency.setToolTipText( "Frequency Correction: adjust "
+ "value +/- to align the displayed frequency label with the "
+ "actual signals" );
JSpinner.NumberEditor editor =
(JSpinner.NumberEditor)mCorrectionFrequency.getEditor();
DecimalFormat format = editor.getFormat();
format.setMinimumFractionDigits( 1 );
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
mCorrectionFrequency.setValue( mSelectedConfig.getFrequencyCorrection() );
mCorrectionFrequency.addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
double value = ((SpinnerNumberModel)mCorrectionFrequency
.getModel()).getNumber().doubleValue();
try
{
mSelectedConfig.setFrequencyCorrection( value );
mController.setFrequencyCorrection( value );
save();
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - couldn't "
+ "apply frequency correction value: " + value +
e1.getLocalizedMessage() );
mLog.error( "FuncubeDonglePro Controller - couldn't apply "
+ "frequency correction value: " + value, e1 );
}
}
} );
correctionPanel.add( new JLabel( "Frequency PPM:" ) );
correctionPanel.add( mCorrectionFrequency, "growx,push" );
/**
* Inphase DC Correction
*/
mCorrectionDCI = new CorrectionSpinner( Correction.DC_INPHASE,
mSelectedConfig.getInphaseDCCorrection(), 0.00001, 5 );
mCorrectionDCI.setToolTipText( "DC Bias Correction/Inphase "
+ "Component: valid values are -1.0 to 1.0 (default: 0.0)" );
correctionPanel.add( new JLabel( "DC Inphase:" ) );
correctionPanel.add( mCorrectionDCI, "growx,push" );
/**
* Quadrature DC Correction
*/
mCorrectionDCQ = new CorrectionSpinner( Correction.DC_QUADRATURE,
mSelectedConfig.getQuadratureDCCorrection(), 0.00001, 5 );
mCorrectionDCQ.setToolTipText( "DC Bias Correction/Quadrature "
+ "Component: valid values are -1.0 to 1.0 (default: 0.0)" );
correctionPanel.add( new JLabel( "DC Quadrature:" ) );
correctionPanel.add( mCorrectionDCQ, "growx,push" );
/**
* Gain Correction
*/
mCorrectionGain = new CorrectionSpinner( Correction.GAIN,
mSelectedConfig.getGainCorrection(), 0.00001, 5 );
mCorrectionGain.setToolTipText( "Gain Correction: valid values are "
+ "-1.0 to 1.0 (default: 0.0)" );
correctionPanel.add( new JLabel( "Gain:" ) );
correctionPanel.add( mCorrectionGain, "growx,push" );
/**
* Phase Correction
*/
mCorrectionPhase = new CorrectionSpinner( Correction.PHASE,
mSelectedConfig.getPhaseCorrection(), 0.00001, 5 );
mCorrectionPhase.setToolTipText( "Phase Correction: valid values are "
+ "-1.0 to 1.0 (default: 0.0)" );
correctionPanel.add( new JLabel( "Phase:" ) );
correctionPanel.add( mCorrectionPhase, "growx,push" );
tabs.add( "Correction", correctionPanel );
/**
* Create a new configuration
*/
mNewConfiguration = new JButton( "New" );
mNewConfiguration.setToolTipText( "Create a new tuner configuration "
+ "for each of your dongles to keep track of the specific "
+ "settings for each dongle" );
mNewConfiguration.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
// TunerConfiguration config =
// mSettingsManager.addNewTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO,
// "New Configuration" );
mComboConfigurations.setModel( getModel() );
// mComboConfigurations.setSelectedItem( config );
repaint();
}
} );
add( mNewConfiguration, "growx,push" );
/**
* Delete the currently selected configuration
*/
mDeleteConfiguration = new JButton( "Delete" );
mDeleteConfiguration.setToolTipText( "Deletes the currently selected "
+ "tuner configuration. Note: the DEFAULT tuner "
+ "configuration will be recreated if you delete it, "
+ "after you restart the application" );
mDeleteConfiguration.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
FCD1TunerConfiguration selected =
(FCD1TunerConfiguration)mComboConfigurations
.getItemAt( mComboConfigurations.getSelectedIndex() );
if( selected != null )
{
int n = JOptionPane.showConfirmDialog(
FCD1TunerConfigurationPanel.this,
"Are you sure you want to delete '"
+ selected.getName() + "'?",
"Are you sure?",
JOptionPane.YES_NO_OPTION );
if( n == JOptionPane.YES_OPTION )
{
// mSettingsManager.deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedIndex( 0 );
repaint();
}
}
}
} );
add( mDeleteConfiguration, "growx,push" );
}
private void update( FCD1TunerConfiguration config )
{
mSelectedConfig = config;
try
{
mController.apply( config );
mName.setText( config.getName() );
mComboLNAGain.setSelectedItem( mSelectedConfig.getLNAGain() );
mComboLNAEnhance.setSelectedItem( mSelectedConfig.getLNAEnhance() );
mComboMixerGain.setSelectedItem( mSelectedConfig.getMixerGain() );
mCorrectionFrequency.setValue( config.getFrequencyCorrection() );
mCorrectionDCI.setValue( config.getInphaseDCCorrection() );
mCorrectionDCQ.setValue( config.getQuadratureDCCorrection() );
mCorrectionGain.setValue( config.getGainCorrection() );
mCorrectionPhase.setValue( config.getPhaseCorrection() );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO,
// mController.getUSBAddress(), config );
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - couldn't "
+ "apply the tuner configuration settings - " +
e1.getLocalizedMessage() );
mLog.error( "FuncubeDonglePro Controller - couldn't apply "
+ "config [" + config.getName() + "]", e1 );
}
}
private ComboBoxModel<FCD1TunerConfiguration> getModel()
{
// ArrayList<TunerConfiguration> configs =
// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
DefaultComboBoxModel<FCD1TunerConfiguration> model =
new DefaultComboBoxModel<FCD1TunerConfiguration>();
// for( TunerConfiguration config: configs )
// {
// model.addElement( (FCD1TunerConfiguration)config );
// }
return model;
}
@SuppressWarnings( "unused" )
private FCD1TunerConfiguration getNamedConfiguration( String name )
{
// ArrayList<TunerConfiguration> configs =
// mSettingsManager.getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO );
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (FCD1TunerConfiguration)config;
// }
// }
return null;
}
private void save()
{
// mSettingsManager.save();
}
public enum Correction { GAIN, PHASE, DC_INPHASE, DC_QUADRATURE };
public class CorrectionSpinner extends JSpinner
{
private static final long serialVersionUID = 1L;
private static final double sMIN_VALUE = -1.0d;
private static final double sMAX_VALUE = 1.0d;
private Correction mCorrectionComponent;
public CorrectionSpinner( Correction component,
double initialValue,
double step,
int decimalPlaces )
{
mCorrectionComponent = component;
SpinnerModel model = new SpinnerNumberModel( initialValue,
sMIN_VALUE, sMAX_VALUE, step );
setModel( model );
JSpinner.NumberEditor editor = (JSpinner.NumberEditor)getEditor();
DecimalFormat format = editor.getFormat();
format.setMinimumFractionDigits( decimalPlaces );
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
double value =
((SpinnerNumberModel)getModel()).getNumber().doubleValue();
try
{
switch( mCorrectionComponent )
{
case DC_INPHASE:
mSelectedConfig.setInphaseDCCorrection( value );
mController.setDCCorrectionInPhase( value );
break;
case DC_QUADRATURE:
mSelectedConfig.setQuadratureDCCorrection( value );
mController.setDCCorrectionQuadrature( value );
break;
case GAIN:
mSelectedConfig.setGainCorrection( value );
mController.setGainCorrection( value );
break;
case PHASE:
mSelectedConfig.setPhaseCorrection( value );
mController.setPhaseCorrection( value );
break;
}
//Save the change(s) to the selected tuner config
save();
}
catch ( UsbClaimException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - cannot claim FCD "
+ "Controller to apply "
+ mCorrectionComponent.toString() +
" correction value [" + value + "]" );
mLog.error( "FuncubeDonglePro Controller - usb claim "
+ "exception while applying "
+ mCorrectionComponent.toString()
+ " correction value [" + value + "]", e1 );
}
catch ( UsbException e1 )
{
JOptionPane.showMessageDialog(
FCD1TunerConfigurationPanel.this,
"FCD Pro Tuner Controller - USB error from FCD "
+ "Controller while applying "
+ mCorrectionComponent.toString() +
" correction value [" + value + "]" );
mLog.error( "FuncubeDonglePro Controller - usb "
+ "exception while applying "
+ mCorrectionComponent.toString()
+ " correction value [" + value + "]", e1 );
}
}
} );
}
}
}

View File

@@ -56,7 +56,7 @@ public class FCD1TunerController extends FCDTunerController
private LNAEnhance mLNAEnhance;
private MixerGain mMixerGain;
private FCD1TunerConfiguration mTunerConfiguration;
private FCD1TunerEditorPanel mEditor;
private FCD1TunerEditor mEditor;
public FCD1TunerController( Device device, DeviceDescriptor descriptor )
{

View File

@@ -0,0 +1,528 @@
/*******************************************************************************
* 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.fcd.proV1;
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.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JSeparator;
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 net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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.fcd.FCDTuner;
import source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
import source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
import source.tuner.fcd.proV1.FCD1TunerController.MixerGain;
public class FCD1TunerEditor extends TunerConfigurationEditor
{
private static final long serialVersionUID = 1L;
private final static Logger mLog = LoggerFactory.getLogger( FCD1TunerEditor.class );
private JTextField mConfigurationName;
private JButton mTunerInfo;
private JSpinner mFrequencyCorrection;
private JComboBox<LNAGain> mComboLNAGain;
private JComboBox<LNAEnhance> mComboLNAEnhance;
private JComboBox<MixerGain> mComboMixerGain;
private CorrectionSpinner mCorrectionDCI;
private CorrectionSpinner mCorrectionDCQ;
private CorrectionSpinner mCorrectionGain;
private CorrectionSpinner mCorrectionPhase;
private boolean mLoading;
private FCD1TunerController mController;
public FCD1TunerEditor( TunerConfigurationModel tunerConfigurationModel, FCDTuner tuner )
{
super( tunerConfigurationModel );
mController = (FCD1TunerController)tuner.getController();
init();
}
private FCD1TunerConfiguration getConfiguration()
{
if( hasItem() )
{
return (FCD1TunerConfiguration)getItem();
}
return null;
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 4", "[right][grow,fill][right][grow,fill]",
"[][][][][][][][][][][][grow]" ) );
add( new JLabel( "FCD Pro Tuner Configuration" ), "span,align center" );
mConfigurationName = new JTextField();
mConfigurationName.setEnabled( false );
mConfigurationName.addFocusListener( new FocusListener()
{
@Override
public void focusLost( FocusEvent e )
{
save();
}
@Override
public void focusGained( FocusEvent e ) {}
} );
add( new JLabel( "Name:" ) );
add( mConfigurationName, "span 2" );
mTunerInfo = new JButton( "Tuner Info" );
mTunerInfo.setEnabled( false );
mTunerInfo.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
JOptionPane.showMessageDialog( FCD1TunerEditor.this, getTunerInfo(),
"Tuner Info", JOptionPane.INFORMATION_MESSAGE );
}
} );
add( mTunerInfo );
SpinnerModel model = new SpinnerNumberModel( 0.0, //initial value
-1000.0, //min
1000.0, //max
0.1 ); //step
mFrequencyCorrection = new JSpinner( model );
mFrequencyCorrection.setEnabled( false );
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 )
{
double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
try
{
mController.setFrequencyCorrection( value );
save();
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog( FCD1TunerEditor.this, "FCD Pro Tuner "
+ "Controller - couldn't apply frequency correction value: " + value +
e1.getLocalizedMessage() );
mLog.error( "FuncubeDonglePro Controller - couldn't apply "
+ "frequency correction value: " + value, e1 );
}
}
} );
add( new JLabel( "PPM:" ) );
add( mFrequencyCorrection, "wrap" );
add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
add( new JLabel( "Gain" ), "span,align center" );
mComboLNAGain = new JComboBox<LNAGain>( LNAGain.values() );
mComboLNAGain.setEnabled( false );
mComboLNAGain.setToolTipText( "Adjust the low noise amplifier gain setting." );
mComboLNAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
LNAGain gain = (LNAGain)mComboLNAGain.getSelectedItem();
try
{
mController.setLNAGain( gain );
save();
}
catch ( Exception e )
{
JOptionPane.showMessageDialog( FCD1TunerEditor.this, "FCD Pro Tuner Controller"
+ " - error setting LNA gain [" + gain.toString() + "]" );
mLog.error( "FuncubeDonglePro Controller - error setting gain [" + gain.toString() + "]", e );
}
}
} );
add( new JLabel( "LNA:" ) );
add( mComboLNAGain );
/**
* LNA Enhance
*/
mComboLNAEnhance = new JComboBox<LNAEnhance>( LNAEnhance.values() );
mComboLNAEnhance.setToolTipText( "Adjust the LNA enhance setting. Default value is OFF" );
mComboLNAEnhance.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
LNAEnhance enhance = (LNAEnhance)mComboLNAEnhance.getSelectedItem();
try
{
mController.setLNAEnhance( enhance );
save();
}
catch ( Exception e1 )
{
JOptionPane.showMessageDialog( FCD1TunerEditor.this, "FCD Pro Tuner"
+ " error setting LNA enhance gain [" + enhance.toString() + "]" );
mLog.error( "FCDPro - error setting LNA enhance [" + enhance.toString() + "]", e1 );
}
}
} );
add( new JLabel( "Enhance:" ) );
add( mComboLNAEnhance );
/**
* Mixer Gain
*/
mComboMixerGain = new JComboBox<MixerGain>( MixerGain.values() );
mComboMixerGain.setToolTipText( "Adjust mixer gain setting" );
mComboMixerGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent arg0 )
{
MixerGain gain = (MixerGain)mComboMixerGain.getSelectedItem();
try
{
mController.setMixerGain( gain );
save();
}
catch ( Exception e1 )
{
JOptionPane.showMessageDialog( FCD1TunerEditor.this, "FCDPro - error setting"
+ " mixer gain [" + gain.toString() + "]" );
mLog.error( "FCDPro - error setting mixer gain [" + gain.toString() + "]", e1 );
}
}
} );
add( new JLabel( "Mixer:" ) );
add( mComboMixerGain, "wrap" );
add( new JSeparator( JSeparator.HORIZONTAL ), "span,grow" );
add( new JLabel( "Correction" ), "span,align center" );
/**
* Inphase DC Correction
*/
mCorrectionDCI = new CorrectionSpinner( Correction.DC_INPHASE, 0.0, 0.00001, 5 );
mCorrectionDCI.setEnabled( false );
mCorrectionDCI.setToolTipText( "DC Bias Correction/Inphase "
+ "Component: valid values are -1.0 to 1.0 (default: 0.0)" );
add( new JLabel( "DC Inphase:" ) );
add( mCorrectionDCI );
/**
* Quadrature DC Correction
*/
mCorrectionDCQ = new CorrectionSpinner( Correction.DC_QUADRATURE, 0.0, 0.00001, 5 );
mCorrectionDCQ.setToolTipText( "DC Bias Correction/Quadrature "
+ "Component: valid values are -1.0 to 1.0 (default: 0.0)" );
add( new JLabel( "DC Quadrature:" ) );
add( mCorrectionDCQ );
/**
* Gain Correction
*/
mCorrectionGain = new CorrectionSpinner( Correction.GAIN, 0.0, 0.00001, 5 );
mCorrectionGain.setToolTipText( "Gain Correction: valid values are "
+ "-1.0 to 1.0 (default: 0.0)" );
add( new JLabel( "Gain:" ) );
add( mCorrectionGain );
/**
* Phase Correction
*/
mCorrectionPhase = new CorrectionSpinner( Correction.PHASE, 0.0, 0.00001, 5 );
mCorrectionPhase.setToolTipText( "Phase Correction: valid values are "
+ "-1.0 to 1.0 (default: 0.0)" );
add( new JLabel( "Phase:" ) );
add( mCorrectionPhase );
}
/**
* 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( mTunerInfo.isEnabled() != enabled )
{
mTunerInfo.setEnabled( enabled );
}
if( mFrequencyCorrection.isEnabled() != enabled )
{
mFrequencyCorrection.setEnabled( enabled );
}
if( mComboLNAEnhance.isEnabled() != enabled )
{
mComboLNAEnhance.setEnabled( enabled );
}
if( mComboLNAGain.isEnabled() != enabled )
{
mComboLNAGain.setEnabled( enabled );
}
if( mComboMixerGain.isEnabled() != enabled )
{
mComboMixerGain.setEnabled( enabled );
}
if( mCorrectionDCI.isEnabled() != enabled )
{
mCorrectionDCI.setEnabled( enabled );
}
if( mCorrectionDCQ.isEnabled() != enabled )
{
mCorrectionDCQ.setEnabled( enabled );
}
if( mCorrectionGain.isEnabled() != enabled )
{
mCorrectionGain.setEnabled( enabled );
}
if( mCorrectionPhase.isEnabled() != enabled )
{
mCorrectionPhase.setEnabled( enabled );
}
}
private String getTunerInfo()
{
StringBuilder sb = new StringBuilder();
sb.append( "<html><h3>Funcube Dongle Pro Tuner</h3>" );
sb.append( "<b>USB ID: </b>" );
sb.append( mController.getUSBID() );
sb.append( "<br>" );
sb.append( "<b>USB Address: </b>" );
sb.append( mController.getUSBAddress() );
sb.append( "<br>" );
sb.append( "<b>USB Speed: </b>" );
sb.append( mController.getUSBSpeed() );
sb.append( "<br>" );
sb.append( "<b>Cellular Band: </b>" );
sb.append( mController.getConfiguration().getBandBlocking() );
sb.append( "<br>" );
sb.append( "<b>Firmware: </b>" );
sb.append( mController.getConfiguration().getFirmware() );
sb.append( "<br>" );
return sb.toString();
}
@Override
public void save()
{
if( hasItem() && !mLoading )
{
FCD1TunerConfiguration config = getConfiguration();
config.setName( mConfigurationName.getText() );
double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
config.setFrequencyCorrection( value );
config.setLNAEnhance( (LNAEnhance)mComboLNAEnhance.getSelectedItem() );
config.setLNAGain( (LNAGain)mComboLNAGain.getSelectedItem() );
config.setMixerGain( (MixerGain)mComboMixerGain.getSelectedItem() );
double dci = ((SpinnerNumberModel)mCorrectionDCI.getModel()).getNumber().doubleValue();
config.setInphaseDCCorrection( dci );
double dcq = ((SpinnerNumberModel)mCorrectionDCQ.getModel()).getNumber().doubleValue();
config.setQuadratureDCCorrection( dcq );
double gain = ((SpinnerNumberModel)mCorrectionGain.getModel()).getNumber().doubleValue();
config.setGainCorrection( gain );
double phase = ((SpinnerNumberModel)mCorrectionPhase.getModel()).getNumber().doubleValue();
config.setPhaseCorrection( phase );
getTunerConfigurationModel().broadcast( new TunerConfigurationEvent( getConfiguration(), Event.CHANGE ) );
}
}
@Override
public void setItem( TunerConfiguration tunerConfiguration )
{
super.setItem( tunerConfiguration );
if( hasItem() )
{
FCD1TunerConfiguration config = getConfiguration();
//Toggle loading so that we don't fire a change event and schedule a settings file save
mLoading = true;
if( tunerConfiguration.isAssigned() )
{
setControlsEnabled( true );
mConfigurationName.setText( config.getName() );
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
mComboLNAEnhance.setSelectedItem( config.getLNAEnhance() );
mComboLNAGain.setSelectedItem( config.getLNAGain() );
mComboMixerGain.setSelectedItem( config.getMixerGain() );
mCorrectionDCI.setValue( config.getInphaseDCCorrection() );
mCorrectionDCQ.setValue( config.getQuadratureDCCorrection() );
mCorrectionGain.setValue( config.getGainCorrection() );
mCorrectionPhase.setValue( config.getPhaseCorrection() );
}
else
{
setControlsEnabled( false );
mConfigurationName.setText( config.getName() );
}
mLoading = false;
}
else
{
setControlsEnabled( false );
mConfigurationName.setText( "" );
}
}
public enum Correction { GAIN, PHASE, DC_INPHASE, DC_QUADRATURE };
public class CorrectionSpinner extends JSpinner
{
private static final long serialVersionUID = 1L;
private static final double MIN_VALUE = -1.0d;
private static final double MAX_VALUE = 1.0d;
private Correction mCorrectionComponent;
public CorrectionSpinner( Correction component, double initialValue, double step, int decimalPlaces )
{
mCorrectionComponent = component;
SpinnerModel model = new SpinnerNumberModel( initialValue, MIN_VALUE, MAX_VALUE, step );
setModel( model );
JSpinner.NumberEditor editor = (JSpinner.NumberEditor)getEditor();
DecimalFormat format = editor.getFormat();
format.setMinimumFractionDigits( decimalPlaces );
editor.getTextField().setHorizontalAlignment( SwingConstants.CENTER );
addChangeListener( new ChangeListener()
{
@Override
public void stateChanged( ChangeEvent e )
{
double value =
((SpinnerNumberModel)getModel()).getNumber().doubleValue();
try
{
switch( mCorrectionComponent )
{
case DC_INPHASE:
mController.setDCCorrectionInPhase( value );
break;
case DC_QUADRATURE:
mController.setDCCorrectionQuadrature( value );
break;
case GAIN:
mController.setGainCorrection( value );
break;
case PHASE:
mController.setPhaseCorrection( value );
break;
}
save();
}
catch ( Exception e1 )
{
JOptionPane.showMessageDialog( FCD1TunerEditor.this, "FCDPro - error "
+ "applying " + mCorrectionComponent.toString() + " correction value ["
+ value + "]" );
mLog.error( "FCDPro - error applying "+ mCorrectionComponent.toString()
+ " correction value [" + value + "]", e1 );
}
}
} );
}
}
}

View File

@@ -1,110 +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.fcd.proV1;
import gui.control.JFrequencyControl;
import java.awt.Color;
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.fcd.FCDTuner;
import source.tuner.fcd.FCDTunerDetailsPanel;
import source.tuner.frequency.FrequencyChangeEvent;
import source.tuner.frequency.FrequencyChangeEvent.Event;
import source.tuner.frequency.IFrequencyChangeProcessor;
import com.jidesoft.swing.JideTabbedPane;
public class FCD1TunerEditorPanel extends JPanel implements IFrequencyChangeProcessor
{
private static final long serialVersionUID = 1L;
private final static Logger mLog =
LoggerFactory.getLogger( FCD1TunerEditorPanel.class );
private FCDTuner mTuner;
private FCD1TunerController mController;
private SettingsManager mSettingsManager;
private JFrequencyControl mFrequencyControl;
public FCD1TunerEditorPanel( FCDTuner tuner, SettingsManager settingsManager )
{
mTuner = tuner;
mController = (FCD1TunerController)mTuner.getController();
mSettingsManager = settingsManager;
initGUI();
}
private void initGUI()
{
setLayout( new MigLayout( "fill,wrap 2", "[grow,right][grow]", "[][][grow]" ) );
add( new JLabel( "Funcube Dongle Pro Tuner" ), "span, align center" );
mFrequencyControl = new JFrequencyControl();
mFrequencyControl.addListener( this );
/* Add frequency control as listener to tuner to get frequency changes
* that are invoked elsewhere, to keep the control in sync with the
* frequency */
mTuner.getController().addListener( mFrequencyControl );
mFrequencyControl.setFrequency( mController.getFrequency(), false );
add( mFrequencyControl, "span,align center" );
JideTabbedPane tabs = new JideTabbedPane();
tabs.setFont( this.getFont() );
tabs.setForeground( Color.BLACK );
tabs.add( "Configuration", new FCD1TunerConfigurationPanel(
mSettingsManager, mController ) );
tabs.add( "Info", new FCDTunerDetailsPanel( mController ) );
add( tabs, "span,push,grow" );
}
@Override
public void frequencyChanged( FrequencyChangeEvent event )
{
if( event.getEvent() == Event.NOTIFICATION_FREQUENCY_CHANGE )
{
try
{
mController.setFrequency( event.getValue().longValue() );
}
catch ( SourceException e )
{
mLog.error( "FCTProController - error setting frequency [" +
event.getValue().longValue() + "]", e );
}
}
}
}

View File

@@ -1,376 +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.fcd.proplusV2;
import java.awt.ComponentOrientation;
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.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JCheckBox;
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 net.miginfocom.swing.MigLayout;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import settings.SettingsManager;
import source.SourceException;
public class FCD2TunerConfigurationPanel extends JPanel
{
private final static Logger mLog =
LoggerFactory.getLogger( FCD2TunerConfigurationPanel.class );
private static final long serialVersionUID = 1L;
private SettingsManager mSettingsManager;
private FCD2TunerController mController;
private FCD2TunerConfiguration mSelectedConfig;
private JButton mNewConfiguration;
private JButton mDeleteConfiguration;
private JComboBox<FCD2TunerConfiguration> mComboConfigurations;
private JTextField mName;
private JCheckBox mLNAGain;
private JCheckBox mMixerGain;
private JSpinner mFrequencyCorrection;
public FCD2TunerConfigurationPanel( SettingsManager settingsManager,
FCD2TunerController controller )
{
mSettingsManager = settingsManager;
mController = controller;
init();
}
private void init()
{
setLayout( new MigLayout( "fill,wrap 2", "[right][left]", "[][][][][][grow]" ) );
mComboConfigurations = new JComboBox<FCD2TunerConfiguration>();
mComboConfigurations.setModel( getModel() );
mComboConfigurations.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
FCD2TunerConfiguration selected =
(FCD2TunerConfiguration)mComboConfigurations
.getItemAt( mComboConfigurations.getSelectedIndex() );
if( selected != null )
{
update( selected );
}
}
});
add( new JLabel( "Config:" ) );
add( mComboConfigurations, "growx,push" );
mName = new JTextField();
mName.addFocusListener( new FocusListener()
{
@Override
public void focusLost( FocusEvent e )
{
mSelectedConfig.setName( mName.getText() );
save();
}
@Override
public void focusGained( FocusEvent e ) {}
} );
add( new JLabel( "Name" ) );
add( mName, "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 )
{
double value = ((SpinnerNumberModel)mFrequencyCorrection
.getModel()).getNumber().doubleValue();
try
{
mController.setFrequencyCorrection( value );
mSelectedConfig.setFrequencyCorrection( value );
save();
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
FCD2TunerConfigurationPanel.this,
"FCD Pro Plus Tuner Controller - couldn't "
+ "apply frequency correction value: " + value +
e1.getLocalizedMessage() );
mLog.error( "FuncubeDongleProPlus Controller - couldn't apply "
+ "frequency correction value: " + value, e1 );
}
}
} );
add( new JLabel( "Correction PPM:" ) );
add( mFrequencyCorrection, "growx,push" );
/**
* LNA Gain
*/
mLNAGain = new JCheckBox( "LNA Gain:" );
mLNAGain.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT );
mLNAGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
mSelectedConfig.setGainLNA( mLNAGain.isSelected() );
save();
update( mSelectedConfig );
}
} );
add( mLNAGain );
/**
* Mixer Gain
*/
mMixerGain = new JCheckBox( "Mixer Gain:" );
mMixerGain.setComponentOrientation( ComponentOrientation.RIGHT_TO_LEFT );
mMixerGain.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
mSelectedConfig.setGainMixer( mMixerGain.isSelected() );
save();
update( mSelectedConfig );
}
} );
add( mMixerGain );
/**
* 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() );
// }
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 );
}
mComboConfigurations.setSelectedItem( mSelectedConfig );
/**
* Create a new configuration
*/
mNewConfiguration = new JButton( "New" );
mNewConfiguration.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
// TunerConfiguration config =
// mSettingsManager
// .addNewTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
// "New Configuration" );
mComboConfigurations.setModel( getModel() );
// mComboConfigurations.setSelectedItem( config );
repaint();
}
} );
add( mNewConfiguration, "growx,push" );
/**
* Delete the currently selected configuration
*/
mDeleteConfiguration = new JButton( "Delete" );
mDeleteConfiguration.addActionListener( new ActionListener()
{
@Override
public void actionPerformed( ActionEvent e )
{
FCD2TunerConfiguration selected =
(FCD2TunerConfiguration)mComboConfigurations
.getItemAt( mComboConfigurations.getSelectedIndex() );
if( selected != null )
{
int n = JOptionPane.showConfirmDialog(
FCD2TunerConfigurationPanel.this,
"Are you sure you want to delete '"
+ selected.getName() + "'?",
"Are you sure?",
JOptionPane.YES_NO_OPTION );
if( n == JOptionPane.YES_OPTION )
{
// mSettingsManager
// .deleteTunerConfiguration( selected );
mComboConfigurations.setModel( getModel() );
mComboConfigurations.setSelectedIndex( 0 );
repaint();
}
}
}
} );
add( mDeleteConfiguration, "growx,push" );
}
private void update( FCD2TunerConfiguration config )
{
mSelectedConfig = config;
try
{
mController.apply( config );
mName.setText( config.getName() );
mLNAGain.setSelected( config.getGainLNA() );
mMixerGain.setSelected( config.getGainMixer() );
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
// mSettingsManager.setSelectedTunerConfiguration(
// TunerType.FUNCUBE_DONGLE_PRO_PLUS,
// mController.getUSBAddress(), config );
}
catch ( SourceException e1 )
{
JOptionPane.showMessageDialog(
FCD2TunerConfigurationPanel.this,
"FCD Pro Plus Tuner Controller - couldn't "
+ "apply the tuner configuration settings - " +
e1.getLocalizedMessage() );
mLog.error( "FuncubeDongleProPlus Controller - couldn't apply "
+ "config [" + config.getName() + "]", e1 );
}
}
private ComboBoxModel<FCD2TunerConfiguration> getModel()
{
// ArrayList<TunerConfiguration> configs =
// mSettingsManager
// .getTunerConfigurations( TunerType.FUNCUBE_DONGLE_PRO_PLUS );
DefaultComboBoxModel<FCD2TunerConfiguration> model =
new DefaultComboBoxModel<FCD2TunerConfiguration>();
// 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 );
// for( TunerConfiguration config: configs )
// {
// if( config.getName().contentEquals( name ) )
// {
// return (FCD2TunerConfiguration)config;
// }
// }
return null;
}
private void save()
{
// mSettingsManager.save();
}
}