Resolves #170 adding support for Airspy Mini tuner's 3 and 6 MHz

sample rates.

Resolves issue in PolyphaseChannelManager responding to sample rate
changes in the tuner.  The manager now recreates the channelizer when
needed if the tuner's sample rate has changed since the last time the
channelizer was used.

Updates the Tuner selection view to reflect tuner lock state.  Updates
the tuner editors to enable/disable frequency controller and sample
rate controls according to the tuner's lock state.
This commit is contained in:
Denny
2018-07-14 07:45:42 -04:00
parent 9e7fa7618d
commit 104c4f72be
18 changed files with 376 additions and 348 deletions

View File

@@ -80,8 +80,7 @@ public class AirspyTunerController extends USBTunerController
public static final long FREQUENCY_MAX = 1800000000l;
public static final long FREQUENCY_DEFAULT = 101100000;
public static final double USABLE_BANDWIDTH_PERCENT = 0.90;
public static final AirspySampleRate DEFAULT_SAMPLE_RATE =
new AirspySampleRate(0, 10000000, "10.00 MHz");
public static final AirspySampleRate DEFAULT_SAMPLE_RATE = new AirspySampleRate(0, 10000000, "10.00 MHz");
private static final long USB_TIMEOUT_MS = 2000l; //milliseconds
private static final byte USB_INTERFACE = (byte) 0x0;
@@ -168,7 +167,7 @@ public class AirspyTunerController extends USBTunerController
try
{
setSampleRate(DEFAULT_SAMPLE_RATE);
setSampleRate(mSampleRates.get(0));
}
catch(IllegalArgumentException | LibUsbException | UsbException e)
{
@@ -292,8 +291,7 @@ public class AirspyTunerController extends USBTunerController
}
catch(UsbException e)
{
throw new SourceException("Couldn't set sample rate [" +
rate.toString() + "]", e);
throw new SourceException("Couldn't set sample rate [" + rate.toString() + "]", e);
}
try
@@ -314,8 +312,7 @@ public class AirspyTunerController extends USBTunerController
}
catch(Exception e)
{
throw new SourceException("Couldn't apply gain settings from "
+ "airspy config", e);
throw new SourceException("Couldn't apply gain settings from airspy config", e);
}
try
@@ -389,8 +386,7 @@ public class AirspyTunerController extends USBTunerController
* is not supported by the current firmware
* @throws UsbException if there was a USB error
*/
public void setSampleRate(AirspySampleRate rate) throws
LibUsbException, UsbException, SourceException
public void setSampleRate(AirspySampleRate rate) throws LibUsbException, UsbException, SourceException
{
if(rate.getRate() != mSampleRate)
{
@@ -398,8 +394,7 @@ public class AirspyTunerController extends USBTunerController
if(result != 1)
{
throw new UsbException("Error setting sample rate [" +
rate + "] rate - return value [" + result + "]");
throw new UsbException("Error setting sample rate [" + rate + "] rate - return value [" + result + "]");
}
else
{
@@ -607,8 +602,7 @@ public class AirspyTunerController extends USBTunerController
* Queries the device for available sample rates. Will always provide at
* least the default 10 MHz sample rate.
*/
private void determineAvailableSampleRates()
throws LibUsbException, UsbException
private void determineAvailableSampleRates() throws LibUsbException, UsbException
{
mSampleRates.clear();
@@ -629,7 +623,6 @@ public class AirspyTunerController extends USBTunerController
for(int x = 0; x < count; x++)
{
int rate = EndianUtils.readSwappedInteger(rawRates, (x * 4));
mSampleRates.add(new AirspySampleRate(x, rate, formatSampleRate(rate)));
}
}

View File

@@ -43,7 +43,6 @@ import javax.swing.SwingConstants;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.usb.UsbException;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
@@ -55,8 +54,7 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
{
private static final long serialVersionUID = 1L;
private final static Logger mLog =
LoggerFactory.getLogger(AirspyTunerEditor.class);
private final static Logger mLog = LoggerFactory.getLogger(AirspyTunerEditor.class);
private JTextField mConfigurationName;
private JButton mTunerInfo;
@@ -103,24 +101,6 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
return null;
}
/**
* Updates the enabled state of the sample rate combo control.
*
* @param enabled state for the sample rate control
*/
@Override
public void setSampleRateControl(boolean enabled)
{
EventQueue.invokeLater(new Runnable()
{
@Override
public void run()
{
mSampleRateCombo.setEnabled(enabled);
}
});
}
private void init()
{
setLayout(new MigLayout("fill,wrap 4", "[right][grow,fill][right][grow,fill]",
@@ -616,6 +596,21 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
return null;
}
/**
* Updates the sample rate tooltip according to the tuner controller's lock state.
*/
private void updateSampleRateToolTip()
{
if(mController.isLocked())
{
mSampleRateCombo.setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
}
else
{
mSampleRateCombo.setToolTipText("Select a sample rate for the tuner");
}
}
/**
* Sets all controls to the argument enabled state
*/
@@ -631,7 +626,13 @@ public class AirspyTunerEditor extends TunerConfigurationEditor
mTunerInfo.setEnabled(enabled);
}
if(mSampleRateCombo.isEnabled() != enabled)
updateSampleRateToolTip();
if(mController.isLocked())
{
mSampleRateCombo.setEnabled(false);
}
else if(mSampleRateCombo.isEnabled() != enabled)
{
mSampleRateCombo.setEnabled(enabled);
}