mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-14 09:37:36 -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:
@@ -119,10 +119,10 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
TunerConfigurationModel tunerConfigurationModel = new TunerConfigurationModel();
|
TunerConfigurationModel tunerConfigurationModel = new TunerConfigurationModel();
|
||||||
TunerModel tunerModel = new TunerModel( tunerConfigurationModel );
|
TunerModel tunerModel = new TunerModel( tunerConfigurationModel );
|
||||||
|
|
||||||
mSettingsManager = new SettingsManager( tunerConfigurationModel );
|
|
||||||
|
|
||||||
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
|
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
|
||||||
|
|
||||||
|
mSettingsManager = new SettingsManager( threadPoolManager, tunerConfigurationModel );
|
||||||
|
|
||||||
AliasModel aliasModel = new AliasModel();
|
AliasModel aliasModel = new AliasModel();
|
||||||
|
|
||||||
ChannelModel channelModel = new ChannelModel();
|
ChannelModel channelModel = new ChannelModel();
|
||||||
|
|||||||
@@ -8,10 +8,15 @@ public class EmptyEditor<T> extends Editor<T>
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public EmptyEditor()
|
public EmptyEditor( String descriptor )
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "insets 0 0 0 0", "[center]", "[grow]" ) );
|
setLayout( new MigLayout( "insets 0 0 0 0", "[center]", "[grow]" ) );
|
||||||
add( new JLabel( "Please select an item" ), "wrap" );
|
add( new JLabel( "Please select " + descriptor ), "wrap" );
|
||||||
|
}
|
||||||
|
|
||||||
|
public EmptyEditor()
|
||||||
|
{
|
||||||
|
this( "an item" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* SDR Trunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2016 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -28,10 +28,8 @@ import map.DefaultIcon;
|
|||||||
import map.MapIcon;
|
import map.MapIcon;
|
||||||
import settings.ColorSetting.ColorSettingName;
|
import settings.ColorSetting.ColorSettingName;
|
||||||
import source.recording.RecordingConfiguration;
|
import source.recording.RecordingConfiguration;
|
||||||
import source.tuner.TunerType;
|
|
||||||
import source.tuner.airspy.AirspyTunerConfiguration;
|
import source.tuner.airspy.AirspyTunerConfiguration;
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
import source.tuner.configuration.TunerConfiguration;
|
||||||
import source.tuner.configuration.TunerConfigurationAssignment;
|
|
||||||
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
|
import source.tuner.fcd.proV1.FCD1TunerConfiguration;
|
||||||
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
|
import source.tuner.fcd.proplusV2.FCD2TunerConfiguration;
|
||||||
import source.tuner.hackrf.HackRFTunerConfiguration;
|
import source.tuner.hackrf.HackRFTunerConfiguration;
|
||||||
@@ -54,8 +52,7 @@ import source.tuner.rtl.r820t.R820TTunerConfiguration;
|
|||||||
R820TTunerConfiguration.class,
|
R820TTunerConfiguration.class,
|
||||||
RecordingConfiguration.class,
|
RecordingConfiguration.class,
|
||||||
Setting.class,
|
Setting.class,
|
||||||
TunerConfiguration.class,
|
TunerConfiguration.class } )
|
||||||
TunerConfigurationAssignment.class} )
|
|
||||||
|
|
||||||
@XmlRootElement( name = "SDRTrunk_settings" )
|
@XmlRootElement( name = "SDRTrunk_settings" )
|
||||||
public class Settings
|
public class Settings
|
||||||
@@ -65,9 +62,6 @@ public class Settings
|
|||||||
private List<TunerConfiguration> mTunerConfiguration =
|
private List<TunerConfiguration> mTunerConfiguration =
|
||||||
new ArrayList<TunerConfiguration>();
|
new ArrayList<TunerConfiguration>();
|
||||||
|
|
||||||
private List<TunerConfigurationAssignment> mConfigurationAssignments =
|
|
||||||
new ArrayList<TunerConfigurationAssignment>();
|
|
||||||
|
|
||||||
private List<RecordingConfiguration> mRecordingConfigurations =
|
private List<RecordingConfiguration> mRecordingConfigurations =
|
||||||
new ArrayList<RecordingConfiguration>();
|
new ArrayList<RecordingConfiguration>();
|
||||||
|
|
||||||
@@ -89,7 +83,6 @@ public class Settings
|
|||||||
public void addRecordingConfiguration( RecordingConfiguration config )
|
public void addRecordingConfiguration( RecordingConfiguration config )
|
||||||
{
|
{
|
||||||
mRecordingConfigurations.add( config );
|
mRecordingConfigurations.add( config );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRecordingConfiguration( RecordingConfiguration config )
|
public void removeRecordingConfiguration( RecordingConfiguration config )
|
||||||
@@ -108,33 +101,6 @@ public class Settings
|
|||||||
mTunerConfiguration = configs;
|
mTunerConfiguration = configs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTunerConfiguration( TunerConfiguration config )
|
|
||||||
{
|
|
||||||
mTunerConfiguration.add( config );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeTunerConfiguration( TunerConfiguration config )
|
|
||||||
{
|
|
||||||
mTunerConfiguration.remove( config );
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArrayList<TunerConfiguration> getTunerConfigurations( TunerType type )
|
|
||||||
{
|
|
||||||
ArrayList<TunerConfiguration> configs =
|
|
||||||
new ArrayList<TunerConfiguration>();
|
|
||||||
|
|
||||||
for( TunerConfiguration config: mTunerConfiguration )
|
|
||||||
{
|
|
||||||
if( config.getTunerType() == type )
|
|
||||||
{
|
|
||||||
configs.add( config );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return configs;
|
|
||||||
}
|
|
||||||
|
|
||||||
@XmlElement( name="setting" )
|
@XmlElement( name="setting" )
|
||||||
public List<Setting> getSettings()
|
public List<Setting> getSettings()
|
||||||
{
|
{
|
||||||
@@ -254,59 +220,6 @@ public class Settings
|
|||||||
return icons;
|
return icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElement( name="tuner_configuration_assignment" )
|
|
||||||
public List<TunerConfigurationAssignment> getSelectedTunerConfiguration()
|
|
||||||
{
|
|
||||||
return mConfigurationAssignments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedTunerConfiguration( List<TunerConfigurationAssignment> configs )
|
|
||||||
{
|
|
||||||
mConfigurationAssignments = configs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSelectedTunerConfiguration( TunerConfigurationAssignment config )
|
|
||||||
{
|
|
||||||
mConfigurationAssignments.add( config );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeSelectedTunerConfiguration( TunerConfigurationAssignment config )
|
|
||||||
{
|
|
||||||
mConfigurationAssignments.remove( config );
|
|
||||||
}
|
|
||||||
|
|
||||||
public TunerConfigurationAssignment getConfigurationAssignment( TunerType type, String uniqueID )
|
|
||||||
{
|
|
||||||
for( TunerConfigurationAssignment config: mConfigurationAssignments )
|
|
||||||
{
|
|
||||||
if( config.getTunerType() == type &&
|
|
||||||
uniqueID.contentEquals( config.getUniqueID() ) )
|
|
||||||
{
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConfigurationAssignment( TunerType type,
|
|
||||||
String uniqueID,
|
|
||||||
String tunerConfigurationName )
|
|
||||||
{
|
|
||||||
TunerConfigurationAssignment config = getConfigurationAssignment( type, uniqueID );
|
|
||||||
|
|
||||||
if( config == null )
|
|
||||||
{
|
|
||||||
config = new TunerConfigurationAssignment();
|
|
||||||
config.setTunerType( type );
|
|
||||||
config.setUniqueID( uniqueID );
|
|
||||||
addSelectedTunerConfiguration( config );
|
|
||||||
}
|
|
||||||
|
|
||||||
config.setTunerConfigurationName( tunerConfigurationName );
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapViewSetting getMapViewSetting( String name )
|
public MapViewSetting getMapViewSetting( String name )
|
||||||
{
|
{
|
||||||
for( Setting setting: mSettings )
|
for( Setting setting: mSettings )
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
@@ -45,6 +47,8 @@ import org.jdesktop.swingx.mapviewer.GeoPosition;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import controller.ThreadPoolManager;
|
||||||
|
import playlist.PlaylistManager.PlaylistSaveTask;
|
||||||
import properties.SystemProperties;
|
import properties.SystemProperties;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.ColorSetting.ColorSettingName;
|
import settings.ColorSetting.ColorSettingName;
|
||||||
@@ -72,14 +76,19 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
new HashMap<String,ImageIcon>();
|
new HashMap<String,ImageIcon>();
|
||||||
|
|
||||||
private TunerConfigurationModel mTunerConfigurationModel;
|
private TunerConfigurationModel mTunerConfigurationModel;
|
||||||
private boolean mLoading = false;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
|
|
||||||
public SettingsManager( TunerConfigurationModel tunerConfigurationModel )
|
private boolean mLoadingSettings = false;
|
||||||
|
private AtomicBoolean mSettingsSavePending = new AtomicBoolean();
|
||||||
|
|
||||||
|
public SettingsManager( ThreadPoolManager threadPoolManager,
|
||||||
|
TunerConfigurationModel tunerConfigurationModel )
|
||||||
{
|
{
|
||||||
//TODO: move settings and icons into a SettingsModel and an IconModel
|
//TODO: move settings and icons into a SettingsModel and an IconModel
|
||||||
//and update this class to only provide loading, saving, and model
|
//and update this class to only provide loading, saving, and model
|
||||||
//change detection producing a save.
|
//change detection producing a save.
|
||||||
|
|
||||||
|
mThreadPoolManager = threadPoolManager;
|
||||||
mTunerConfigurationModel = tunerConfigurationModel;
|
mTunerConfigurationModel = tunerConfigurationModel;
|
||||||
|
|
||||||
//Register for tuner config events so that we can save the settings
|
//Register for tuner config events so that we can save the settings
|
||||||
@@ -112,9 +121,9 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
@Override
|
@Override
|
||||||
public void receive( TunerConfigurationEvent t )
|
public void receive( TunerConfigurationEvent t )
|
||||||
{
|
{
|
||||||
if( !mLoading )
|
if( !mLoadingSettings )
|
||||||
{
|
{
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +205,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
|
|
||||||
broadcastSettingChange( setting );
|
broadcastSettingChange( setting );
|
||||||
|
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetColorSetting( ColorSettingName name )
|
public void resetColorSetting( ColorSettingName name )
|
||||||
@@ -242,7 +251,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
|
|
||||||
broadcastSettingChange( setting );
|
broadcastSettingChange( setting );
|
||||||
|
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapIcon[] getMapIcons()
|
public MapIcon[] getMapIcons()
|
||||||
@@ -339,7 +348,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
|
|
||||||
broadcastSettingDeleted( existing );
|
broadcastSettingDeleted( existing );
|
||||||
|
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +371,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
existing.setName( icon.getName() );
|
existing.setName( icon.getName() );
|
||||||
existing.setPath( icon.getPath() );
|
existing.setPath( icon.getPath() );
|
||||||
broadcastSettingChange( existing );
|
broadcastSettingChange( existing );
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +388,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
existing.setName( newName );
|
existing.setName( newName );
|
||||||
existing.setPath( newPath );
|
existing.setPath( newPath );
|
||||||
broadcastSettingChange( existing );
|
broadcastSettingChange( existing );
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,7 +548,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
|
|
||||||
defaultIconSetting.setName( icon.getName() );
|
defaultIconSetting.setName( icon.getName() );
|
||||||
|
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
|
|
||||||
broadcastSettingChange( defaultIconSetting );
|
broadcastSettingChange( defaultIconSetting );
|
||||||
}
|
}
|
||||||
@@ -553,7 +562,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
{
|
{
|
||||||
mSettings.addSetting( setting );
|
mSettings.addSetting( setting );
|
||||||
|
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
|
|
||||||
broadcastSettingChange( setting );
|
broadcastSettingChange( setting );
|
||||||
}
|
}
|
||||||
@@ -566,13 +575,13 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
public void addRecordingConfiguration( RecordingConfiguration config )
|
public void addRecordingConfiguration( RecordingConfiguration config )
|
||||||
{
|
{
|
||||||
mSettings.addRecordingConfiguration( config );
|
mSettings.addRecordingConfiguration( config );
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeRecordingConfiguration( RecordingConfiguration config )
|
public void removeRecordingConfiguration( RecordingConfiguration config )
|
||||||
{
|
{
|
||||||
mSettings.removeRecordingConfiguration( config );
|
mSettings.removeRecordingConfiguration( config );
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapViewSetting getMapViewSetting( String name, GeoPosition position, int zoom )
|
public MapViewSetting getMapViewSetting( String name, GeoPosition position, int zoom )
|
||||||
@@ -600,11 +609,12 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
loc.setGeoPosition( position );
|
loc.setGeoPosition( position );
|
||||||
loc.setZoom( zoom );
|
loc.setZoom( zoom );
|
||||||
|
|
||||||
save();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
private void save()
|
||||||
{
|
{
|
||||||
|
mLog.debug( "Saving settings" );
|
||||||
saveTunerConfigurationModel();
|
saveTunerConfigurationModel();
|
||||||
|
|
||||||
JAXBContext context = null;
|
JAXBContext context = null;
|
||||||
@@ -685,7 +695,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
*/
|
*/
|
||||||
public void load( Path settingsPath )
|
public void load( Path settingsPath )
|
||||||
{
|
{
|
||||||
mLoading = true;
|
mLoadingSettings = true;
|
||||||
|
|
||||||
if( Files.exists( settingsPath ) )
|
if( Files.exists( settingsPath ) )
|
||||||
{
|
{
|
||||||
@@ -748,7 +758,7 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
|
|
||||||
loadTunerConfigurationModel();
|
loadTunerConfigurationModel();
|
||||||
|
|
||||||
mLoading = false;
|
mLoadingSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadTunerConfigurationModel()
|
private void loadTunerConfigurationModel()
|
||||||
@@ -818,4 +828,35 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
{
|
{
|
||||||
mListeners.remove( listener );
|
mListeners.remove( listener );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedules a settings save task. Subsequent calls to this method will be ignored until the
|
||||||
|
* save event occurs, thus limiting repetitive saving to a minimum.
|
||||||
|
*/
|
||||||
|
private void scheduleSettingsSave()
|
||||||
|
{
|
||||||
|
if( !mLoadingSettings )
|
||||||
|
{
|
||||||
|
if( mSettingsSavePending.compareAndSet( false, true ) )
|
||||||
|
{
|
||||||
|
mThreadPoolManager.scheduleOnce( new SettingsSaveTask(),
|
||||||
|
2, TimeUnit.SECONDS );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the settings save pending flag to false and proceeds to save the
|
||||||
|
* settings.
|
||||||
|
*/
|
||||||
|
public class SettingsSaveTask implements Runnable
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
mSettingsSavePending.set( false );
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class Recording implements Comparable<Recording>,
|
|||||||
public void setAlias( String alias )
|
public void setAlias( String alias )
|
||||||
{
|
{
|
||||||
mConfiguration.setAlias( alias );
|
mConfiguration.setAlias( alias );
|
||||||
mSettingsManager.save();
|
// mSettingsManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRecordingFile( File file ) throws SourceException
|
public void setRecordingFile( File file ) throws SourceException
|
||||||
@@ -51,7 +51,7 @@ public class Recording implements Comparable<Recording>,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mConfiguration.setFilePath( file.getAbsolutePath() );
|
mConfiguration.setFilePath( file.getAbsolutePath() );
|
||||||
mSettingsManager.save();
|
// mSettingsManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +96,7 @@ public class Recording implements Comparable<Recording>,
|
|||||||
|
|
||||||
mConfiguration.setCenterFrequency( frequency );
|
mConfiguration.setCenterFrequency( frequency );
|
||||||
|
|
||||||
mSettingsManager.save();
|
// mSettingsManager.save();
|
||||||
|
|
||||||
mCenterFrequency = frequency;
|
mCenterFrequency = frequency;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import java.awt.event.ActionListener;
|
|||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
@@ -43,8 +44,9 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" );
|
private JLabel mSelectedTunerType = new JLabel( "No Tuner Selected" );
|
||||||
private JButton mNewConfigurationButton = new JButton( "New" );
|
private JButton mNewConfigurationButton = new JButton( "New" );
|
||||||
private JButton mDeleteConfigurationButton = new JButton( "Delete" );
|
private JButton mDeleteConfigurationButton = new JButton( "Delete" );
|
||||||
|
private JButton mAssignConfigurationButton = new JButton( "Assign" );
|
||||||
private JScrollPane mEditorScroller;
|
private JScrollPane mEditorScroller;
|
||||||
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>();
|
private Editor<TunerConfiguration> mEditor = new EmptyEditor<>( "a tuner" );
|
||||||
private JideSplitPane mEditorSplitPane = new JideSplitPane();
|
private JideSplitPane mEditorSplitPane = new JideSplitPane();
|
||||||
|
|
||||||
public TunerEditor( TunerConfigurationModel tunerConfigurationModel )
|
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]" ) );
|
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]" ) );
|
||||||
|
|
||||||
JPanel listPanel = new JPanel();
|
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" );
|
listPanel.add( mSelectedTunerType, "span" );
|
||||||
|
|
||||||
@@ -84,7 +86,7 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
|
|
||||||
if( modelRow >= 0 )
|
if( modelRow >= 0 )
|
||||||
{
|
{
|
||||||
setConfigurationEditor( mTunerConfigurationModel.getTunerConfiguration( modelRow ) );
|
setTunerConfiguration( mTunerConfigurationModel.getTunerConfiguration( modelRow ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,8 +120,39 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
listPanel.add( mNewConfigurationButton );
|
listPanel.add( mNewConfigurationButton );
|
||||||
|
|
||||||
mDeleteConfigurationButton.setEnabled( false );
|
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 );
|
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
|
//Set preferred size on both scrollers to same width, so they split the space
|
||||||
listPanel.setPreferredSize( new Dimension( 100, 80 ) );
|
listPanel.setPreferredSize( new Dimension( 100, 80 ) );
|
||||||
JScrollPane listScroller = new JScrollPane( listPanel );
|
JScrollPane listScroller = new JScrollPane( listPanel );
|
||||||
@@ -135,6 +168,23 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
add( mEditorSplitPane );
|
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
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
@@ -161,8 +211,11 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
mTunerConfigurationTable.setEnabled( true );
|
mTunerConfigurationTable.setEnabled( true );
|
||||||
mNewConfigurationButton.setEnabled( true );
|
mNewConfigurationButton.setEnabled( true );
|
||||||
|
|
||||||
mRowSorter.setRowFilter( new ConfigurationRowFilter(
|
//Change to an editor for this config's tuner type
|
||||||
tuner.getTunerType(), tuner.getUniqueID() ) );
|
mEditor = TunerConfigurationFactory.getEditor( getItem(), mTunerConfigurationModel );
|
||||||
|
|
||||||
|
mRowSorter.setRowFilter( new ConfigurationRowFilter( tuner.getTunerType(),
|
||||||
|
tuner.getUniqueID() ) );
|
||||||
|
|
||||||
TunerConfiguration assigned = mTunerConfigurationModel
|
TunerConfiguration assigned = mTunerConfigurationModel
|
||||||
.getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
|
.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
|
//Set the displayed frequency without adjusting the tuner's frequency
|
||||||
mFrequencyControl.setFrequency(
|
mFrequencyControl.setFrequency(
|
||||||
tuner.getTunerController().getFrequency(), false );
|
tuner.getTunerController().getFrequency(), false );
|
||||||
|
|
||||||
mEditor = TunerConfigurationFactory
|
|
||||||
.getEditor( getItem(), mTunerConfigurationModel );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -212,13 +262,32 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
mEditorSplitPane.setDividerLocation( 0, split );
|
mEditorSplitPane.setDividerLocation( 0, split );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setConfigurationEditor( TunerConfiguration config )
|
private void setTunerConfiguration( TunerConfiguration config )
|
||||||
{
|
{
|
||||||
if( config != null )
|
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
|
else
|
||||||
@@ -227,6 +296,11 @@ public class TunerEditor extends Editor<Tuner>
|
|||||||
{
|
{
|
||||||
mDeleteConfigurationButton.setEnabled( false );
|
mDeleteConfigurationButton.setEnabled( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( mAssignConfigurationButton.isEnabled() )
|
||||||
|
{
|
||||||
|
mAssignConfigurationButton.setEnabled( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mEditor.setItem( config );
|
mEditor.setItem( config );
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public class AirspyTunerConfiguration extends TunerConfiguration
|
|||||||
private int mIFGain = AirspyTunerController.IF_GAIN_DEFAULT;
|
private int mIFGain = AirspyTunerController.IF_GAIN_DEFAULT;
|
||||||
private int mMixerGain = AirspyTunerController.MIXER_GAIN_DEFAULT;
|
private int mMixerGain = AirspyTunerController.MIXER_GAIN_DEFAULT;
|
||||||
private int mLNAGain = AirspyTunerController.LNA_GAIN_DEFAULT;
|
private int mLNAGain = AirspyTunerController.LNA_GAIN_DEFAULT;
|
||||||
|
private double mFrequencyCorrection = 0.0d;
|
||||||
|
|
||||||
private boolean mMixerAGC = false;
|
private boolean mMixerAGC = false;
|
||||||
private boolean mLNAAGC = false;
|
private boolean mLNAAGC = false;
|
||||||
@@ -128,4 +129,16 @@ public class AirspyTunerConfiguration extends TunerConfiguration
|
|||||||
{
|
{
|
||||||
mLNAAGC = enabled;
|
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.ActionListener;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
@@ -47,11 +46,8 @@ import org.usb4java.LibUsbException;
|
|||||||
|
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.TunerType;
|
|
||||||
import source.tuner.airspy.AirspyTunerController.Gain;
|
import source.tuner.airspy.AirspyTunerController.Gain;
|
||||||
import source.tuner.airspy.AirspyTunerController.GainMode;
|
import source.tuner.airspy.AirspyTunerController.GainMode;
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
|
||||||
import source.tuner.configuration.TunerConfigurationAssignment;
|
|
||||||
|
|
||||||
public class AirspyTunerConfigurationPanel extends JPanel
|
public class AirspyTunerConfigurationPanel extends JPanel
|
||||||
{
|
{
|
||||||
@@ -119,7 +115,7 @@ public class AirspyTunerConfigurationPanel extends JPanel
|
|||||||
mComboConfigurations.setModel( getModel() );
|
mComboConfigurations.setModel( getModel() );
|
||||||
|
|
||||||
/* Determine which tuner configuration should be selected/displayed */
|
/* Determine which tuner configuration should be selected/displayed */
|
||||||
TunerConfigurationAssignment savedConfig = null;
|
// TunerConfigurationAssignment savedConfig = null;
|
||||||
String serial = null;
|
String serial = null;
|
||||||
|
|
||||||
serial = mController.getDeviceInfo().getSerialNumber();
|
serial = mController.getDeviceInfo().getSerialNumber();
|
||||||
@@ -130,11 +126,11 @@ public class AirspyTunerConfigurationPanel extends JPanel
|
|||||||
// TunerType.AIRSPY_R820T, serial );
|
// TunerType.AIRSPY_R820T, serial );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( savedConfig != null )
|
// if( savedConfig != null )
|
||||||
{
|
// {
|
||||||
mSelectedConfig = getNamedConfiguration(
|
// mSelectedConfig = getNamedConfiguration(
|
||||||
savedConfig.getTunerConfigurationName() );
|
// savedConfig.getTunerConfigurationName() );
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* If we couldn't determine the saved/selected config, use the first one */
|
/* If we couldn't determine the saved/selected config, use the first one */
|
||||||
if( mSelectedConfig == null )
|
if( mSelectedConfig == null )
|
||||||
@@ -694,6 +690,6 @@ public class AirspyTunerConfigurationPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
private void save()
|
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;
|
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 int ASSIGNED = 2;
|
||||||
private static final String[] COLUMN_HEADERS = { "Tuner Type", "Name", "Assigned" };
|
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<>();
|
private List<TunerConfiguration> mTunerConfigurations = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table model for managing tuner configurations and tuner configuration
|
* Table model for managing tuner configurations. Provides tuner configuration events to
|
||||||
* assignments. Provides tuner configuration events to registered listeners
|
* registered listeners
|
||||||
*/
|
*/
|
||||||
public TunerConfigurationModel()
|
public TunerConfigurationModel()
|
||||||
{
|
{
|
||||||
@@ -115,7 +116,7 @@ public class TunerConfigurationModel extends AbstractTableModel
|
|||||||
*/
|
*/
|
||||||
public void addListener( Listener<TunerConfigurationEvent> listener )
|
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 )
|
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 )
|
public void broadcast( TunerConfigurationEvent event )
|
||||||
{
|
{
|
||||||
for( Listener<TunerConfigurationEvent> listener: mConfigurationListeners )
|
for( Listener<TunerConfigurationEvent> listener: mConfigurationChangeListeners )
|
||||||
{
|
{
|
||||||
listener.receive( event );
|
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
|
* Returns the tuner configuration that is assigned to the tuner with the
|
||||||
* tuner type and uniqueID, or selects the first existing configuration that
|
* tuner type and uniqueID, or selects the first existing configuration that
|
||||||
|
|||||||
@@ -557,7 +557,7 @@ public class FCD1TunerConfigurationPanel extends JPanel
|
|||||||
|
|
||||||
private void save()
|
private void save()
|
||||||
{
|
{
|
||||||
mSettingsManager.save();
|
// mSettingsManager.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Correction { GAIN, PHASE, DC_INPHASE, DC_QUADRATURE };
|
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.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
@@ -48,9 +47,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceException;
|
import source.SourceException;
|
||||||
import source.tuner.TunerType;
|
|
||||||
import source.tuner.configuration.TunerConfiguration;
|
|
||||||
import source.tuner.configuration.TunerConfigurationAssignment;
|
|
||||||
|
|
||||||
public class FCD2TunerConfigurationPanel extends JPanel
|
public class FCD2TunerConfigurationPanel extends JPanel
|
||||||
{
|
{
|
||||||
@@ -375,6 +371,6 @@ public class FCD2TunerConfigurationPanel extends JPanel
|
|||||||
|
|
||||||
private void save()
|
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.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
@@ -50,9 +49,6 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceException;
|
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.HackRFLNAGain;
|
||||||
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
|
import source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
|
||||||
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
|
import source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
|
||||||
@@ -105,7 +101,7 @@ public class HackRFTunerConfigurationPanel extends JPanel
|
|||||||
mComboConfigurations.setModel( getModel() );
|
mComboConfigurations.setModel( getModel() );
|
||||||
|
|
||||||
/* Determine which tuner configuration should be selected/displayed */
|
/* Determine which tuner configuration should be selected/displayed */
|
||||||
TunerConfigurationAssignment savedConfig = null;
|
// TunerConfigurationAssignment savedConfig = null;
|
||||||
String serial = null;
|
String serial = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -122,12 +118,12 @@ public class HackRFTunerConfigurationPanel extends JPanel
|
|||||||
// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
|
// savedConfig = mSettingsManager.getSelectedTunerConfiguration(
|
||||||
// TunerType.HACKRF, serial );
|
// TunerType.HACKRF, serial );
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
if( savedConfig != null )
|
// if( savedConfig != null )
|
||||||
{
|
// {
|
||||||
mSelectedConfig = getNamedConfiguration(
|
// mSelectedConfig = getNamedConfiguration(
|
||||||
savedConfig.getTunerConfigurationName() );
|
// savedConfig.getTunerConfigurationName() );
|
||||||
}
|
// }
|
||||||
|
|
||||||
/* If we couldn't determine the saved/selected config, use the first one */
|
/* If we couldn't determine the saved/selected config, use the first one */
|
||||||
if( mSelectedConfig == null )
|
if( mSelectedConfig == null )
|
||||||
@@ -556,6 +552,6 @@ public class HackRFTunerConfigurationPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
private void save()
|
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.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
@@ -50,9 +49,6 @@ import org.usb4java.LibUsbException;
|
|||||||
|
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceException;
|
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.RTL2832TunerController.SampleRate;
|
||||||
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
|
import source.tuner.rtl.e4k.E4KTunerController.E4KEnhanceGain;
|
||||||
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;
|
import source.tuner.rtl.e4k.E4KTunerController.E4KGain;
|
||||||
@@ -686,6 +682,6 @@ public class E4KTunerConfigurationPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
private void save()
|
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.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
@@ -50,9 +49,6 @@ import org.usb4java.LibUsbException;
|
|||||||
|
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceException;
|
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.RTL2832TunerController.SampleRate;
|
||||||
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
|
import source.tuner.rtl.r820t.R820TTunerController.R820TGain;
|
||||||
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
|
import source.tuner.rtl.r820t.R820TTunerController.R820TLNAGain;
|
||||||
@@ -694,6 +690,6 @@ public class R820TTunerConfigurationEditorOld extends JPanel
|
|||||||
*/
|
*/
|
||||||
private void save()
|
private void save()
|
||||||
{
|
{
|
||||||
mSettingsManager.save();
|
// mSettingsManager.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,18 +17,15 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package source.tuner.rtl.r820t;
|
package source.tuner.rtl.r820t;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.FocusEvent;
|
import java.awt.event.FocusEvent;
|
||||||
import java.awt.event.FocusListener;
|
import java.awt.event.FocusListener;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
@@ -76,6 +73,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
private JComboBox<R820TLNAGain> mComboLNAGain;
|
private JComboBox<R820TLNAGain> mComboLNAGain;
|
||||||
private JComboBox<R820TVGAGain> mComboVGAGain;
|
private JComboBox<R820TVGAGain> mComboVGAGain;
|
||||||
private JComboBox<SampleRate> mComboSampleRate;
|
private JComboBox<SampleRate> mComboSampleRate;
|
||||||
|
private boolean mLoading;
|
||||||
|
|
||||||
public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel,
|
public R820TTunerEditor( TunerConfigurationModel tunerConfigurationModel,
|
||||||
RTL2832Tuner tuner )
|
RTL2832Tuner tuner )
|
||||||
@@ -95,7 +93,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if( hasItem() )
|
if( hasItem() && !mLoading )
|
||||||
{
|
{
|
||||||
R820TTunerConfiguration config = getConfiguration();
|
R820TTunerConfiguration config = getConfiguration();
|
||||||
|
|
||||||
@@ -133,14 +131,73 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
{
|
{
|
||||||
R820TTunerConfiguration config = getConfiguration();
|
R820TTunerConfiguration config = getConfiguration();
|
||||||
|
|
||||||
mConfigurationName.setText( config.getName() );
|
//Toggle loading so that we don't fire a change event and schedule a settings file save
|
||||||
mFrequencyCorrection.setValue( config.getFrequencyCorrection() );
|
mLoading = true;
|
||||||
mComboSampleRate.setSelectedItem( config.getSampleRate() );
|
|
||||||
mComboMasterGain.setSelectedItem( config.getMasterGain() );
|
if( item.isAssigned() )
|
||||||
mComboMixerGain.setSelectedItem( config.getMixerGain() );
|
{
|
||||||
mComboLNAGain.setSelectedItem( config.getLNAGain() );
|
setControlsEnabled( true );
|
||||||
mComboVGAGain.setSelectedItem( config.getVGAGain() );
|
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()
|
private R820TTunerConfiguration getConfiguration()
|
||||||
@@ -164,6 +221,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
* Tuner Configuration Name
|
* Tuner Configuration Name
|
||||||
*/
|
*/
|
||||||
mConfigurationName = new JTextField();
|
mConfigurationName = new JTextField();
|
||||||
|
mConfigurationName.setEnabled( false );
|
||||||
mConfigurationName.addFocusListener( new FocusListener()
|
mConfigurationName.addFocusListener( new FocusListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -179,6 +237,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
add( mConfigurationName, "span,grow" );
|
add( mConfigurationName, "span,grow" );
|
||||||
|
|
||||||
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
mComboSampleRate = new JComboBox<>( SampleRate.values() );
|
||||||
|
mComboSampleRate.setEnabled( false );
|
||||||
mComboSampleRate.addActionListener( new ActionListener()
|
mComboSampleRate.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -219,6 +278,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
0.1 ); //step
|
0.1 ); //step
|
||||||
|
|
||||||
mFrequencyCorrection = new JSpinner( model );
|
mFrequencyCorrection = new JSpinner( model );
|
||||||
|
mFrequencyCorrection.setEnabled( false );
|
||||||
|
|
||||||
JSpinner.NumberEditor editor =
|
JSpinner.NumberEditor editor =
|
||||||
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
(JSpinner.NumberEditor)mFrequencyCorrection.getEditor();
|
||||||
@@ -258,7 +318,7 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
*/
|
*/
|
||||||
/* Master Gain Control */
|
/* Master Gain Control */
|
||||||
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
mComboMasterGain = new JComboBox<R820TGain>( R820TGain.values() );
|
||||||
|
mComboMasterGain.setEnabled( false );
|
||||||
mComboMasterGain.addActionListener( new ActionListener()
|
mComboMasterGain.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -317,54 +377,49 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
|
|
||||||
/* Mixer Gain Control */
|
/* Mixer Gain Control */
|
||||||
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
|
mComboMixerGain = new JComboBox<R820TMixerGain>( R820TMixerGain.values() );
|
||||||
|
mComboMixerGain.setEnabled( false );
|
||||||
mComboMixerGain.addActionListener( new ActionListener()
|
mComboMixerGain.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed( ActionEvent arg0 )
|
public void actionPerformed( ActionEvent arg0 )
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater( new Runnable()
|
try
|
||||||
{
|
{
|
||||||
@Override
|
R820TMixerGain mixerGain =
|
||||||
public void run()
|
(R820TMixerGain)mComboMixerGain.getSelectedItem();
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
R820TMixerGain mixerGain =
|
|
||||||
(R820TMixerGain)mComboMixerGain.getSelectedItem();
|
|
||||||
|
|
||||||
if( mixerGain == null )
|
if( mixerGain == null )
|
||||||
{
|
{
|
||||||
mixerGain = DEFAULT_GAIN.getMixerGain();
|
mixerGain = DEFAULT_GAIN.getMixerGain();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( mComboMixerGain.isEnabled() )
|
if( mComboMixerGain.isEnabled() )
|
||||||
{
|
{
|
||||||
mController.setMixerGain( mixerGain, true );
|
mController.setMixerGain( mixerGain, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
catch ( UsbException e )
|
catch ( UsbException e )
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog( R820TTunerEditor.this,
|
JOptionPane.showMessageDialog( R820TTunerEditor.this,
|
||||||
"R820T Tuner Controller - couldn't apply the mixer "
|
"R820T Tuner Controller - couldn't apply the mixer "
|
||||||
+ "gain setting - " + e.getLocalizedMessage() );
|
+ "gain setting - " + e.getLocalizedMessage() );
|
||||||
|
|
||||||
mLog.error( "R820T Tuner Controller - couldn't apply mixer "
|
mLog.error( "R820T Tuner Controller - couldn't apply mixer "
|
||||||
+ "gain setting - ", e );
|
+ "gain setting - ", e );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
|
mComboMixerGain.setToolTipText( "<html>Mixer Gain. Set master gain "
|
||||||
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
+ "to <b>MASTER</b> to enable adjustment</html>" );
|
||||||
mComboMixerGain.setEnabled( false );
|
|
||||||
add( new JLabel( "Mixer:" ) );
|
add( new JLabel( "Mixer:" ) );
|
||||||
add( mComboMixerGain );
|
add( mComboMixerGain );
|
||||||
|
|
||||||
/* LNA Gain Control */
|
/* LNA Gain Control */
|
||||||
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
|
mComboLNAGain = new JComboBox<R820TLNAGain>( R820TLNAGain.values() );
|
||||||
|
mComboLNAGain.setEnabled( false );
|
||||||
mComboLNAGain.addActionListener( new ActionListener()
|
mComboLNAGain.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -400,12 +455,13 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
} );
|
} );
|
||||||
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
|
mComboLNAGain.setToolTipText( "<html>LNA Gain. Set master gain "
|
||||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
||||||
mComboLNAGain.setEnabled( false );
|
|
||||||
add( new JLabel( "LNA:" ) );
|
add( new JLabel( "LNA:" ) );
|
||||||
add( mComboLNAGain );
|
add( mComboLNAGain );
|
||||||
|
|
||||||
/* VGA Gain Control */
|
/* VGA Gain Control */
|
||||||
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
|
mComboVGAGain = new JComboBox<R820TVGAGain>( R820TVGAGain.values() );
|
||||||
|
mComboVGAGain.setEnabled( false );
|
||||||
mComboVGAGain.addActionListener( new ActionListener()
|
mComboVGAGain.addActionListener( new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -441,7 +497,6 @@ public class R820TTunerEditor extends TunerConfigurationEditor
|
|||||||
} );
|
} );
|
||||||
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
|
mComboVGAGain.setToolTipText( "<html>VGA Gain. Set master gain "
|
||||||
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
+ "to <b>MANUAL</b> to enable adjustment</html>" );
|
||||||
mComboVGAGain.setEnabled( false );
|
|
||||||
add( new JLabel( "VGA:" ) );
|
add( new JLabel( "VGA:" ) );
|
||||||
add( mComboVGAGain );
|
add( mComboVGAGain );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user