Resolves #64 Persist last tuned frequency to tuner configurations

Task-Url: http://github.com/DSheirer/sdrtrunk/issues/issue/64
This commit is contained in:
denny
2016-04-05 19:30:09 -04:00
parent 5672182609
commit 3231e9828b
9 changed files with 85 additions and 1 deletions

View File

@@ -179,6 +179,7 @@ public class TunerModel extends AbstractTableModel implements Listener<TunerEven
break; break;
case FREQUENCY: case FREQUENCY:
fireTableCellUpdated( index, FREQUENCY ); fireTableCellUpdated( index, FREQUENCY );
mTunerConfigurationModel.tunerFrequencyChanged( event.getTuner() );
break; break;
case SAMPLE_RATE: case SAMPLE_RATE:
fireTableCellUpdated( index, SAMPLE_RATE ); fireTableCellUpdated( index, SAMPLE_RATE );

View File

@@ -36,7 +36,7 @@ import dsp.filter.hilbert.HilbertTransform;
/** /**
* SDR Trunk * SDR Trunk
* Copyright (C) 2015 Dennis Sheirer * Copyright (C) 2015-2016 Dennis Sheirer
* *
* Ported from libairspy at: * Ported from libairspy at:
* https://github.com/airspy/host/tree/master/libairspy * https://github.com/airspy/host/tree/master/libairspy
@@ -324,6 +324,8 @@ public class AirspyTunerController extends TunerController
//linearity and sensitivity modes will automatically override //linearity and sensitivity modes will automatically override
//the custom values. //the custom values.
setGain( airspy.getGain() ); setGain( airspy.getGain() );
setFrequencyCorrection( airspy.getFrequencyCorrection() );
} }
catch( Exception e ) catch( Exception e )
{ {
@@ -331,6 +333,15 @@ public class AirspyTunerController extends TunerController
+ "airspy config", e ); + "airspy config", e );
} }
try
{
setFrequency( airspy.getFrequency() );
}
catch( SourceException se )
{
//Do nothing, we couldn't set the frequency
}
} }
else else
{ {

View File

@@ -31,6 +31,7 @@ public abstract class TunerConfiguration
protected String mName; protected String mName;
protected String mUniqueID; protected String mUniqueID;
protected boolean mAssigned; protected boolean mAssigned;
protected long mFrequency;
/** /**
* Default constructor to support JAXB * Default constructor to support JAXB
@@ -86,6 +87,17 @@ public abstract class TunerConfiguration
mAssigned = assigned; mAssigned = assigned;
} }
@XmlAttribute( name = "frequency" )
public long getFrequency()
{
return mFrequency;
}
public void setFrequency( long frequency )
{
mFrequency = frequency;
}
@XmlAttribute( name = "tuner_type" ) @XmlAttribute( name = "tuner_type" )
public abstract TunerType getTunerType(); public abstract TunerType getTunerType();
} }

View File

@@ -27,6 +27,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import sample.Listener; import sample.Listener;
import source.tuner.Tuner;
import source.tuner.TunerType; import source.tuner.TunerType;
import source.tuner.configuration.TunerConfigurationEvent.Event; import source.tuner.configuration.TunerConfigurationEvent.Event;
@@ -368,4 +369,16 @@ public class TunerConfigurationModel extends AbstractTableModel
return null; return null;
} }
/**
* Stores the latest tuned frequency for the tuner in the currently assigned configuration
*/
public void tunerFrequencyChanged( Tuner tuner )
{
TunerConfiguration assigned = getTunerConfiguration( tuner.getTunerType(), tuner.getUniqueID() );
assigned.setFrequency( tuner.getTunerController().getFrequency() );
broadcast( new TunerConfigurationEvent( assigned, Event.CHANGE ) );
}
} }

View File

@@ -144,6 +144,15 @@ public class FCD1TunerController extends FCDTunerController
+ "exception while applying tuner config - " + + "exception while applying tuner config - " +
e.getLocalizedMessage() ); e.getLocalizedMessage() );
} }
try
{
setFrequency( config.getFrequency() );
}
catch( SourceException se )
{
//Do nothing, we couldn't set the frequency
}
} }
/** /**

View File

@@ -113,8 +113,18 @@ public class FCD2TunerController extends FCDTunerController
FCD2TunerConfiguration fcd2 = (FCD2TunerConfiguration)config; FCD2TunerConfiguration fcd2 = (FCD2TunerConfiguration)config;
setFrequencyCorrection( fcd2.getFrequencyCorrection() ); setFrequencyCorrection( fcd2.getFrequencyCorrection() );
setFrequency( fcd2.getFrequency() );
setLNAGain( fcd2.getGainLNA() ); setLNAGain( fcd2.getGainLNA() );
setMixerGain( fcd2.getGainMixer() ); setMixerGain( fcd2.getGainMixer() );
try
{
setFrequency( fcd2.getFrequency() );
}
catch( SourceException se )
{
//Do nothing, we couldn't set the frequency
}
} }
} }

View File

@@ -372,6 +372,15 @@ public class HackRFTunerController extends TunerController
throw new SourceException( "Error while applying tuner " throw new SourceException( "Error while applying tuner "
+ "configuration", e ); + "configuration", e );
} }
try
{
setFrequency( hackRFConfig.getFrequency() );
}
catch( SourceException se )
{
//Do nothing, we couldn't set the frequency
}
} }
else else
{ {

View File

@@ -152,12 +152,22 @@ public class E4KTunerController extends RTL2832TunerController
E4KEnhanceGain enhanceGain = e4kConfig.getEnhanceGain(); E4KEnhanceGain enhanceGain = e4kConfig.getEnhanceGain();
setEnhanceGain( enhanceGain, true ); setEnhanceGain( enhanceGain, true );
} }
try
{
setFrequency( e4kConfig.getFrequency() );
}
catch( SourceException se )
{
//Do nothing, we couldn't set the frequency
}
} }
catch( UsbException e ) catch( UsbException e )
{ {
throw new SourceException( "E4KTunerController - usb error " throw new SourceException( "E4KTunerController - usb error "
+ "while applying tuner config", e ); + "while applying tuner config", e );
} }
} }
else else
{ {

View File

@@ -126,6 +126,15 @@ public class R820TTunerController extends RTL2832TunerController
R820TVGAGain vgaGain = config.getVGAGain(); R820TVGAGain vgaGain = config.getVGAGain();
setVGAGain( vgaGain, true ); setVGAGain( vgaGain, true );
} }
try
{
setFrequency( config.getFrequency() );
}
catch( SourceException se )
{
//Do nothing, we couldn't set the frequency
}
} }
catch( UsbException e ) catch( UsbException e )
{ {