mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-20 04:27:48 -05:00
Compare commits
1 Commits
master
...
2717-tuner
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
463a805890 |
@@ -0,0 +1,678 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.gui.control;
|
||||||
|
|
||||||
|
import io.github.dsheirer.source.ISourceEventProcessor;
|
||||||
|
import io.github.dsheirer.source.SourceEvent;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
import java.util.function.LongConsumer;
|
||||||
|
import javafx.animation.KeyFrame;
|
||||||
|
import javafx.animation.PauseTransition;
|
||||||
|
import javafx.animation.Timeline;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.css.PseudoClass;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.AccessibleRole;
|
||||||
|
import javafx.scene.control.ContextMenu;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.MenuItem;
|
||||||
|
import javafx.scene.control.SeparatorMenuItem;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.scene.input.Clipboard;
|
||||||
|
import javafx.scene.input.ClipboardContent;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.KeyCombination;
|
||||||
|
import javafx.scene.input.KeyEvent;
|
||||||
|
import javafx.scene.input.MouseButton;
|
||||||
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.input.ScrollEvent;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
|
import javafx.util.Duration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frequency display and tuning control that shows a frequency in MHz with six fractional digits (1 Hz).
|
||||||
|
*
|
||||||
|
* Mouse: hover over a digit to reveal its up/down halves. Click the upper half to increment the digit or the lower
|
||||||
|
* half to decrement it (hold the button to repeat), or use the scroll wheel over the digit. Steps carry into the
|
||||||
|
* higher digits and stop at the minimum/maximum frequency.
|
||||||
|
*
|
||||||
|
* Keyboard: left/right move the digit cursor, up/down (or +/-) step the digit under the cursor. Typing digits
|
||||||
|
* starts a calculator style entry (e.g. 851.0125) that is applied with Enter and cancelled with Escape. Shortcut-C
|
||||||
|
* and Shortcut-V copy and paste the frequency.
|
||||||
|
*
|
||||||
|
* The control only reports user requested frequencies to the listeners. {@link #setFrequency(long)} updates the
|
||||||
|
* display without notifying them, which is how the tuner reports its actual frequency back to the control.
|
||||||
|
*/
|
||||||
|
public class FrequencyControl extends HBox implements ISourceEventProcessor
|
||||||
|
{
|
||||||
|
private static final PseudoClass HOVER_UP = PseudoClass.getPseudoClass("hover-up");
|
||||||
|
private static final PseudoClass HOVER_DOWN = PseudoClass.getPseudoClass("hover-down");
|
||||||
|
private static final PseudoClass LEADING = PseudoClass.getPseudoClass("leading");
|
||||||
|
private static final PseudoClass CURSOR = PseudoClass.getPseudoClass("cursor");
|
||||||
|
private static final PseudoClass ENTRY = PseudoClass.getPseudoClass("entry");
|
||||||
|
private static final PseudoClass TYPED = PseudoClass.getPseudoClass("typed");
|
||||||
|
private static final PseudoClass INVALID = PseudoClass.getPseudoClass("invalid");
|
||||||
|
private static final Duration REPEAT_DELAY = Duration.millis(400);
|
||||||
|
private static final Duration REPEAT_INTERVAL = Duration.millis(70);
|
||||||
|
|
||||||
|
private final List<LongConsumer> mListeners = new CopyOnWriteArrayList<>();
|
||||||
|
private final Digit[] mDigits = new Digit[FrequencyEntry.DIGIT_COUNT];
|
||||||
|
private final FrequencyEntry.TypedEntry mTypedEntry = new FrequencyEntry.TypedEntry();
|
||||||
|
private final Text mProbe = new Text("0");
|
||||||
|
private final Label mUnitLabel = new Label("MHz");
|
||||||
|
private final Tooltip mTooltip = new Tooltip();
|
||||||
|
private final PauseTransition mInvalidFlash = new PauseTransition(Duration.millis(1200));
|
||||||
|
private final Timeline mRepeat = new Timeline();
|
||||||
|
private long mFrequency;
|
||||||
|
private long mMinimum = 1;
|
||||||
|
private long mMaximum = FrequencyEntry.MAXIMUM_DISPLAYABLE;
|
||||||
|
private int mCursorPosition = FrequencyEntry.FRACTION_DIGITS;
|
||||||
|
private double mScrollAccumulator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance
|
||||||
|
*/
|
||||||
|
public FrequencyControl()
|
||||||
|
{
|
||||||
|
getStyleClass().add("frequency-control");
|
||||||
|
URL stylesheet = FrequencyControl.class.getResource("/frequency_control.css");
|
||||||
|
|
||||||
|
if(stylesheet != null)
|
||||||
|
{
|
||||||
|
getStylesheets().add(stylesheet.toExternalForm());
|
||||||
|
}
|
||||||
|
|
||||||
|
setAlignment(Pos.CENTER_LEFT);
|
||||||
|
setFocusTraversable(true);
|
||||||
|
setAccessibleRole(AccessibleRole.SPINNER);
|
||||||
|
setMaxWidth(Region.USE_PREF_SIZE);
|
||||||
|
|
||||||
|
//Invisible probe text, styled like the digits, sizes every digit cell to the same width so that a
|
||||||
|
//proportional font doesn't make the display jitter as the digits change.
|
||||||
|
mProbe.getStyleClass().add("frequency-digit-text");
|
||||||
|
mProbe.setManaged(false);
|
||||||
|
mProbe.setVisible(false);
|
||||||
|
getChildren().add(mProbe);
|
||||||
|
|
||||||
|
for(int position = FrequencyEntry.DIGIT_COUNT - 1; position >= 0; position--)
|
||||||
|
{
|
||||||
|
Digit digit = new Digit(position);
|
||||||
|
mDigits[position] = digit;
|
||||||
|
getChildren().add(digit);
|
||||||
|
|
||||||
|
if(position == FrequencyEntry.FRACTION_DIGITS)
|
||||||
|
{
|
||||||
|
Text point = new Text(".");
|
||||||
|
point.getStyleClass().addAll("frequency-digit-text", "frequency-point");
|
||||||
|
getChildren().add(point);
|
||||||
|
}
|
||||||
|
else if(position % 3 == 0 && position > 0)
|
||||||
|
{
|
||||||
|
Region gap = new Region();
|
||||||
|
gap.getStyleClass().add("frequency-group-gap");
|
||||||
|
getChildren().add(gap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mUnitLabel.getStyleClass().add("frequency-unit");
|
||||||
|
getChildren().add(mUnitLabel);
|
||||||
|
|
||||||
|
Tooltip.install(this, mTooltip);
|
||||||
|
updateTooltip();
|
||||||
|
|
||||||
|
mInvalidFlash.setOnFinished(e -> pseudoClassStateChanged(INVALID, false));
|
||||||
|
mRepeat.setCycleCount(Timeline.INDEFINITE);
|
||||||
|
|
||||||
|
addEventHandler(KeyEvent.KEY_PRESSED, this::keyPressed);
|
||||||
|
addEventHandler(KeyEvent.KEY_TYPED, this::keyTyped);
|
||||||
|
addEventHandler(MouseEvent.MOUSE_PRESSED, e -> requestFocus());
|
||||||
|
focusedProperty().addListener((observable, wasFocused, focused) -> {
|
||||||
|
if(!focused)
|
||||||
|
{
|
||||||
|
cancelEntry();
|
||||||
|
}
|
||||||
|
updateDigits();
|
||||||
|
});
|
||||||
|
disabledProperty().addListener((observable, wasDisabled, disabled) -> {
|
||||||
|
if(disabled)
|
||||||
|
{
|
||||||
|
stopRepeat();
|
||||||
|
cancelEntry();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setOnContextMenuRequested(e -> {
|
||||||
|
buildContextMenu().show(this, e.getScreenX(), e.getScreenY());
|
||||||
|
e.consume();
|
||||||
|
});
|
||||||
|
|
||||||
|
updateDigits();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a listener to be notified of frequencies requested by the user. Listeners are invoked on the JavaFX
|
||||||
|
* application thread.
|
||||||
|
*/
|
||||||
|
public void addListener(LongConsumer listener)
|
||||||
|
{
|
||||||
|
if(listener != null && !mListeners.contains(listener))
|
||||||
|
{
|
||||||
|
mListeners.add(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the listener.
|
||||||
|
*/
|
||||||
|
public void removeListener(LongConsumer listener)
|
||||||
|
{
|
||||||
|
mListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all listeners.
|
||||||
|
*/
|
||||||
|
public void clearListeners()
|
||||||
|
{
|
||||||
|
mListeners.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current frequency in Hertz.
|
||||||
|
*/
|
||||||
|
public long getFrequency()
|
||||||
|
{
|
||||||
|
return mFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the displayed frequency without notifying listeners. Safe to call from any thread.
|
||||||
|
* @param frequency in Hertz
|
||||||
|
*/
|
||||||
|
public void setFrequency(long frequency)
|
||||||
|
{
|
||||||
|
if(Platform.isFxApplicationThread())
|
||||||
|
{
|
||||||
|
mFrequency = Math.max(0, Math.min(FrequencyEntry.MAXIMUM_DISPLAYABLE, frequency));
|
||||||
|
updateDigits();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Platform.runLater(() -> setFrequency(frequency));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the range of frequencies that the user can request.
|
||||||
|
* @param minimum frequency in Hertz
|
||||||
|
* @param maximum frequency in Hertz
|
||||||
|
*/
|
||||||
|
public void setRange(long minimum, long maximum)
|
||||||
|
{
|
||||||
|
mMinimum = Math.max(0, Math.min(minimum, maximum));
|
||||||
|
mMaximum = Math.min(FrequencyEntry.MAXIMUM_DISPLAYABLE, Math.max(minimum, maximum));
|
||||||
|
updateTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Minimum frequency that the user can request.
|
||||||
|
*/
|
||||||
|
public long getMinimum()
|
||||||
|
{
|
||||||
|
return mMinimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum frequency that the user can request.
|
||||||
|
*/
|
||||||
|
public long getMaximum()
|
||||||
|
{
|
||||||
|
return mMaximum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives tuner frequency change notifications and shows the new frequency. Requests are not re-broadcast.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void process(SourceEvent event)
|
||||||
|
{
|
||||||
|
if(event.getEvent() == SourceEvent.Event.NOTIFICATION_FREQUENCY_CHANGE && event.getValue() != null)
|
||||||
|
{
|
||||||
|
setFrequency(event.getValue().longValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Digit position under the keyboard cursor.
|
||||||
|
*/
|
||||||
|
public int getCursorPosition()
|
||||||
|
{
|
||||||
|
return mCursorPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Steps the digit at the position and notifies listeners when the frequency changes.
|
||||||
|
* @param position of the digit (0 = 1 Hz)
|
||||||
|
* @param steps positive to increment, negative to decrement
|
||||||
|
*/
|
||||||
|
public void step(int position, int steps)
|
||||||
|
{
|
||||||
|
if(isDisabled() || steps == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelEntry();
|
||||||
|
long stepped = FrequencyEntry.step(mFrequency, position, steps, mMinimum, mMaximum);
|
||||||
|
request(stepped);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests the frequency on behalf of the user. An out of range frequency is rejected and flagged.
|
||||||
|
* @return true if the frequency was accepted.
|
||||||
|
*/
|
||||||
|
public boolean request(long frequency)
|
||||||
|
{
|
||||||
|
if(frequency < mMinimum || frequency > mMaximum)
|
||||||
|
{
|
||||||
|
flagInvalid();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(frequency != mFrequency)
|
||||||
|
{
|
||||||
|
mFrequency = frequency;
|
||||||
|
updateDigits();
|
||||||
|
|
||||||
|
for(LongConsumer listener: mListeners)
|
||||||
|
{
|
||||||
|
listener.accept(frequency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if a typed entry is in progress.
|
||||||
|
*/
|
||||||
|
public boolean isEntryActive()
|
||||||
|
{
|
||||||
|
return !mTypedEntry.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void keyTyped(KeyEvent event)
|
||||||
|
{
|
||||||
|
if(isDisabled() || event.isShortcutDown() || event.isAltDown())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String character = event.getCharacter();
|
||||||
|
|
||||||
|
if(character == null || character.length() != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
char c = character.charAt(0);
|
||||||
|
|
||||||
|
if((c >= '0' && c <= '9') || c == '.' || c == ',')
|
||||||
|
{
|
||||||
|
mTypedEntry.type(c);
|
||||||
|
updateDigits();
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
else if(c == '+' || c == '=')
|
||||||
|
{
|
||||||
|
step(mCursorPosition, 1);
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
else if(c == '-')
|
||||||
|
{
|
||||||
|
step(mCursorPosition, -1);
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void keyPressed(KeyEvent event)
|
||||||
|
{
|
||||||
|
if(isDisabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.isShortcutDown())
|
||||||
|
{
|
||||||
|
if(event.getCode() == KeyCode.C)
|
||||||
|
{
|
||||||
|
copy();
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
else if(event.getCode() == KeyCode.V)
|
||||||
|
{
|
||||||
|
paste();
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(event.getCode())
|
||||||
|
{
|
||||||
|
case LEFT, KP_LEFT -> moveCursor(1);
|
||||||
|
case RIGHT, KP_RIGHT -> moveCursor(-1);
|
||||||
|
case HOME -> setCursorPosition(FrequencyEntry.DIGIT_COUNT - 1);
|
||||||
|
case END -> setCursorPosition(0);
|
||||||
|
case UP, KP_UP -> step(mCursorPosition, 1);
|
||||||
|
case DOWN, KP_DOWN -> step(mCursorPosition, -1);
|
||||||
|
case PAGE_UP -> step(mCursorPosition, 10);
|
||||||
|
case PAGE_DOWN -> step(mCursorPosition, -10);
|
||||||
|
case ENTER ->
|
||||||
|
{
|
||||||
|
if(!commitEntry())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case ESCAPE ->
|
||||||
|
{
|
||||||
|
if(!isEntryActive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cancelEntry();
|
||||||
|
}
|
||||||
|
case BACK_SPACE ->
|
||||||
|
{
|
||||||
|
if(!isEntryActive())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mTypedEntry.backspace();
|
||||||
|
updateDigits();
|
||||||
|
}
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the typed entry.
|
||||||
|
* @return true if there was an entry to apply.
|
||||||
|
*/
|
||||||
|
private boolean commitEntry()
|
||||||
|
{
|
||||||
|
if(!isEntryActive())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
long frequency = mTypedEntry.getFrequency();
|
||||||
|
mTypedEntry.clear();
|
||||||
|
|
||||||
|
if(!request(frequency))
|
||||||
|
{
|
||||||
|
updateDigits();
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelEntry()
|
||||||
|
{
|
||||||
|
if(isEntryActive())
|
||||||
|
{
|
||||||
|
mTypedEntry.clear();
|
||||||
|
updateDigits();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveCursor(int direction)
|
||||||
|
{
|
||||||
|
cancelEntry();
|
||||||
|
setCursorPosition(mCursorPosition + direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setCursorPosition(int position)
|
||||||
|
{
|
||||||
|
mCursorPosition = Math.max(0, Math.min(FrequencyEntry.DIGIT_COUNT - 1, position));
|
||||||
|
updateDigits();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void copy()
|
||||||
|
{
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(FrequencyEntry.format(mFrequency));
|
||||||
|
Clipboard.getSystemClipboard().setContent(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void paste()
|
||||||
|
{
|
||||||
|
Clipboard clipboard = Clipboard.getSystemClipboard();
|
||||||
|
|
||||||
|
if(clipboard.hasString())
|
||||||
|
{
|
||||||
|
Long frequency = FrequencyEntry.parse(clipboard.getString());
|
||||||
|
|
||||||
|
cancelEntry();
|
||||||
|
|
||||||
|
if(frequency != null)
|
||||||
|
{
|
||||||
|
request(frequency);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
flagInvalid();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContextMenu buildContextMenu()
|
||||||
|
{
|
||||||
|
MenuItem copy = new MenuItem("Copy Frequency");
|
||||||
|
copy.setAccelerator(KeyCombination.keyCombination("Shortcut+C"));
|
||||||
|
copy.setOnAction(e -> copy());
|
||||||
|
|
||||||
|
MenuItem paste = new MenuItem("Paste Frequency");
|
||||||
|
paste.setAccelerator(KeyCombination.keyCombination("Shortcut+V"));
|
||||||
|
paste.setDisable(isDisabled() || !Clipboard.getSystemClipboard().hasString());
|
||||||
|
paste.setOnAction(e -> paste());
|
||||||
|
|
||||||
|
MenuItem minimum = new MenuItem("Tune to Minimum (" + FrequencyEntry.format(mMinimum) + " MHz)");
|
||||||
|
minimum.setDisable(isDisabled());
|
||||||
|
minimum.setOnAction(e -> request(mMinimum));
|
||||||
|
|
||||||
|
MenuItem maximum = new MenuItem("Tune to Maximum (" + FrequencyEntry.format(mMaximum) + " MHz)");
|
||||||
|
maximum.setDisable(isDisabled());
|
||||||
|
maximum.setOnAction(e -> request(mMaximum));
|
||||||
|
|
||||||
|
return new ContextMenu(copy, paste, new SeparatorMenuItem(), minimum, maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void flagInvalid()
|
||||||
|
{
|
||||||
|
pseudoClassStateChanged(INVALID, true);
|
||||||
|
mInvalidFlash.playFromStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTooltip()
|
||||||
|
{
|
||||||
|
mTooltip.setText("Tuning range " + FrequencyEntry.format(mMinimum) + " - " +
|
||||||
|
FrequencyEntry.format(mMaximum) + " MHz\n\n" +
|
||||||
|
"Hover over a digit and use the scroll wheel, or click its upper or lower half, to step it.\n" +
|
||||||
|
"Or type a frequency in MHz (e.g. 851.0125) and press Enter. Escape cancels.\n" +
|
||||||
|
"Arrow keys move between digits and step the selected digit.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refreshes every digit's value and state.
|
||||||
|
*/
|
||||||
|
private void updateDigits()
|
||||||
|
{
|
||||||
|
boolean entry = isEntryActive();
|
||||||
|
long shown = entry ? mTypedEntry.getFrequency() : mFrequency;
|
||||||
|
boolean focused = isFocused();
|
||||||
|
pseudoClassStateChanged(ENTRY, entry);
|
||||||
|
|
||||||
|
for(Digit digit: mDigits)
|
||||||
|
{
|
||||||
|
int position = digit.getPosition();
|
||||||
|
digit.setValue(FrequencyEntry.getDigit(shown, position));
|
||||||
|
digit.pseudoClassStateChanged(LEADING, FrequencyEntry.isLeadingZero(shown, position));
|
||||||
|
digit.pseudoClassStateChanged(TYPED, entry && mTypedEntry.isTyped(position));
|
||||||
|
digit.pseudoClassStateChanged(CURSOR, focused && !entry && position == mCursorPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
setAccessibleText(FrequencyEntry.format(mFrequency) + " MHz");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopRepeat()
|
||||||
|
{
|
||||||
|
mRepeat.stop();
|
||||||
|
mRepeat.getKeyFrames().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A single digit with up and down halves.
|
||||||
|
*/
|
||||||
|
private class Digit extends VBox
|
||||||
|
{
|
||||||
|
private final int mPosition;
|
||||||
|
private final Text mText = new Text("0");
|
||||||
|
private final Region mUpHalf = new Region();
|
||||||
|
private final Region mDownHalf = new Region();
|
||||||
|
|
||||||
|
Digit(int position)
|
||||||
|
{
|
||||||
|
mPosition = position;
|
||||||
|
getStyleClass().add("frequency-digit");
|
||||||
|
setAlignment(Pos.CENTER);
|
||||||
|
|
||||||
|
Region upArrow = new Region();
|
||||||
|
upArrow.getStyleClass().addAll("frequency-arrow", "frequency-arrow-up");
|
||||||
|
Region downArrow = new Region();
|
||||||
|
downArrow.getStyleClass().addAll("frequency-arrow", "frequency-arrow-down");
|
||||||
|
|
||||||
|
mText.getStyleClass().add("frequency-digit-text");
|
||||||
|
|
||||||
|
mUpHalf.getStyleClass().addAll("frequency-half", "frequency-half-up");
|
||||||
|
mDownHalf.getStyleClass().addAll("frequency-half", "frequency-half-down");
|
||||||
|
|
||||||
|
StackPane cell = new StackPane(mUpHalf, mDownHalf, mText);
|
||||||
|
cell.getStyleClass().add("frequency-digit-cell");
|
||||||
|
StackPane.setAlignment(mUpHalf, Pos.TOP_CENTER);
|
||||||
|
StackPane.setAlignment(mDownHalf, Pos.BOTTOM_CENTER);
|
||||||
|
mUpHalf.maxHeightProperty().bind(cell.heightProperty().divide(2));
|
||||||
|
mDownHalf.maxHeightProperty().bind(cell.heightProperty().divide(2));
|
||||||
|
cell.minWidthProperty().bind(mProbe.layoutBoundsProperty().map(bounds -> bounds.getWidth() + 4));
|
||||||
|
cell.prefWidthProperty().bind(cell.minWidthProperty());
|
||||||
|
|
||||||
|
//Arrow size follows the digit font size, so it scales with the user's GUI scale
|
||||||
|
upArrow.prefWidthProperty().bind(mProbe.layoutBoundsProperty().map(bounds -> bounds.getWidth() * 0.6));
|
||||||
|
upArrow.prefHeightProperty().bind(mProbe.layoutBoundsProperty().map(bounds -> bounds.getHeight() * 0.18));
|
||||||
|
upArrow.maxWidthProperty().bind(upArrow.prefWidthProperty());
|
||||||
|
upArrow.maxHeightProperty().bind(upArrow.prefHeightProperty());
|
||||||
|
downArrow.prefWidthProperty().bind(upArrow.prefWidthProperty());
|
||||||
|
downArrow.prefHeightProperty().bind(upArrow.prefHeightProperty());
|
||||||
|
downArrow.maxWidthProperty().bind(upArrow.prefWidthProperty());
|
||||||
|
downArrow.maxHeightProperty().bind(upArrow.prefHeightProperty());
|
||||||
|
|
||||||
|
getChildren().addAll(upArrow, cell, downArrow);
|
||||||
|
|
||||||
|
addEventHandler(MouseEvent.MOUSE_MOVED, e -> setHalf(e.getY() < getHeight() / 2 ? 1 : -1));
|
||||||
|
addEventHandler(MouseEvent.MOUSE_ENTERED, e -> setHalf(e.getY() < getHeight() / 2 ? 1 : -1));
|
||||||
|
addEventHandler(MouseEvent.MOUSE_EXITED, e -> {
|
||||||
|
setHalf(0);
|
||||||
|
stopRepeat();
|
||||||
|
});
|
||||||
|
addEventHandler(MouseEvent.MOUSE_PRESSED, this::pressed);
|
||||||
|
addEventHandler(MouseEvent.MOUSE_RELEASED, e -> stopRepeat());
|
||||||
|
addEventHandler(ScrollEvent.SCROLL, this::scrolled);
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPosition()
|
||||||
|
{
|
||||||
|
return mPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValue(int value)
|
||||||
|
{
|
||||||
|
mText.setText(String.valueOf(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setHalf(int half)
|
||||||
|
{
|
||||||
|
pseudoClassStateChanged(HOVER_UP, half > 0);
|
||||||
|
pseudoClassStateChanged(HOVER_DOWN, half < 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pressed(MouseEvent event)
|
||||||
|
{
|
||||||
|
if(event.getButton() != MouseButton.PRIMARY || isDisabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
requestFocus();
|
||||||
|
mCursorPosition = mPosition;
|
||||||
|
int direction = event.getY() < getHeight() / 2 ? 1 : -1;
|
||||||
|
setHalf(direction);
|
||||||
|
step(mPosition, direction);
|
||||||
|
|
||||||
|
stopRepeat();
|
||||||
|
mRepeat.getKeyFrames().add(new KeyFrame(REPEAT_INTERVAL, e -> step(mPosition, direction)));
|
||||||
|
mRepeat.setDelay(REPEAT_DELAY);
|
||||||
|
mRepeat.playFromStart();
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scrolled(ScrollEvent event)
|
||||||
|
{
|
||||||
|
if(isDisabled() || event.getDeltaY() == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Accumulate so that high resolution (touchpad) scrolling steps once per wheel notch
|
||||||
|
double notch = event.getMultiplierY() > 1 ? event.getMultiplierY() : 40;
|
||||||
|
mScrollAccumulator += event.getDeltaY() / notch;
|
||||||
|
int steps = (int)mScrollAccumulator;
|
||||||
|
|
||||||
|
if(steps != 0)
|
||||||
|
{
|
||||||
|
mScrollAccumulator -= steps;
|
||||||
|
mCursorPosition = mPosition;
|
||||||
|
step(mPosition, steps);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.consume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
372
src/main/java/io/github/dsheirer/gui/control/FrequencyEntry.java
Normal file
372
src/main/java/io/github/dsheirer/gui/control/FrequencyEntry.java
Normal file
@@ -0,0 +1,372 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.gui.control;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frequency arithmetic for the {@link FrequencyControl}, kept free of JavaFX so that it can be unit tested.
|
||||||
|
*
|
||||||
|
* The control shows a frequency in MHz as a fixed number of digits: {@link #INTEGER_DIGITS} MHz digits and
|
||||||
|
* {@link #FRACTION_DIGITS} fractional digits, so the least significant digit is 1 Hz. Digit positions are
|
||||||
|
* numbered by their power of ten in Hertz: position 0 is the 1 Hz digit and position 9 is the 1000 MHz digit.
|
||||||
|
*/
|
||||||
|
public final class FrequencyEntry
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Number of MHz (integer) digits.
|
||||||
|
*/
|
||||||
|
public static final int INTEGER_DIGITS = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of fractional MHz digits (precision to 1 Hz).
|
||||||
|
*/
|
||||||
|
public static final int FRACTION_DIGITS = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Total number of displayed digits.
|
||||||
|
*/
|
||||||
|
public static final int DIGIT_COUNT = INTEGER_DIGITS + FRACTION_DIGITS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Largest frequency that fits the display: 9999.999999 MHz.
|
||||||
|
*/
|
||||||
|
public static final long MAXIMUM_DISPLAYABLE = 9_999_999_999L;
|
||||||
|
|
||||||
|
private FrequencyEntry()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value of the digit at the position.
|
||||||
|
* @param frequency in Hertz
|
||||||
|
* @param position power of ten (0 = 1 Hz)
|
||||||
|
* @return digit 0-9
|
||||||
|
*/
|
||||||
|
public static int getDigit(long frequency, int position)
|
||||||
|
{
|
||||||
|
return (int)((Math.abs(frequency) / pow10(position)) % 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the digit at the position is a leading zero, which the control shows dimmed. The 1 MHz digit is
|
||||||
|
* never a leading zero.
|
||||||
|
*/
|
||||||
|
public static boolean isLeadingZero(long frequency, int position)
|
||||||
|
{
|
||||||
|
return position > FRACTION_DIGITS && Math.abs(frequency) < pow10(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Steps the frequency by a number of units of the digit position, carrying into the higher digits, and clamps
|
||||||
|
* the result to the range. A step that would leave the range lands on the range limit.
|
||||||
|
* @param frequency current value in Hertz
|
||||||
|
* @param position power of ten for the digit being stepped
|
||||||
|
* @param steps positive to increment, negative to decrement
|
||||||
|
* @param minimum allowed frequency
|
||||||
|
* @param maximum allowed frequency
|
||||||
|
* @return stepped and clamped frequency
|
||||||
|
*/
|
||||||
|
public static long step(long frequency, int position, int steps, long minimum, long maximum)
|
||||||
|
{
|
||||||
|
long stepped = frequency + (steps * pow10(position));
|
||||||
|
return clamp(stepped, minimum, maximum);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the digit at the position with a new value, without carry.
|
||||||
|
*/
|
||||||
|
public static long setDigit(long frequency, int position, int digit)
|
||||||
|
{
|
||||||
|
long unit = pow10(position);
|
||||||
|
int current = getDigit(frequency, position);
|
||||||
|
return frequency + ((long)(digit - current) * unit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clamps the frequency to the range.
|
||||||
|
*/
|
||||||
|
public static long clamp(long frequency, long minimum, long maximum)
|
||||||
|
{
|
||||||
|
return Math.max(minimum, Math.min(maximum, frequency));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a typed or pasted frequency. A bare number is in MHz (e.g. 851.0125) unless it is too large to be MHz
|
||||||
|
* for the display, in which case it is read as Hertz (e.g. 851012500). An optional unit suffix of Hz, kHz, MHz
|
||||||
|
* or GHz (any case, with or without a space) overrides that. Thousands separators (comma, underscore or space)
|
||||||
|
* are ignored.
|
||||||
|
* @param text to parse
|
||||||
|
* @return frequency in Hertz, or null if the text isn't a frequency or has more precision than 1 Hz.
|
||||||
|
*/
|
||||||
|
public static Long parse(String text)
|
||||||
|
{
|
||||||
|
if(text == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String value = text.trim().toLowerCase().replace(",", "").replace("_", "").replace(" ", "");
|
||||||
|
|
||||||
|
if(value.isEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal multiplier = null;
|
||||||
|
|
||||||
|
if(value.endsWith("ghz"))
|
||||||
|
{
|
||||||
|
multiplier = BigDecimal.valueOf(1_000_000_000L);
|
||||||
|
value = value.substring(0, value.length() - 3);
|
||||||
|
}
|
||||||
|
else if(value.endsWith("mhz"))
|
||||||
|
{
|
||||||
|
multiplier = BigDecimal.valueOf(1_000_000L);
|
||||||
|
value = value.substring(0, value.length() - 3);
|
||||||
|
}
|
||||||
|
else if(value.endsWith("khz"))
|
||||||
|
{
|
||||||
|
multiplier = BigDecimal.valueOf(1_000L);
|
||||||
|
value = value.substring(0, value.length() - 3);
|
||||||
|
}
|
||||||
|
else if(value.endsWith("hz"))
|
||||||
|
{
|
||||||
|
multiplier = BigDecimal.ONE;
|
||||||
|
value = value.substring(0, value.length() - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal number;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
number = new BigDecimal(value);
|
||||||
|
}
|
||||||
|
catch(NumberFormatException nfe)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(number.signum() < 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(multiplier == null)
|
||||||
|
{
|
||||||
|
//A whole number too large to be MHz on the display is taken as Hertz
|
||||||
|
boolean whole = number.stripTrailingZeros().scale() <= 0;
|
||||||
|
multiplier = (whole && number.compareTo(BigDecimal.valueOf(10_000)) >= 0) ? BigDecimal.ONE :
|
||||||
|
BigDecimal.valueOf(1_000_000L);
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal hertz = number.multiply(multiplier).stripTrailingZeros();
|
||||||
|
|
||||||
|
if(hertz.scale() > 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return hertz.longValueExact();
|
||||||
|
}
|
||||||
|
catch(ArithmeticException ae)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the frequency in MHz with all six fractional digits, e.g. 851.012500
|
||||||
|
*/
|
||||||
|
public static String format(long frequency)
|
||||||
|
{
|
||||||
|
return BigDecimal.valueOf(frequency, FRACTION_DIGITS).toPlainString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ten raised to the power.
|
||||||
|
*/
|
||||||
|
public static long pow10(int power)
|
||||||
|
{
|
||||||
|
long value = 1;
|
||||||
|
|
||||||
|
for(int x = 0; x < power; x++)
|
||||||
|
{
|
||||||
|
value *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculator style typed entry. Digits typed before the decimal point fill the MHz digits from the right and
|
||||||
|
* digits typed after it fill the fractional digits from the left, so typing 851.0125 shows 851.012500.
|
||||||
|
*/
|
||||||
|
public static class TypedEntry
|
||||||
|
{
|
||||||
|
private final StringBuilder mIntegerPart = new StringBuilder();
|
||||||
|
private final StringBuilder mFractionPart = new StringBuilder();
|
||||||
|
private boolean mDecimal = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a typed character.
|
||||||
|
* @param c digit or decimal point
|
||||||
|
* @return true if the character was accepted
|
||||||
|
*/
|
||||||
|
public boolean type(char c)
|
||||||
|
{
|
||||||
|
if(c == '.' || c == ',')
|
||||||
|
{
|
||||||
|
if(mDecimal)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mDecimal = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(c < '0' || c > '9')
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mDecimal)
|
||||||
|
{
|
||||||
|
if(mFractionPart.length() >= FRACTION_DIGITS)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mFractionPart.append(c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Ignore leading zeros so they don't use up the MHz digits
|
||||||
|
if(mIntegerPart.isEmpty() && c == '0')
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(mIntegerPart.length() >= INTEGER_DIGITS)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mIntegerPart.append(c);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the last typed character.
|
||||||
|
* @return true if there is still something typed after the removal.
|
||||||
|
*/
|
||||||
|
public boolean backspace()
|
||||||
|
{
|
||||||
|
if(!mFractionPart.isEmpty())
|
||||||
|
{
|
||||||
|
mFractionPart.setLength(mFractionPart.length() - 1);
|
||||||
|
}
|
||||||
|
else if(mDecimal)
|
||||||
|
{
|
||||||
|
mDecimal = false;
|
||||||
|
}
|
||||||
|
else if(!mIntegerPart.isEmpty())
|
||||||
|
{
|
||||||
|
mIntegerPart.setLength(mIntegerPart.length() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return !isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if nothing has been typed.
|
||||||
|
*/
|
||||||
|
public boolean isEmpty()
|
||||||
|
{
|
||||||
|
return mIntegerPart.isEmpty() && mFractionPart.isEmpty() && !mDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of fractional digits typed so far.
|
||||||
|
*/
|
||||||
|
public int getFractionDigitsTyped()
|
||||||
|
{
|
||||||
|
return mFractionPart.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the decimal point has been typed.
|
||||||
|
*/
|
||||||
|
public boolean hasDecimal()
|
||||||
|
{
|
||||||
|
return mDecimal;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of MHz digits typed so far.
|
||||||
|
*/
|
||||||
|
public int getIntegerDigitsTyped()
|
||||||
|
{
|
||||||
|
return mIntegerPart.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frequency for what has been typed so far.
|
||||||
|
*/
|
||||||
|
public long getFrequency()
|
||||||
|
{
|
||||||
|
long mhz = mIntegerPart.isEmpty() ? 0 : Long.parseLong(mIntegerPart.toString());
|
||||||
|
long fraction = 0;
|
||||||
|
|
||||||
|
if(!mFractionPart.isEmpty())
|
||||||
|
{
|
||||||
|
fraction = Long.parseLong(mFractionPart.toString()) * pow10(FRACTION_DIGITS - mFractionPart.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (mhz * 1_000_000L) + fraction;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if the digit at the position has been typed, as opposed to an implied trailing zero.
|
||||||
|
*/
|
||||||
|
public boolean isTyped(int position)
|
||||||
|
{
|
||||||
|
if(position >= FRACTION_DIGITS)
|
||||||
|
{
|
||||||
|
return position - FRACTION_DIGITS < mIntegerPart.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (FRACTION_DIGITS - 1 - position) < mFractionPart.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the typed entry.
|
||||||
|
*/
|
||||||
|
public void clear()
|
||||||
|
{
|
||||||
|
mIntegerPart.setLength(0);
|
||||||
|
mFractionPart.setLength(0);
|
||||||
|
mDecimal = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
111
src/main/java/io/github/dsheirer/gui/control/FrequencyField.java
Normal file
111
src/main/java/io/github/dsheirer/gui/control/FrequencyField.java
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.gui.control;
|
||||||
|
|
||||||
|
import java.util.function.LongPredicate;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Text field for a frequency in MHz (to 1 Hz). The value is committed when the user presses Enter or leaves the
|
||||||
|
* field. A commit handler can reject the new value, which restores the previous value. Escape reverts the text.
|
||||||
|
*/
|
||||||
|
public class FrequencyField extends TextField
|
||||||
|
{
|
||||||
|
private long mFrequency;
|
||||||
|
private LongPredicate mCommitHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance
|
||||||
|
* @param frequency initial value in Hertz
|
||||||
|
*/
|
||||||
|
public FrequencyField(long frequency)
|
||||||
|
{
|
||||||
|
getStyleClass().add("frequency-field");
|
||||||
|
setPrefColumnCount(11);
|
||||||
|
setFrequency(frequency);
|
||||||
|
|
||||||
|
setOnAction(e -> commit());
|
||||||
|
focusedProperty().addListener((observable, wasFocused, focused) -> {
|
||||||
|
if(!focused)
|
||||||
|
{
|
||||||
|
commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setOnKeyPressed(e -> {
|
||||||
|
if(e.getCode() == KeyCode.ESCAPE)
|
||||||
|
{
|
||||||
|
setText(FrequencyEntry.format(mFrequency));
|
||||||
|
e.consume();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the handler for committed values. The handler returns false to reject the value.
|
||||||
|
*/
|
||||||
|
public void setCommitHandler(LongPredicate handler)
|
||||||
|
{
|
||||||
|
mCommitHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current frequency in Hertz.
|
||||||
|
*/
|
||||||
|
public long getFrequency()
|
||||||
|
{
|
||||||
|
return mFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the frequency without invoking the commit handler.
|
||||||
|
*/
|
||||||
|
public void setFrequency(long frequency)
|
||||||
|
{
|
||||||
|
mFrequency = frequency;
|
||||||
|
setText(FrequencyEntry.format(frequency));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void commit()
|
||||||
|
{
|
||||||
|
Long parsed = FrequencyEntry.parse(getText());
|
||||||
|
|
||||||
|
if(parsed == null)
|
||||||
|
{
|
||||||
|
setText(FrequencyEntry.format(mFrequency));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(parsed == mFrequency)
|
||||||
|
{
|
||||||
|
setText(FrequencyEntry.format(mFrequency));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
long previous = mFrequency;
|
||||||
|
mFrequency = parsed;
|
||||||
|
setText(FrequencyEntry.format(parsed));
|
||||||
|
|
||||||
|
if(mCommitHandler != null && !mCommitHandler.test(parsed))
|
||||||
|
{
|
||||||
|
setFrequency(previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
/*
|
|
||||||
* *****************************************************************************
|
|
||||||
* Copyright (C) 2014-2024 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 io.github.dsheirer.gui.control;
|
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.text.AttributeSet;
|
|
||||||
import javax.swing.text.BadLocationException;
|
|
||||||
import javax.swing.text.Document;
|
|
||||||
import javax.swing.text.DocumentFilter;
|
|
||||||
import javax.swing.text.PlainDocument;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Swing text field control for entering frequency (MHz) values.
|
|
||||||
*/
|
|
||||||
public class FrequencyTextField extends JTextField
|
|
||||||
{
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(FrequencyTextField.class);
|
|
||||||
//Value range: 0.000001 to 9999.999999
|
|
||||||
private static final String REGEX = "^[0-9]{0,4}[.]?[0-9]{0,6}$";
|
|
||||||
//This lets users start typing a really small number like 1 Hertz ... 0.00000
|
|
||||||
private static final String ZEROS_REGEX = "^0?([.]0{0,5})?$";
|
|
||||||
private double mMinimum;
|
|
||||||
private double mMaximum;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an instance
|
|
||||||
*
|
|
||||||
* @param minimum allowable frequency value in Hertz
|
|
||||||
* @param maximum allowable frequency value in Hertz
|
|
||||||
* @param current frequency value in Hertz
|
|
||||||
*/
|
|
||||||
public FrequencyTextField(long minimum, long maximum, long current)
|
|
||||||
{
|
|
||||||
super(8);
|
|
||||||
mMinimum = minimum / 1E6d;
|
|
||||||
mMaximum = maximum / 1E6d;
|
|
||||||
|
|
||||||
PlainDocument document = (PlainDocument)this.getDocument();
|
|
||||||
document.setDocumentFilter(new FrequencyFilter());
|
|
||||||
setFrequency(current);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current frequency value
|
|
||||||
* @return frequency in Hertz
|
|
||||||
*/
|
|
||||||
public long getFrequency()
|
|
||||||
{
|
|
||||||
String value = getText();
|
|
||||||
|
|
||||||
if(value == null || value.isEmpty())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return (long)(Double.parseDouble(getText()) * 1E6d);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
LOGGER.error("Unable to parse frequency value from text [" + value + "] " + e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current frequency value
|
|
||||||
* @param frequency in Hertz
|
|
||||||
*/
|
|
||||||
public void setFrequency(long frequency)
|
|
||||||
{
|
|
||||||
double frequencyMHz = frequency / 1E6d;
|
|
||||||
|
|
||||||
if(isValid(String.valueOf(frequencyMHz)))
|
|
||||||
{
|
|
||||||
setText(String.valueOf(frequencyMHz));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGGER.warn("Can't set frequency [" + frequency + "Hz / " + frequencyMHz + "MHz] with current minimum [" + mMinimum + "MHz] and maximum [" + mMaximum + "MHz] limits");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if the value is a valid double value that is between the minimum and maximum extents.
|
|
||||||
* @param value to test
|
|
||||||
* @return true if it is valid.
|
|
||||||
*/
|
|
||||||
private boolean isValid(String value)
|
|
||||||
{
|
|
||||||
if(value == null || value.isEmpty() || value.matches(ZEROS_REGEX))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(value.matches(REGEX))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
double frequency = Double.parseDouble(value);
|
|
||||||
return mMinimum <= frequency && frequency <= mMaximum;
|
|
||||||
}
|
|
||||||
catch(NumberFormatException e)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Input filter for user entered values.
|
|
||||||
*/
|
|
||||||
class FrequencyFilter extends DocumentFilter
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException
|
|
||||||
{
|
|
||||||
Document doc = fb.getDocument();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(doc.getText(0, doc.getLength()));
|
|
||||||
sb.insert(offset, string);
|
|
||||||
|
|
||||||
if(isValid(sb.toString()))
|
|
||||||
{
|
|
||||||
super.insertString(fb, offset, string, attr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void replace(FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException
|
|
||||||
{
|
|
||||||
Document doc = fb.getDocument();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(doc.getText(0, doc.getLength()));
|
|
||||||
sb.replace(offset, offset + length, text);
|
|
||||||
|
|
||||||
if(isValid(sb.toString()))
|
|
||||||
{
|
|
||||||
super.replace(fb, offset, length, text, attrs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(FilterBypass fb, int offset, int length) throws BadLocationException
|
|
||||||
{
|
|
||||||
Document doc = fb.getDocument();
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append(doc.getText(0, doc.getLength()));
|
|
||||||
sb.delete(offset, offset + length);
|
|
||||||
|
|
||||||
if(isValid(sb.toString()))
|
|
||||||
{
|
|
||||||
super.remove(fb, offset, length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
JFrame frame = new JFrame("Frequency Control Test");
|
|
||||||
frame.setSize(300, 200);
|
|
||||||
FrequencyTextField ftf = new FrequencyTextField(1, 9_999_999_999l, 101_100_000);
|
|
||||||
frame.setLayout(new MigLayout());
|
|
||||||
frame.add(ftf);
|
|
||||||
|
|
||||||
EventQueue.invokeLater(() -> frame.setVisible(true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,593 +0,0 @@
|
|||||||
/*
|
|
||||||
* *****************************************************************************
|
|
||||||
* Copyright (C) 2014-2024 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 io.github.dsheirer.gui.control;
|
|
||||||
|
|
||||||
import io.github.dsheirer.source.ISourceEventProcessor;
|
|
||||||
import io.github.dsheirer.source.InvalidFrequencyException;
|
|
||||||
import io.github.dsheirer.source.SourceEvent;
|
|
||||||
import io.github.dsheirer.source.SourceException;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.event.KeyEvent;
|
|
||||||
import java.awt.event.KeyListener;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.MouseWheelEvent;
|
|
||||||
import java.awt.event.MouseWheelListener;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.apache.commons.math3.util.FastMath;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.UIManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom frequency controller for displaying or editing frequency values in MHz.
|
|
||||||
*/
|
|
||||||
public class JFrequencyControl extends JPanel implements ISourceEventProcessor
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(JFrequencyControl.class);
|
|
||||||
private List<ISourceEventProcessor> mProcessors = new ArrayList<>();
|
|
||||||
private Color mHighlightColor = Color.YELLOW;
|
|
||||||
private long mFrequency;
|
|
||||||
private HashMap<Integer,Digit> mDigits = new HashMap<Integer,Digit>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
public JFrequencyControl()
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the control/layout.
|
|
||||||
*/
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[]0[]", ""));
|
|
||||||
|
|
||||||
Font font = new Font(Font.MONOSPACED, Font.BOLD, 30);
|
|
||||||
|
|
||||||
for(int x = 9; x >= 0; x--)
|
|
||||||
{
|
|
||||||
Digit digit = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
digit = new Digit(x);
|
|
||||||
}
|
|
||||||
catch(ParseException e)
|
|
||||||
{
|
|
||||||
mLog.error("JFrequencyControl - parse exception constructing a digit - " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(digit != null)
|
|
||||||
{
|
|
||||||
mDigits.put(x, digit);
|
|
||||||
|
|
||||||
add(digit);
|
|
||||||
|
|
||||||
digit.setFont(font);
|
|
||||||
|
|
||||||
if(x == 6)
|
|
||||||
{
|
|
||||||
add(new JLabel(". "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
revalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables or disables the control.
|
|
||||||
* @param enabled true if this component should be enabled, false otherwise
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setEnabled(boolean enabled)
|
|
||||||
{
|
|
||||||
super.setEnabled(enabled);
|
|
||||||
|
|
||||||
for(Digit digit : mDigits.values())
|
|
||||||
{
|
|
||||||
digit.setEnabled(enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Receives a frequency change event invoked by another control. We don't
|
|
||||||
* rebroadcast this event, just set the control to indicate the new frequency.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void process(SourceEvent event)
|
|
||||||
{
|
|
||||||
switch(event.getEvent())
|
|
||||||
{
|
|
||||||
case NOTIFICATION_FREQUENCY_CHANGE:
|
|
||||||
EventQueue.invokeLater(() -> setFrequency(event.getValue().longValue(), false));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the frequency into the display and optionally fires a change event
|
|
||||||
* to all registered listeners
|
|
||||||
*/
|
|
||||||
public void setFrequency(long frequency, boolean fireChangeEvent)
|
|
||||||
{
|
|
||||||
mFrequency = frequency;
|
|
||||||
|
|
||||||
for(Digit digit : mDigits.values())
|
|
||||||
{
|
|
||||||
digit.setFrequency(frequency, fireChangeEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Current frequency value for the control.
|
|
||||||
* @return frequency
|
|
||||||
*/
|
|
||||||
public long getFrequency()
|
|
||||||
{
|
|
||||||
return mFrequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the frequency value according to the manually changed digit value.
|
|
||||||
*/
|
|
||||||
private void updateFrequency()
|
|
||||||
{
|
|
||||||
long frequency = 0;
|
|
||||||
|
|
||||||
for(Digit digit : mDigits.values())
|
|
||||||
{
|
|
||||||
frequency += digit.getFrequency();
|
|
||||||
}
|
|
||||||
|
|
||||||
mFrequency = frequency;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fires a source changed event
|
|
||||||
* @throws SourceException of there's an error
|
|
||||||
*/
|
|
||||||
private void fireSourceChanged() throws SourceException
|
|
||||||
{
|
|
||||||
updateFrequency();
|
|
||||||
Iterator<ISourceEventProcessor> it = mProcessors.iterator();
|
|
||||||
SourceEvent event = SourceEvent.frequencyRequest(mFrequency);
|
|
||||||
while(it.hasNext())
|
|
||||||
{
|
|
||||||
it.next().process(event);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the source event listener
|
|
||||||
* @param processor
|
|
||||||
*/
|
|
||||||
public void addListener(ISourceEventProcessor processor)
|
|
||||||
{
|
|
||||||
if(!mProcessors.contains(processor))
|
|
||||||
{
|
|
||||||
mProcessors.add(processor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove all source event processors
|
|
||||||
*/
|
|
||||||
public void clearListeners()
|
|
||||||
{
|
|
||||||
mProcessors.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the source event processor
|
|
||||||
* @param processor
|
|
||||||
*/
|
|
||||||
public void removeListener(ISourceEventProcessor processor)
|
|
||||||
{
|
|
||||||
mProcessors.remove(processor);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom single digit value editor.
|
|
||||||
*/
|
|
||||||
public class Digit extends JTextField
|
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private int mPower = 0;
|
|
||||||
private long mValue = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
* @param position of the digit where a position of 1 is the ones unit of MHz and a position of -1 is the tenths
|
|
||||||
* unit of MHz.
|
|
||||||
* @throws ParseException if there is an error
|
|
||||||
*/
|
|
||||||
private Digit(int position) throws ParseException
|
|
||||||
{
|
|
||||||
super("0");
|
|
||||||
setColumns(1);
|
|
||||||
|
|
||||||
mPower = position;
|
|
||||||
setToolTipText(getTooltip(mPower));
|
|
||||||
Listener listener = new Listener();
|
|
||||||
|
|
||||||
this.addKeyListener(listener);
|
|
||||||
this.addMouseListener(listener);
|
|
||||||
this.addMouseWheelListener(listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates a custom tooltip for the current hover-over digit.
|
|
||||||
* @param power of the digit in units of 10
|
|
||||||
* @return custom tooptip.
|
|
||||||
*/
|
|
||||||
private static String getTooltip(int power)
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("Center frequency ");
|
|
||||||
switch(power)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
sb.append("1 Hertz");
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
sb.append("10 Hertz");
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
sb.append("100 Hertz");
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
sb.append("1 Kilohertz");
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
sb.append("10 Kilohertz");
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
sb.append("100 Kilohertz");
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
sb.append("1 Megahertz");
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
sb.append("10 Megahertz");
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
sb.append("100 Megahertz");
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
sb.append("1 Gigahertz");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(" units. Type a number, use up/down arrows, or click the upper/lower digit control to adjust");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets this digit to the value of the column in frequency that corresponds
|
|
||||||
* to the power (ie column) set for this digit. Optionally, fires a
|
|
||||||
* value change event to all listeners.
|
|
||||||
*/
|
|
||||||
public void setFrequency(long frequency, boolean fireChangeEvent)
|
|
||||||
{
|
|
||||||
//Strip the digits higher than this one
|
|
||||||
long lower = frequency % (long)(FastMath.pow(10, mPower + 1));
|
|
||||||
//Set the value to int value of dividing by 10 to this power
|
|
||||||
long value = (long)(lower / (long)(FastMath.pow(10, mPower)));
|
|
||||||
set(value, fireChangeEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Frequency value.
|
|
||||||
* @return frequency value.
|
|
||||||
*/
|
|
||||||
public long getFrequency()
|
|
||||||
{
|
|
||||||
return mValue * (long)FastMath.pow(10, mPower);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increments the unit value and fires a change event
|
|
||||||
*/
|
|
||||||
public void increment()
|
|
||||||
{
|
|
||||||
increment(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increments the unit value and fires a change event
|
|
||||||
* @param fireChangeEvent true to fire an event
|
|
||||||
*/
|
|
||||||
public void increment(boolean fireChangeEvent)
|
|
||||||
{
|
|
||||||
if(isEnabled())
|
|
||||||
{
|
|
||||||
set(mValue + 1, fireChangeEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrements the unit value and fires a change event.
|
|
||||||
*/
|
|
||||||
public void decrement()
|
|
||||||
{
|
|
||||||
decrement(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decrements the unit value and optionally fires a change event.
|
|
||||||
* @param fireChangeEvent set to true to fire an event
|
|
||||||
*/
|
|
||||||
public void decrement(boolean fireChangeEvent)
|
|
||||||
{
|
|
||||||
if(isEnabled())
|
|
||||||
{
|
|
||||||
set(mValue - 1, fireChangeEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convenience wrapper to change amount and fire change event
|
|
||||||
*/
|
|
||||||
private void set(long amount)
|
|
||||||
{
|
|
||||||
set(amount, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the value and optionally fires change event to listeners
|
|
||||||
*/
|
|
||||||
private void set(long amount, boolean fireChangeEvent)
|
|
||||||
{
|
|
||||||
long previous = mValue;
|
|
||||||
boolean higherDigitIncremented = false;
|
|
||||||
boolean higherDigitDecremented = false;
|
|
||||||
|
|
||||||
mValue = amount;
|
|
||||||
|
|
||||||
|
|
||||||
while(mValue < 0)
|
|
||||||
{
|
|
||||||
mValue += 10;
|
|
||||||
Digit nextHigherDigit = mDigits.get(mPower + 1);
|
|
||||||
|
|
||||||
if(nextHigherDigit != null)
|
|
||||||
{
|
|
||||||
nextHigherDigit.decrement(false);
|
|
||||||
higherDigitDecremented = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
while(mValue > 9)
|
|
||||||
{
|
|
||||||
mValue -= 10;
|
|
||||||
Digit nextHigherDigit = mDigits.get(mPower + 1);
|
|
||||||
|
|
||||||
if(nextHigherDigit != null)
|
|
||||||
{
|
|
||||||
nextHigherDigit.increment(false);
|
|
||||||
higherDigitIncremented = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fireChangeEvent)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fireSourceChanged();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
mValue = previous;
|
|
||||||
|
|
||||||
if(higherDigitIncremented)
|
|
||||||
{
|
|
||||||
Digit nextHigherDigit = mDigits.get(mPower + 1);
|
|
||||||
|
|
||||||
if(nextHigherDigit != null)
|
|
||||||
{
|
|
||||||
nextHigherDigit.decrement(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(higherDigitDecremented)
|
|
||||||
{
|
|
||||||
Digit nextHigherDigit = mDigits.get(mPower + 1);
|
|
||||||
|
|
||||||
if(nextHigherDigit != null)
|
|
||||||
{
|
|
||||||
nextHigherDigit.increment(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(se instanceof InvalidFrequencyException ife)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(this, ife.getMessage() + " for this tuner.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
setText(String.valueOf(mValue));
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiple Listener interface implementation
|
|
||||||
*/
|
|
||||||
private class Listener implements KeyListener, MouseListener, MouseWheelListener
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void keyReleased(KeyEvent e)
|
|
||||||
{
|
|
||||||
int key = e.getKeyCode();
|
|
||||||
|
|
||||||
switch(key)
|
|
||||||
{
|
|
||||||
case KeyEvent.VK_0:
|
|
||||||
case KeyEvent.VK_NUMPAD0:
|
|
||||||
set(0);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_1:
|
|
||||||
case KeyEvent.VK_NUMPAD1:
|
|
||||||
set(1);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_2:
|
|
||||||
case KeyEvent.VK_NUMPAD2:
|
|
||||||
set(2);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_3:
|
|
||||||
case KeyEvent.VK_NUMPAD3:
|
|
||||||
set(3);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_4:
|
|
||||||
case KeyEvent.VK_NUMPAD4:
|
|
||||||
set(4);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_5:
|
|
||||||
case KeyEvent.VK_NUMPAD5:
|
|
||||||
set(5);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_6:
|
|
||||||
case KeyEvent.VK_NUMPAD6:
|
|
||||||
set(6);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_7:
|
|
||||||
case KeyEvent.VK_NUMPAD7:
|
|
||||||
set(7);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_8:
|
|
||||||
case KeyEvent.VK_NUMPAD8:
|
|
||||||
set(8);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_9:
|
|
||||||
case KeyEvent.VK_NUMPAD9:
|
|
||||||
set(9);
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_LEFT:
|
|
||||||
Digit.this.transferFocusBackward();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_RIGHT:
|
|
||||||
Digit.this.transferFocus();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_UP:
|
|
||||||
increment();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_DOWN:
|
|
||||||
decrement();
|
|
||||||
break;
|
|
||||||
case KeyEvent.VK_TAB:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
set(mValue);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void keyPressed(KeyEvent e) {}
|
|
||||||
@Override
|
|
||||||
public void keyTyped(KeyEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e)
|
|
||||||
{
|
|
||||||
switch(e.getButton())
|
|
||||||
{
|
|
||||||
case MouseEvent.BUTTON1:
|
|
||||||
increment();
|
|
||||||
break;
|
|
||||||
case MouseEvent.BUTTON2:
|
|
||||||
break;
|
|
||||||
case MouseEvent.BUTTON3:
|
|
||||||
decrement();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void mousePressed(MouseEvent e) {}
|
|
||||||
public void mouseReleased(MouseEvent e) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e)
|
|
||||||
{
|
|
||||||
Color bg = UIManager.getColor("TextField.selectionBackground");
|
|
||||||
Color fg = UIManager.getColor("TextField.selectionForeground");
|
|
||||||
Digit.this.setBackground(bg != null ? bg : Color.YELLOW);
|
|
||||||
Digit.this.setForeground(fg != null ? fg : Color.BLACK);
|
|
||||||
repaint(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e)
|
|
||||||
{
|
|
||||||
Color bg = UIManager.getColor("TextField.background");
|
|
||||||
Color fg = UIManager.getColor("TextField.foreground");
|
|
||||||
Digit.this.setBackground(bg != null ? bg : Color.WHITE);
|
|
||||||
Digit.this.setForeground(fg != null ? fg : Color.BLACK);
|
|
||||||
repaint(); }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseWheelMoved(MouseWheelEvent e)
|
|
||||||
{
|
|
||||||
//Swing delivers mouse wheel events to disabled components, so check enabled state explicitly so that
|
|
||||||
//the wheel can't bypass the lock when the tuner is providing channels.
|
|
||||||
if(isEnabled())
|
|
||||||
{
|
|
||||||
set(mValue - e.getWheelRotation());
|
|
||||||
}
|
|
||||||
else if(getParent() != null)
|
|
||||||
{
|
|
||||||
//Pass the event up so that an enclosing scroll pane can still scroll while this control is locked
|
|
||||||
getParent().dispatchEvent(SwingUtilities.convertMouseEvent(Digit.this, e, getParent()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -23,50 +23,35 @@ import io.github.dsheirer.source.tuner.airspy.AirspyTunerController.Gain;
|
|||||||
import io.github.dsheirer.source.tuner.airspy.AirspyTunerController.GainMode;
|
import io.github.dsheirer.source.tuner.airspy.AirspyTunerController.GainMode;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import io.github.dsheirer.source.tuner.ui.GainSlider;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import java.awt.event.ActionEvent;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.collections.FXCollections;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.JButton;
|
import javafx.scene.layout.Region;
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Airspy tuner editor/controller
|
* Airspy tuner editor
|
||||||
*/
|
*/
|
||||||
public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfiguration>
|
public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private ComboBox<AirspySampleRate> mSampleRateCombo;
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(AirspyTunerEditor.class);
|
private ComboBox<GainMode> mGainModeCombo;
|
||||||
private JButton mTunerInfoButton;
|
private GainSlider mMasterGainSlider;
|
||||||
private JComboBox<AirspySampleRate> mSampleRateCombo;
|
private Label mMasterGainLabel;
|
||||||
private JComboBox<GainMode> mGainModeCombo;
|
private GainSlider mIFGainSlider;
|
||||||
private JSlider mMasterGainSlider;
|
private Label mIFGainLabel;
|
||||||
private JLabel mMasterGainLabel;
|
private GainSlider mLNAGainSlider;
|
||||||
private JLabel mMasterGainValueLabel;
|
private Label mLNAGainLabel;
|
||||||
private JSlider mIFGainSlider;
|
private GainSlider mMixerGainSlider;
|
||||||
private JLabel mIFGainLabel;
|
private Label mMixerGainLabel;
|
||||||
private JLabel mIFGainValueLabel;
|
private CheckBox mLNAAGCCheckBox;
|
||||||
private JSlider mLNAGainSlider;
|
private CheckBox mMixerAGCCheckBox;
|
||||||
private JLabel mLNAGainValueLabel;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JSlider mMixerGainSlider;
|
|
||||||
private JLabel mMixerGainValueLabel;
|
|
||||||
private JCheckBox mLNAAGCCheckBox;
|
|
||||||
private JCheckBox mMixerAGCCheckBox;
|
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -78,7 +63,7 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,125 +78,62 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
return AirspyTunerController.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
return AirspyTunerController.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
|
|
||||||
|
TunerSection gain = addSection("Gain");
|
||||||
|
gain.addRow("Mode", getGainModeCombo());
|
||||||
|
mMasterGainLabel = gain.addRow("Master", getMasterGainSlider(), new Region());
|
||||||
|
mIFGainLabel = gain.addRow("IF", getIFGainSlider(), new Region());
|
||||||
|
mMixerGainLabel = gain.addRow("Mixer", getMixerGainSlider(), getMixerAGCCheckBox());
|
||||||
|
mLNAGainLabel = gain.addRow("LNA", getLNAGainSlider(), getLNAAGCCheckBox());
|
||||||
|
|
||||||
|
TunerSection options = addSection("Options");
|
||||||
|
options.addControl(getBiasTCheckBox());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
getSampleRateCombo().setDisable(!hasTuner() || getTuner().getTunerController().isLockedSampleRate());
|
||||||
|
getBiasTCheckBox().setDisable(!hasTuner());
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getTunerInfoButton().setEnabled(hasTuner());
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
getBiasTCheckBox().setSelected(hasTuner() && hasConfiguration() && getConfiguration().isBiasT());
|
getBiasTCheckBox().setSelected(hasTuner() && hasConfiguration() && getConfiguration().isBiasT());
|
||||||
updateGainComponents((hasTuner() && hasConfiguration()) ? getConfiguration().getGain() : null);
|
updateGainComponents((hasTuner() && hasConfiguration()) ? getConfiguration().getGain() : null);
|
||||||
|
|
||||||
if(hasTuner())
|
if(hasTuner())
|
||||||
{
|
{
|
||||||
List<AirspySampleRate> rates = getTuner().getController().getSampleRates();
|
List<AirspySampleRate> rates = getTuner().getController().getSampleRates();
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>(rates.toArray(new AirspySampleRate[rates.size()])));
|
getSampleRateCombo().getItems().setAll(rates);
|
||||||
|
|
||||||
if(hasConfiguration())
|
if(hasConfiguration())
|
||||||
{
|
{
|
||||||
AirspySampleRate sampleRate = getSampleRate(getConfiguration().getSampleRate());
|
getSampleRateCombo().setValue(getSampleRate(getConfiguration().getSampleRate()));
|
||||||
getSampleRateCombo().setSelectedItem(sampleRate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>());
|
getSampleRateCombo().getItems().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
updateSampleRateToolTip();
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
|
||||||
"[][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel());
|
|
||||||
add(getTunerInfoButton());
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel(""));
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Gain Control"), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Mode:"));
|
|
||||||
add(getGainModeCombo(), "wrap");
|
|
||||||
|
|
||||||
add(getMasterGainLabel());
|
|
||||||
add(getMasterGainSlider());
|
|
||||||
add(getMasterGainValueLabel());
|
|
||||||
|
|
||||||
add(getIFGainLabel());
|
|
||||||
add(getIFGainSlider());
|
|
||||||
add(getIFGainValueLabel());
|
|
||||||
|
|
||||||
add(getMixerAGCCheckBox());
|
|
||||||
add(getMixerGainSlider());
|
|
||||||
add(getMixerGainValueLabel());
|
|
||||||
|
|
||||||
add(getLNAAGCCheckBox());
|
|
||||||
add(getLNAGainSlider());
|
|
||||||
add(getLNAGainValueLabel());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkbox to enable/disable Bias-T power for active antennas
|
* Checkbox to enable/disable Bias-T power for active antennas
|
||||||
*/
|
*/
|
||||||
private JCheckBox getBiasTCheckBox()
|
private CheckBox getBiasTCheckBox()
|
||||||
{
|
{
|
||||||
if(mBiasTCheckBox == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasTCheckBox.setEnabled(false);
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasTCheckBox.setToolTipText("Enable Bias-T power output for active antennas");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable Bias-T power output for active antennas"));
|
||||||
mBiasTCheckBox.addActionListener(e ->
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
{
|
if(hasTuner() && !isLoading() &&
|
||||||
if(hasTuner() && !isLoading())
|
applyToTuner("Bias-T", () -> getTuner().getController().setBiasT(mBiasTCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T", e1);
|
|
||||||
JOptionPane.showMessageDialog(mBiasTCheckBox, "Couldn't set Bias-T: " + e1.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -219,26 +141,19 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
return mBiasTCheckBox;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCheckBox getLNAAGCCheckBox()
|
private CheckBox getLNAAGCCheckBox()
|
||||||
{
|
{
|
||||||
if(mLNAAGCCheckBox == null)
|
if(mLNAAGCCheckBox == null)
|
||||||
{
|
{
|
||||||
mLNAAGCCheckBox = new JCheckBox("AGC LNA:");
|
mLNAAGCCheckBox = new CheckBox("AGC");
|
||||||
mLNAAGCCheckBox.setEnabled(false);
|
mLNAAGCCheckBox.setTooltip(new Tooltip("Automatic LNA gain control"));
|
||||||
mLNAAGCCheckBox.addActionListener(e ->
|
mLNAAGCCheckBox.setDisable(true);
|
||||||
{
|
mLNAAGCCheckBox.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
if(hasTuner() && !isLoading() && applyToTuner("LNA AGC",
|
||||||
|
() -> getTuner().getController().setLNAAGC(getLNAAGCCheckBox().isSelected())))
|
||||||
{
|
{
|
||||||
try
|
getLNAGainSlider().setDisable(getLNAAGCCheckBox().isSelected());
|
||||||
{
|
save();
|
||||||
getTuner().getController().setLNAAGC(getLNAAGCCheckBox().isSelected());
|
|
||||||
getLNAGainSlider().setEnabled(!getLNAAGCCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting LNA AGC Enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -246,26 +161,19 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
return mLNAAGCCheckBox;
|
return mLNAAGCCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCheckBox getMixerAGCCheckBox()
|
private CheckBox getMixerAGCCheckBox()
|
||||||
{
|
{
|
||||||
if(mMixerAGCCheckBox == null)
|
if(mMixerAGCCheckBox == null)
|
||||||
{
|
{
|
||||||
mMixerAGCCheckBox = new JCheckBox("AGC Mixer:");
|
mMixerAGCCheckBox = new CheckBox("AGC");
|
||||||
mMixerAGCCheckBox.setEnabled(false);
|
mMixerAGCCheckBox.setTooltip(new Tooltip("Automatic mixer gain control"));
|
||||||
mMixerAGCCheckBox.addActionListener(e ->
|
mMixerAGCCheckBox.setDisable(true);
|
||||||
{
|
mMixerAGCCheckBox.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
if(hasTuner() && !isLoading() && applyToTuner("mixer AGC",
|
||||||
|
() -> getTuner().getController().setMixerAGC(getMixerAGCCheckBox().isSelected())))
|
||||||
{
|
{
|
||||||
try
|
getMixerGainSlider().setDisable(getMixerAGCCheckBox().isSelected());
|
||||||
{
|
save();
|
||||||
getTuner().getController().setMixerAGC(getMixerAGCCheckBox().isSelected());
|
|
||||||
getMixerGainSlider().setEnabled(!getMixerAGCCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Mixer AGC Enabled");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -273,93 +181,37 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
return mMixerAGCCheckBox;
|
return mMixerAGCCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getLNAGainValueLabel()
|
private GainSlider getLNAGainSlider()
|
||||||
{
|
|
||||||
if(mLNAGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mLNAGainValueLabel = new JLabel("0");
|
|
||||||
mLNAGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mLNAGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getLNAGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mLNAGainSlider == null)
|
if(mLNAGainSlider == null)
|
||||||
{
|
{
|
||||||
mLNAGainSlider = new JSlider(JSlider.HORIZONTAL, AirspyTunerController.LNA_GAIN_MIN,
|
mLNAGainSlider = new GainSlider(AirspyTunerController.LNA_GAIN_MIN, AirspyTunerController.LNA_GAIN_MAX,
|
||||||
AirspyTunerController.LNA_GAIN_MAX, AirspyTunerController.LNA_GAIN_MIN);
|
AirspyTunerController.LNA_GAIN_MIN);
|
||||||
mLNAGainSlider.setEnabled(false);
|
mLNAGainSlider.setDisable(true);
|
||||||
mLNAGainSlider.setMajorTickSpacing(1);
|
mLNAGainSlider.setOnChange(gain -> {
|
||||||
mLNAGainSlider.setPaintTicks(true);
|
if(hasTuner() && !isLoading() &&
|
||||||
mLNAGainSlider.addChangeListener(event ->
|
applyToTuner("LNA gain", () -> getTuner().getController().setLNAGain(gain)))
|
||||||
{
|
|
||||||
int gain = mLNAGainSlider.getValue();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setLNAGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set airspy LNA gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mLNAGainSlider, "Couldn't set LNA gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLNAGainValueLabel().setText(String.valueOf(gain));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mLNAGainSlider;
|
return mLNAGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getMixerGainValueLabel()
|
private GainSlider getMixerGainSlider()
|
||||||
{
|
|
||||||
if(mMixerGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mMixerGainValueLabel = new JLabel("0");
|
|
||||||
mMixerGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMixerGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getMixerGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mMixerGainSlider == null)
|
if(mMixerGainSlider == null)
|
||||||
{
|
{
|
||||||
mMixerGainSlider = new JSlider(JSlider.HORIZONTAL, AirspyTunerController.MIXER_GAIN_MIN,
|
mMixerGainSlider = new GainSlider(AirspyTunerController.MIXER_GAIN_MIN,
|
||||||
AirspyTunerController.MIXER_GAIN_MAX, AirspyTunerController.MIXER_GAIN_MIN);
|
AirspyTunerController.MIXER_GAIN_MAX, AirspyTunerController.MIXER_GAIN_MIN);
|
||||||
mMixerGainSlider.setEnabled(false);
|
mMixerGainSlider.setDisable(true);
|
||||||
mMixerGainSlider.setMajorTickSpacing(1);
|
mMixerGainSlider.setOnChange(gain -> {
|
||||||
mMixerGainSlider.setPaintTicks(true);
|
if(hasTuner() && !isLoading() &&
|
||||||
mMixerGainSlider.addChangeListener(new ChangeListener()
|
applyToTuner("mixer gain", () -> getTuner().getController().setMixerGain(gain)))
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void stateChanged(ChangeEvent event)
|
|
||||||
{
|
{
|
||||||
int gain = mMixerGainSlider.getValue();
|
save();
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setMixerGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set airspy Mixer gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mMixerGainSlider, "Couldn't set Mixer gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getMixerGainValueLabel().setText(String.valueOf(gain));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -367,134 +219,77 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
return mMixerGainSlider;
|
return mMixerGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getIFGainLabel()
|
private GainSlider getIFGainSlider()
|
||||||
{
|
|
||||||
if(mIFGainLabel == null)
|
|
||||||
{
|
|
||||||
mIFGainLabel = new JLabel("IF:");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mIFGainLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getIFGainValueLabel()
|
|
||||||
{
|
|
||||||
if(mIFGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mIFGainValueLabel = new JLabel("0");
|
|
||||||
mIFGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mIFGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getIFGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mIFGainSlider == null)
|
if(mIFGainSlider == null)
|
||||||
{
|
{
|
||||||
mIFGainSlider = new JSlider(JSlider.HORIZONTAL, AirspyTunerController.IF_GAIN_MIN,
|
mIFGainSlider = new GainSlider(AirspyTunerController.IF_GAIN_MIN, AirspyTunerController.IF_GAIN_MAX,
|
||||||
AirspyTunerController.IF_GAIN_MAX, AirspyTunerController.IF_GAIN_MIN);
|
AirspyTunerController.IF_GAIN_MIN);
|
||||||
mIFGainSlider.setEnabled(false);
|
mIFGainSlider.setDisable(true);
|
||||||
mIFGainSlider.setMajorTickSpacing(1);
|
mIFGainSlider.setOnChange(gain -> {
|
||||||
mIFGainSlider.setPaintTicks(true);
|
if(hasTuner() && !isLoading() &&
|
||||||
mIFGainSlider.addChangeListener(event ->
|
applyToTuner("IF gain", () -> getTuner().getController().setIFGain(gain)))
|
||||||
{
|
|
||||||
int gain = mIFGainSlider.getValue();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setIFGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set airspy IF gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mIFGainSlider, "Couldn't set IF gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getIFGainValueLabel().setText(String.valueOf(gain));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mIFGainSlider;
|
return mIFGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getMasterGainLabel()
|
private GainSlider getMasterGainSlider()
|
||||||
{
|
|
||||||
if(mMasterGainLabel == null)
|
|
||||||
{
|
|
||||||
mMasterGainLabel = new JLabel("Master:");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMasterGainLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getMasterGainValueLabel()
|
|
||||||
{
|
|
||||||
if(mMasterGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mMasterGainValueLabel = new JLabel("0");
|
|
||||||
mMasterGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMasterGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getMasterGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mMasterGainSlider == null)
|
if(mMasterGainSlider == null)
|
||||||
{
|
{
|
||||||
mMasterGainSlider = new JSlider(JSlider.HORIZONTAL, AirspyTunerController.GAIN_MIN,
|
mMasterGainSlider = new GainSlider(AirspyTunerController.GAIN_MIN, AirspyTunerController.GAIN_MAX,
|
||||||
AirspyTunerController.GAIN_MAX, AirspyTunerController.GAIN_MIN);
|
AirspyTunerController.GAIN_MIN);
|
||||||
mMasterGainSlider.setEnabled(false);
|
mMasterGainSlider.setDisable(true);
|
||||||
mMasterGainSlider.setMajorTickSpacing(1);
|
mMasterGainSlider.setOnChange(value -> {
|
||||||
mMasterGainSlider.setPaintTicks(true);
|
Gain gain = Gain.getGain(getGainModeCombo().getValue(), value);
|
||||||
|
|
||||||
mMasterGainSlider.addChangeListener(event ->
|
if(hasTuner() && !isLoading() && applyToTuner("gain", () -> getTuner().getController().setGain(gain)))
|
||||||
{
|
|
||||||
GainMode mode = (GainMode)mGainModeCombo.getSelectedItem();
|
|
||||||
int value = mMasterGainSlider.getValue();
|
|
||||||
Gain gain = Gain.getGain(mode, value);
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set airspy gain to:" + gain.name(), e);
|
|
||||||
JOptionPane.showMessageDialog(mMasterGainSlider, "Couldn't set gain value to " +
|
|
||||||
gain.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMasterGainValueLabel().setText(String.valueOf(value));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mMasterGainSlider;
|
return mMasterGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<GainMode> getGainModeCombo()
|
private ComboBox<GainMode> getGainModeCombo()
|
||||||
{
|
{
|
||||||
if(mGainModeCombo == null)
|
if(mGainModeCombo == null)
|
||||||
{
|
{
|
||||||
mGainModeCombo = new JComboBox<>(GainMode.values());
|
mGainModeCombo = new ComboBox<>(FXCollections.observableArrayList(GainMode.values()));
|
||||||
mGainModeCombo.setEnabled(false);
|
mGainModeCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mGainModeCombo.addActionListener(e ->
|
mGainModeCombo.setDisable(true);
|
||||||
{
|
mGainModeCombo.setTooltip(new Tooltip("Linearity and sensitivity modes set all gains from the master " +
|
||||||
|
"gain. Custom mode sets each gain separately."));
|
||||||
|
mGainModeCombo.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
if(hasTuner() && !isLoading())
|
||||||
{
|
{
|
||||||
GainMode mode = (GainMode)mGainModeCombo.getSelectedItem();
|
Gain gain = Gain.getGain(mGainModeCombo.getValue(), getMasterGainSlider().getValue());
|
||||||
int value = getMasterGainSlider().getValue();
|
setLoading(true);
|
||||||
Gain gain = Gain.getGain(mode, value);
|
|
||||||
updateGainComponents(gain);
|
updateGainComponents(gain);
|
||||||
|
setLoading(false);
|
||||||
|
applyToTuner("gain mode", () -> {
|
||||||
|
AirspyTunerController controller = getTuner().getController();
|
||||||
|
|
||||||
|
if(gain == Gain.CUSTOM)
|
||||||
|
{
|
||||||
|
controller.setMixerAGC(getMixerAGCCheckBox().isSelected());
|
||||||
|
controller.setLNAAGC(getLNAAGCCheckBox().isSelected());
|
||||||
|
controller.setIFGain(getIFGainSlider().getValue());
|
||||||
|
controller.setMixerGain(getMixerGainSlider().getValue());
|
||||||
|
controller.setLNAGain(getLNAGainSlider().getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
controller.setGain(gain);
|
||||||
|
}
|
||||||
|
});
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -503,37 +298,23 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
return mGainModeCombo;
|
return mGainModeCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<AirspySampleRate> getSampleRateCombo()
|
private ComboBox<AirspySampleRate> getSampleRateCombo()
|
||||||
{
|
{
|
||||||
if(mSampleRateCombo == null)
|
if(mSampleRateCombo == null)
|
||||||
{
|
{
|
||||||
mSampleRateCombo = new JComboBox<>();
|
mSampleRateCombo = new ComboBox<>();
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.addActionListener(new ActionListener()
|
mSampleRateCombo.setDisable(true);
|
||||||
{
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
@Override
|
AirspySampleRate rate = mSampleRateCombo.getValue();
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
|
if(hasTuner() && !isLoading() && rate != null &&
|
||||||
|
applyToTuner("sample rate [" + rate.getLabel() + "]",
|
||||||
|
() -> getTuner().getController().setSampleRate(rate)))
|
||||||
{
|
{
|
||||||
if(hasTuner() && !isLoading())
|
//Adjust the min/max values for the sample rate.
|
||||||
{
|
adjustForSampleRate(rate.getRate());
|
||||||
AirspySampleRate rate = (AirspySampleRate)mSampleRateCombo.getSelectedItem();
|
save();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(rate);
|
|
||||||
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(rate.getRate());
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(AirspyTunerEditor.this,
|
|
||||||
"Couldn't set sample rate to " + rate.getLabel());
|
|
||||||
mLog.error("Error setting airspy sample rate", e1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -542,48 +323,29 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hyperlink button that provides tuner information
|
* Updates the enabled state of each of the gain controls according to the specified gain mode. The master gain
|
||||||
*/
|
* control is enabled for linearity and sensitivity and the individual gain controls are disabled, and vice-versa
|
||||||
private JButton getTunerInfoButton()
|
* for custom mode.
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(AirspyTunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the enabled state of each of the gain controls according to the
|
|
||||||
* specified gain mode. The master gain control is enabled for linearity
|
|
||||||
* and sensitivity and the individual gain controls are disabled, and
|
|
||||||
* vice-versa for custom mode.
|
|
||||||
*/
|
*/
|
||||||
private void updateGainComponents(Gain gain)
|
private void updateGainComponents(Gain gain)
|
||||||
{
|
{
|
||||||
if(hasTuner() && gain != null)
|
if(hasTuner() && gain != null)
|
||||||
{
|
{
|
||||||
boolean isCustom = gain.equals(Gain.CUSTOM);
|
boolean isCustom = gain.equals(Gain.CUSTOM);
|
||||||
|
getGainModeCombo().setDisable(false);
|
||||||
getGainModeCombo().setEnabled(true);
|
getGainModeCombo().setValue(gain.getGainMode());
|
||||||
getGainModeCombo().setSelectedItem(gain.getGainMode());
|
mMasterGainLabel.setDisable(isCustom);
|
||||||
getMasterGainLabel().setEnabled(!isCustom);
|
getMasterGainSlider().setDisable(isCustom);
|
||||||
getMasterGainSlider().setEnabled(!isCustom);
|
|
||||||
getMasterGainSlider().setValue(gain.getValue());
|
getMasterGainSlider().setValue(gain.getValue());
|
||||||
getMasterGainValueLabel().setEnabled(!isCustom);
|
mIFGainLabel.setDisable(!isCustom);
|
||||||
getIFGainLabel().setEnabled(isCustom);
|
getIFGainSlider().setDisable(!isCustom);
|
||||||
getIFGainSlider().setEnabled(isCustom);
|
mLNAGainLabel.setDisable(!isCustom);
|
||||||
getIFGainValueLabel().setEnabled(isCustom);
|
getLNAAGCCheckBox().setDisable(!isCustom);
|
||||||
getLNAAGCCheckBox().setEnabled(isCustom);
|
getLNAGainSlider().setDisable(!isCustom || getConfiguration().isLNAAGC());
|
||||||
getLNAGainSlider().setEnabled(isCustom && !getConfiguration().isLNAAGC());
|
mMixerGainLabel.setDisable(!isCustom);
|
||||||
getLNAGainValueLabel().setEnabled(isCustom);
|
getMixerAGCCheckBox().setDisable(!isCustom);
|
||||||
getMixerAGCCheckBox().setEnabled(isCustom);
|
getMixerGainSlider().setDisable(!isCustom || getConfiguration().isMixerAGC());
|
||||||
getMixerGainSlider().setEnabled(isCustom && !getConfiguration().isMixerAGC());
|
|
||||||
getMixerGainValueLabel().setEnabled(isCustom);
|
|
||||||
if(isCustom)
|
if(isCustom)
|
||||||
{
|
{
|
||||||
getIFGainSlider().setValue(getConfiguration().getIFGain());
|
getIFGainSlider().setValue(getConfiguration().getIFGain());
|
||||||
@@ -603,25 +365,23 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getGainModeCombo().setEnabled(false);
|
getGainModeCombo().setDisable(true);
|
||||||
getMasterGainLabel().setEnabled(false);
|
mMasterGainLabel.setDisable(true);
|
||||||
getMasterGainSlider().setEnabled(false);
|
getMasterGainSlider().setDisable(true);
|
||||||
getMasterGainSlider().setValue(0);
|
getMasterGainSlider().setValue(0);
|
||||||
getMasterGainValueLabel().setEnabled(false);
|
mIFGainLabel.setDisable(true);
|
||||||
getIFGainLabel().setEnabled(false);
|
getIFGainSlider().setDisable(true);
|
||||||
getIFGainSlider().setEnabled(false);
|
|
||||||
getIFGainSlider().setValue(0);
|
getIFGainSlider().setValue(0);
|
||||||
getIFGainValueLabel().setEnabled(false);
|
mLNAGainLabel.setDisable(true);
|
||||||
getLNAAGCCheckBox().setEnabled(false);
|
getLNAAGCCheckBox().setDisable(true);
|
||||||
getLNAAGCCheckBox().setSelected(false);
|
getLNAAGCCheckBox().setSelected(false);
|
||||||
getLNAGainSlider().setEnabled(false);
|
getLNAGainSlider().setDisable(true);
|
||||||
getLNAGainSlider().setValue(0);
|
getLNAGainSlider().setValue(0);
|
||||||
getLNAGainValueLabel().setEnabled(false);
|
mMixerGainLabel.setDisable(true);
|
||||||
getMixerAGCCheckBox().setEnabled(false);
|
getMixerAGCCheckBox().setDisable(true);
|
||||||
getMixerAGCCheckBox().setSelected(false);
|
getMixerAGCCheckBox().setSelected(false);
|
||||||
getMixerGainSlider().setEnabled(false);
|
getMixerGainSlider().setDisable(true);
|
||||||
getMixerGainSlider().setValue(0);
|
getMixerGainSlider().setValue(0);
|
||||||
getMixerGainValueLabel().setEnabled(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,21 +390,21 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
AirspyTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
if(getSampleRateCombo().getValue() != null)
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
{
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setSampleRate(getSampleRateCombo().getValue().getRate());
|
||||||
getConfiguration().setSampleRate(((AirspySampleRate)getSampleRateCombo().getSelectedItem()).getRate());
|
}
|
||||||
Gain gain = Gain.getGain((GainMode)mGainModeCombo.getSelectedItem(), getMasterGainSlider().getValue());
|
|
||||||
getConfiguration().setGain(gain);
|
config.setGain(Gain.getGain(getGainModeCombo().getValue(), getMasterGainSlider().getValue()));
|
||||||
getConfiguration().setIFGain(getIFGainSlider().getValue());
|
config.setIFGain(getIFGainSlider().getValue());
|
||||||
getConfiguration().setMixerGain(getMixerGainSlider().getValue());
|
config.setMixerGain(getMixerGainSlider().getValue());
|
||||||
getConfiguration().setLNAGain(getLNAGainSlider().getValue());
|
config.setLNAGain(getLNAGainSlider().getValue());
|
||||||
getConfiguration().setMixerAGC(getMixerAGCCheckBox().isSelected());
|
config.setMixerAGC(getMixerAGCCheckBox().isSelected());
|
||||||
getConfiguration().setLNAAGC(getLNAAGCCheckBox().isSelected());
|
config.setLNAAGC(getLNAAGCCheckBox().isSelected());
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -668,7 +428,7 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rates.size() > 0)
|
if(!rates.isEmpty())
|
||||||
{
|
{
|
||||||
return rates.get(0);
|
return rates.get(0);
|
||||||
}
|
}
|
||||||
@@ -684,56 +444,32 @@ public class AirspyTunerEditor extends TunerEditor<AirspyTuner, AirspyTunerConfi
|
|||||||
{
|
{
|
||||||
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
getSampleRateCombo().setTooltip(new Tooltip("Sample rate is locked. Disable decoding channels to unlock."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
getSampleRateCombo().setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
getSampleRateCombo().setDisable(!hasTuner() || locked);
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
updateSampleRateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTunerInfo()
|
@Override
|
||||||
|
protected String getTunerInfo()
|
||||||
{
|
{
|
||||||
if(getDiscoveredTuner().getTunerStatus() == TunerStatus.ERROR)
|
StringBuilder sb = new StringBuilder();
|
||||||
{
|
AirspyDeviceInformation info = getTuner().getController().getDeviceInfo();
|
||||||
return getDiscoveredTuner().getErrorMessage();
|
sb.append("<html><h3>Airspy Tuner</h3>");
|
||||||
}
|
sb.append("<b>Serial: </b>").append(info.getSerialNumber()).append("<br>");
|
||||||
|
String[] firmware = info.getVersion().split(" ");
|
||||||
if(hasTuner())
|
sb.append("<b>Firmware: </b>").append(firmware.length > 1 ? firmware[0] : info.getVersion()).append("<br>");
|
||||||
{
|
sb.append("<b>Part: </b>").append(info.getPartNumber()).append("<br>");
|
||||||
StringBuilder sb = new StringBuilder();
|
sb.append("<b>Board: </b>").append(info.getBoardName()).append("<br>");
|
||||||
|
return sb.toString();
|
||||||
AirspyDeviceInformation info = getTuner().getController().getDeviceInfo();
|
|
||||||
|
|
||||||
sb.append("<html><h3>Airspy Tuner</h3>");
|
|
||||||
sb.append("<b>Serial: </b>");
|
|
||||||
sb.append(info.getSerialNumber());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Firmware: </b>");
|
|
||||||
String[] firmware = info.getVersion().split(" ");
|
|
||||||
sb.append(firmware.length > 1 ? firmware[0] : info.getVersion());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Part: </b>");
|
|
||||||
sb.append(info.getPartNumber());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Board: </b>");
|
|
||||||
sb.append(info.getBoardName());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,50 +16,40 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.airspy.hf;
|
package io.github.dsheirer.source.tuner.airspy.hf;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.SourceException;
|
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import org.slf4j.Logger;
|
import javafx.collections.FXCollections;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.CheckBox;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
import javax.swing.JComboBox;
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tuner editor for Airspy HF+/Discovery tuners
|
* Airspy HF+ tuner editor
|
||||||
*/
|
*/
|
||||||
public class AirspyHfTunerEditor extends TunerEditor<AirspyHfTuner,AirspyHfTunerConfiguration>
|
public class AirspyHfTunerEditor extends TunerEditor<AirspyHfTuner,AirspyHfTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(AirspyHfTunerEditor.class);
|
private ComboBox<AirspyHfSampleRate> mSampleRateCombo;
|
||||||
private JComboBox<AirspyHfSampleRate> mSampleRateCombo;
|
private ComboBox<Attenuation> mAttenuationCombo;
|
||||||
private JComboBox<Attenuation> mAttenuationCombo;
|
private CheckBox mAgcCheckBox;
|
||||||
private JToggleButton mAgcToggleButton;
|
private CheckBox mLnaCheckBox;
|
||||||
private JToggleButton mLnaToggleButton;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JToggleButton mBiasTToggleButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
*
|
* @param userPreferences for settings
|
||||||
* @param userPreferences
|
* @param tunerManager for state updates
|
||||||
* @param tunerManager for requesting configuration saves.
|
* @param discoveredTuner to edit or control.
|
||||||
* @param discoveredTuner
|
|
||||||
*/
|
*/
|
||||||
public AirspyHfTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
public AirspyHfTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -76,61 +66,41 @@ public class AirspyHfTunerEditor extends TunerEditor<AirspyHfTuner,AirspyHfTuner
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
"[][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
TunerSection gain = addSection("Gain");
|
||||||
add(getTunerIdLabel(), "wrap");
|
gain.addRow("Attenuation", getAttenuationCombo(), getAgcCheckBox());
|
||||||
|
gain.addControl(getLnaCheckBox());
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
TunerSection options = addSection("Options");
|
||||||
add(getTunerStatusLabel(), "wrap");
|
options.addControl(getBiasTCheckBox());
|
||||||
|
}
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
@Override
|
||||||
|
protected String getTunerInfo()
|
||||||
add(new JSeparator(), "span,growx,push");
|
{
|
||||||
|
AirspyHfTunerController controller = getTuner().getController();
|
||||||
add(new JLabel("Frequency (MHz):"));
|
return "<html><h3>Airspy HF+ Tuner</h3>" +
|
||||||
add(getFrequencyPanel(), "wrap");
|
"<b>Board: </b>" + controller.getBoardId() + "<br>" +
|
||||||
|
"<b>Serial: </b>" + controller.getSerialNumber() + "<br>" +
|
||||||
add(new JLabel("Sample Rate:"));
|
"<b>Firmware: </b>" + controller.getFirmwareVersion() + "<br>";
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span");
|
|
||||||
|
|
||||||
JPanel buttonPanel = new JPanel();
|
|
||||||
buttonPanel.setLayout(new MigLayout("insets 0", "[left]", ""));
|
|
||||||
buttonPanel.add(getAgcToggleButton());
|
|
||||||
buttonPanel.add(getLnaToggleButton());
|
|
||||||
buttonPanel.add(getBiasTToggleButton());
|
|
||||||
add(new JLabel(" "));
|
|
||||||
add(buttonPanel, "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Attenuation:"));
|
|
||||||
add(getAttenuationCombo(), "wrap");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void save()
|
protected void save()
|
||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && hasTuner() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
AirspyHfTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setSampleRate((int)getTuner().getController().getSampleRate());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setAttenuation(getAttenuationCombo().getValue());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setAgc(getAgcCheckBox().isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setLna(getLnaCheckBox().isSelected());
|
||||||
getConfiguration().setSampleRate((int)getTuner().getController().getSampleRate());
|
|
||||||
|
|
||||||
Attenuation attenuation = (Attenuation)getAttenuationCombo().getSelectedItem();
|
|
||||||
getConfiguration().setAttenuation(attenuation);
|
|
||||||
getConfiguration().setAgc(getAgcToggleButton().isSelected());
|
|
||||||
getConfiguration().setLna(getLnaToggleButton().isSelected());
|
|
||||||
|
|
||||||
//Only update bias-T when the device supports it, so the saved setting isn't lost on unsupported firmware.
|
|
||||||
if(getTuner().getController().isBiasTSupported())
|
if(getTuner().getController().isBiasTSupported())
|
||||||
{
|
{
|
||||||
getConfiguration().setBiasT(getBiasTToggleButton().isSelected());
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
@@ -140,123 +110,80 @@ public class AirspyHfTunerEditor extends TunerEditor<AirspyHfTuner,AirspyHfTuner
|
|||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
if(hasTuner())
|
if(hasTuner())
|
||||||
{
|
{
|
||||||
getTunerIdLabel().setText("Airspy " + getTuner().getController().getBoardId() + " SER# " +
|
AirspyHfTunerController controller = getTuner().getController();
|
||||||
getTuner().getController().getSerialNumber() + " FW " + getTuner().getController().getFirmwareVersion());
|
getSampleRateCombo().setDisable(controller.isLockedSampleRate());
|
||||||
|
getSampleRateCombo().getItems().setAll(controller.getAvailableSampleRates());
|
||||||
getSampleRateCombo().setEnabled(!getTuner().getTunerController().isLockedSampleRate());
|
getSampleRateCombo().setValue(controller.getCurrentAirspySampleRate());
|
||||||
getSampleRateCombo().removeAllItems();
|
getAgcCheckBox().setDisable(false);
|
||||||
for(AirspyHfSampleRate sampleRate: getTuner().getController().getAvailableSampleRates())
|
getAgcCheckBox().setSelected(controller.getAgc());
|
||||||
{
|
getLnaCheckBox().setDisable(false);
|
||||||
getSampleRateCombo().addItem(sampleRate);
|
getLnaCheckBox().setSelected(controller.getLna());
|
||||||
}
|
boolean biasTSupported = controller.isBiasTSupported();
|
||||||
getAgcToggleButton().setEnabled(true);
|
getBiasTCheckBox().setDisable(!biasTSupported);
|
||||||
getAgcToggleButton().setSelected(getTuner().getController().getAgc());
|
getBiasTCheckBox().setSelected(biasTSupported && controller.getBiasT());
|
||||||
getLnaToggleButton().setEnabled(true);
|
getBiasTCheckBox().setTooltip(new Tooltip(biasTSupported ? "Enable Bias-T power output for active " +
|
||||||
getLnaToggleButton().setSelected(getTuner().getController().getLna());
|
"antennas" : "Bias-T not supported by this device or firmware"));
|
||||||
boolean biasTSupported = getTuner().getController().isBiasTSupported();
|
getAttenuationCombo().setDisable(controller.getAgc());
|
||||||
getBiasTToggleButton().setEnabled(biasTSupported);
|
getAttenuationCombo().setValue(controller.getAttenuation());
|
||||||
getBiasTToggleButton().setSelected(biasTSupported && getTuner().getController().getBiasT());
|
|
||||||
getBiasTToggleButton().setToolTipText(biasTSupported ? "Enable Bias-T power output for active antennas" :
|
|
||||||
"Bias-T not supported by this device or firmware");
|
|
||||||
getSampleRateCombo().setSelectedItem(getTuner().getController().getCurrentAirspySampleRate());
|
|
||||||
getAttenuationCombo().setEnabled(!getTuner().getController().getAgc());
|
|
||||||
getAttenuationCombo().setSelectedItem(getTuner().getController().getAttenuation());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getTunerIdLabel().setText("Airspy HF+");
|
getAgcCheckBox().setDisable(true);
|
||||||
getAgcToggleButton().setEnabled(false);
|
getAgcCheckBox().setSelected(false);
|
||||||
getAgcToggleButton().setSelected(false);
|
getLnaCheckBox().setDisable(true);
|
||||||
getLnaToggleButton().setEnabled(false);
|
getLnaCheckBox().setSelected(false);
|
||||||
getLnaToggleButton().setSelected(false);
|
getBiasTCheckBox().setDisable(true);
|
||||||
getBiasTToggleButton().setEnabled(false);
|
getBiasTCheckBox().setSelected(false);
|
||||||
getBiasTToggleButton().setSelected(false);
|
getBiasTCheckBox().setTooltip(new Tooltip("No tuner available"));
|
||||||
getBiasTToggleButton().setToolTipText("No tuner available");
|
getSampleRateCombo().setDisable(true);
|
||||||
getSampleRateCombo().setEnabled(false);
|
getAttenuationCombo().setDisable(true);
|
||||||
getAttenuationCombo().setEnabled(false);
|
getAttenuationCombo().setValue(Attenuation.A0);
|
||||||
getAttenuationCombo().setSelectedItem(Attenuation.A0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSampleRateToolTip();
|
updateSampleRateToolTip();
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
private void updateSampleRateToolTip()
|
||||||
{
|
{
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
getSampleRateCombo().setTooltip(new Tooltip("Sample rate is locked. Disable decoding channels to unlock."));
|
||||||
}
|
}
|
||||||
else if(hasTuner())
|
else if(hasTuner())
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
getSampleRateCombo().setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
getSampleRateCombo().setTooltip(new Tooltip("No tuner available"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
getSampleRateCombo().setDisable(!hasTuner() || locked);
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
updateSampleRateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private ComboBox<AirspyHfSampleRate> getSampleRateCombo()
|
||||||
* Sample rate combo for selecting among available sample rates.
|
|
||||||
* @return sample rate combo
|
|
||||||
*/
|
|
||||||
private JComboBox<AirspyHfSampleRate> getSampleRateCombo()
|
|
||||||
{
|
{
|
||||||
if(mSampleRateCombo == null)
|
if(mSampleRateCombo == null)
|
||||||
{
|
{
|
||||||
mSampleRateCombo = new JComboBox<>();
|
mSampleRateCombo = new ComboBox<>();
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.addActionListener(e ->
|
mSampleRateCombo.setDisable(true);
|
||||||
{
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
if(!isLoading())
|
AirspyHfSampleRate sampleRate = mSampleRateCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && sampleRate != null &&
|
||||||
|
applyToTuner("sample rate [" + sampleRate + "]",
|
||||||
|
() -> getTuner().getController().setSampleRate(sampleRate)))
|
||||||
{
|
{
|
||||||
AirspyHfSampleRate sampleRate = (AirspyHfSampleRate)mSampleRateCombo.getSelectedItem();
|
adjustForSampleRate(sampleRate.getSampleRate());
|
||||||
|
save();
|
||||||
if(sampleRate != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(sampleRate);
|
|
||||||
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(sampleRate.getSampleRate());
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Airspy Hf Sample Rate [" + sampleRate + "]", se);
|
|
||||||
JOptionPane.showMessageDialog(AirspyHfTunerEditor.this,
|
|
||||||
"Airspy Tuner Controller - couldn't apply the sample rate setting [" +
|
|
||||||
sampleRate + "] " + se.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -264,33 +191,22 @@ public class AirspyHfTunerEditor extends TunerEditor<AirspyHfTuner,AirspyHfTuner
|
|||||||
return mSampleRateCombo;
|
return mSampleRateCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private ComboBox<Attenuation> getAttenuationCombo()
|
||||||
* Combobox with available attenuation items
|
|
||||||
* @return combo box
|
|
||||||
*/
|
|
||||||
private JComboBox<Attenuation> getAttenuationCombo()
|
|
||||||
{
|
{
|
||||||
if(mAttenuationCombo == null)
|
if(mAttenuationCombo == null)
|
||||||
{
|
{
|
||||||
mAttenuationCombo = new JComboBox<>(Attenuation.values());
|
mAttenuationCombo = new ComboBox<>(FXCollections.observableArrayList(Attenuation.values()));
|
||||||
mAttenuationCombo.setToolTipText("Attenuation applies when the AGC is off");
|
mAttenuationCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mAttenuationCombo.setEnabled(false);
|
mAttenuationCombo.setTooltip(new Tooltip("Attenuation applies when the AGC is off"));
|
||||||
mAttenuationCombo.addActionListener(e -> {
|
mAttenuationCombo.setDisable(true);
|
||||||
if(!isLoading())
|
mAttenuationCombo.setOnAction(e -> {
|
||||||
|
Attenuation selected = mAttenuationCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && selected != null &&
|
||||||
|
applyToTuner("attenuation [" + selected + "]",
|
||||||
|
() -> getTuner().getController().setAttenuation(selected)))
|
||||||
{
|
{
|
||||||
Attenuation selected = (Attenuation)mAttenuationCombo.getSelectedItem();
|
save();
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setAttenuation(selected);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Airspy Hf attenuation [" + selected + "]", se);
|
|
||||||
JOptionPane.showMessageDialog(AirspyHfTunerEditor.this,
|
|
||||||
"Airspy Tuner Controller - couldn't apply attenuation setting [" +
|
|
||||||
selected + "] " + se.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -298,98 +214,67 @@ public class AirspyHfTunerEditor extends TunerEditor<AirspyHfTuner,AirspyHfTuner
|
|||||||
return mAttenuationCombo;
|
return mAttenuationCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private CheckBox getAgcCheckBox()
|
||||||
* Automatic Gain Control (AGC) toggle button
|
|
||||||
*/
|
|
||||||
private JToggleButton getAgcToggleButton()
|
|
||||||
{
|
{
|
||||||
if(mAgcToggleButton == null)
|
if(mAgcCheckBox == null)
|
||||||
{
|
{
|
||||||
mAgcToggleButton = new JToggleButton("AGC");
|
mAgcCheckBox = new CheckBox("AGC");
|
||||||
mAgcToggleButton.setToolTipText("Automatic Gain Control");
|
mAgcCheckBox.setTooltip(new Tooltip("Automatic gain control"));
|
||||||
mAgcToggleButton.setEnabled(false);
|
mAgcCheckBox.setDisable(true);
|
||||||
mAgcToggleButton.addActionListener(e -> {
|
mAgcCheckBox.setOnAction(e -> {
|
||||||
if(!isLoading())
|
if(!isLoading() && hasTuner() &&
|
||||||
|
applyToTuner("AGC", () -> getTuner().getController().setAgc(mAgcCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
getAttenuationCombo().setDisable(mAgcCheckBox.isSelected());
|
||||||
{
|
save();
|
||||||
getTuner().getController().setAgc(mAgcToggleButton.isSelected());
|
|
||||||
getAttenuationCombo().setEnabled(!mAgcToggleButton.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Airspy HF AGC", se);
|
|
||||||
JOptionPane.showMessageDialog(AirspyHfTunerEditor.this,
|
|
||||||
"Airspy HF Tuner Controller - couldn't change AGC setting" + se.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mAgcToggleButton;
|
return mAgcCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private CheckBox getLnaCheckBox()
|
||||||
* Low Noise Amplifier (LNA) toggle button
|
|
||||||
*/
|
|
||||||
private JToggleButton getLnaToggleButton()
|
|
||||||
{
|
{
|
||||||
if(mLnaToggleButton == null)
|
if(mLnaCheckBox == null)
|
||||||
{
|
{
|
||||||
mLnaToggleButton = new JToggleButton("LNA");
|
mLnaCheckBox = new CheckBox("LNA (low noise amplifier)");
|
||||||
mLnaToggleButton.setToolTipText("Low Noise Amplifier");
|
mLnaCheckBox.setTooltip(new Tooltip("Turn on the low noise amplifier"));
|
||||||
mLnaToggleButton.setEnabled(false);
|
mLnaCheckBox.setDisable(true);
|
||||||
mLnaToggleButton.addActionListener(e -> {
|
mLnaCheckBox.setOnAction(e -> {
|
||||||
if(!isLoading())
|
if(!isLoading() && hasTuner() &&
|
||||||
|
applyToTuner("LNA", () -> getTuner().getController().setLna(mLnaCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setLna(mLnaToggleButton.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Airspy HF LNA", se);
|
|
||||||
JOptionPane.showMessageDialog(AirspyHfTunerEditor.this,
|
|
||||||
"Airspy HF Tuner Controller - couldn't change LNA setting" + se.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mLnaToggleButton;
|
return mLnaCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private CheckBox getBiasTCheckBox()
|
||||||
* Bias-T toggle button, enabled only when the device firmware supports a bias-T.
|
|
||||||
*/
|
|
||||||
private JToggleButton getBiasTToggleButton()
|
|
||||||
{
|
{
|
||||||
if(mBiasTToggleButton == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasTToggleButton = new JToggleButton("Bias-T");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasTToggleButton.setToolTipText("Enable Bias-T power output for active antennas");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable Bias-T power output for active antennas"));
|
||||||
mBiasTToggleButton.setEnabled(false);
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasTToggleButton.addActionListener(e -> {
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
if(hasTuner() && !isLoading())
|
||||||
{
|
{
|
||||||
try
|
if(applyToTuner("Bias-T", () -> getTuner().getController().setBiasT(mBiasTCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
getTuner().getController().setBiasT(mBiasTToggleButton.isSelected());
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
catch(SourceException se)
|
else
|
||||||
{
|
{
|
||||||
mLog.error("Error setting Airspy HF Bias-T", se);
|
mBiasTCheckBox.setSelected(getTuner().getController().getBiasT());
|
||||||
mBiasTToggleButton.setSelected(getTuner().getController().getBiasT());
|
|
||||||
JOptionPane.showMessageDialog(AirspyHfTunerEditor.this,
|
|
||||||
"Airspy HF Tuner Controller - couldn't change Bias-T setting " + se.getLocalizedMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mBiasTToggleButton;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.bladerf;
|
package io.github.dsheirer.source.tuner.bladerf;
|
||||||
|
|
||||||
import io.github.dsheirer.bladerf.GainMode;
|
import io.github.dsheirer.bladerf.GainMode;
|
||||||
@@ -25,41 +24,26 @@ import io.github.dsheirer.bladerf.Range;
|
|||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import io.github.dsheirer.source.tuner.ui.GainSlider;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import java.awt.Component;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import java.io.Serial;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.ComboBox;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javafx.util.StringConverter;
|
||||||
import javax.swing.DefaultListCellRenderer;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JList;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bladeRF tuner editor
|
* bladeRF tuner editor. sdrtrunk uses the RX1 connector as a single tuner.
|
||||||
*/
|
*/
|
||||||
public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerConfiguration>
|
public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerConfiguration>
|
||||||
{
|
{
|
||||||
@Serial
|
private ComboBox<BladeRfSampleRate> mSampleRateCombo;
|
||||||
private static final long serialVersionUID = 1L;
|
private CheckBox mBiasTCheckBox;
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(BladeRfTunerEditor.class);
|
private ComboBox<GainModeInfo> mGainModeCombo;
|
||||||
private JButton mTunerInfoButton;
|
private GainSlider mGainSlider;
|
||||||
private JComboBox<BladeRfSampleRate> mSampleRateCombo;
|
private Label mGainLabel;
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
private JComboBox<GainModeInfo> mGainModeCombo;
|
|
||||||
private JSlider mGainSlider;
|
|
||||||
private JLabel mGainValueLabel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -71,7 +55,7 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,78 +74,33 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]", "[][][][][][][][][][][][grow]"));
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
TunerSection gain = addSection("Gain");
|
||||||
add(getTunerIdLabel());
|
gain.addRow("Mode", getGainModeCombo());
|
||||||
add(getTunerInfoButton());
|
mGainLabel = gain.addRow("Gain", getGainSlider());
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
TunerSection options = addSection("Options");
|
||||||
add(getTunerStatusLabel(), "wrap");
|
options.addControl(getBiasTCheckBox());
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx");
|
|
||||||
add(new JLabel("Gain Control"), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Mode:"));
|
|
||||||
add(getGainModeCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainSlider());
|
|
||||||
add(getGainValueLabel());
|
|
||||||
|
|
||||||
//Empty row that takes all extra vertical space so that the controls stay stacked at the top of the editor.
|
|
||||||
add(new JLabel(), "span,pushy");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
if(hasStartedTuner())
|
||||||
|
|
||||||
boolean started = hasStartedTuner();
|
|
||||||
getTunerIdLabel().setText(started ? getTuner().getPreferredName() : getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getTunerInfoButton().setEnabled(started);
|
|
||||||
|
|
||||||
if(started)
|
|
||||||
{
|
{
|
||||||
BladeRfTunerController controller = getTuner().getController();
|
BladeRfTunerController controller = getTuner().getController();
|
||||||
List<BladeRfSampleRate> rates = controller.getSampleRates();
|
List<BladeRfSampleRate> rates = controller.getSampleRates();
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>(rates.toArray(new BladeRfSampleRate[0])));
|
getSampleRateCombo().getItems().setAll(rates);
|
||||||
getSampleRateCombo().setSelectedItem(controller.getBladeRfSampleRate());
|
getSampleRateCombo().setValue(controller.getBladeRfSampleRate());
|
||||||
getSampleRateCombo().setEnabled(!controller.isLockedSampleRate());
|
getSampleRateCombo().setDisable(controller.isLockedSampleRate());
|
||||||
|
|
||||||
getBiasTCheckBox().setVisible(controller.isBiasTSupported());
|
getBiasTCheckBox().setVisible(controller.isBiasTSupported());
|
||||||
getBiasTCheckBox().setEnabled(true);
|
getBiasTCheckBox().setDisable(false);
|
||||||
|
|
||||||
List<GainModeInfo> modes = controller.getGainModes();
|
List<GainModeInfo> modes = controller.getGainModes();
|
||||||
getGainModeCombo().setModel(new DefaultComboBoxModel<>(modes.toArray(new GainModeInfo[0])));
|
getGainModeCombo().getItems().setAll(modes);
|
||||||
getGainModeCombo().setEnabled(true);
|
getGainModeCombo().setDisable(false);
|
||||||
|
|
||||||
Range range = controller.getGainRange();
|
Range range = controller.getGainRange();
|
||||||
getGainSlider().setMinimum((int)range.min());
|
getGainSlider().setRange((int)range.min(), (int)range.max());
|
||||||
getGainSlider().setMaximum((int)range.max());
|
|
||||||
|
|
||||||
if(hasConfiguration())
|
if(hasConfiguration())
|
||||||
{
|
{
|
||||||
@@ -172,7 +111,7 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
{
|
{
|
||||||
if(mode.mode() == getConfiguration().getGainMode())
|
if(mode.mode() == getConfiguration().getGainMode())
|
||||||
{
|
{
|
||||||
getGainModeCombo().setSelectedItem(mode);
|
getGainModeCombo().setValue(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,81 +120,50 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>());
|
getSampleRateCombo().getItems().clear();
|
||||||
getSampleRateCombo().setEnabled(false);
|
getSampleRateCombo().setDisable(true);
|
||||||
getBiasTCheckBox().setEnabled(false);
|
getBiasTCheckBox().setDisable(true);
|
||||||
getBiasTCheckBox().setSelected(false);
|
getBiasTCheckBox().setSelected(false);
|
||||||
getGainModeCombo().setModel(new DefaultComboBoxModel<>());
|
getGainModeCombo().getItems().clear();
|
||||||
getGainModeCombo().setEnabled(false);
|
getGainModeCombo().setDisable(true);
|
||||||
getGainSlider().setEnabled(false);
|
getGainSlider().setDisable(true);
|
||||||
getGainValueLabel().setEnabled(false);
|
mGainLabel.setDisable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the tuner has finished starting, since a status update can arrive while it's starting or restarting.
|
* Indicates if the tuner is started, which is when the controller has the gain range.
|
||||||
*/
|
*/
|
||||||
private boolean hasStartedTuner()
|
private boolean hasStartedTuner()
|
||||||
{
|
{
|
||||||
return hasTuner() && getTuner().getController().getGainRange() != null;
|
return hasTuner() && getTuner().getController().getGainRange() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables the gain slider when the gain mode is manual and refreshes the gain value label.
|
|
||||||
*/
|
|
||||||
private void updateGainControls()
|
private void updateGainControls()
|
||||||
{
|
{
|
||||||
GainModeInfo mode = (GainModeInfo)getGainModeCombo().getSelectedItem();
|
GainModeInfo mode = getGainModeCombo().getValue();
|
||||||
boolean manual = hasTuner() && mode != null && mode.mode() == GainMode.MANUAL;
|
boolean manual = hasTuner() && mode != null && mode.mode() == GainMode.MANUAL;
|
||||||
getGainSlider().setEnabled(manual);
|
getGainSlider().setDisable(!manual);
|
||||||
getGainValueLabel().setEnabled(manual);
|
mGainLabel.setDisable(!manual);
|
||||||
getGainValueLabel().setText(manual ? getGainSlider().getValue() + " dB" : "AGC");
|
getGainSlider().setFormatter(value -> manual ? value + " dB" : "AGC");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private ComboBox<BladeRfSampleRate> getSampleRateCombo()
|
||||||
* Button that provides tuner information
|
|
||||||
*/
|
|
||||||
private JButton getTunerInfoButton()
|
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(_ -> JOptionPane.showMessageDialog(BladeRfTunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JComboBox<BladeRfSampleRate> getSampleRateCombo()
|
|
||||||
{
|
{
|
||||||
if(mSampleRateCombo == null)
|
if(mSampleRateCombo == null)
|
||||||
{
|
{
|
||||||
mSampleRateCombo = new JComboBox<>();
|
mSampleRateCombo = new ComboBox<>();
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.addActionListener(_ ->
|
mSampleRateCombo.setDisable(true);
|
||||||
{
|
mSampleRateCombo.setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
if(hasTuner() && !isLoading())
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
|
BladeRfSampleRate rate = mSampleRateCombo.getValue();
|
||||||
|
|
||||||
|
if(hasTuner() && !isLoading() && rate != null &&
|
||||||
|
applyToTuner("sample rate [" + rate + "]", () -> getTuner().getController().setSampleRate(rate)))
|
||||||
{
|
{
|
||||||
BladeRfSampleRate rate = (BladeRfSampleRate)mSampleRateCombo.getSelectedItem();
|
adjustForSampleRate(rate.getRate());
|
||||||
|
save();
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(rate);
|
|
||||||
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(rate.getRate());
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting bladeRF sample rate", e1);
|
|
||||||
JOptionPane.showMessageDialog(BladeRfTunerEditor.this, "Couldn't set sample rate to " + rate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -263,30 +171,19 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
return mSampleRateCombo;
|
return mSampleRateCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private CheckBox getBiasTCheckBox()
|
||||||
* Checkbox to enable/disable Bias-T power for active antennas
|
|
||||||
*/
|
|
||||||
private JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
{
|
||||||
if(mBiasTCheckBox == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasTCheckBox.setEnabled(false);
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasTCheckBox.setToolTipText("Enable Bias-T power output for active antennas. Also powers the RX2 connector.");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable Bias-T power output for active antennas. Also powers the " +
|
||||||
mBiasTCheckBox.addActionListener(_ ->
|
"RX2 connector."));
|
||||||
{
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
if(hasTuner() && !isLoading() &&
|
||||||
|
applyToTuner("Bias-T", () -> getTuner().getController().setBiasT(mBiasTCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T", e1);
|
|
||||||
JOptionPane.showMessageDialog(mBiasTCheckBox, "Couldn't set Bias-T: " + e1.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -294,39 +191,36 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
return mBiasTCheckBox;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<GainModeInfo> getGainModeCombo()
|
private ComboBox<GainModeInfo> getGainModeCombo()
|
||||||
{
|
{
|
||||||
if(mGainModeCombo == null)
|
if(mGainModeCombo == null)
|
||||||
{
|
{
|
||||||
mGainModeCombo = new JComboBox<>();
|
mGainModeCombo = new ComboBox<>();
|
||||||
mGainModeCombo.setEnabled(false);
|
mGainModeCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mGainModeCombo.setRenderer(new DefaultListCellRenderer()
|
mGainModeCombo.setDisable(true);
|
||||||
|
mGainModeCombo.setConverter(new StringConverter<>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean selected,
|
public String toString(GainModeInfo mode)
|
||||||
boolean focused)
|
|
||||||
{
|
{
|
||||||
Object label = value instanceof GainModeInfo mode ? mode.name() : value;
|
return mode == null ? "" : mode.name();
|
||||||
return super.getListCellRendererComponent(list, label, index, selected, focused);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GainModeInfo fromString(String text)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mGainModeCombo.addActionListener(_ ->
|
mGainModeCombo.setOnAction(e -> {
|
||||||
{
|
GainModeInfo mode = mGainModeCombo.getValue();
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
GainModeInfo mode = (GainModeInfo)mGainModeCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
if(hasTuner() && !isLoading() && mode != null &&
|
||||||
{
|
applyToTuner("gain mode [" + mode.name() + "]",
|
||||||
getTuner().getController().setGainMode(mode.mode());
|
() -> getTuner().getController().setGainMode(mode.mode())))
|
||||||
updateGainControls();
|
{
|
||||||
save();
|
updateGainControls();
|
||||||
}
|
save();
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting bladeRF gain mode", e1);
|
|
||||||
JOptionPane.showMessageDialog(mGainModeCombo, "Couldn't set gain mode to " + mode.name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -334,107 +228,73 @@ public class BladeRfTunerEditor extends TunerEditor<BladeRfTuner, BladeRfTunerCo
|
|||||||
return mGainModeCombo;
|
return mGainModeCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSlider getGainSlider()
|
private GainSlider getGainSlider()
|
||||||
{
|
{
|
||||||
if(mGainSlider == null)
|
if(mGainSlider == null)
|
||||||
{
|
{
|
||||||
mGainSlider = new JSlider(JSlider.HORIZONTAL, 0, 60, BladeRfTunerController.GAIN_DEFAULT);
|
mGainSlider = new GainSlider(0, 60, BladeRfTunerController.GAIN_DEFAULT);
|
||||||
mGainSlider.setEnabled(false);
|
mGainSlider.setDisable(true);
|
||||||
mGainSlider.setMajorTickSpacing(5);
|
mGainSlider.setFormatter(value -> value + " dB");
|
||||||
mGainSlider.setPaintTicks(true);
|
mGainSlider.setOnChange(gain -> {
|
||||||
mGainSlider.addChangeListener(_ ->
|
if(hasTuner() && !isLoading() &&
|
||||||
{
|
applyToTuner("gain", () -> getTuner().getController().setGain(gain)))
|
||||||
int gain = mGainSlider.getValue();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set bladeRF gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mGainSlider, "Couldn't set gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGainControls();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mGainSlider;
|
return mGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getGainValueLabel()
|
|
||||||
{
|
|
||||||
if(mGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mGainValueLabel = new JLabel("0 dB");
|
|
||||||
mGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
BladeRfTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
|
|
||||||
if(getSampleRateCombo().getSelectedItem() instanceof BladeRfSampleRate rate)
|
if(getSampleRateCombo().getValue() instanceof BladeRfSampleRate rate)
|
||||||
{
|
{
|
||||||
getConfiguration().setSampleRate(rate.getRate());
|
config.setSampleRate(rate.getRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getGainModeCombo().getSelectedItem() instanceof GainModeInfo mode)
|
if(getGainModeCombo().getValue() instanceof GainModeInfo mode)
|
||||||
{
|
{
|
||||||
getConfiguration().setGainMode(mode.mode());
|
config.setGainMode(mode.mode());
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfiguration().setGain(getGainSlider().getValue());
|
config.setGain(getGainSlider().getValue());
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
getSampleRateCombo().setDisable(!hasStartedTuner() || locked);
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
getSampleRateCombo().setTooltip(new Tooltip(locked ? "Sample rate is locked. Disable decoding channels " +
|
||||||
getSampleRateCombo().setToolTipText(locked ? "Sample Rate is locked. Disable decoding channels to unlock." :
|
"to unlock." : "Select a sample rate for the tuner"));
|
||||||
"Select a sample rate for the tuner");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTunerInfo()
|
@Override
|
||||||
|
protected String getTunerInfo()
|
||||||
{
|
{
|
||||||
if(getDiscoveredTuner().getTunerStatus() == TunerStatus.ERROR)
|
if(!hasStartedTuner())
|
||||||
{
|
{
|
||||||
return getDiscoveredTuner().getErrorMessage();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasTuner())
|
BladeRfDeviceInformation info = getTuner().getController().getDeviceInfo();
|
||||||
{
|
StringBuilder sb = new StringBuilder();
|
||||||
BladeRfDeviceInformation info = getTuner().getController().getDeviceInfo();
|
sb.append("<html><h3>bladeRF Tuner</h3>");
|
||||||
StringBuilder sb = new StringBuilder();
|
sb.append("<b>Serial: </b>").append(info.serial()).append("<br>");
|
||||||
sb.append("<html><h3>bladeRF Tuner</h3>");
|
sb.append("<b>Board: </b>").append(info.board()).append("<br>");
|
||||||
sb.append("<b>Serial: </b>").append(info.serial()).append("<br>");
|
sb.append("<b>Firmware: </b>").append(info.firmware()).append("<br>");
|
||||||
sb.append("<b>Board: </b>").append(info.board()).append("<br>");
|
sb.append("<b>FPGA: </b>").append(info.fpga()).append("<br>");
|
||||||
sb.append("<b>Firmware: </b>").append(info.firmware()).append("<br>");
|
sb.append("<b>USB Speed: </b>").append(info.speed()).append("<br>");
|
||||||
sb.append("<b>FPGA: </b>").append(info.fpga()).append("<br>");
|
return sb.toString();
|
||||||
sb.append("<b>USB Speed: </b>").append(info.speed()).append("<br>");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
package io.github.dsheirer.source.tuner.fcd.proV1;
|
package io.github.dsheirer.source.tuner.fcd.proV1;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.SourceException;
|
|
||||||
import io.github.dsheirer.source.tuner.fcd.FCDTuner;
|
import io.github.dsheirer.source.tuner.fcd.FCDTuner;
|
||||||
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
|
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAEnhance;
|
||||||
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
|
import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.LNAGain;
|
||||||
@@ -27,34 +26,24 @@ import io.github.dsheirer.source.tuner.fcd.proV1.FCD1TunerController.MixerGain;
|
|||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import java.text.DecimalFormat;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.collections.FXCollections;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Spinner;
|
||||||
import javax.swing.JButton;
|
import javafx.scene.control.SpinnerValueFactory;
|
||||||
import javax.swing.JCheckBox;
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.JComboBox;
|
import javafx.util.StringConverter;
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSpinner;
|
|
||||||
import javax.swing.SpinnerModel;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.SwingConstants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Funcube Dongle Pro tuner editor
|
* Funcube Dongle Pro tuner editor
|
||||||
*/
|
*/
|
||||||
public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration>
|
public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private ComboBox<LNAGain> mLnaGainCombo;
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(FCD1TunerEditor.class);
|
private ComboBox<LNAEnhance> mLnaEnhanceCombo;
|
||||||
private JButton mTunerInfoButton;
|
private ComboBox<MixerGain> mMixerGainCombo;
|
||||||
private JComboBox<LNAGain> mLnaGainCombo;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JComboBox<LNAEnhance> mLnaEnhanceCombo;
|
|
||||||
private JComboBox<MixerGain> mMixerGainCombo;
|
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
private CorrectionSpinner mCorrectionDCI;
|
private CorrectionSpinner mCorrectionDCI;
|
||||||
private CorrectionSpinner mCorrectionDCQ;
|
private CorrectionSpinner mCorrectionDCQ;
|
||||||
private CorrectionSpinner mGainCorrectionSpinner;
|
private CorrectionSpinner mGainCorrectionSpinner;
|
||||||
@@ -63,14 +52,14 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for wide-band recordings
|
* @param userPreferences for wide-band recordings
|
||||||
* @param tunerManager to save configuration
|
* @param tunerManager for saving tuner configuration
|
||||||
* @param discoveredTuner to control
|
* @param discoveredTuner for the optionally usable tuner and controller
|
||||||
*/
|
*/
|
||||||
public FCD1TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
public FCD1TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FCD1TunerController getController()
|
private FCD1TunerController getController()
|
||||||
@@ -95,120 +84,64 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
return FCD1TunerController.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
return FCD1TunerController.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
TunerSection gain = addSection("Gain");
|
||||||
|
gain.addRow("LNA", getLnaGainCombo());
|
||||||
|
gain.addRow("LNA Enhance", getLnaEnhanceCombo());
|
||||||
|
gain.addRow("Mixer", getMixerGainCombo());
|
||||||
|
|
||||||
|
TunerSection correction = addSection("I/Q Correction");
|
||||||
|
correction.addRow("DC Inphase", getDcCorrectionSpinnerI());
|
||||||
|
correction.addRow("DC Quadrature", getDcCorrectionSpinnerQ());
|
||||||
|
correction.addRow("Gain", getGainCorrectionSpinner());
|
||||||
|
correction.addRow("Phase", getPhaseCorrectionSpinner());
|
||||||
|
|
||||||
|
TunerSection options = addSection("Options");
|
||||||
|
options.addControl(getBiasTCheckBox());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getTunerInfoButton().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
if(hasTuner() && hasConfiguration())
|
if(hasTuner() && hasConfiguration())
|
||||||
{
|
{
|
||||||
getMixerGainCombo().setSelectedItem(getConfiguration().getMixerGain());
|
FCD1TunerConfiguration config = getConfiguration();
|
||||||
getLnaEnhanceCombo().setSelectedItem(getConfiguration().getLNAEnhance());
|
getMixerGainCombo().setValue(config.getMixerGain());
|
||||||
getLnaGainCombo().setSelectedItem(getConfiguration().getLNAGain());
|
getLnaEnhanceCombo().setValue(config.getLNAEnhance());
|
||||||
getBiasTCheckBox().setSelected(getConfiguration().isBiasT());
|
getLnaGainCombo().setValue(config.getLNAGain());
|
||||||
getDcCorrectionSpinnerI().setValue(getConfiguration().getInphaseDCCorrection());
|
getBiasTCheckBox().setSelected(config.isBiasT());
|
||||||
getDcCorrectionSpinnerQ().setValue(getConfiguration().getQuadratureDCCorrection());
|
getDcCorrectionSpinnerI().setCorrection(config.getInphaseDCCorrection());
|
||||||
getPhaseCorrectionSpinner().setValue(getConfiguration().getGainCorrection());
|
getDcCorrectionSpinnerQ().setCorrection(config.getQuadratureDCCorrection());
|
||||||
getGainCorrectionSpinner().setValue(getConfiguration().getPhaseCorrection());
|
getGainCorrectionSpinner().setCorrection(config.getGainCorrection());
|
||||||
|
getPhaseCorrectionSpinner().setCorrection(config.getPhaseCorrection());
|
||||||
}
|
}
|
||||||
|
|
||||||
getMixerGainCombo().setEnabled(hasTuner());
|
getMixerGainCombo().setDisable(!hasTuner());
|
||||||
getLnaEnhanceCombo().setEnabled(hasTuner());
|
getLnaEnhanceCombo().setDisable(!hasTuner());
|
||||||
getLnaGainCombo().setEnabled(hasTuner());
|
getLnaGainCombo().setDisable(!hasTuner());
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
getBiasTCheckBox().setDisable(!hasTuner());
|
||||||
getDcCorrectionSpinnerI().setEnabled(hasTuner());
|
getDcCorrectionSpinnerI().setDisable(!hasTuner());
|
||||||
getDcCorrectionSpinnerQ().setEnabled(hasTuner());
|
getDcCorrectionSpinnerQ().setDisable(!hasTuner());
|
||||||
getPhaseCorrectionSpinner().setEnabled(hasTuner());
|
getPhaseCorrectionSpinner().setDisable(!hasTuner());
|
||||||
getGainCorrectionSpinner().setEnabled(hasTuner());
|
getGainCorrectionSpinner().setDisable(!hasTuner());
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private ComboBox<LNAGain> getLnaGainCombo()
|
||||||
{
|
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
|
||||||
"[][][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel());
|
|
||||||
add(getTunerInfoButton());
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Gain"), "span,align center");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLnaGainCombo(), "wrap");
|
|
||||||
add(new JLabel("Enhance:"));
|
|
||||||
add(getLnaEnhanceCombo(), "wrap");
|
|
||||||
add(new JLabel("Mixer:"));
|
|
||||||
add(getMixerGainCombo(), "wrap");
|
|
||||||
add(new JLabel(""));
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Correction"), "span,align center");
|
|
||||||
add(new JLabel("DC Inphase:"));
|
|
||||||
add(getDcCorrectionSpinnerI(), "wrap");
|
|
||||||
add(new JLabel("DC Quadrature:"));
|
|
||||||
add(getDcCorrectionSpinnerQ(), "wrap");
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainCorrectionSpinner(), "wrap");
|
|
||||||
add(new JLabel("Phase:"));
|
|
||||||
add(getPhaseCorrectionSpinner(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
public JComboBox getLnaGainCombo()
|
|
||||||
{
|
{
|
||||||
if(mLnaGainCombo == null)
|
if(mLnaGainCombo == null)
|
||||||
{
|
{
|
||||||
mLnaGainCombo = new JComboBox<>(LNAGain.values());
|
mLnaGainCombo = new ComboBox<>(FXCollections.observableArrayList(LNAGain.values()));
|
||||||
mLnaGainCombo.setEnabled(false);
|
mLnaGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mLnaGainCombo.setToolTipText("Adjust the low noise amplifier gain setting.");
|
mLnaGainCombo.setDisable(true);
|
||||||
mLnaGainCombo.addActionListener(arg0 ->
|
mLnaGainCombo.setTooltip(new Tooltip("Adjust the low noise amplifier gain setting."));
|
||||||
{
|
mLnaGainCombo.setOnAction(e -> {
|
||||||
if(!isLoading())
|
LNAGain gain = mLnaGainCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && gain != null &&
|
||||||
|
applyToTuner("LNA gain [" + gain + "]", () -> getController().setLNAGain(gain)))
|
||||||
{
|
{
|
||||||
LNAGain gain = (LNAGain) mLnaGainCombo.getSelectedItem();
|
save();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getController().setLNAGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(FCD1TunerEditor.this, "FCD Pro Tuner " +
|
|
||||||
"Controller - error setting LNA gain [" + gain + "]");
|
|
||||||
|
|
||||||
mLog.error("FuncubeDonglePro Controller - error setting gain [" + gain + "]", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -216,30 +149,18 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
return mLnaGainCombo;
|
return mLnaGainCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private CheckBox getBiasTCheckBox()
|
||||||
* Checkbox to enable/disable Bias-T power for active antennas
|
|
||||||
*/
|
|
||||||
public JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
{
|
||||||
if(mBiasTCheckBox == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasTCheckBox.setEnabled(false);
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasTCheckBox.setToolTipText("Enable Bias-T power output for active antennas");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable Bias-T power output for active antennas"));
|
||||||
mBiasTCheckBox.addActionListener(event ->
|
mBiasTCheckBox.setOnAction(event -> {
|
||||||
{
|
if(hasTuner() && !isLoading() &&
|
||||||
if(hasTuner() && !isLoading())
|
applyToTuner("Bias-T", () -> getController().setBiasT(mBiasTCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getController().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set bias-T for FCD Pro", e);
|
|
||||||
JOptionPane.showMessageDialog(FCD1TunerEditor.this, "Couldn't set Bias-T: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -247,31 +168,21 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
return mBiasTCheckBox;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JComboBox getLnaEnhanceCombo()
|
private ComboBox<LNAEnhance> getLnaEnhanceCombo()
|
||||||
{
|
{
|
||||||
if(mLnaEnhanceCombo == null)
|
if(mLnaEnhanceCombo == null)
|
||||||
{
|
{
|
||||||
mLnaEnhanceCombo = new JComboBox<>(LNAEnhance.values());
|
mLnaEnhanceCombo = new ComboBox<>(FXCollections.observableArrayList(LNAEnhance.values()));
|
||||||
mLnaEnhanceCombo.setEnabled(false);
|
mLnaEnhanceCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mLnaEnhanceCombo.setToolTipText("Adjust the LNA enhance setting. Default value is OFF");
|
mLnaEnhanceCombo.setDisable(true);
|
||||||
mLnaEnhanceCombo.addActionListener(arg0 ->
|
mLnaEnhanceCombo.setTooltip(new Tooltip("Adjust the LNA enhance setting. Default value is OFF"));
|
||||||
{
|
mLnaEnhanceCombo.setOnAction(e -> {
|
||||||
if(!isLoading())
|
LNAEnhance enhance = mLnaEnhanceCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && enhance != null &&
|
||||||
|
applyToTuner("LNA enhance [" + enhance + "]", () -> getController().setLNAEnhance(enhance)))
|
||||||
{
|
{
|
||||||
LNAEnhance enhance = (LNAEnhance) mLnaEnhanceCombo.getSelectedItem();
|
save();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getController().setLNAEnhance(enhance);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(FCD1TunerEditor.this, "FCD Pro Tuner"
|
|
||||||
+ " error setting LNA enhance gain [" + enhance + "]");
|
|
||||||
|
|
||||||
mLog.error("FCDPro - error setting LNA enhance [" + enhance + "]", e1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -279,31 +190,21 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
return mLnaEnhanceCombo;
|
return mLnaEnhanceCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JComboBox getMixerGainCombo()
|
private ComboBox<MixerGain> getMixerGainCombo()
|
||||||
{
|
{
|
||||||
if(mMixerGainCombo == null)
|
if(mMixerGainCombo == null)
|
||||||
{
|
{
|
||||||
mMixerGainCombo = new JComboBox<>(MixerGain.values());
|
mMixerGainCombo = new ComboBox<>(FXCollections.observableArrayList(MixerGain.values()));
|
||||||
mMixerGainCombo.setEnabled(false);
|
mMixerGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mMixerGainCombo.setToolTipText("Adjust mixer gain setting");
|
mMixerGainCombo.setDisable(true);
|
||||||
mMixerGainCombo.addActionListener(arg0 ->
|
mMixerGainCombo.setTooltip(new Tooltip("Adjust mixer gain setting"));
|
||||||
{
|
mMixerGainCombo.setOnAction(e -> {
|
||||||
if(!isLoading())
|
MixerGain gain = mMixerGainCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && gain != null &&
|
||||||
|
applyToTuner("mixer gain [" + gain + "]", () -> getController().setMixerGain(gain)))
|
||||||
{
|
{
|
||||||
MixerGain gain = (MixerGain) mMixerGainCombo.getSelectedItem();
|
save();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getController().setMixerGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(FCD1TunerEditor.this, "FCDPro - error setting"
|
|
||||||
+ " mixer gain [" + gain + "]");
|
|
||||||
|
|
||||||
mLog.error("FCDPro - error setting mixer gain [" + gain + "]", e1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -311,102 +212,60 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
return mMixerGainCombo;
|
return mMixerGainCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CorrectionSpinner getDcCorrectionSpinnerQ()
|
private CorrectionSpinner getDcCorrectionSpinnerQ()
|
||||||
{
|
{
|
||||||
if(mCorrectionDCQ == null)
|
if(mCorrectionDCQ == null)
|
||||||
{
|
{
|
||||||
mCorrectionDCQ = new CorrectionSpinner(Correction.DC_QUADRATURE, 0.0, 0.00001, 5);
|
mCorrectionDCQ = new CorrectionSpinner(Correction.DC_QUADRATURE);
|
||||||
mCorrectionDCQ.setEnabled(false);
|
mCorrectionDCQ.setTooltip(new Tooltip("DC bias correction, quadrature component: -1.0 to 1.0 (default: 0.0)"));
|
||||||
mCorrectionDCQ.setToolTipText("DC Bias Correction/Quadrature Component: valid values are -1.0 to 1.0 (default: 0.0)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mCorrectionDCQ;
|
return mCorrectionDCQ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CorrectionSpinner getDcCorrectionSpinnerI()
|
private CorrectionSpinner getDcCorrectionSpinnerI()
|
||||||
{
|
{
|
||||||
if(mCorrectionDCI == null)
|
if(mCorrectionDCI == null)
|
||||||
{
|
{
|
||||||
mCorrectionDCI = new CorrectionSpinner(Correction.DC_INPHASE, 0.0, 0.00001, 5);
|
mCorrectionDCI = new CorrectionSpinner(Correction.DC_INPHASE);
|
||||||
mCorrectionDCI.setEnabled(false);
|
mCorrectionDCI.setTooltip(new Tooltip("DC bias correction, inphase component: -1.0 to 1.0 (default: 0.0)"));
|
||||||
mCorrectionDCI.setToolTipText("DC Bias Correction/Inphase Component: valid values are -1.0 to 1.0 (default: 0.0)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mCorrectionDCI;
|
return mCorrectionDCI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CorrectionSpinner getGainCorrectionSpinner()
|
private CorrectionSpinner getGainCorrectionSpinner()
|
||||||
{
|
{
|
||||||
if(mGainCorrectionSpinner == null)
|
if(mGainCorrectionSpinner == null)
|
||||||
{
|
{
|
||||||
mGainCorrectionSpinner = new CorrectionSpinner(Correction.GAIN, 0.0, 0.00001, 5);
|
mGainCorrectionSpinner = new CorrectionSpinner(Correction.GAIN);
|
||||||
mGainCorrectionSpinner.setEnabled(false);
|
mGainCorrectionSpinner.setTooltip(new Tooltip("Gain correction: -1.0 to 1.0 (default: 0.0)"));
|
||||||
mGainCorrectionSpinner.setToolTipText("Gain Correction: valid values are -1.0 to 1.0 (default: 0.0)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mGainCorrectionSpinner;
|
return mGainCorrectionSpinner;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CorrectionSpinner getPhaseCorrectionSpinner()
|
private CorrectionSpinner getPhaseCorrectionSpinner()
|
||||||
{
|
{
|
||||||
if(mPhaseCorrectionSpinner == null)
|
if(mPhaseCorrectionSpinner == null)
|
||||||
{
|
{
|
||||||
mPhaseCorrectionSpinner = new CorrectionSpinner(Correction.PHASE, 0.0, 0.00001, 5);
|
mPhaseCorrectionSpinner = new CorrectionSpinner(Correction.PHASE);
|
||||||
mPhaseCorrectionSpinner.setEnabled(false);
|
mPhaseCorrectionSpinner.setTooltip(new Tooltip("Phase correction: -1.0 to 1.0 (default: 0.0)"));
|
||||||
mPhaseCorrectionSpinner.setToolTipText("Phase Correction: valid values are -1.0 to 1.0 (default: 0.0)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mPhaseCorrectionSpinner;
|
return mPhaseCorrectionSpinner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected String getTunerInfo()
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getTunerInfoButton()
|
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Tuner Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(FCD1TunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTunerInfo()
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append("<html><h3>Funcube Dongle Pro Tuner</h3>");
|
sb.append("<html><h3>Funcube Dongle Pro Tuner</h3>");
|
||||||
|
sb.append("<b>USB ID: </b>").append(getController().getUSBID()).append("<br>");
|
||||||
if(hasTuner())
|
sb.append("<b>USB Address: </b>").append(getController().getUSBAddress()).append("<br>");
|
||||||
{
|
sb.append("<b>USB Speed: </b>").append(getController().getUSBSpeed()).append("<br>");
|
||||||
sb.append("<b>USB ID: </b>");
|
sb.append("<b>Cellular Band: </b>").append(getController().getConfiguration().getBandBlocking()).append("<br>");
|
||||||
sb.append(getController().getUSBID());
|
sb.append("<b>Firmware: </b>").append(getController().getConfiguration().getFirmware()).append("<br>");
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>USB Address: </b>");
|
|
||||||
sb.append(getController().getUSBAddress());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>USB Speed: </b>");
|
|
||||||
sb.append(getController().getUSBSpeed());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Cellular Band: </b>");
|
|
||||||
sb.append(getController().getConfiguration().getBandBlocking());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Firmware: </b>");
|
|
||||||
sb.append(getController().getConfiguration().getFirmware());
|
|
||||||
sb.append("<br>");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,88 +274,95 @@ public class FCD1TunerEditor extends TunerEditor<FCDTuner,FCD1TunerConfiguration
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
FCD1TunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setLNAEnhance(getLnaEnhanceCombo().getValue());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setLNAGain(getLnaGainCombo().getValue());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setMixerGain(getMixerGainCombo().getValue());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
getConfiguration().setLNAEnhance((LNAEnhance) mLnaEnhanceCombo.getSelectedItem());
|
config.setInphaseDCCorrection(getDcCorrectionSpinnerI().getCorrection());
|
||||||
getConfiguration().setLNAGain((LNAGain) mLnaGainCombo.getSelectedItem());
|
config.setQuadratureDCCorrection(getDcCorrectionSpinnerQ().getCorrection());
|
||||||
getConfiguration().setMixerGain((MixerGain) mMixerGainCombo.getSelectedItem());
|
config.setGainCorrection(getGainCorrectionSpinner().getCorrection());
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
config.setPhaseCorrection(getPhaseCorrectionSpinner().getCorrection());
|
||||||
double dci = ((SpinnerNumberModel)mCorrectionDCI.getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setInphaseDCCorrection(dci);
|
|
||||||
double dcq = ((SpinnerNumberModel)mCorrectionDCQ.getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setQuadratureDCCorrection(dcq);
|
|
||||||
double gain = ((SpinnerNumberModel) mGainCorrectionSpinner.getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setGainCorrection(gain);
|
|
||||||
double phase = ((SpinnerNumberModel) mPhaseCorrectionSpinner.getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setPhaseCorrection(phase);
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Correction {GAIN, PHASE, DC_INPHASE, DC_QUADRATURE};
|
public enum Correction {GAIN, PHASE, DC_INPHASE, DC_QUADRATURE}
|
||||||
|
|
||||||
public class CorrectionSpinner extends JSpinner
|
/**
|
||||||
|
* Spinner for a correction value in the range -1.0 to 1.0 with five decimal places.
|
||||||
|
*/
|
||||||
|
public class CorrectionSpinner extends Spinner<Double>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final double MIN_VALUE = -1.0d;
|
private static final double MIN_VALUE = -1.0d;
|
||||||
private static final double MAX_VALUE = 1.0d;
|
private static final double MAX_VALUE = 1.0d;
|
||||||
|
private final Correction mCorrectionComponent;
|
||||||
|
|
||||||
private Correction mCorrectionComponent;
|
public CorrectionSpinner(Correction component)
|
||||||
|
|
||||||
public CorrectionSpinner(Correction component, double initialValue, double step, int decimalPlaces)
|
|
||||||
{
|
{
|
||||||
mCorrectionComponent = component;
|
mCorrectionComponent = component;
|
||||||
|
SpinnerValueFactory.DoubleSpinnerValueFactory factory =
|
||||||
SpinnerModel model = new SpinnerNumberModel(initialValue, MIN_VALUE, MAX_VALUE, step);
|
new SpinnerValueFactory.DoubleSpinnerValueFactory(MIN_VALUE, MAX_VALUE, 0.0, 0.00001);
|
||||||
setModel(model);
|
factory.setConverter(new StringConverter<>()
|
||||||
|
|
||||||
JSpinner.NumberEditor editor = (JSpinner.NumberEditor)getEditor();
|
|
||||||
|
|
||||||
DecimalFormat format = editor.getFormat();
|
|
||||||
format.setMinimumFractionDigits(decimalPlaces);
|
|
||||||
|
|
||||||
editor.getTextField().setHorizontalAlignment(SwingConstants.CENTER);
|
|
||||||
|
|
||||||
addChangeListener(e ->
|
|
||||||
{
|
{
|
||||||
if(!isLoading())
|
@Override
|
||||||
|
public String toString(Double value)
|
||||||
{
|
{
|
||||||
double value = ((SpinnerNumberModel)getModel()).getNumber().doubleValue();
|
return value == null ? "" : String.format("%.5f", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Double fromString(String text)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch(mCorrectionComponent)
|
return Double.parseDouble(text.trim().replace(',', '.'));
|
||||||
{
|
|
||||||
case DC_INPHASE:
|
|
||||||
getController().setDCCorrectionInPhase(value);
|
|
||||||
break;
|
|
||||||
case DC_QUADRATURE:
|
|
||||||
getController().setDCCorrectionQuadrature(value);
|
|
||||||
break;
|
|
||||||
case GAIN:
|
|
||||||
getController().setGainCorrection(value);
|
|
||||||
break;
|
|
||||||
case PHASE:
|
|
||||||
getController().setPhaseCorrection(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
catch(Exception e1)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
JOptionPane.showMessageDialog(FCD1TunerEditor.this, "FCDPro - error "
|
return factory.getValue();
|
||||||
+ "applying " + mCorrectionComponent.toString() + " correction value [" + value + "]");
|
|
||||||
|
|
||||||
mLog.error("FCDPro - error applying " + mCorrectionComponent.toString() + " correction value [" +
|
|
||||||
value + "]", e1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
setValueFactory(factory);
|
||||||
|
setEditable(true);
|
||||||
|
setDisable(true);
|
||||||
|
setMaxWidth(Double.MAX_VALUE);
|
||||||
|
focusedProperty().addListener((observable, wasFocused, focused) -> {
|
||||||
|
if(!focused)
|
||||||
|
{
|
||||||
|
increment(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
valueProperty().addListener((observable, oldValue, value) -> {
|
||||||
|
if(!isLoading() && hasTuner() && value != null &&
|
||||||
|
applyToTuner(mCorrectionComponent + " correction [" + value + "]", () -> apply(value)))
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void apply(double value) throws Exception
|
||||||
|
{
|
||||||
|
switch(mCorrectionComponent)
|
||||||
|
{
|
||||||
|
case DC_INPHASE -> getController().setDCCorrectionInPhase(value);
|
||||||
|
case DC_QUADRATURE -> getController().setDCCorrectionQuadrature(value);
|
||||||
|
case GAIN -> getController().setGainCorrection(value);
|
||||||
|
case PHASE -> getController().setPhaseCorrection(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCorrection(double value)
|
||||||
|
{
|
||||||
|
getValueFactory().setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCorrection()
|
||||||
|
{
|
||||||
|
return getValue() != null ? getValue() : 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -19,46 +19,38 @@
|
|||||||
package io.github.dsheirer.source.tuner.fcd.proplusV2;
|
package io.github.dsheirer.source.tuner.fcd.proplusV2;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.SourceException;
|
|
||||||
import io.github.dsheirer.source.tuner.fcd.FCDTuner;
|
import io.github.dsheirer.source.tuner.fcd.FCDTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.Tooltip;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Funcube Dongle Pro Plus tuner editor
|
* Funcube Dongle Pro Plus tuner editor
|
||||||
*/
|
*/
|
||||||
public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguration>
|
public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguration>
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(FCD2TunerEditor.class);
|
private CheckBox mLnaGainCheckBox;
|
||||||
private static final long serialVersionUID = 1L;
|
private CheckBox mMixerGainCheckBox;
|
||||||
private JButton mTunerInfoButton;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JCheckBox mLnaGainCheckBox;
|
|
||||||
private JCheckBox mMixerGainCheckBox;
|
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for wide-band recordings
|
* @param userPreferences for wide-band recordings
|
||||||
* @param tunerManager to save configuration
|
* @param tunerManager for saving tuner configuration
|
||||||
* @param discoveredTuner to control
|
* @param discoveredTuner for the optionally usable tuner and controller
|
||||||
*/
|
*/
|
||||||
public FCD2TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
public FCD2TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection gain = addSection("Gain");
|
||||||
tunerStatusUpdated();
|
gain.addControl(getLnaGainCheckBox());
|
||||||
|
gain.addControl(getMixerGainCheckBox());
|
||||||
|
TunerSection options = addSection("Options");
|
||||||
|
options.addControl(getBiasTCheckBox());
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private FCD2TunerController getController()
|
private FCD2TunerController getController()
|
||||||
@@ -86,29 +78,9 @@ public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguratio
|
|||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
getLnaGainCheckBox().setDisable(!hasTuner());
|
||||||
|
getMixerGainCheckBox().setDisable(!hasTuner());
|
||||||
if(hasTuner())
|
getBiasTCheckBox().setDisable(!hasTuner());
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getTunerInfoButton().setEnabled(hasTuner());
|
|
||||||
getLnaGainCheckBox().setEnabled(hasTuner());
|
|
||||||
getMixerGainCheckBox().setEnabled(hasTuner());
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
if(hasTuner() && hasConfiguration())
|
if(hasTuner() && hasConfiguration())
|
||||||
{
|
{
|
||||||
@@ -116,69 +88,19 @@ public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguratio
|
|||||||
getMixerGainCheckBox().setSelected(getConfiguration().getGainMixer());
|
getMixerGainCheckBox().setSelected(getConfiguration().getGainMixer());
|
||||||
getBiasTCheckBox().setSelected(getConfiguration().isBiasT());
|
getBiasTCheckBox().setSelected(getConfiguration().isBiasT());
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private CheckBox getLnaGainCheckBox()
|
||||||
{
|
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
|
||||||
"[][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel());
|
|
||||||
add(getTunerInfoButton());
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
JPanel checkBoxPanel = new JPanel();
|
|
||||||
checkBoxPanel.setLayout(new MigLayout("insets 0", "[left][left][left]", ""));
|
|
||||||
checkBoxPanel.add(getLnaGainCheckBox());
|
|
||||||
checkBoxPanel.add(getMixerGainCheckBox());
|
|
||||||
checkBoxPanel.add(getBiasTCheckBox());
|
|
||||||
add(checkBoxPanel, "span,align left");
|
|
||||||
}
|
|
||||||
|
|
||||||
public JButton getTunerInfoButton()
|
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Tuner Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(FCD2TunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JCheckBox getLnaGainCheckBox()
|
|
||||||
{
|
{
|
||||||
if(mLnaGainCheckBox == null)
|
if(mLnaGainCheckBox == null)
|
||||||
{
|
{
|
||||||
mLnaGainCheckBox = new JCheckBox("LNA Gain");
|
mLnaGainCheckBox = new CheckBox("LNA gain");
|
||||||
mLnaGainCheckBox.setEnabled(false);
|
mLnaGainCheckBox.setDisable(true);
|
||||||
mLnaGainCheckBox.addActionListener(event ->
|
mLnaGainCheckBox.setOnAction(event -> {
|
||||||
{
|
if(!isLoading() && hasTuner() && applyToTuner("LNA gain",
|
||||||
if(!isLoading())
|
() -> getController().setLNAGain(getLnaGainCheckBox().isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getController().setLNAGain(getLnaGainCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set LNA gain for FCD2", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -186,25 +108,17 @@ public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguratio
|
|||||||
return mLnaGainCheckBox;
|
return mLnaGainCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JCheckBox getMixerGainCheckBox()
|
private CheckBox getMixerGainCheckBox()
|
||||||
{
|
{
|
||||||
if(mMixerGainCheckBox == null)
|
if(mMixerGainCheckBox == null)
|
||||||
{
|
{
|
||||||
mMixerGainCheckBox = new JCheckBox("Mixer Gain");
|
mMixerGainCheckBox = new CheckBox("Mixer gain");
|
||||||
mMixerGainCheckBox.setEnabled(false);
|
mMixerGainCheckBox.setDisable(true);
|
||||||
mMixerGainCheckBox.addActionListener(event ->
|
mMixerGainCheckBox.setOnAction(event -> {
|
||||||
{
|
if(!isLoading() && hasTuner() && applyToTuner("mixer gain",
|
||||||
if(!isLoading())
|
() -> getController().setMixerGain(getMixerGainCheckBox().isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getController().setMixerGain(getMixerGainCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set mixer gain for FCD2", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -212,30 +126,18 @@ public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguratio
|
|||||||
return mMixerGainCheckBox;
|
return mMixerGainCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private CheckBox getBiasTCheckBox()
|
||||||
* Checkbox to enable/disable Bias-T power for active antennas
|
|
||||||
*/
|
|
||||||
public JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
{
|
||||||
if(mBiasTCheckBox == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasTCheckBox.setEnabled(false);
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasTCheckBox.setToolTipText("Enable Bias-T power output for active antennas");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable Bias-T power output for active antennas"));
|
||||||
mBiasTCheckBox.addActionListener(event ->
|
mBiasTCheckBox.setOnAction(event -> {
|
||||||
{
|
if(hasTuner() && !isLoading() && applyToTuner("Bias-T",
|
||||||
if(hasTuner() && !isLoading())
|
() -> getController().setBiasT(getBiasTCheckBox().isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getController().setBiasT(getBiasTCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set bias-T for FCD2", e);
|
|
||||||
JOptionPane.showMessageDialog(mBiasTCheckBox, "Couldn't set Bias-T: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -244,40 +146,15 @@ public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguratio
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected String getTunerInfo()
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTunerInfo()
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append("<html><h3>Funcube Dongle Pro Plus Tuner</h3>");
|
sb.append("<html><h3>Funcube Dongle Pro Plus Tuner</h3>");
|
||||||
|
sb.append("<b>USB ID: </b>").append(getController().getUSBID()).append("<br>");
|
||||||
if(hasTuner())
|
sb.append("<b>USB Address: </b>").append(getController().getUSBAddress()).append("<br>");
|
||||||
{
|
sb.append("<b>USB Speed: </b>").append(getController().getUSBSpeed()).append("<br>");
|
||||||
sb.append("<b>USB ID: </b>");
|
sb.append("<b>Cellular Band: </b>").append(getController().getConfiguration().getBandBlocking()).append("<br>");
|
||||||
sb.append(getController().getUSBID());
|
sb.append("<b>Firmware: </b>").append(getController().getConfiguration().getFirmware()).append("<br>");
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>USB Address: </b>");
|
|
||||||
sb.append(getController().getUSBAddress());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>USB Speed: </b>");
|
|
||||||
sb.append(getController().getUSBSpeed());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Cellular Band: </b>");
|
|
||||||
sb.append(getController().getConfiguration().getBandBlocking());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Firmware: </b>");
|
|
||||||
sb.append(getController().getConfiguration().getFirmware());
|
|
||||||
sb.append("<br>");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,16 +163,12 @@ public class FCD2TunerEditor extends TunerEditor<FCDTuner, FCD2TunerConfiguratio
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
FCD2TunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setGainLNA(getLnaGainCheckBox().isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setGainMixer(getMixerGainCheckBox().isSelected());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
getConfiguration().setGainLNA(getLnaGainCheckBox().isSelected());
|
|
||||||
getConfiguration().setGainMixer(getMixerGainCheckBox().isSelected());
|
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,50 +20,43 @@ package io.github.dsheirer.source.tuner.hackrf;
|
|||||||
|
|
||||||
import io.github.dsheirer.hackrf.HackRf;
|
import io.github.dsheirer.hackrf.HackRf;
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.SourceException;
|
|
||||||
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
|
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFLNAGain;
|
||||||
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
|
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFSampleRate;
|
||||||
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
|
import io.github.dsheirer.source.tuner.hackrf.HackRFTunerController.HackRFVGAGain;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.scene.control.CheckBox;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HackRF Tuner Editor
|
* HackRF tuner editor
|
||||||
*/
|
*/
|
||||||
public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfiguration>
|
public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(HackRFTunerEditor.class);
|
private final static Logger mLog = LoggerFactory.getLogger(HackRFTunerEditor.class);
|
||||||
private JButton mTunerInfo;
|
private ComboBox<HackRFSampleRate> mSampleRateCombo;
|
||||||
private JComboBox<HackRFSampleRate> mSampleRateCombo;
|
private CheckBox mAmplifierCheckBox;
|
||||||
private JToggleButton mAmplifier;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JToggleButton mBiasT;
|
private ComboBox<HackRFLNAGain> mLnaGainCombo;
|
||||||
private JComboBox<HackRFLNAGain> mLnaGainCombo;
|
private ComboBox<HackRFVGAGain> mVgaGainCombo;
|
||||||
private JComboBox<HackRFVGAGain> mVgaGainCombo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for wide-band recordings
|
* @param userPreferences for wide-band recordings
|
||||||
* @param tunerManager to save configuration
|
* @param tunerManager for saving tuner configuration
|
||||||
* @param discoveredTuner to control
|
* @param discoveredTuner for the optionally usable HackRF tuner and controller
|
||||||
*/
|
*/
|
||||||
public HackRFTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
public HackRFTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,116 +73,55 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
"[][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
TunerSection gain = addSection("Gain");
|
||||||
add(getTunerIdLabel());
|
gain.addRow("LNA", getLnaGainCombo());
|
||||||
add(getTunerInfoButton());
|
gain.addRow("VGA", getVgaGainCombo());
|
||||||
|
gain.addControl(getAmplifierCheckBox());
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
TunerSection options = addSection("Options");
|
||||||
add(getTunerStatusLabel(), "wrap");
|
options.addControl(getBiasTCheckBox());
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Gain Control"));
|
|
||||||
add(getAmplifierToggle(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLnaGainCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("VGA:"));
|
|
||||||
add(getVgaGainCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Bias-T:"));
|
|
||||||
add(getBiasTToggle(), "wrap");
|
|
||||||
|
|
||||||
//Empty filler row that grows to take up the remaining vertical space
|
|
||||||
add(new JLabel(), "span,grow,push");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
getSampleRateCombo().setDisable(!hasTuner() || getTuner().getTunerController().isLockedSampleRate());
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
updateSampleRateToolTip();
|
updateSampleRateToolTip();
|
||||||
getTunerInfoButton().setEnabled(hasTuner());
|
getAmplifierCheckBox().setDisable(!hasTuner());
|
||||||
|
getBiasTCheckBox().setDisable(!hasTuner());
|
||||||
getAmplifierToggle().setEnabled(hasTuner());
|
getLnaGainCombo().setDisable(!hasTuner());
|
||||||
getBiasTToggle().setEnabled(hasTuner());
|
getVgaGainCombo().setDisable(!hasTuner());
|
||||||
getLnaGainCombo().setEnabled(hasTuner());
|
|
||||||
getVgaGainCombo().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
if(hasConfiguration())
|
if(hasConfiguration())
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setSelectedItem(getConfiguration().getSampleRate());
|
getSampleRateCombo().setValue(getConfiguration().getSampleRate());
|
||||||
getAmplifierToggle().setSelected(getConfiguration().getAmplifierEnabled());
|
getAmplifierCheckBox().setSelected(getConfiguration().getAmplifierEnabled());
|
||||||
getBiasTToggle().setSelected(getConfiguration().isBiasT());
|
getBiasTCheckBox().setSelected(getConfiguration().isBiasT());
|
||||||
getLnaGainCombo().setSelectedItem(getConfiguration().getLNAGain());
|
getLnaGainCombo().setValue(getConfiguration().getLNAGain());
|
||||||
getVgaGainCombo().setSelectedItem(getConfiguration().getVGAGain());
|
getVgaGainCombo().setValue(getConfiguration().getVGAGain());
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox getVgaGainCombo()
|
private ComboBox<HackRFVGAGain> getVgaGainCombo()
|
||||||
{
|
{
|
||||||
if(mVgaGainCombo == null)
|
if(mVgaGainCombo == null)
|
||||||
{
|
{
|
||||||
mVgaGainCombo = new JComboBox<HackRFVGAGain>(HackRFVGAGain.values());
|
mVgaGainCombo = new ComboBox<>(FXCollections.observableArrayList(HackRFVGAGain.values()));
|
||||||
mVgaGainCombo.setToolTipText("<html>VGA Gain. Adjust to set the baseband gain</html>");
|
mVgaGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mVgaGainCombo.setEnabled(false);
|
mVgaGainCombo.setTooltip(new Tooltip("VGA gain. Adjust to set the baseband gain"));
|
||||||
mVgaGainCombo.addActionListener(arg0 ->
|
mVgaGainCombo.setDisable(true);
|
||||||
{
|
mVgaGainCombo.setOnAction(e -> {
|
||||||
if(!isLoading())
|
if(!isLoading() && hasTuner())
|
||||||
{
|
{
|
||||||
try
|
HackRFVGAGain vgaGain = mVgaGainCombo.getValue() != null ? mVgaGainCombo.getValue() :
|
||||||
|
HackRFVGAGain.GAIN_16;
|
||||||
|
|
||||||
|
if(applyToTuner("VGA gain", () -> getTuner().getController().setVGAGain(vgaGain)))
|
||||||
{
|
{
|
||||||
HackRFVGAGain vgaGain = (HackRFVGAGain) mVgaGainCombo.getSelectedItem();
|
|
||||||
|
|
||||||
if(vgaGain == null)
|
|
||||||
{
|
|
||||||
vgaGain = HackRFVGAGain.GAIN_16;
|
|
||||||
}
|
|
||||||
|
|
||||||
getTuner().getController().setVGAGain(vgaGain);
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(HackRFTunerEditor.this, "HackRF Tuner Controller"
|
|
||||||
+ " - couldn't apply the VGA gain setting - " + e.getLocalizedMessage());
|
|
||||||
|
|
||||||
mLog.error("HackRF Tuner Controller - couldn't apply VGA gain setting", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -197,35 +129,24 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
|||||||
return mVgaGainCombo;
|
return mVgaGainCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox getLnaGainCombo()
|
private ComboBox<HackRFLNAGain> getLnaGainCombo()
|
||||||
{
|
{
|
||||||
if(mLnaGainCombo == null)
|
if(mLnaGainCombo == null)
|
||||||
{
|
{
|
||||||
mLnaGainCombo = new JComboBox<HackRFLNAGain>(HackRFLNAGain.values());
|
mLnaGainCombo = new ComboBox<>(FXCollections.observableArrayList(HackRFLNAGain.values()));
|
||||||
mLnaGainCombo.setToolTipText("<html>LNA Gain. Adjust to set the IF gain</html>");
|
mLnaGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mLnaGainCombo.setEnabled(false);
|
mLnaGainCombo.setTooltip(new Tooltip("LNA gain. Adjust to set the IF gain"));
|
||||||
mLnaGainCombo.addActionListener(arg0 ->
|
mLnaGainCombo.setDisable(true);
|
||||||
{
|
mLnaGainCombo.setOnAction(e -> {
|
||||||
if(!isLoading())
|
if(!isLoading() && hasTuner())
|
||||||
{
|
{
|
||||||
try
|
HackRFLNAGain lnaGain = mLnaGainCombo.getValue() != null ? mLnaGainCombo.getValue() :
|
||||||
|
HackRFLNAGain.GAIN_16;
|
||||||
|
|
||||||
|
if(applyToTuner("LNA gain", () -> getTuner().getController().setLNAGain(lnaGain)))
|
||||||
{
|
{
|
||||||
HackRFLNAGain lnaGain = (HackRFLNAGain) mLnaGainCombo.getSelectedItem();
|
|
||||||
|
|
||||||
if(lnaGain == null)
|
|
||||||
{
|
|
||||||
lnaGain = HackRFLNAGain.GAIN_16;
|
|
||||||
}
|
|
||||||
|
|
||||||
getTuner().getController().setLNAGain(lnaGain);
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(HackRFTunerEditor.this, "HackRF Tuner Controller"
|
|
||||||
+ " - couldn't apply the LNA gain setting - " + e.getLocalizedMessage());
|
|
||||||
mLog.error("HackRF Tuner Controller - couldn't apply LNA gain setting - ", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -233,97 +154,61 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
|||||||
return mLnaGainCombo;
|
return mLnaGainCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JToggleButton getAmplifierToggle()
|
private CheckBox getAmplifierCheckBox()
|
||||||
{
|
{
|
||||||
if(mAmplifier == null)
|
if(mAmplifierCheckBox == null)
|
||||||
{
|
{
|
||||||
mAmplifier = new JToggleButton("Amplifier");
|
mAmplifierCheckBox = new CheckBox("RF amplifier");
|
||||||
mAmplifier.setToolTipText("Enable or disable the gain amplifier");
|
mAmplifierCheckBox.setTooltip(new Tooltip("Enable or disable the RF gain amplifier"));
|
||||||
mAmplifier.setEnabled(false);
|
mAmplifierCheckBox.setDisable(true);
|
||||||
mAmplifier.addActionListener(arg0 ->
|
mAmplifierCheckBox.setOnAction(e -> {
|
||||||
{
|
if(!isLoading() && hasTuner() && applyToTuner("amplifier",
|
||||||
if(!isLoading())
|
() -> getTuner().getController().setAmplifierEnabled(mAmplifierCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setAmplifierEnabled(mAmplifier.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("couldn't enable/disable amplifier", e);
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(HackRFTunerEditor.this, "Couldn't change amplifier setting",
|
|
||||||
"Error changing amplifier setting", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mAmplifier;
|
return mAmplifierCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JToggleButton getBiasTToggle()
|
private CheckBox getBiasTCheckBox()
|
||||||
{
|
{
|
||||||
if(mBiasT == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasT = new JToggleButton("Disabled");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasT.setToolTipText("Enable or disable Bias-T power (3.3V) on the antenna port for active antennas or LNAs");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable or disable Bias-T power (3.3V) on the antenna port for " +
|
||||||
mBiasT.setEnabled(false);
|
"active antennas or LNAs"));
|
||||||
//Item listener also fires for programmatic setSelected() when the configuration loads
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasT.addItemListener(e -> mBiasT.setText(mBiasT.isSelected() ? "Enabled" : "Disabled"));
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
mBiasT.addActionListener(arg0 ->
|
if(!isLoading() && hasTuner() && applyToTuner("Bias-T",
|
||||||
{
|
() -> getTuner().getController().setBiasTEnabled(mBiasTCheckBox.isSelected())))
|
||||||
if(!isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setBiasTEnabled(mBiasT.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e)
|
|
||||||
{
|
|
||||||
mLog.error("couldn't enable/disable bias-t", e);
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(HackRFTunerEditor.this, "Couldn't change Bias-T setting",
|
|
||||||
"Error changing Bias-T setting", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mBiasT;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox getSampleRateCombo()
|
private ComboBox<HackRFSampleRate> getSampleRateCombo()
|
||||||
{
|
{
|
||||||
if(mSampleRateCombo == null)
|
if(mSampleRateCombo == null)
|
||||||
{
|
{
|
||||||
HackRFSampleRate[] validRates = HackRFSampleRate.VALID_SAMPLE_RATES.toArray(new HackRFSampleRate[0]);
|
mSampleRateCombo = new ComboBox<>(FXCollections.observableArrayList(HackRFSampleRate.VALID_SAMPLE_RATES));
|
||||||
mSampleRateCombo = new JComboBox<>(validRates);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setDisable(true);
|
||||||
mSampleRateCombo.addActionListener(e ->
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
{
|
HackRFSampleRate sampleRate = mSampleRateCombo.getValue();
|
||||||
if(!isLoading())
|
|
||||||
|
if(!isLoading() && hasTuner() && sampleRate != null &&
|
||||||
|
applyToTuner("sample rate [" + sampleRate.getLabel() + "]",
|
||||||
|
() -> getTuner().getController().setSampleRate(sampleRate)))
|
||||||
{
|
{
|
||||||
HackRFSampleRate sampleRate = (HackRFSampleRate)getSampleRateCombo().getSelectedItem();
|
adjustForSampleRate(sampleRate.getRate());
|
||||||
|
save();
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(sampleRate);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(sampleRate.getRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException e2)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(HackRFTunerEditor.this, "HackRF Tuner Controller"
|
|
||||||
+ " - couldn't apply the sample rate setting [" + sampleRate.getLabel() +
|
|
||||||
"] " + e2.getLocalizedMessage());
|
|
||||||
|
|
||||||
mLog.error("HackRF Tuner Controller - couldn't apply sample rate setting [" +
|
|
||||||
sampleRate.getLabel() + "]", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -331,47 +216,29 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
|||||||
return mSampleRateCombo;
|
return mSampleRateCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton getTunerInfoButton()
|
|
||||||
{
|
|
||||||
if(mTunerInfo == null)
|
|
||||||
{
|
|
||||||
mTunerInfo = new JButton("Tuner Info");
|
|
||||||
mTunerInfo.setToolTipText("Provides details and information about the tuner");
|
|
||||||
mTunerInfo.setEnabled(false);
|
|
||||||
mTunerInfo.addActionListener(e -> JOptionPane.showMessageDialog(HackRFTunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
private void updateSampleRateToolTip()
|
||||||
{
|
{
|
||||||
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
||||||
{
|
{
|
||||||
mSampleRateCombo.setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
getSampleRateCombo().setTooltip(new Tooltip("Sample rate is locked. Disable decoding channels to unlock."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mSampleRateCombo.setToolTipText("Select a sample rate for the tuner");
|
getSampleRateCombo().setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
getSampleRateCombo().setDisable(!hasTuner() || locked);
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
updateSampleRateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTunerInfo()
|
@Override
|
||||||
|
protected String getTunerInfo()
|
||||||
{
|
{
|
||||||
HackRFTunerController controller = hasTuner() ? getTuner().getController() : null;
|
HackRFTunerController controller = hasTuner() ? getTuner().getController() : null;
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("<html><h3>HackRF Tuner</h3>");
|
sb.append("<html><h3>HackRF Tuner</h3>");
|
||||||
appendInfo(sb, "Board", controller != null ? controller.getBoardName() : null);
|
appendInfo(sb, "Board", controller != null ? controller.getBoardName() : null);
|
||||||
@@ -391,9 +258,6 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Appends a labeled tuner info value, or Unknown when the value is not available.
|
|
||||||
*/
|
|
||||||
private static void appendInfo(StringBuilder sb, String label, String value)
|
private static void appendInfo(StringBuilder sb, String label, String value)
|
||||||
{
|
{
|
||||||
sb.append("<b>").append(label).append(": </b>").append(value != null ? value : "Unknown").append("<br>");
|
sb.append("<b>").append(label).append(": </b>").append(value != null ? value : "Unknown").append("<br>");
|
||||||
@@ -404,18 +268,14 @@ public class HackRFTunerEditor extends TunerEditor<HackRFTuner,HackRFTunerConfig
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
HackRFTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setSampleRate(getSampleRateCombo().getValue());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setAmplifierEnabled(getAmplifierCheckBox().isSelected());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setLNAGain(getLnaGainCombo().getValue());
|
||||||
getConfiguration().setSampleRate((HackRFSampleRate)getSampleRateCombo().getSelectedItem());
|
config.setVGAGain(getVgaGainCombo().getValue());
|
||||||
getConfiguration().setAmplifierEnabled(getAmplifierToggle().isSelected());
|
|
||||||
getConfiguration().setBiasT(getBiasTToggle().isSelected());
|
|
||||||
getConfiguration().setLNAGain((HackRFLNAGain)getLnaGainCombo().getSelectedItem());
|
|
||||||
getConfiguration().setVGAGain((HackRFVGAGain)getVgaGainCombo().getSelectedItem());
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -23,50 +23,35 @@ import io.github.dsheirer.source.tuner.hydrasdr.HydraSdrTunerController.Gain;
|
|||||||
import io.github.dsheirer.source.tuner.hydrasdr.HydraSdrTunerController.GainMode;
|
import io.github.dsheirer.source.tuner.hydrasdr.HydraSdrTunerController.GainMode;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import io.github.dsheirer.source.tuner.ui.GainSlider;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import java.awt.event.ActionEvent;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.collections.FXCollections;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.JButton;
|
import javafx.scene.layout.Region;
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HydraSDR tuner editor/controller
|
* HydraSDR tuner editor
|
||||||
*/
|
*/
|
||||||
public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTunerConfiguration>
|
public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private ComboBox<HydraSdrSampleRate> mSampleRateCombo;
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(HydraSdrTunerEditor.class);
|
private ComboBox<GainMode> mGainModeCombo;
|
||||||
private JButton mTunerInfoButton;
|
private GainSlider mMasterGainSlider;
|
||||||
private JComboBox<HydraSdrSampleRate> mSampleRateCombo;
|
private Label mMasterGainLabel;
|
||||||
private JComboBox<GainMode> mGainModeCombo;
|
private GainSlider mIFGainSlider;
|
||||||
private JSlider mMasterGainSlider;
|
private Label mIFGainLabel;
|
||||||
private JLabel mMasterGainLabel;
|
private GainSlider mLNAGainSlider;
|
||||||
private JLabel mMasterGainValueLabel;
|
private Label mLNAGainLabel;
|
||||||
private JSlider mIFGainSlider;
|
private GainSlider mMixerGainSlider;
|
||||||
private JLabel mIFGainLabel;
|
private Label mMixerGainLabel;
|
||||||
private JLabel mIFGainValueLabel;
|
private CheckBox mLNAAGCCheckBox;
|
||||||
private JSlider mLNAGainSlider;
|
private CheckBox mMixerAGCCheckBox;
|
||||||
private JLabel mLNAGainValueLabel;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JSlider mMixerGainSlider;
|
|
||||||
private JLabel mMixerGainValueLabel;
|
|
||||||
private JCheckBox mLNAAGCCheckBox;
|
|
||||||
private JCheckBox mMixerAGCCheckBox;
|
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -78,7 +63,7 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -93,182 +78,62 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
return HydraSdrTunerController.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
return HydraSdrTunerController.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void init()
|
||||||
|
{
|
||||||
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
|
|
||||||
|
TunerSection gain = addSection("Gain");
|
||||||
|
gain.addRow("Mode", getGainModeCombo());
|
||||||
|
mMasterGainLabel = gain.addRow("Master", getMasterGainSlider(), new Region());
|
||||||
|
mIFGainLabel = gain.addRow("IF", getIFGainSlider(), new Region());
|
||||||
|
mMixerGainLabel = gain.addRow("Mixer", getMixerGainSlider(), getMixerAGCCheckBox());
|
||||||
|
mLNAGainLabel = gain.addRow("LNA", getLNAGainSlider(), getLNAAGCCheckBox());
|
||||||
|
|
||||||
|
TunerSection options = addSection("Options");
|
||||||
|
options.addControl(getBiasTCheckBox());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
getSampleRateCombo().setDisable(!hasTuner() || getTuner().getTunerController().isLockedSampleRate());
|
||||||
|
getBiasTCheckBox().setDisable(!hasTuner());
|
||||||
if(hasTuner())
|
getBiasTCheckBox().setSelected(hasTuner() && hasConfiguration() && getConfiguration().isBiasT());
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getTunerInfoButton().setEnabled(hasTuner());
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
if(hasTuner() && hasConfiguration())
|
|
||||||
{
|
|
||||||
getBiasTCheckBox().setSelected(getConfiguration().isBiasT());
|
|
||||||
}
|
|
||||||
updateGainComponents((hasTuner() && hasConfiguration()) ? getConfiguration().getGain() : null);
|
updateGainComponents((hasTuner() && hasConfiguration()) ? getConfiguration().getGain() : null);
|
||||||
|
|
||||||
if(hasTuner())
|
if(hasTuner())
|
||||||
{
|
{
|
||||||
List<HydraSdrSampleRate> rates = getTuner().getController().getSampleRates();
|
List<HydraSdrSampleRate> rates = getTuner().getController().getSampleRates();
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>(rates.toArray(new HydraSdrSampleRate[rates.size()])));
|
getSampleRateCombo().getItems().setAll(rates);
|
||||||
|
|
||||||
if(hasConfiguration())
|
if(hasConfiguration())
|
||||||
{
|
{
|
||||||
HydraSdrSampleRate sampleRate = getSampleRate(getConfiguration().getSampleRate());
|
getSampleRateCombo().setValue(getSampleRate(getConfiguration().getSampleRate()));
|
||||||
getSampleRateCombo().setSelectedItem(sampleRate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>());
|
getSampleRateCombo().getItems().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
updateSampleRateToolTip();
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
|
||||||
"[][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel());
|
|
||||||
add(getTunerInfoButton());
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Gain Control"), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Mode:"));
|
|
||||||
add(getGainModeCombo(), "wrap");
|
|
||||||
|
|
||||||
add(getMasterGainLabel());
|
|
||||||
add(getMasterGainSlider());
|
|
||||||
add(getMasterGainValueLabel());
|
|
||||||
|
|
||||||
add(getIFGainLabel());
|
|
||||||
add(getIFGainSlider());
|
|
||||||
add(getIFGainValueLabel());
|
|
||||||
|
|
||||||
add(getMixerAGCCheckBox());
|
|
||||||
add(getMixerGainSlider());
|
|
||||||
add(getMixerGainValueLabel());
|
|
||||||
|
|
||||||
add(getLNAAGCCheckBox());
|
|
||||||
add(getLNAGainSlider());
|
|
||||||
add(getLNAGainValueLabel());
|
|
||||||
}
|
|
||||||
|
|
||||||
private JCheckBox getLNAAGCCheckBox()
|
|
||||||
{
|
|
||||||
if(mLNAAGCCheckBox == null)
|
|
||||||
{
|
|
||||||
mLNAAGCCheckBox = new JCheckBox("AGC LNA:");
|
|
||||||
mLNAAGCCheckBox.setEnabled(false);
|
|
||||||
mLNAAGCCheckBox.addActionListener(e ->
|
|
||||||
{
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setLNAAGC(getLNAAGCCheckBox().isSelected());
|
|
||||||
getLNAGainSlider().setEnabled(!getLNAAGCCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting LNA AGC Enabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mLNAAGCCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JCheckBox getMixerAGCCheckBox()
|
|
||||||
{
|
|
||||||
if(mMixerAGCCheckBox == null)
|
|
||||||
{
|
|
||||||
mMixerAGCCheckBox = new JCheckBox("AGC Mixer:");
|
|
||||||
mMixerAGCCheckBox.setEnabled(false);
|
|
||||||
mMixerAGCCheckBox.addActionListener(e ->
|
|
||||||
{
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setMixerAGC(getMixerAGCCheckBox().isSelected());
|
|
||||||
getMixerGainSlider().setEnabled(!getMixerAGCCheckBox().isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Mixer AGC Enabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMixerAGCCheckBox;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checkbox to enable/disable Bias-T power for active antennas
|
* Checkbox to enable/disable Bias-T power for active antennas
|
||||||
*/
|
*/
|
||||||
private JCheckBox getBiasTCheckBox()
|
private CheckBox getBiasTCheckBox()
|
||||||
{
|
{
|
||||||
if(mBiasTCheckBox == null)
|
if(mBiasTCheckBox == null)
|
||||||
{
|
{
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T");
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
mBiasTCheckBox.setEnabled(false);
|
mBiasTCheckBox.setDisable(true);
|
||||||
mBiasTCheckBox.setToolTipText("Enable Bias-T power output for active antennas");
|
mBiasTCheckBox.setTooltip(new Tooltip("Enable Bias-T power output for active antennas"));
|
||||||
mBiasTCheckBox.addActionListener(e ->
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
{
|
if(hasTuner() && !isLoading() &&
|
||||||
if(hasTuner() && !isLoading())
|
applyToTuner("Bias-T", () -> getTuner().getController().setBiasT(mBiasTCheckBox.isSelected())))
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T", e1);
|
|
||||||
JOptionPane.showMessageDialog(mBiasTCheckBox, "Couldn't set Bias-T: " + e1.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -276,93 +141,77 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
return mBiasTCheckBox;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getLNAGainValueLabel()
|
private CheckBox getLNAAGCCheckBox()
|
||||||
{
|
{
|
||||||
if(mLNAGainValueLabel == null)
|
if(mLNAAGCCheckBox == null)
|
||||||
{
|
{
|
||||||
mLNAGainValueLabel = new JLabel("0");
|
mLNAAGCCheckBox = new CheckBox("AGC");
|
||||||
mLNAGainValueLabel.setEnabled(false);
|
mLNAAGCCheckBox.setTooltip(new Tooltip("Automatic LNA gain control"));
|
||||||
|
mLNAAGCCheckBox.setDisable(true);
|
||||||
|
mLNAAGCCheckBox.setOnAction(e -> {
|
||||||
|
if(hasTuner() && !isLoading() && applyToTuner("LNA AGC",
|
||||||
|
() -> getTuner().getController().setLNAAGC(getLNAAGCCheckBox().isSelected())))
|
||||||
|
{
|
||||||
|
getLNAGainSlider().setDisable(getLNAAGCCheckBox().isSelected());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mLNAGainValueLabel;
|
return mLNAAGCCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSlider getLNAGainSlider()
|
private CheckBox getMixerAGCCheckBox()
|
||||||
|
{
|
||||||
|
if(mMixerAGCCheckBox == null)
|
||||||
|
{
|
||||||
|
mMixerAGCCheckBox = new CheckBox("AGC");
|
||||||
|
mMixerAGCCheckBox.setTooltip(new Tooltip("Automatic mixer gain control"));
|
||||||
|
mMixerAGCCheckBox.setDisable(true);
|
||||||
|
mMixerAGCCheckBox.setOnAction(e -> {
|
||||||
|
if(hasTuner() && !isLoading() && applyToTuner("mixer AGC",
|
||||||
|
() -> getTuner().getController().setMixerAGC(getMixerAGCCheckBox().isSelected())))
|
||||||
|
{
|
||||||
|
getMixerGainSlider().setDisable(getMixerAGCCheckBox().isSelected());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mMixerAGCCheckBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GainSlider getLNAGainSlider()
|
||||||
{
|
{
|
||||||
if(mLNAGainSlider == null)
|
if(mLNAGainSlider == null)
|
||||||
{
|
{
|
||||||
mLNAGainSlider = new JSlider(JSlider.HORIZONTAL, HydraSdrTunerController.LNA_GAIN_MIN,
|
mLNAGainSlider = new GainSlider(HydraSdrTunerController.LNA_GAIN_MIN, HydraSdrTunerController.LNA_GAIN_MAX,
|
||||||
HydraSdrTunerController.LNA_GAIN_MAX, HydraSdrTunerController.LNA_GAIN_MIN);
|
HydraSdrTunerController.LNA_GAIN_MIN);
|
||||||
mLNAGainSlider.setEnabled(false);
|
mLNAGainSlider.setDisable(true);
|
||||||
mLNAGainSlider.setMajorTickSpacing(1);
|
mLNAGainSlider.setOnChange(gain -> {
|
||||||
mLNAGainSlider.setPaintTicks(true);
|
if(hasTuner() && !isLoading() &&
|
||||||
mLNAGainSlider.addChangeListener(event ->
|
applyToTuner("LNA gain", () -> getTuner().getController().setLNAGain(gain)))
|
||||||
{
|
|
||||||
int gain = mLNAGainSlider.getValue();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setLNAGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set HydraSDR LNA gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mLNAGainSlider, "Couldn't set LNA gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getLNAGainValueLabel().setText(String.valueOf(gain));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mLNAGainSlider;
|
return mLNAGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getMixerGainValueLabel()
|
private GainSlider getMixerGainSlider()
|
||||||
{
|
|
||||||
if(mMixerGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mMixerGainValueLabel = new JLabel("0");
|
|
||||||
mMixerGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMixerGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getMixerGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mMixerGainSlider == null)
|
if(mMixerGainSlider == null)
|
||||||
{
|
{
|
||||||
mMixerGainSlider = new JSlider(JSlider.HORIZONTAL, HydraSdrTunerController.MIXER_GAIN_MIN,
|
mMixerGainSlider = new GainSlider(HydraSdrTunerController.MIXER_GAIN_MIN,
|
||||||
HydraSdrTunerController.MIXER_GAIN_MAX, HydraSdrTunerController.MIXER_GAIN_MIN);
|
HydraSdrTunerController.MIXER_GAIN_MAX, HydraSdrTunerController.MIXER_GAIN_MIN);
|
||||||
mMixerGainSlider.setEnabled(false);
|
mMixerGainSlider.setDisable(true);
|
||||||
mMixerGainSlider.setMajorTickSpacing(1);
|
mMixerGainSlider.setOnChange(gain -> {
|
||||||
mMixerGainSlider.setPaintTicks(true);
|
if(hasTuner() && !isLoading() &&
|
||||||
mMixerGainSlider.addChangeListener(new ChangeListener()
|
applyToTuner("mixer gain", () -> getTuner().getController().setMixerGain(gain)))
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void stateChanged(ChangeEvent event)
|
|
||||||
{
|
{
|
||||||
int gain = mMixerGainSlider.getValue();
|
save();
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setMixerGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set HydraSDR Mixer gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mMixerGainSlider, "Couldn't set Mixer gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getMixerGainValueLabel().setText(String.valueOf(gain));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -370,134 +219,77 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
return mMixerGainSlider;
|
return mMixerGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getIFGainLabel()
|
private GainSlider getIFGainSlider()
|
||||||
{
|
|
||||||
if(mIFGainLabel == null)
|
|
||||||
{
|
|
||||||
mIFGainLabel = new JLabel("IF:");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mIFGainLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getIFGainValueLabel()
|
|
||||||
{
|
|
||||||
if(mIFGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mIFGainValueLabel = new JLabel("0");
|
|
||||||
mIFGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mIFGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getIFGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mIFGainSlider == null)
|
if(mIFGainSlider == null)
|
||||||
{
|
{
|
||||||
mIFGainSlider = new JSlider(JSlider.HORIZONTAL, HydraSdrTunerController.IF_GAIN_MIN,
|
mIFGainSlider = new GainSlider(HydraSdrTunerController.IF_GAIN_MIN, HydraSdrTunerController.IF_GAIN_MAX,
|
||||||
HydraSdrTunerController.IF_GAIN_MAX, HydraSdrTunerController.IF_GAIN_MIN);
|
HydraSdrTunerController.IF_GAIN_MIN);
|
||||||
mIFGainSlider.setEnabled(false);
|
mIFGainSlider.setDisable(true);
|
||||||
mIFGainSlider.setMajorTickSpacing(1);
|
mIFGainSlider.setOnChange(gain -> {
|
||||||
mIFGainSlider.setPaintTicks(true);
|
if(hasTuner() && !isLoading() &&
|
||||||
mIFGainSlider.addChangeListener(event ->
|
applyToTuner("IF gain", () -> getTuner().getController().setIFGain(gain)))
|
||||||
{
|
|
||||||
int gain = mIFGainSlider.getValue();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setIFGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set HydraSDR IF gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mIFGainSlider, "Couldn't set IF gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getIFGainValueLabel().setText(String.valueOf(gain));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mIFGainSlider;
|
return mIFGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getMasterGainLabel()
|
private GainSlider getMasterGainSlider()
|
||||||
{
|
|
||||||
if(mMasterGainLabel == null)
|
|
||||||
{
|
|
||||||
mMasterGainLabel = new JLabel("Master:");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMasterGainLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getMasterGainValueLabel()
|
|
||||||
{
|
|
||||||
if(mMasterGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mMasterGainValueLabel = new JLabel("0");
|
|
||||||
mMasterGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mMasterGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JSlider getMasterGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mMasterGainSlider == null)
|
if(mMasterGainSlider == null)
|
||||||
{
|
{
|
||||||
mMasterGainSlider = new JSlider(JSlider.HORIZONTAL, HydraSdrTunerController.GAIN_MIN,
|
mMasterGainSlider = new GainSlider(HydraSdrTunerController.GAIN_MIN, HydraSdrTunerController.GAIN_MAX,
|
||||||
HydraSdrTunerController.GAIN_MAX, HydraSdrTunerController.GAIN_MIN);
|
HydraSdrTunerController.GAIN_MIN);
|
||||||
mMasterGainSlider.setEnabled(false);
|
mMasterGainSlider.setDisable(true);
|
||||||
mMasterGainSlider.setMajorTickSpacing(1);
|
mMasterGainSlider.setOnChange(value -> {
|
||||||
mMasterGainSlider.setPaintTicks(true);
|
Gain gain = Gain.getGain(getGainModeCombo().getValue(), value);
|
||||||
|
|
||||||
mMasterGainSlider.addChangeListener(event ->
|
if(hasTuner() && !isLoading() && applyToTuner("gain", () -> getTuner().getController().setGain(gain)))
|
||||||
{
|
|
||||||
GainMode mode = (GainMode)mGainModeCombo.getSelectedItem();
|
|
||||||
int value = mMasterGainSlider.getValue();
|
|
||||||
Gain gain = Gain.getGain(mode, value);
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set HydraSDR gain to:" + gain.name(), e);
|
|
||||||
JOptionPane.showMessageDialog(mMasterGainSlider, "Couldn't set gain value to " +
|
|
||||||
gain.getValue());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMasterGainValueLabel().setText(String.valueOf(value));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mMasterGainSlider;
|
return mMasterGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<GainMode> getGainModeCombo()
|
private ComboBox<GainMode> getGainModeCombo()
|
||||||
{
|
{
|
||||||
if(mGainModeCombo == null)
|
if(mGainModeCombo == null)
|
||||||
{
|
{
|
||||||
mGainModeCombo = new JComboBox<>(GainMode.values());
|
mGainModeCombo = new ComboBox<>(FXCollections.observableArrayList(GainMode.values()));
|
||||||
mGainModeCombo.setEnabled(false);
|
mGainModeCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mGainModeCombo.addActionListener(e ->
|
mGainModeCombo.setDisable(true);
|
||||||
{
|
mGainModeCombo.setTooltip(new Tooltip("Linearity and sensitivity modes set all gains from the master " +
|
||||||
|
"gain. Custom mode sets each gain separately."));
|
||||||
|
mGainModeCombo.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
if(hasTuner() && !isLoading())
|
||||||
{
|
{
|
||||||
GainMode mode = (GainMode)mGainModeCombo.getSelectedItem();
|
Gain gain = Gain.getGain(mGainModeCombo.getValue(), getMasterGainSlider().getValue());
|
||||||
int value = getMasterGainSlider().getValue();
|
setLoading(true);
|
||||||
Gain gain = Gain.getGain(mode, value);
|
|
||||||
updateGainComponents(gain);
|
updateGainComponents(gain);
|
||||||
|
setLoading(false);
|
||||||
|
applyToTuner("gain mode", () -> {
|
||||||
|
HydraSdrTunerController controller = getTuner().getController();
|
||||||
|
|
||||||
|
if(gain == Gain.CUSTOM)
|
||||||
|
{
|
||||||
|
controller.setMixerAGC(getMixerAGCCheckBox().isSelected());
|
||||||
|
controller.setLNAAGC(getLNAAGCCheckBox().isSelected());
|
||||||
|
controller.setIFGain(getIFGainSlider().getValue());
|
||||||
|
controller.setMixerGain(getMixerGainSlider().getValue());
|
||||||
|
controller.setLNAGain(getLNAGainSlider().getValue());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
controller.setGain(gain);
|
||||||
|
}
|
||||||
|
});
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -506,37 +298,23 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
return mGainModeCombo;
|
return mGainModeCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<HydraSdrSampleRate> getSampleRateCombo()
|
private ComboBox<HydraSdrSampleRate> getSampleRateCombo()
|
||||||
{
|
{
|
||||||
if(mSampleRateCombo == null)
|
if(mSampleRateCombo == null)
|
||||||
{
|
{
|
||||||
mSampleRateCombo = new JComboBox<>();
|
mSampleRateCombo = new ComboBox<>();
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.addActionListener(new ActionListener()
|
mSampleRateCombo.setDisable(true);
|
||||||
{
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
@Override
|
HydraSdrSampleRate rate = mSampleRateCombo.getValue();
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
|
if(hasTuner() && !isLoading() && rate != null &&
|
||||||
|
applyToTuner("sample rate [" + rate.getLabel() + "]",
|
||||||
|
() -> getTuner().getController().setSampleRate(rate)))
|
||||||
{
|
{
|
||||||
if(hasTuner() && !isLoading())
|
//Adjust the min/max values for the sample rate.
|
||||||
{
|
adjustForSampleRate(rate.getRate());
|
||||||
HydraSdrSampleRate rate = (HydraSdrSampleRate)mSampleRateCombo.getSelectedItem();
|
save();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(rate);
|
|
||||||
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(rate.getRate());
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(HydraSdrTunerEditor.this,
|
|
||||||
"Couldn't set sample rate to " + rate.getLabel());
|
|
||||||
mLog.error("Error setting HydraSDR sample rate", e1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -545,48 +323,29 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hyperlink button that provides tuner information
|
* Updates the enabled state of each of the gain controls according to the specified gain mode. The master gain
|
||||||
*/
|
* control is enabled for linearity and sensitivity and the individual gain controls are disabled, and vice-versa
|
||||||
private JButton getTunerInfoButton()
|
* for custom mode.
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(HydraSdrTunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the enabled state of each of the gain controls according to the
|
|
||||||
* specified gain mode. The master gain control is enabled for linearity
|
|
||||||
* and sensitivity and the individual gain controls are disabled, and
|
|
||||||
* vice-versa for custom mode.
|
|
||||||
*/
|
*/
|
||||||
private void updateGainComponents(Gain gain)
|
private void updateGainComponents(Gain gain)
|
||||||
{
|
{
|
||||||
if(hasTuner() && gain != null)
|
if(hasTuner() && gain != null)
|
||||||
{
|
{
|
||||||
boolean isCustom = gain.equals(Gain.CUSTOM);
|
boolean isCustom = gain.equals(Gain.CUSTOM);
|
||||||
|
getGainModeCombo().setDisable(false);
|
||||||
getGainModeCombo().setEnabled(true);
|
getGainModeCombo().setValue(gain.getGainMode());
|
||||||
getGainModeCombo().setSelectedItem(gain.getGainMode());
|
mMasterGainLabel.setDisable(isCustom);
|
||||||
getMasterGainLabel().setEnabled(!isCustom);
|
getMasterGainSlider().setDisable(isCustom);
|
||||||
getMasterGainSlider().setEnabled(!isCustom);
|
|
||||||
getMasterGainSlider().setValue(gain.getValue());
|
getMasterGainSlider().setValue(gain.getValue());
|
||||||
getMasterGainValueLabel().setEnabled(!isCustom);
|
mIFGainLabel.setDisable(!isCustom);
|
||||||
getIFGainLabel().setEnabled(isCustom);
|
getIFGainSlider().setDisable(!isCustom);
|
||||||
getIFGainSlider().setEnabled(isCustom);
|
mLNAGainLabel.setDisable(!isCustom);
|
||||||
getIFGainValueLabel().setEnabled(isCustom);
|
getLNAAGCCheckBox().setDisable(!isCustom);
|
||||||
getLNAAGCCheckBox().setEnabled(isCustom);
|
getLNAGainSlider().setDisable(!isCustom || getConfiguration().isLNAAGC());
|
||||||
getLNAGainSlider().setEnabled(isCustom && !getConfiguration().isLNAAGC());
|
mMixerGainLabel.setDisable(!isCustom);
|
||||||
getLNAGainValueLabel().setEnabled(isCustom);
|
getMixerAGCCheckBox().setDisable(!isCustom);
|
||||||
getMixerAGCCheckBox().setEnabled(isCustom);
|
getMixerGainSlider().setDisable(!isCustom || getConfiguration().isMixerAGC());
|
||||||
getMixerGainSlider().setEnabled(isCustom && !getConfiguration().isMixerAGC());
|
|
||||||
getMixerGainValueLabel().setEnabled(isCustom);
|
|
||||||
if(isCustom)
|
if(isCustom)
|
||||||
{
|
{
|
||||||
getIFGainSlider().setValue(getConfiguration().getIFGain());
|
getIFGainSlider().setValue(getConfiguration().getIFGain());
|
||||||
@@ -606,25 +365,23 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getGainModeCombo().setEnabled(false);
|
getGainModeCombo().setDisable(true);
|
||||||
getMasterGainLabel().setEnabled(false);
|
mMasterGainLabel.setDisable(true);
|
||||||
getMasterGainSlider().setEnabled(false);
|
getMasterGainSlider().setDisable(true);
|
||||||
getMasterGainSlider().setValue(0);
|
getMasterGainSlider().setValue(0);
|
||||||
getMasterGainValueLabel().setEnabled(false);
|
mIFGainLabel.setDisable(true);
|
||||||
getIFGainLabel().setEnabled(false);
|
getIFGainSlider().setDisable(true);
|
||||||
getIFGainSlider().setEnabled(false);
|
|
||||||
getIFGainSlider().setValue(0);
|
getIFGainSlider().setValue(0);
|
||||||
getIFGainValueLabel().setEnabled(false);
|
mLNAGainLabel.setDisable(true);
|
||||||
getLNAAGCCheckBox().setEnabled(false);
|
getLNAAGCCheckBox().setDisable(true);
|
||||||
getLNAAGCCheckBox().setSelected(false);
|
getLNAAGCCheckBox().setSelected(false);
|
||||||
getLNAGainSlider().setEnabled(false);
|
getLNAGainSlider().setDisable(true);
|
||||||
getLNAGainSlider().setValue(0);
|
getLNAGainSlider().setValue(0);
|
||||||
getLNAGainValueLabel().setEnabled(false);
|
mMixerGainLabel.setDisable(true);
|
||||||
getMixerAGCCheckBox().setEnabled(false);
|
getMixerAGCCheckBox().setDisable(true);
|
||||||
getMixerAGCCheckBox().setSelected(false);
|
getMixerAGCCheckBox().setSelected(false);
|
||||||
getMixerGainSlider().setEnabled(false);
|
getMixerGainSlider().setDisable(true);
|
||||||
getMixerGainSlider().setValue(0);
|
getMixerGainSlider().setValue(0);
|
||||||
getMixerGainValueLabel().setEnabled(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,21 +390,21 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
HydraSdrTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
if(getSampleRateCombo().getValue() != null)
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
{
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setSampleRate(getSampleRateCombo().getValue().getRate());
|
||||||
getConfiguration().setSampleRate(((HydraSdrSampleRate)getSampleRateCombo().getSelectedItem()).getRate());
|
}
|
||||||
Gain gain = Gain.getGain((GainMode)mGainModeCombo.getSelectedItem(), getMasterGainSlider().getValue());
|
|
||||||
getConfiguration().setGain(gain);
|
config.setGain(Gain.getGain(getGainModeCombo().getValue(), getMasterGainSlider().getValue()));
|
||||||
getConfiguration().setIFGain(getIFGainSlider().getValue());
|
config.setIFGain(getIFGainSlider().getValue());
|
||||||
getConfiguration().setMixerGain(getMixerGainSlider().getValue());
|
config.setMixerGain(getMixerGainSlider().getValue());
|
||||||
getConfiguration().setLNAGain(getLNAGainSlider().getValue());
|
config.setLNAGain(getLNAGainSlider().getValue());
|
||||||
getConfiguration().setMixerAGC(getMixerAGCCheckBox().isSelected());
|
config.setMixerAGC(getMixerAGCCheckBox().isSelected());
|
||||||
getConfiguration().setLNAAGC(getLNAAGCCheckBox().isSelected());
|
config.setLNAAGC(getLNAAGCCheckBox().isSelected());
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
config.setBiasT(getBiasTCheckBox().isSelected());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -671,7 +428,7 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rates.size() > 0)
|
if(!rates.isEmpty())
|
||||||
{
|
{
|
||||||
return rates.get(0);
|
return rates.get(0);
|
||||||
}
|
}
|
||||||
@@ -687,55 +444,31 @@ public class HydraSdrTunerEditor extends TunerEditor<HydraSdrTuner, HydraSdrTune
|
|||||||
{
|
{
|
||||||
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
if(hasTuner() && getTuner().getController().isLockedSampleRate())
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
getSampleRateCombo().setTooltip(new Tooltip("Sample rate is locked. Disable decoding channels to unlock."));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
getSampleRateCombo().setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
getSampleRateCombo().setDisable(!hasTuner() || locked);
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
updateSampleRateToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTunerInfo()
|
@Override
|
||||||
|
protected String getTunerInfo()
|
||||||
{
|
{
|
||||||
if(getDiscoveredTuner().getTunerStatus() == TunerStatus.ERROR)
|
StringBuilder sb = new StringBuilder();
|
||||||
{
|
HydraSdrDeviceInformation info = getTuner().getController().getDeviceInfo();
|
||||||
return getDiscoveredTuner().getErrorMessage();
|
sb.append("<html><h3>HydraSDR Tuner</h3>");
|
||||||
}
|
sb.append("<b>Serial: </b>").append(info.getSerialNumber()).append("<br>");
|
||||||
|
sb.append("<b>Firmware: </b>").append(info.getVersion()).append("<br>");
|
||||||
if(hasTuner())
|
sb.append("<b>Part: </b>").append(info.getPartNumber()).append("<br>");
|
||||||
{
|
sb.append("<b>Board: </b>").append(info.getBoardName()).append("<br>");
|
||||||
StringBuilder sb = new StringBuilder();
|
return sb.toString();
|
||||||
|
|
||||||
HydraSdrDeviceInformation info = getTuner().getController().getDeviceInfo();
|
|
||||||
|
|
||||||
sb.append("<html><h3>HydraSDR Tuner</h3>");
|
|
||||||
sb.append("<b>Serial: </b>");
|
|
||||||
sb.append(info.getSerialNumber());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Firmware: </b>");
|
|
||||||
sb.append(info.getVersion());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Part: </b>");
|
|
||||||
sb.append(info.getPartNumber());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
sb.append("<b>Board: </b>");
|
|
||||||
sb.append(info.getBoardName());
|
|
||||||
sb.append("<br>");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,42 +16,25 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.limesdr;
|
package io.github.dsheirer.source.tuner.limesdr;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import io.github.dsheirer.source.tuner.ui.GainSlider;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import java.io.Serial;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import java.util.List;
|
import javafx.scene.control.ComboBox;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.Tooltip;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LimeSDR tuner editor
|
* LimeSDR tuner editor
|
||||||
*/
|
*/
|
||||||
public class LimeSdrTunerEditor extends TunerEditor<LimeSdrTuner, LimeSdrTunerConfiguration>
|
public class LimeSdrTunerEditor extends TunerEditor<LimeSdrTuner, LimeSdrTunerConfiguration>
|
||||||
{
|
{
|
||||||
@Serial
|
private ComboBox<LimeSdrSampleRate> mSampleRateCombo;
|
||||||
private static final long serialVersionUID = 1L;
|
private ComboBox<String> mAntennaCombo;
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(LimeSdrTunerEditor.class);
|
private GainSlider mGainSlider;
|
||||||
private JButton mTunerInfoButton;
|
|
||||||
private JComboBox<LimeSdrSampleRate> mSampleRateCombo;
|
|
||||||
private JComboBox<String> mAntennaCombo;
|
|
||||||
private JSlider mGainSlider;
|
|
||||||
private JLabel mGainValueLabel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -63,7 +46,7 @@ public class LimeSdrTunerEditor extends TunerEditor<LimeSdrTuner, LimeSdrTunerCo
|
|||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,142 +65,62 @@ public class LimeSdrTunerEditor extends TunerEditor<LimeSdrTuner, LimeSdrTunerCo
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]", "[][][][][][][][][][][grow]"));
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
|
getTuningSection().addRow("Antenna", getAntennaCombo());
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
TunerSection gain = addSection("Gain");
|
||||||
add(getTunerIdLabel());
|
gain.addRow("Gain", getGainSlider());
|
||||||
add(getTunerInfoButton());
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Antenna:"));
|
|
||||||
add(getAntennaCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainSlider());
|
|
||||||
add(getGainValueLabel());
|
|
||||||
|
|
||||||
//Empty row that takes all extra vertical space so that the controls stay stacked at the top of the editor.
|
|
||||||
add(new JLabel(), "span,pushy");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
if(hasStartedTuner())
|
||||||
|
|
||||||
boolean started = hasStartedTuner();
|
|
||||||
getTunerIdLabel().setText(started ? getTuner().getPreferredName() : getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getTunerInfoButton().setEnabled(started);
|
|
||||||
|
|
||||||
if(started)
|
|
||||||
{
|
{
|
||||||
LimeSdrTunerController controller = getTuner().getController();
|
LimeSdrTunerController controller = getTuner().getController();
|
||||||
List<LimeSdrSampleRate> rates = controller.getSampleRates();
|
getSampleRateCombo().getItems().setAll(controller.getSampleRates());
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>(rates.toArray(new LimeSdrSampleRate[0])));
|
getSampleRateCombo().setValue(controller.getLimeSdrSampleRate());
|
||||||
getSampleRateCombo().setSelectedItem(controller.getLimeSdrSampleRate());
|
getSampleRateCombo().setDisable(controller.isLockedSampleRate());
|
||||||
getSampleRateCombo().setEnabled(!controller.isLockedSampleRate());
|
getAntennaCombo().getItems().setAll(controller.getAntennas());
|
||||||
|
getAntennaCombo().setValue(controller.getAntenna());
|
||||||
List<String> antennas = controller.getAntennas();
|
getAntennaCombo().setDisable(false);
|
||||||
getAntennaCombo().setModel(new DefaultComboBoxModel<>(antennas.toArray(new String[0])));
|
|
||||||
getAntennaCombo().setSelectedItem(controller.getAntenna());
|
|
||||||
getAntennaCombo().setEnabled(true);
|
|
||||||
|
|
||||||
getGainSlider().setValue(controller.getGain());
|
getGainSlider().setValue(controller.getGain());
|
||||||
getGainSlider().setEnabled(true);
|
getGainSlider().setDisable(false);
|
||||||
getGainValueLabel().setEnabled(true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
getSampleRateCombo().setModel(new DefaultComboBoxModel<>());
|
getSampleRateCombo().getItems().clear();
|
||||||
getSampleRateCombo().setEnabled(false);
|
getSampleRateCombo().setDisable(true);
|
||||||
getAntennaCombo().setModel(new DefaultComboBoxModel<>());
|
getAntennaCombo().getItems().clear();
|
||||||
getAntennaCombo().setEnabled(false);
|
getAntennaCombo().setDisable(true);
|
||||||
getGainSlider().setEnabled(false);
|
getGainSlider().setDisable(true);
|
||||||
getGainValueLabel().setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGainLabel();
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the tuner has finished starting, since a status update can arrive while it's starting or restarting.
|
* Indicates if the tuner is started, which is when the controller knows the selected antenna.
|
||||||
*/
|
*/
|
||||||
private boolean hasStartedTuner()
|
private boolean hasStartedTuner()
|
||||||
{
|
{
|
||||||
return hasTuner() && getTuner().getController().getAntenna() != null;
|
return hasTuner() && getTuner().getController().getAntenna() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateGainLabel()
|
private ComboBox<LimeSdrSampleRate> getSampleRateCombo()
|
||||||
{
|
|
||||||
getGainValueLabel().setText(getGainSlider().getValue() + " dB");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button that provides tuner information
|
|
||||||
*/
|
|
||||||
private JButton getTunerInfoButton()
|
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(_ -> JOptionPane.showMessageDialog(LimeSdrTunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JComboBox<LimeSdrSampleRate> getSampleRateCombo()
|
|
||||||
{
|
{
|
||||||
if(mSampleRateCombo == null)
|
if(mSampleRateCombo == null)
|
||||||
{
|
{
|
||||||
mSampleRateCombo = new JComboBox<>();
|
mSampleRateCombo = new ComboBox<>();
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.addActionListener(_ ->
|
mSampleRateCombo.setDisable(true);
|
||||||
{
|
mSampleRateCombo.setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
if(hasTuner() && !isLoading())
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
|
LimeSdrSampleRate rate = mSampleRateCombo.getValue();
|
||||||
|
|
||||||
|
if(hasTuner() && !isLoading() && rate != null &&
|
||||||
|
applyToTuner("sample rate [" + rate + "]", () -> getTuner().getController().setSampleRate(rate)))
|
||||||
{
|
{
|
||||||
LimeSdrSampleRate rate = (LimeSdrSampleRate)mSampleRateCombo.getSelectedItem();
|
adjustForSampleRate(rate.getRate());
|
||||||
|
save();
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(rate);
|
|
||||||
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(rate.getRate());
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting LimeSDR sample rate", e1);
|
|
||||||
JOptionPane.showMessageDialog(LimeSdrTunerEditor.this, "Couldn't set sample rate to " + rate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -225,29 +128,21 @@ public class LimeSdrTunerEditor extends TunerEditor<LimeSdrTuner, LimeSdrTunerCo
|
|||||||
return mSampleRateCombo;
|
return mSampleRateCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<String> getAntennaCombo()
|
private ComboBox<String> getAntennaCombo()
|
||||||
{
|
{
|
||||||
if(mAntennaCombo == null)
|
if(mAntennaCombo == null)
|
||||||
{
|
{
|
||||||
mAntennaCombo = new JComboBox<>();
|
mAntennaCombo = new ComboBox<>();
|
||||||
mAntennaCombo.setEnabled(false);
|
mAntennaCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mAntennaCombo.setToolTipText("Receive port: LNAW wideband (default), LNAL low band, LNAH high band");
|
mAntennaCombo.setDisable(true);
|
||||||
mAntennaCombo.addActionListener(_ ->
|
mAntennaCombo.setTooltip(new Tooltip("Receive port: LNAW wideband (default), LNAL low band, LNAH high band"));
|
||||||
{
|
mAntennaCombo.setOnAction(e -> {
|
||||||
if(hasTuner() && !isLoading())
|
String antenna = mAntennaCombo.getValue();
|
||||||
{
|
|
||||||
String antenna = (String)mAntennaCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
if(hasTuner() && !isLoading() && antenna != null &&
|
||||||
{
|
applyToTuner("antenna [" + antenna + "]", () -> getTuner().getController().setAntenna(antenna)))
|
||||||
getTuner().getController().setAntenna(antenna);
|
{
|
||||||
save();
|
save();
|
||||||
}
|
|
||||||
catch(Exception e1)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting LimeSDR antenna", e1);
|
|
||||||
JOptionPane.showMessageDialog(mAntennaCombo, "Couldn't set antenna to " + antenna);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -255,109 +150,75 @@ public class LimeSdrTunerEditor extends TunerEditor<LimeSdrTuner, LimeSdrTunerCo
|
|||||||
return mAntennaCombo;
|
return mAntennaCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JSlider getGainSlider()
|
private GainSlider getGainSlider()
|
||||||
{
|
{
|
||||||
if(mGainSlider == null)
|
if(mGainSlider == null)
|
||||||
{
|
{
|
||||||
mGainSlider = new JSlider(JSlider.HORIZONTAL, LimeSdrTunerController.GAIN_MINIMUM,
|
mGainSlider = new GainSlider(LimeSdrTunerController.GAIN_MINIMUM, LimeSdrTunerController.GAIN_MAXIMUM,
|
||||||
LimeSdrTunerController.GAIN_MAXIMUM, LimeSdrTunerController.GAIN_DEFAULT);
|
LimeSdrTunerController.GAIN_DEFAULT);
|
||||||
mGainSlider.setEnabled(false);
|
mGainSlider.setDisable(true);
|
||||||
mGainSlider.setMajorTickSpacing(5);
|
mGainSlider.setFormatter(value -> value + " dB");
|
||||||
mGainSlider.setPaintTicks(true);
|
mGainSlider.setOnChange(gain -> {
|
||||||
mGainSlider.addChangeListener(_ ->
|
if(hasTuner() && !isLoading() &&
|
||||||
{
|
applyToTuner("gain", () -> getTuner().getController().setGain(gain)))
|
||||||
int gain = mGainSlider.getValue();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
{
|
||||||
try
|
save();
|
||||||
{
|
|
||||||
getTuner().getController().setGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set LimeSDR gain to:" + gain, e);
|
|
||||||
JOptionPane.showMessageDialog(mGainSlider, "Couldn't set gain value to " + gain);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGainLabel();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mGainSlider;
|
return mGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JLabel getGainValueLabel()
|
|
||||||
{
|
|
||||||
if(mGainValueLabel == null)
|
|
||||||
{
|
|
||||||
mGainValueLabel = new JLabel("0 dB");
|
|
||||||
mGainValueLabel.setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return mGainValueLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
LimeSdrTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
|
|
||||||
if(getSampleRateCombo().getSelectedItem() instanceof LimeSdrSampleRate rate)
|
if(getSampleRateCombo().getValue() instanceof LimeSdrSampleRate rate)
|
||||||
{
|
{
|
||||||
getConfiguration().setSampleRate(rate.getRate());
|
config.setSampleRate(rate.getRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getAntennaCombo().getSelectedItem() instanceof String antenna)
|
if(getAntennaCombo().getValue() instanceof String antenna)
|
||||||
{
|
{
|
||||||
getConfiguration().setAntenna(antenna);
|
config.setAntenna(antenna);
|
||||||
}
|
}
|
||||||
|
|
||||||
getConfiguration().setGain(getGainSlider().getValue());
|
config.setGain(getGainSlider().getValue());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
getSampleRateCombo().setDisable(!hasStartedTuner() || locked);
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
getSampleRateCombo().setTooltip(new Tooltip(locked ? "Sample rate is locked. Disable decoding channels " +
|
||||||
getSampleRateCombo().setToolTipText(locked ? "Sample Rate is locked. Disable decoding channels to unlock." :
|
"to unlock." : "Select a sample rate for the tuner"));
|
||||||
"Select a sample rate for the tuner");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getTunerInfo()
|
@Override
|
||||||
|
protected String getTunerInfo()
|
||||||
{
|
{
|
||||||
if(getDiscoveredTuner().getTunerStatus() == TunerStatus.ERROR)
|
if(!hasStartedTuner())
|
||||||
{
|
{
|
||||||
return getDiscoveredTuner().getErrorMessage();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasTuner())
|
LimeSdrDeviceInformation info = getTuner().getController().getDeviceInfo();
|
||||||
{
|
StringBuilder sb = new StringBuilder();
|
||||||
LimeSdrDeviceInformation info = getTuner().getController().getDeviceInfo();
|
sb.append("<html><h3>LimeSDR Tuner</h3>");
|
||||||
StringBuilder sb = new StringBuilder();
|
sb.append("<b>Board: </b>").append(info.board()).append("<br>");
|
||||||
sb.append("<html><h3>LimeSDR Tuner</h3>");
|
sb.append("<b>Serial: </b>").append(info.serial()).append("<br>");
|
||||||
sb.append("<b>Board: </b>").append(info.board()).append("<br>");
|
sb.append("<b>Hardware: </b>").append(info.hardware()).append("<br>");
|
||||||
sb.append("<b>Serial: </b>").append(info.serial()).append("<br>");
|
sb.append("<b>Firmware: </b>").append(info.firmware()).append("<br>");
|
||||||
sb.append("<b>Hardware: </b>").append(info.hardware()).append("<br>");
|
sb.append("<b>Gateware: </b>").append(info.gateware()).append("<br>");
|
||||||
sb.append("<b>Firmware: </b>").append(info.firmware()).append("<br>");
|
sb.append("<b>Connection: </b>").append(info.connection()).append("<br>");
|
||||||
sb.append("<b>Gateware: </b>").append(info.gateware()).append("<br>");
|
sb.append("<b>LimeSuiteNG: </b>").append(info.library()).append("<br>");
|
||||||
sb.append("<b>Connection: </b>").append(info.connection()).append("<br>");
|
return sb.toString();
|
||||||
sb.append("<b>LimeSuiteNG: </b>").append(info.library()).append("<br>");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,165 +18,150 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dsheirer.source.tuner.network;
|
package io.github.dsheirer.source.tuner.network;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import io.github.dsheirer.gui.control.FrequencyEntry;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredNetworkTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredNetworkTuner;
|
||||||
import io.github.dsheirer.source.tuner.ui.DiscoveredTunerModel;
|
import io.github.dsheirer.source.tuner.ui.DiscoveredTunerModel;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.ButtonBar;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Dialog;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
/**
|
||||||
import javax.swing.JComboBox;
|
* Dialog for adding an rtl_tcp network tuner.
|
||||||
import javax.swing.JFrame;
|
*/
|
||||||
import javax.swing.JLabel;
|
public class AddNetworkTunerDialog extends Dialog<ButtonType> {
|
||||||
import javax.swing.JOptionPane;
|
private static final Logger mLog = LoggerFactory.getLogger(AddNetworkTunerDialog.class);
|
||||||
import javax.swing.JPanel;
|
private static final ButtonType ADD = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
|
||||||
import javax.swing.JTextField;
|
private final UserPreferences mUserPreferences;
|
||||||
|
private final DiscoveredTunerModel mDiscoveredTunerModel;
|
||||||
|
private final TunerConfigurationManager mTunerConfigurationManager;
|
||||||
|
private final ComboBox<String> mTypeComboBox = new ComboBox<>();
|
||||||
|
private final TextField mHostField = new TextField();
|
||||||
|
private final TextField mPortField = new TextField("1234");
|
||||||
|
private final TextField mFrequencyField = new TextField();
|
||||||
|
private final Label mValidationLabel = new Label();
|
||||||
|
|
||||||
public class AddNetworkTunerDialog extends JFrame {
|
public AddNetworkTunerDialog(Window owner, UserPreferences userPreferences, DiscoveredTunerModel discoveredTunerModel,
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(AddNetworkTunerDialog.class);
|
|
||||||
private UserPreferences mUserPreferences;
|
|
||||||
private DiscoveredTunerModel mDiscoveredTunerModel;
|
|
||||||
private TunerConfigurationManager mTunerConfigurationManager;
|
|
||||||
private JLabel mTypeLabel;
|
|
||||||
private JLabel mHostLabel;
|
|
||||||
private JLabel mPortLabel;
|
|
||||||
private JLabel mFrequencyLabel;
|
|
||||||
private JComboBox mTypeComboBox;
|
|
||||||
private JTextField mHostField;
|
|
||||||
private JTextField mPortField;
|
|
||||||
private JTextField mFrequencyField;
|
|
||||||
private JButton mAddButton;
|
|
||||||
private JButton mCancelButton;
|
|
||||||
|
|
||||||
public AddNetworkTunerDialog(UserPreferences userPreferences, DiscoveredTunerModel discoveredTunerModel,
|
|
||||||
TunerConfigurationManager tunerConfigurationManager) {
|
TunerConfigurationManager tunerConfigurationManager) {
|
||||||
Validate.notNull(userPreferences, "UserPreferences cannot be null");
|
Validate.notNull(userPreferences, "UserPreferences cannot be null");
|
||||||
Validate.notNull(discoveredTunerModel, "TunerModel cannot be null");
|
Validate.notNull(discoveredTunerModel, "TunerModel cannot be null");
|
||||||
Validate.notNull(tunerConfigurationManager, "TunerConfigurationManager cannot be null");
|
Validate.notNull(tunerConfigurationManager, "TunerConfigurationManager cannot be null");
|
||||||
|
|
||||||
mDiscoveredTunerModel = discoveredTunerModel;
|
mDiscoveredTunerModel = discoveredTunerModel;
|
||||||
mUserPreferences = userPreferences;
|
mUserPreferences = userPreferences;
|
||||||
mTunerConfigurationManager = tunerConfigurationManager;
|
mTunerConfigurationManager = tunerConfigurationManager;
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
initOwner(owner);
|
||||||
setTitle("Add Network Tuner");
|
setTitle("Add Network Tuner");
|
||||||
setSize(new Dimension(500, 250));
|
setHeaderText("Add an rtl_tcp network tuner");
|
||||||
|
|
||||||
JPanel content = new JPanel();
|
mTypeComboBox.getItems().add("rtl-tcp");
|
||||||
content.setLayout(new MigLayout("", "[align right][][]", "[][][][][grow][]"));
|
mTypeComboBox.getSelectionModel().selectFirst();
|
||||||
|
mTypeComboBox.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
mHostField.setPromptText("hostname or IP address");
|
||||||
|
mPortField.setPromptText("e.g. 1234");
|
||||||
|
mFrequencyField.setPromptText("e.g. 851.0125");
|
||||||
|
mValidationLabel.getStyleClass().add("tuner-validation");
|
||||||
|
mValidationLabel.setWrapText(true);
|
||||||
|
mValidationLabel.setStyle("-fx-text-fill: #d9443a;");
|
||||||
|
|
||||||
mTypeLabel = new JLabel("Type:");
|
GridPane grid = new GridPane();
|
||||||
content.add(mTypeLabel);
|
grid.setHgap(10);
|
||||||
|
grid.setVgap(8);
|
||||||
|
grid.setPadding(new Insets(10));
|
||||||
|
grid.addRow(0, new Label("Type"), mTypeComboBox);
|
||||||
|
grid.addRow(1, new Label("Host"), mHostField);
|
||||||
|
grid.addRow(2, new Label("Port"), mPortField);
|
||||||
|
grid.addRow(3, new Label("Frequency (MHz)"), mFrequencyField);
|
||||||
|
grid.add(mValidationLabel, 0, 4, 2, 1);
|
||||||
|
GridPane.setHgrow(mHostField, Priority.ALWAYS);
|
||||||
|
grid.setPrefWidth(420);
|
||||||
|
|
||||||
String[] options = { "rtl-tcp" };
|
getDialogPane().setContent(grid);
|
||||||
mTypeComboBox = new JComboBox<>(options);
|
getDialogPane().getButtonTypes().addAll(ADD, ButtonType.CANCEL);
|
||||||
content.add(mTypeComboBox, "span2,grow,wrap");
|
|
||||||
|
|
||||||
mHostLabel = new JLabel("Host:");
|
Node addButton = getDialogPane().lookupButton(ADD);
|
||||||
content.add(mHostLabel);
|
addButton.setDisable(true);
|
||||||
|
Runnable validate = () -> {
|
||||||
|
String error = getValidationError();
|
||||||
|
mValidationLabel.setText(error == null ? "" : error);
|
||||||
|
addButton.setDisable(error != null);
|
||||||
|
};
|
||||||
|
mHostField.textProperty().addListener((observable, oldValue, newValue) -> validate.run());
|
||||||
|
mPortField.textProperty().addListener((observable, oldValue, newValue) -> validate.run());
|
||||||
|
mFrequencyField.textProperty().addListener((observable, oldValue, newValue) -> validate.run());
|
||||||
|
validate.run();
|
||||||
|
mValidationLabel.setText("");
|
||||||
|
|
||||||
mHostField = new JTextField("");
|
setResultConverter(buttonType -> {
|
||||||
mHostField.setToolTipText("Enter the hostname or IP address of the network tuner");
|
if (buttonType == ADD) {
|
||||||
content.add(mHostField, "span2,grow,wrap");
|
addTuner();
|
||||||
|
|
||||||
mPortLabel = new JLabel("Port:");
|
|
||||||
content.add(mPortLabel);
|
|
||||||
|
|
||||||
mPortField = new JTextField("");
|
|
||||||
mHostField.setToolTipText("Enter the port number of the network tuner");
|
|
||||||
content.add(mPortField, "span2,grow,wrap");
|
|
||||||
|
|
||||||
mFrequencyLabel = new JLabel("Frequency (Hz):");
|
|
||||||
content.add(mFrequencyLabel);
|
|
||||||
|
|
||||||
mFrequencyField = new JTextField("");
|
|
||||||
mFrequencyField.setToolTipText("Enter the center frequency of the network tuner in Hertz (Hz)");
|
|
||||||
content.add(mFrequencyField, "span2,grow,wrap");
|
|
||||||
|
|
||||||
content.add(new JLabel(""), "wrap");
|
|
||||||
content.add(new JLabel(""));
|
|
||||||
|
|
||||||
mAddButton = new JButton("Add");
|
|
||||||
// mAddButton.setEnabled(false);
|
|
||||||
mAddButton.addActionListener(e -> {
|
|
||||||
|
|
||||||
long frequency = getFrequency();
|
|
||||||
|
|
||||||
if (frequency <= 0 || frequency > Integer.MAX_VALUE) {
|
|
||||||
JOptionPane.showMessageDialog(AddNetworkTunerDialog.this,
|
|
||||||
"Please provide a center frequency (1Hz to 2.14 GHz)",
|
|
||||||
"Center Frequency Required",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return buttonType;
|
||||||
mLog.info("Adding network tuner = frequency [" + frequency + "] host [" + getHost() + ":" + getPort() + "]");
|
|
||||||
|
|
||||||
try {
|
|
||||||
NetworkTunerConfiguration config = NetworkTunerConfiguration.create();
|
|
||||||
config.setFrequency(frequency);
|
|
||||||
config.setHost(getHost());
|
|
||||||
config.setPort(getPort());
|
|
||||||
mTunerConfigurationManager.addTunerConfiguration(config);
|
|
||||||
DiscoveredNetworkTuner discoveredNetworkTuner = new DiscoveredNetworkTuner(mUserPreferences, config);
|
|
||||||
mDiscoveredTunerModel.addDiscoveredTuner(discoveredNetworkTuner);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
mLog.error("Error adding network tuner", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddNetworkTunerDialog.this.setVisible(false);
|
|
||||||
});
|
});
|
||||||
content.add(mAddButton, "grow,push");
|
|
||||||
|
|
||||||
mCancelButton = new JButton("Cancel");
|
Platform.runLater(mHostField::requestFocus);
|
||||||
mCancelButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
AddNetworkTunerDialog.this.setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
content.add(mCancelButton, "grow,push");
|
|
||||||
|
|
||||||
setContentPane(content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getFrequency() {
|
/**
|
||||||
String text = mFrequencyField.getText();
|
* Validation error for the current entries, or null when they are valid.
|
||||||
|
*/
|
||||||
if (text != null && !text.isEmpty()) {
|
private String getValidationError() {
|
||||||
try {
|
if (getHost().isEmpty()) {
|
||||||
return Long.parseLong(text);
|
return "Enter the host name or IP address of the rtl_tcp server";
|
||||||
} catch (Exception e) {
|
|
||||||
// Do nothing, we couldn't parse the frequency value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0l;
|
if (getPort() <= 0) {
|
||||||
|
return "Enter a port number from 1 to " + Short.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Long frequency = FrequencyEntry.parse(mFrequencyField.getText());
|
||||||
|
|
||||||
|
if (frequency == null || frequency <= 0 || frequency > Integer.MAX_VALUE) {
|
||||||
|
return "Enter a center frequency up to 2147.483647 MHz";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTuner() {
|
||||||
|
long frequency = FrequencyEntry.parse(mFrequencyField.getText());
|
||||||
|
mLog.info("Adding network tuner = frequency [" + frequency + "] host [" + getHost() + ":" + getPort() + "]");
|
||||||
|
|
||||||
|
try {
|
||||||
|
NetworkTunerConfiguration config = NetworkTunerConfiguration.create();
|
||||||
|
config.setFrequency(frequency);
|
||||||
|
config.setHost(getHost());
|
||||||
|
config.setPort(getPort());
|
||||||
|
mTunerConfigurationManager.addTunerConfiguration(config);
|
||||||
|
DiscoveredNetworkTuner discoveredNetworkTuner = new DiscoveredNetworkTuner(mUserPreferences, config);
|
||||||
|
mDiscoveredTunerModel.addDiscoveredTuner(discoveredNetworkTuner);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
mLog.error("Error adding network tuner", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHost() {
|
private String getHost() {
|
||||||
return mHostField.getText();
|
return mHostField.getText() == null ? "" : mHostField.getText().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private short getPort() {
|
private short getPort() {
|
||||||
String text = mPortField.getText();
|
try {
|
||||||
|
return Short.parseShort(mPortField.getText().trim());
|
||||||
if (text != null && !text.isEmpty()) {
|
} catch (Exception e) {
|
||||||
try {
|
return 0;
|
||||||
return Short.parseShort(text);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Do nothing, we couldn't parse the port value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,42 +18,30 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dsheirer.source.tuner.network;
|
package io.github.dsheirer.source.tuner.network;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal tuner editor for a network (rtl_tcp) tuner that has not been started. Mirrors
|
* Editor for a network tuner that is disabled or not connected. Shows the status and the enable switch only.
|
||||||
* RTL2832UnknownTunerEditor's pattern: only the id/status labels and the button panel are shown -
|
|
||||||
* no frequency/sample-rate/gain controls, since there's no live tuner to configure yet.
|
|
||||||
*/
|
*/
|
||||||
public class NetworkTunerDisabledEditor extends TunerEditor<NetworkTuner, NetworkTunerConfiguration> {
|
public class NetworkTunerDisabledEditor extends TunerEditor<NetworkTuner, NetworkTunerConfiguration> {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public NetworkTunerDisabledEditor(UserPreferences userPreferences, TunerManager tunerManager,
|
public NetworkTunerDisabledEditor(UserPreferences userPreferences, TunerManager tunerManager,
|
||||||
DiscoveredTuner discoveredTuner) {
|
DiscoveredTuner discoveredTuner) {
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection section = addSection("Network Tuner");
|
||||||
tunerStatusUpdated();
|
Label message = new Label("Enable the tuner to connect to the rtl_tcp server and change its settings.");
|
||||||
|
message.setWrapText(true);
|
||||||
|
section.addFullRow(message);
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
@Override
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]", "[][][][grow]"));
|
protected boolean hasTuningControls() {
|
||||||
|
return false;
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -75,20 +63,6 @@ public class NetworkTunerDisabledEditor extends TunerEditor<NetworkTuner, Networ
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated() {
|
protected void tunerStatusUpdated() {
|
||||||
setLoading(true);
|
//No-op - the header shows the status
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if (getDiscoveredTuner().hasErrorMessage()) {
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked) {
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,53 +18,37 @@
|
|||||||
*/
|
*/
|
||||||
package io.github.dsheirer.source.tuner.network;
|
package io.github.dsheirer.source.tuner.network;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController.SampleRate;
|
import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController.SampleRate;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
|
import java.util.List;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.scene.control.CheckBox;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.util.StringConverter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Editor for an rtl_tcp network tuner.
|
||||||
|
*/
|
||||||
public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerConfiguration> {
|
public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerConfiguration> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final List<Integer> R820T_GAINS_TENTHS_DB = List.of(0, 9, 14, 27, 37, 77, 87, 125, 144, 157, 166,
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(NetworkTunerEditor.class);
|
197, 207, 229, 254, 280, 297, 328, 338, 364, 372, 386, 402, 421, 434, 439, 445, 480, 496);
|
||||||
|
|
||||||
//R820T total gain table (tenths of dB), from librtlsdr's rtlsdr_get_tuner_gains() - most rtl_tcp
|
private CheckBox mBiasTCheckBox;
|
||||||
//servers are backed by an R820T/R820T2 dongle and report this same gain table.
|
private ComboBox<SampleRate> mSampleRateCombo;
|
||||||
private static final Integer[] R820T_GAINS_TENTHS_DB = {0, 9, 14, 27, 37, 77, 87, 125, 144, 157, 166, 197, 207,
|
private CheckBox mGainAutoCheckBox;
|
||||||
229, 254, 280, 297, 328, 338, 364, 372, 386, 402, 421, 434, 439, 445, 480, 496};
|
private ComboBox<Integer> mGainCombo;
|
||||||
|
private CheckBox mAutoReconnectCheckBox;
|
||||||
private JButton mTunerInfoButton;
|
|
||||||
private JToggleButton mBiasTButton;
|
|
||||||
private JComboBox<SampleRate> mSampleRateCombo;
|
|
||||||
private JCheckBox mGainAutoCheckBox;
|
|
||||||
private JComboBox<Integer> mGainCombo;
|
|
||||||
private JCheckBox mAutoReconnectCheckBox;
|
|
||||||
|
|
||||||
public NetworkTunerEditor(UserPreferences userPreferences, TunerManager tunerManager,
|
public NetworkTunerEditor(UserPreferences userPreferences, TunerManager tunerManager,
|
||||||
DiscoveredTuner discoveredTuner) {
|
DiscoveredTuner discoveredTuner) {
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked) {
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
//Matches the USB RTL2832/R8x tuner pattern: sample rate can't change while channels are active. Gain and
|
|
||||||
//Bias-T don't affect channelizing, so they remain adjustable regardless of lock state.
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !locked);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,134 +58,92 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getMaximumTunableFrequency() {
|
public long getMaximumTunableFrequency() {
|
||||||
return 2200000000l;
|
return 2200000000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
|
|
||||||
|
TunerSection gain = addSection("Gain");
|
||||||
|
gain.addRow("Gain", getGainCombo(), getGainAutoCheckBox());
|
||||||
|
|
||||||
|
TunerSection options = addSection("Options");
|
||||||
|
options.addControl(getBiasTCheckBox());
|
||||||
|
options.addControl(getAutoReconnectCheckBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated() {
|
protected void tunerStatusUpdated() {
|
||||||
setLoading(true);
|
getBiasTCheckBox().setDisable(!hasTuner());
|
||||||
|
getGainAutoCheckBox().setDisable(!hasTuner());
|
||||||
if (hasTuner()) {
|
getAutoReconnectCheckBox().setDisable(!hasTuner());
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
updateSampleRateControl();
|
||||||
} else {
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if (getDiscoveredTuner().hasErrorMessage()) {
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
getTunerInfoButton().setEnabled(hasTuner());
|
|
||||||
getBiasTButton().setEnabled(hasTuner());
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner());
|
|
||||||
getGainAutoCheckBox().setEnabled(hasTuner());
|
|
||||||
getAutoReconnectCheckBox().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
if (hasConfiguration()) {
|
if (hasConfiguration()) {
|
||||||
getBiasTButton().setSelected(getConfiguration().isBiasTEnabled());
|
getBiasTCheckBox().setSelected(getConfiguration().isBiasTEnabled());
|
||||||
getSampleRateCombo().setSelectedItem(closestSampleRate(getConfiguration().getSampleRate()));
|
getSampleRateCombo().setValue(closestSampleRate(getConfiguration().getSampleRate()));
|
||||||
getGainAutoCheckBox().setSelected(getConfiguration().isGainAuto());
|
getGainAutoCheckBox().setSelected(getConfiguration().isGainAuto());
|
||||||
getGainCombo().setSelectedItem(closestGain(getConfiguration().getGain()));
|
getGainCombo().setValue(closestGain(getConfiguration().getGain()));
|
||||||
getGainCombo().setEnabled(hasTuner() && !getConfiguration().isGainAuto());
|
getGainCombo().setDisable(!hasTuner() || getConfiguration().isGainAuto());
|
||||||
getAutoReconnectCheckBox().setSelected(getConfiguration().isAutoReconnect());
|
getAutoReconnectCheckBox().setSelected(getConfiguration().isAutoReconnect());
|
||||||
|
} else {
|
||||||
|
getGainCombo().setDisable(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tunerLockStateUpdated(boolean locked) {
|
||||||
|
updateSampleRateControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSampleRateControl() {
|
||||||
|
getSampleRateCombo().setDisable(!hasTuner() || getTuner().getTunerController().isLockedSampleRate());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTunerInfo() {
|
||||||
|
if (!hasConfiguration()) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setLoading(false);
|
return "<html><h3>rtl_tcp Network Tuner</h3>" +
|
||||||
|
"<b>Host: </b>" + getConfiguration().getHost() + "<br>" +
|
||||||
|
"<b>Port: </b>" + getConfiguration().getPort() + "<br>" +
|
||||||
|
"<b>Tuner Type: </b>rtl_tcp<br>";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private CheckBox getBiasTCheckBox() {
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]", "[][][][][][][][][grow]"));
|
if (mBiasTCheckBox == null) {
|
||||||
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
add(new JLabel("Tuner:"));
|
mBiasTCheckBox.setTooltip(new Tooltip("Ask the rtl_tcp server to provide DC power on the antenna connector"));
|
||||||
add(getTunerIdLabel());
|
mBiasTCheckBox.setDisable(true);
|
||||||
add(getTunerInfoButton());
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel());
|
|
||||||
add(getBiasTButton(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainAutoCheckBox(), "split 2");
|
|
||||||
add(getGainCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Auto-Reconnect:"));
|
|
||||||
add(getAutoReconnectCheckBox(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bias-T toggle button, matching the USB RTL2832/R8x tuner editor's top-row placement.
|
|
||||||
*/
|
|
||||||
private JToggleButton getBiasTButton() {
|
|
||||||
if (mBiasTButton == null) {
|
|
||||||
mBiasTButton = new JToggleButton("Bias-T");
|
|
||||||
mBiasTButton.setEnabled(false);
|
|
||||||
mBiasTButton.addActionListener(e -> {
|
|
||||||
if (!isLoading()) {
|
if (!isLoading()) {
|
||||||
boolean enabled = mBiasTButton.isSelected();
|
|
||||||
|
|
||||||
if (hasTuner()) {
|
if (hasTuner()) {
|
||||||
getTuner().getTunerController().setBiasTEnabled(enabled);
|
getTuner().getTunerController().setBiasTEnabled(mBiasTCheckBox.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mBiasTButton;
|
return mBiasTCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private ComboBox<SampleRate> getSampleRateCombo() {
|
||||||
* Hyperlink-style button that shows the network tuner's connection details.
|
|
||||||
*/
|
|
||||||
private JButton getTunerInfoButton() {
|
|
||||||
if (mTunerInfoButton == null) {
|
|
||||||
mTunerInfoButton = new JButton("Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(NetworkTunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTunerInfo() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
sb.append("<html><h3>rtl_tcp Network Tuner</h3>");
|
|
||||||
sb.append("<b>Host: </b>").append(getConfiguration().getHost()).append("<br>");
|
|
||||||
sb.append("<b>Port: </b>").append(getConfiguration().getPort()).append("<br>");
|
|
||||||
sb.append("<b>Tuner Type: </b>rtl_tcp<br>");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private JComboBox<SampleRate> getSampleRateCombo() {
|
|
||||||
if (mSampleRateCombo == null) {
|
if (mSampleRateCombo == null) {
|
||||||
mSampleRateCombo = new JComboBox<>(SampleRate.values());
|
mSampleRateCombo = new ComboBox<>(FXCollections.observableArrayList(SampleRate.values()));
|
||||||
mSampleRateCombo.setEnabled(false);
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
mSampleRateCombo.setDisable(true);
|
||||||
if (!isLoading()) {
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
SampleRate sampleRate = (SampleRate) mSampleRateCombo.getSelectedItem();
|
SampleRate sampleRate = mSampleRateCombo.getValue();
|
||||||
|
|
||||||
if (sampleRate != null) {
|
if (!isLoading() && sampleRate != null) {
|
||||||
if (hasTuner()) {
|
if (hasTuner()) {
|
||||||
getTuner().getTunerController().setSampleRate(sampleRate.getRate());
|
getTuner().getTunerController().setSampleRate(sampleRate.getRate());
|
||||||
}
|
adjustForSampleRate(sampleRate.getRate());
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -209,18 +151,18 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
return mSampleRateCombo;
|
return mSampleRateCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCheckBox getGainAutoCheckBox() {
|
private CheckBox getGainAutoCheckBox() {
|
||||||
if (mGainAutoCheckBox == null) {
|
if (mGainAutoCheckBox == null) {
|
||||||
mGainAutoCheckBox = new JCheckBox("Auto");
|
mGainAutoCheckBox = new CheckBox("Auto");
|
||||||
mGainAutoCheckBox.addActionListener(e -> {
|
mGainAutoCheckBox.setTooltip(new Tooltip("Let the rtl_tcp server's tuner set the gain automatically"));
|
||||||
|
mGainAutoCheckBox.setOnAction(e -> {
|
||||||
boolean gainAuto = mGainAutoCheckBox.isSelected();
|
boolean gainAuto = mGainAutoCheckBox.isSelected();
|
||||||
getGainCombo().setEnabled(hasTuner() && !gainAuto);
|
getGainCombo().setDisable(!hasTuner() || gainAuto);
|
||||||
|
|
||||||
if (!isLoading()) {
|
if (!isLoading()) {
|
||||||
if (hasTuner()) {
|
if (hasTuner()) {
|
||||||
getTuner().getTunerController().setGainAuto(gainAuto);
|
getTuner().getTunerController().setGainAuto(gainAuto);
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -229,22 +171,31 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
return mGainAutoCheckBox;
|
return mGainAutoCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JComboBox<Integer> getGainCombo() {
|
private ComboBox<Integer> getGainCombo() {
|
||||||
if (mGainCombo == null) {
|
if (mGainCombo == null) {
|
||||||
mGainCombo = new JComboBox<>(R820T_GAINS_TENTHS_DB);
|
mGainCombo = new ComboBox<>(FXCollections.observableArrayList(R820T_GAINS_TENTHS_DB));
|
||||||
mGainCombo.setEnabled(false);
|
mGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
mGainCombo.setToolTipText("Gain in tenths of dB. Uncheck Auto to enable manual gain.");
|
mGainCombo.setDisable(true);
|
||||||
mGainCombo.addActionListener(e -> {
|
mGainCombo.setTooltip(new Tooltip("Manual gain. Uncheck Auto to enable manual gain."));
|
||||||
if (!isLoading()) {
|
mGainCombo.setConverter(new StringConverter<>() {
|
||||||
Integer gain = (Integer) mGainCombo.getSelectedItem();
|
@Override
|
||||||
|
public String toString(Integer gain) {
|
||||||
|
return gain == null ? "" : String.format("%.1f dB", gain / 10.0);
|
||||||
|
}
|
||||||
|
|
||||||
if (gain != null) {
|
@Override
|
||||||
if (hasTuner()) {
|
public Integer fromString(String text) {
|
||||||
getTuner().getTunerController().setGain(gain);
|
return null;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
mGainCombo.setOnAction(e -> {
|
||||||
|
Integer gain = mGainCombo.getValue();
|
||||||
|
|
||||||
save();
|
if (!isLoading() && gain != null) {
|
||||||
|
if (hasTuner()) {
|
||||||
|
getTuner().getTunerController().setGain(gain);
|
||||||
}
|
}
|
||||||
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -252,18 +203,16 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
return mGainCombo;
|
return mGainCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JCheckBox getAutoReconnectCheckBox() {
|
private CheckBox getAutoReconnectCheckBox() {
|
||||||
if (mAutoReconnectCheckBox == null) {
|
if (mAutoReconnectCheckBox == null) {
|
||||||
mAutoReconnectCheckBox = new JCheckBox();
|
mAutoReconnectCheckBox = new CheckBox("Auto-reconnect");
|
||||||
mAutoReconnectCheckBox.setToolTipText("Automatically reconnect if the connection to the rtl_tcp server is lost");
|
mAutoReconnectCheckBox.setTooltip(new Tooltip("Automatically reconnect if the connection to the rtl_tcp " +
|
||||||
mAutoReconnectCheckBox.addActionListener(e -> {
|
"server is lost"));
|
||||||
|
mAutoReconnectCheckBox.setOnAction(e -> {
|
||||||
if (!isLoading()) {
|
if (!isLoading()) {
|
||||||
boolean autoReconnect = mAutoReconnectCheckBox.isSelected();
|
|
||||||
|
|
||||||
if (hasTuner()) {
|
if (hasTuner()) {
|
||||||
getTuner().getTunerController().setAutoReconnect(autoReconnect);
|
getTuner().getTunerController().setAutoReconnect(mAutoReconnectCheckBox.isSelected());
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -272,9 +221,6 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
return mAutoReconnectCheckBox;
|
return mAutoReconnectCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the SampleRate enum value closest to the specified sample rate (Hz).
|
|
||||||
*/
|
|
||||||
private static SampleRate closestSampleRate(long sampleRate) {
|
private static SampleRate closestSampleRate(long sampleRate) {
|
||||||
SampleRate closest = SampleRate.values()[0];
|
SampleRate closest = SampleRate.values()[0];
|
||||||
|
|
||||||
@@ -287,11 +233,8 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
return closest;
|
return closest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the R820T gain table entry closest to the specified gain value (tenths of dB).
|
|
||||||
*/
|
|
||||||
private static int closestGain(int gain) {
|
private static int closestGain(int gain) {
|
||||||
int closest = R820T_GAINS_TENTHS_DB[0];
|
int closest = R820T_GAINS_TENTHS_DB.get(0);
|
||||||
|
|
||||||
for (int candidate : R820T_GAINS_TENTHS_DB) {
|
for (int candidate : R820T_GAINS_TENTHS_DB) {
|
||||||
if (Math.abs(candidate - gain) < Math.abs(closest - gain)) {
|
if (Math.abs(candidate - gain) < Math.abs(closest - gain)) {
|
||||||
@@ -306,23 +249,21 @@ public class NetworkTunerEditor extends TunerEditor<NetworkTuner, NetworkTunerCo
|
|||||||
public void save() {
|
public void save() {
|
||||||
if (hasConfiguration() && !isLoading()) {
|
if (hasConfiguration() && !isLoading()) {
|
||||||
NetworkTunerConfiguration config = getConfiguration();
|
NetworkTunerConfiguration config = getConfiguration();
|
||||||
config.setFrequency(getFrequencyControl().getFrequency());
|
saveCommonSettings(config);
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
SampleRate sampleRate = getSampleRateCombo().getValue();
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
|
|
||||||
SampleRate sampleRate = (SampleRate) getSampleRateCombo().getSelectedItem();
|
|
||||||
if (sampleRate != null) {
|
if (sampleRate != null) {
|
||||||
config.setSampleRate(sampleRate.getRate());
|
config.setSampleRate(sampleRate.getRate());
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setGainAuto(getGainAutoCheckBox().isSelected());
|
config.setGainAuto(getGainAutoCheckBox().isSelected());
|
||||||
|
Integer gain = getGainCombo().getValue();
|
||||||
|
|
||||||
Integer gain = (Integer) getGainCombo().getSelectedItem();
|
|
||||||
if (gain != null) {
|
if (gain != null) {
|
||||||
config.setGain(gain);
|
config.setGain(gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
config.setBiasTEnabled(getBiasTButton().isSelected());
|
config.setBiasTEnabled(getBiasTCheckBox().isSelected());
|
||||||
config.setAutoReconnect(getAutoReconnectCheckBox().isSelected());
|
config.setAutoReconnect(getAutoReconnectCheckBox().isSelected());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,246 +16,227 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.recording;
|
package io.github.dsheirer.source.tuner.recording;
|
||||||
|
|
||||||
|
import io.github.dsheirer.gui.control.FrequencyEntry;
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.properties.SystemProperties;
|
import io.github.dsheirer.properties.SystemProperties;
|
||||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredRecordingTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredRecordingTuner;
|
||||||
import io.github.dsheirer.source.tuner.ui.DiscoveredTunerModel;
|
import io.github.dsheirer.source.tuner.ui.DiscoveredTunerModel;
|
||||||
import io.github.dsheirer.source.wave.SDRSharpIQRecording;
|
import io.github.dsheirer.source.wave.SDRSharpIQRecording;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.geometry.Insets;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.ButtonBar;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
import javafx.scene.control.Dialog;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
import javafx.stage.FileChooser;
|
||||||
|
import javafx.stage.Window;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog to select a recording and specify a center frequency for use in adding a Recording Tuner
|
* Dialog for adding a recording tuner that replays a baseband recording file.
|
||||||
*/
|
*/
|
||||||
public class AddRecordingTunerDialog extends JFrame
|
public class AddRecordingTunerDialog extends Dialog<ButtonType>
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(AddRecordingTunerDialog.class);
|
private final static Logger mLog = LoggerFactory.getLogger(AddRecordingTunerDialog.class);
|
||||||
private static final String SELECT_A_FILE = "Please select a recording file";
|
private static final String SELECT_A_FILE = "No recording selected";
|
||||||
private static final String LAST_FILE_BROWSE_LOCATION_KEY = "AddRecordingTunerDialog.lastBrowseLocation";
|
private static final String LAST_FILE_BROWSE_LOCATION_KEY = "AddRecordingTunerDialog.lastBrowseLocation";
|
||||||
private UserPreferences mUserPreferences;
|
private static final ButtonType ADD = new ButtonType("Add", ButtonBar.ButtonData.OK_DONE);
|
||||||
private DiscoveredTunerModel mDiscoveredTunerModel;
|
|
||||||
private TunerConfigurationManager mTunerConfigurationManager;
|
|
||||||
private JButton mSelectFileButton;
|
|
||||||
private File mSelectedRecording;
|
|
||||||
private JLabel mRecordingFileLabel;
|
|
||||||
private JLabel mFrequencyLabel;
|
|
||||||
private JTextField mFrequencyTextField;
|
|
||||||
private JButton mAddButton;
|
|
||||||
private JButton mCancelButton;
|
|
||||||
private static final Pattern TUNER_RECORDING_PATTERN = Pattern.compile(".*_(\\d*)_baseband_\\d{8}_\\d{6}\\.wav");
|
private static final Pattern TUNER_RECORDING_PATTERN = Pattern.compile(".*_(\\d*)_baseband_\\d{8}_\\d{6}\\.wav");
|
||||||
|
private final UserPreferences mUserPreferences;
|
||||||
|
private final DiscoveredTunerModel mDiscoveredTunerModel;
|
||||||
|
private final TunerConfigurationManager mTunerConfigurationManager;
|
||||||
|
private final Label mRecordingFileLabel = new Label(SELECT_A_FILE);
|
||||||
|
private final TextField mFrequencyField = new TextField();
|
||||||
|
private final Label mValidationLabel = new Label();
|
||||||
|
private File mSelectedRecording;
|
||||||
|
private Node mAddButton;
|
||||||
|
|
||||||
public AddRecordingTunerDialog(UserPreferences userPreferences, DiscoveredTunerModel discoveredTunerModel,
|
/**
|
||||||
|
* Constructs an instance
|
||||||
|
* @param owner window for the dialog
|
||||||
|
* @param userPreferences for the default recording directory
|
||||||
|
* @param discoveredTunerModel to add the recording tuner to
|
||||||
|
* @param tunerConfigurationManager to add the recording tuner configuration to
|
||||||
|
*/
|
||||||
|
public AddRecordingTunerDialog(Window owner, UserPreferences userPreferences, DiscoveredTunerModel discoveredTunerModel,
|
||||||
TunerConfigurationManager tunerConfigurationManager)
|
TunerConfigurationManager tunerConfigurationManager)
|
||||||
{
|
{
|
||||||
Validate.notNull(userPreferences, "UserPreferences cannot be null");
|
Validate.notNull(userPreferences, "UserPreferences cannot be null");
|
||||||
Validate.notNull(discoveredTunerModel, "TunerModel cannot be null");
|
Validate.notNull(discoveredTunerModel, "TunerModel cannot be null");
|
||||||
Validate.notNull(tunerConfigurationManager, "TunerConfigurationManager cannot be null");
|
Validate.notNull(tunerConfigurationManager, "TunerConfigurationManager cannot be null");
|
||||||
|
|
||||||
mDiscoveredTunerModel = discoveredTunerModel;
|
mDiscoveredTunerModel = discoveredTunerModel;
|
||||||
mUserPreferences = userPreferences;
|
mUserPreferences = userPreferences;
|
||||||
mTunerConfigurationManager = tunerConfigurationManager;
|
mTunerConfigurationManager = tunerConfigurationManager;
|
||||||
|
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
initOwner(owner);
|
||||||
setTitle("Select Recording File");
|
setTitle("Add Recording Tuner");
|
||||||
setSize(new Dimension(500, 250));
|
setHeaderText("Replay a baseband recording (.wav or SDR# .iq) as a tuner");
|
||||||
|
|
||||||
JPanel content = new JPanel();
|
Button selectFileButton = new Button("Select ...");
|
||||||
content.setLayout(new MigLayout("", "[align right][][]", "[][][grow][]"));
|
selectFileButton.setOnAction(e -> selectFile());
|
||||||
|
mRecordingFileLabel.setWrapText(true);
|
||||||
|
mFrequencyField.setPromptText("e.g. 851.0125");
|
||||||
|
mValidationLabel.setWrapText(true);
|
||||||
|
mValidationLabel.setStyle("-fx-text-fill: #d9443a;");
|
||||||
|
|
||||||
mSelectFileButton = new JButton("Select ...");
|
GridPane grid = new GridPane();
|
||||||
mSelectFileButton.addActionListener(e -> {
|
grid.setHgap(10);
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
grid.setVgap(8);
|
||||||
String lastBrowsedDirectory = SystemProperties.getInstance().get(LAST_FILE_BROWSE_LOCATION_KEY, "");
|
grid.setPadding(new Insets(10));
|
||||||
|
grid.addRow(0, selectFileButton, mRecordingFileLabel);
|
||||||
|
grid.addRow(1, new Label("Frequency (MHz)"), mFrequencyField);
|
||||||
|
grid.add(mValidationLabel, 0, 2, 2, 1);
|
||||||
|
GridPane.setHgrow(mFrequencyField, Priority.ALWAYS);
|
||||||
|
grid.setPrefWidth(460);
|
||||||
|
|
||||||
File browseDirectory;
|
getDialogPane().setContent(grid);
|
||||||
|
getDialogPane().getButtonTypes().addAll(ADD, ButtonType.CANCEL);
|
||||||
|
mAddButton = getDialogPane().lookupButton(ADD);
|
||||||
|
mAddButton.setDisable(true);
|
||||||
|
mFrequencyField.textProperty().addListener((observable, oldValue, newValue) -> validate());
|
||||||
|
|
||||||
if(lastBrowsedDirectory != null && !lastBrowsedDirectory.isEmpty())
|
setResultConverter(buttonType -> {
|
||||||
|
if(buttonType == ADD)
|
||||||
{
|
{
|
||||||
browseDirectory = new File(lastBrowsedDirectory);
|
addTuner();
|
||||||
}
|
}
|
||||||
else
|
return buttonType;
|
||||||
{
|
|
||||||
browseDirectory = mUserPreferences.getDirectoryPreference().getDefaultRecordingDirectory().toFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
fileChooser.setCurrentDirectory(browseDirectory);
|
|
||||||
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
|
||||||
FileNameExtensionFilter basebandFilter = new FileNameExtensionFilter("Baseband Recordings (*.wav, *.iq)",
|
|
||||||
"wav", SDRSharpIQRecording.FILE_EXTENSION);
|
|
||||||
fileChooser.addChoosableFileFilter(basebandFilter);
|
|
||||||
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("Wave Recordings (*.wav)", "wav"));
|
|
||||||
fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("SDRSharp I/Q Recordings (*.iq)",
|
|
||||||
SDRSharpIQRecording.FILE_EXTENSION));
|
|
||||||
fileChooser.setFileFilter(basebandFilter);
|
|
||||||
|
|
||||||
int returnVal = fileChooser.showOpenDialog(AddRecordingTunerDialog.this);
|
|
||||||
|
|
||||||
File lastDirectory = fileChooser.getCurrentDirectory();
|
|
||||||
|
|
||||||
if(lastDirectory != null)
|
|
||||||
{
|
|
||||||
SystemProperties.getInstance().set(LAST_FILE_BROWSE_LOCATION_KEY, lastDirectory.getAbsolutePath());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(returnVal == JFileChooser.APPROVE_OPTION)
|
|
||||||
{
|
|
||||||
mSelectedRecording = fileChooser.getSelectedFile();
|
|
||||||
|
|
||||||
if(SDRSharpIQRecording.hasIQExtension(mSelectedRecording))
|
|
||||||
{
|
|
||||||
SDRSharpIQRecording iqRecording = SDRSharpIQRecording.parse(mSelectedRecording);
|
|
||||||
|
|
||||||
if(iqRecording == null)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
|
||||||
"<html>Unable to determine the sample rate and center frequency from the I/Q recording " +
|
|
||||||
"file name.<br>Expected format: <i>yyyyMMdd-HHmmss_label_TUNER_123456789Hz_10MSps.iq</i></html>",
|
|
||||||
"Unsupported I/Q Recording",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
mSelectedRecording = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mLog.info("Selected " + iqRecording);
|
|
||||||
|
|
||||||
if(mFrequencyTextField.getText() == null || mFrequencyTextField.getText().isEmpty())
|
|
||||||
{
|
|
||||||
mFrequencyTextField.setText(String.valueOf(iqRecording.getCenterFrequency()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(mSelectedRecording != null &&
|
|
||||||
(mFrequencyTextField.getText() == null || mFrequencyTextField.getText().isEmpty()))
|
|
||||||
{
|
|
||||||
Matcher m = TUNER_RECORDING_PATTERN.matcher(mSelectedRecording.getName());
|
|
||||||
|
|
||||||
if(m.matches())
|
|
||||||
{
|
|
||||||
mFrequencyTextField.setText(m.group(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mAddButton.setEnabled(mSelectedRecording != null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mSelectedRecording = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
mRecordingFileLabel.setText(mSelectedRecording != null ? mSelectedRecording.getName() : SELECT_A_FILE);
|
|
||||||
});
|
});
|
||||||
content.add(mSelectFileButton);
|
|
||||||
|
|
||||||
mRecordingFileLabel = new JLabel(SELECT_A_FILE);
|
|
||||||
content.add(mRecordingFileLabel, "span 2,wrap");
|
|
||||||
|
|
||||||
mFrequencyLabel = new JLabel("Frequency (Hz):");
|
|
||||||
content.add(mFrequencyLabel);
|
|
||||||
|
|
||||||
mFrequencyTextField = new JTextField("");
|
|
||||||
mFrequencyTextField.setToolTipText("Center frequency for the recording in Hertz (Hz)");
|
|
||||||
content.add(mFrequencyTextField, "span 2,grow,wrap");
|
|
||||||
|
|
||||||
content.add(new JLabel(""), "wrap");
|
|
||||||
|
|
||||||
content.add(new JLabel(""));
|
|
||||||
|
|
||||||
mAddButton = new JButton("Add");
|
|
||||||
mAddButton.setEnabled(false);
|
|
||||||
mAddButton.addActionListener(e -> {
|
|
||||||
if(mSelectedRecording == null)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
|
||||||
"Please select a recording file",
|
|
||||||
"Select a Recording File",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long frequency = getFrequency();
|
|
||||||
|
|
||||||
if(frequency <= 0 || frequency > Integer.MAX_VALUE)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(AddRecordingTunerDialog.this,
|
|
||||||
"Please provide a recording center frequency (1 Hz to 2.14 GHz)",
|
|
||||||
"Center Frequency Required",
|
|
||||||
JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mLog.info("Adding recording tuner = frequency [" + frequency +
|
|
||||||
"] recording [" + mSelectedRecording.getAbsolutePath() + "]");
|
|
||||||
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
RecordingTunerConfiguration config = RecordingTunerConfiguration.create();
|
|
||||||
config.setFrequency(frequency);
|
|
||||||
config.setPath(mSelectedRecording.getAbsolutePath());
|
|
||||||
mTunerConfigurationManager.addTunerConfiguration(config);
|
|
||||||
DiscoveredRecordingTuner discoveredRecordingTuner = new DiscoveredRecordingTuner(mUserPreferences, config);
|
|
||||||
mDiscoveredTunerModel.addDiscoveredTuner(discoveredRecordingTuner);
|
|
||||||
}
|
|
||||||
catch(Exception ex)
|
|
||||||
{
|
|
||||||
mLog.error("Error adding recording tuner", ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddRecordingTunerDialog.this.setVisible(false);
|
|
||||||
});
|
|
||||||
content.add(mAddButton, "grow,push");
|
|
||||||
|
|
||||||
mCancelButton = new JButton("Cancel");
|
|
||||||
mCancelButton.addActionListener(new ActionListener()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e)
|
|
||||||
{
|
|
||||||
AddRecordingTunerDialog.this.setVisible(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
content.add(mCancelButton, "grow,push");
|
|
||||||
|
|
||||||
setContentPane(content);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getFrequency()
|
private void selectFile()
|
||||||
{
|
{
|
||||||
String text = mFrequencyTextField.getText();
|
FileChooser fileChooser = new FileChooser();
|
||||||
|
fileChooser.setTitle("Select Recording File");
|
||||||
|
String lastBrowsedDirectory = SystemProperties.getInstance().get(LAST_FILE_BROWSE_LOCATION_KEY, "");
|
||||||
|
File browseDirectory = (lastBrowsedDirectory != null && !lastBrowsedDirectory.isEmpty()) ?
|
||||||
|
new File(lastBrowsedDirectory) : mUserPreferences.getDirectoryPreference().getDefaultRecordingDirectory().toFile();
|
||||||
|
|
||||||
if(text != null && !text.isEmpty())
|
if(browseDirectory.isDirectory())
|
||||||
{
|
{
|
||||||
try
|
fileChooser.setInitialDirectory(browseDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
FileChooser.ExtensionFilter basebandFilter = new FileChooser.ExtensionFilter("Baseband Recordings (*.wav, *.iq)",
|
||||||
|
"*.wav", "*." + SDRSharpIQRecording.FILE_EXTENSION);
|
||||||
|
fileChooser.getExtensionFilters().addAll(basebandFilter,
|
||||||
|
new FileChooser.ExtensionFilter("Wave Recordings (*.wav)", "*.wav"),
|
||||||
|
new FileChooser.ExtensionFilter("SDRSharp I/Q Recordings (*.iq)", "*." + SDRSharpIQRecording.FILE_EXTENSION));
|
||||||
|
fileChooser.setSelectedExtensionFilter(basebandFilter);
|
||||||
|
|
||||||
|
File selected = fileChooser.showOpenDialog(getDialogPane().getScene().getWindow());
|
||||||
|
|
||||||
|
if(selected == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(selected.getParentFile() != null)
|
||||||
|
{
|
||||||
|
SystemProperties.getInstance().set(LAST_FILE_BROWSE_LOCATION_KEY, selected.getParentFile().getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
mSelectedRecording = selected;
|
||||||
|
|
||||||
|
if(SDRSharpIQRecording.hasIQExtension(selected))
|
||||||
|
{
|
||||||
|
SDRSharpIQRecording iqRecording = SDRSharpIQRecording.parse(selected);
|
||||||
|
|
||||||
|
if(iqRecording == null)
|
||||||
{
|
{
|
||||||
return Long.parseLong(text);
|
Alert alert = new Alert(Alert.AlertType.ERROR, "Unable to determine the sample rate and center " +
|
||||||
|
"frequency from the I/Q recording file name.\n\nExpected format: " +
|
||||||
|
"yyyyMMdd-HHmmss_label_TUNER_123456789Hz_10MSps.iq");
|
||||||
|
alert.initOwner(getDialogPane().getScene().getWindow());
|
||||||
|
alert.setTitle("Unsupported I/Q Recording");
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.showAndWait();
|
||||||
|
mSelectedRecording = null;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
else
|
||||||
{
|
{
|
||||||
//Do nothing, we couldn't parse the frequency value
|
mLog.info("Selected " + iqRecording);
|
||||||
|
|
||||||
|
if(mFrequencyField.getText() == null || mFrequencyField.getText().isEmpty())
|
||||||
|
{
|
||||||
|
mFrequencyField.setText(FrequencyEntry.format(iqRecording.getCenterFrequency()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(mFrequencyField.getText() == null || mFrequencyField.getText().isEmpty())
|
||||||
|
{
|
||||||
|
Matcher m = TUNER_RECORDING_PATTERN.matcher(selected.getName());
|
||||||
|
|
||||||
|
if(m.matches() && !m.group(1).isEmpty())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mFrequencyField.setText(FrequencyEntry.format(Long.parseLong(m.group(1))));
|
||||||
|
}
|
||||||
|
catch(NumberFormatException nfe)
|
||||||
|
{
|
||||||
|
//Leave the frequency for the user to enter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0l;
|
mRecordingFileLabel.setText(mSelectedRecording != null ? mSelectedRecording.getName() : SELECT_A_FILE);
|
||||||
|
validate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validate()
|
||||||
|
{
|
||||||
|
String error = null;
|
||||||
|
|
||||||
|
if(mSelectedRecording == null)
|
||||||
|
{
|
||||||
|
error = "Select a recording file";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Long frequency = FrequencyEntry.parse(mFrequencyField.getText());
|
||||||
|
|
||||||
|
if(frequency == null || frequency <= 0 || frequency > Integer.MAX_VALUE)
|
||||||
|
{
|
||||||
|
error = "Enter the recording's center frequency, up to 2147.483647 MHz";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mValidationLabel.setText(error == null ? "" : error);
|
||||||
|
mAddButton.setDisable(error != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTuner()
|
||||||
|
{
|
||||||
|
long frequency = FrequencyEntry.parse(mFrequencyField.getText());
|
||||||
|
mLog.info("Adding recording tuner = frequency [" + frequency + "] recording [" +
|
||||||
|
mSelectedRecording.getAbsolutePath() + "]");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RecordingTunerConfiguration config = RecordingTunerConfiguration.create();
|
||||||
|
config.setFrequency(frequency);
|
||||||
|
config.setPath(mSelectedRecording.getAbsolutePath());
|
||||||
|
mTunerConfigurationManager.addTunerConfiguration(config);
|
||||||
|
DiscoveredRecordingTuner discoveredRecordingTuner = new DiscoveredRecordingTuner(mUserPreferences, config);
|
||||||
|
mDiscoveredTunerModel.addDiscoveredTuner(discoveredRecordingTuner);
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
mLog.error("Error adding recording tuner", ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -22,39 +22,28 @@ import io.github.dsheirer.preference.UserPreferences;
|
|||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.Label;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recording tuner configuration editor
|
* Recording tuner editor. Shows the recording file and the frequency of the recording.
|
||||||
*/
|
*/
|
||||||
public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTunerConfiguration>
|
public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private final Label mRecordingPath = new Label();
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(RecordingTunerEditor.class);
|
|
||||||
private JLabel mRecordingPath;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for wide-band recordings
|
* @param userPreferences for settings
|
||||||
* @param tunerManager for saving configurations
|
* @param tunerManager for saving configurations
|
||||||
* @param discoveredTuner for this configuration
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public RecordingTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
public RecordingTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
mRecordingPath.setWrapText(true);
|
||||||
tunerStatusUpdated();
|
mRecordingPath.getStyleClass().add("tuner-value-label");
|
||||||
}
|
getTuningSection().addRow("File", mRecordingPath);
|
||||||
|
refresh();
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -72,62 +61,7 @@ public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTu
|
|||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
mRecordingPath.setText(hasConfiguration() ? getConfiguration().getPath() : "");
|
||||||
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
if(hasConfiguration())
|
|
||||||
{
|
|
||||||
getRecordingPath().setText(getConfiguration().getPath());
|
|
||||||
}
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill]",
|
|
||||||
"[][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("File:"));
|
|
||||||
add(getRecordingPath(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getRecordingPath()
|
|
||||||
{
|
|
||||||
if(mRecordingPath == null)
|
|
||||||
{
|
|
||||||
mRecordingPath = new JLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRecordingPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -137,9 +71,9 @@ public class RecordingTunerEditor extends TunerEditor<RecordingTuner,RecordingTu
|
|||||||
{
|
{
|
||||||
RecordingTunerConfiguration config = getConfiguration();
|
RecordingTunerConfiguration config = getConfiguration();
|
||||||
config.setFrequency(getFrequencyControl().getFrequency());
|
config.setFrequency(getFrequencyControl().getFrequency());
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
config.setMinimumFrequency(getMinimumFrequencyField().getFrequency());
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setMaximumFrequency(getMaximumFrequencyField().getFrequency());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
package io.github.dsheirer.source.tuner.rtl;
|
package io.github.dsheirer.source.tuner.rtl;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.SourceException;
|
|
||||||
import io.github.dsheirer.source.tuner.TunerType;
|
import io.github.dsheirer.source.tuner.TunerType;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
@@ -27,17 +26,12 @@ import io.github.dsheirer.source.tuner.rtl.RTL2832TunerController.SampleRate;
|
|||||||
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration;
|
import io.github.dsheirer.source.tuner.rtl.e4k.E4KTunerConfiguration;
|
||||||
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerConfiguration;
|
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerConfiguration;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import javax.swing.JButton;
|
import javafx.collections.FXCollections;
|
||||||
import javax.swing.JComboBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javax.swing.JLabel;
|
import javafx.scene.control.ComboBox;
|
||||||
import javax.swing.JOptionPane;
|
import javafx.scene.control.Label;
|
||||||
import javax.swing.JSeparator;
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RTL-2832 tuner editor for all supported embedded tuner types (E4000, FC0012, FC0013, FC2580, R820T and R828D).
|
* RTL-2832 tuner editor for all supported embedded tuner types (E4000, FC0012, FC0013, FC2580, R820T and R828D).
|
||||||
@@ -47,15 +41,12 @@ import org.slf4j.LoggerFactory;
|
|||||||
*/
|
*/
|
||||||
public class RTL2832TunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerConfiguration>
|
public class RTL2832TunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(RTL2832TunerEditor.class);
|
private ComboBox<SampleRate> mSampleRateCombo;
|
||||||
private static final long serialVersionUID = 1L;
|
private CheckBox mBiasTCheckBox;
|
||||||
private JButton mTunerInfoButton;
|
private CheckBox mAgcCheckBox;
|
||||||
private JToggleButton mBiasTButton;
|
private ComboBox<Gain> mGainCombo;
|
||||||
private JComboBox<SampleRate> mSampleRateCombo;
|
private Label mIFGainLabel;
|
||||||
private JToggleButton mAgcToggleButton;
|
private ComboBox<Integer> mIFGainCombo;
|
||||||
private JComboBox<Gain> mGainCombo;
|
|
||||||
private JLabel mIFGainLabel;
|
|
||||||
private JComboBox<Integer> mIFGainCombo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -67,7 +58,7 @@ public class RTL2832TunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerCo
|
|||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
init();
|
||||||
tunerStatusUpdated();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,11 +83,6 @@ public class RTL2832TunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerCo
|
|||||||
return R8xTunerConfiguration.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
return R8xTunerConfiguration.MAXIMUM_TUNABLE_FREQUENCY_HZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLogPrefix()
|
|
||||||
{
|
|
||||||
return (hasTuner() ? getTuner().getController().getTunerType().getLabel() : "RTL-2832") + " Tuner Controller - ";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates if the tuner has an E4000 embedded tuner, which supports IF gain control.
|
* Indicates if the tuner has an E4000 embedded tuner, which supports IF gain control.
|
||||||
*/
|
*/
|
||||||
@@ -107,338 +93,18 @@ public class RTL2832TunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerCo
|
|||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
"[][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
TunerSection gain = addSection("Gain");
|
||||||
add(getTunerIdLabel());
|
gain.addRow("Gain", getGainCombo(), getAgcCheckBox());
|
||||||
add(getTunerInfoButton());
|
mIFGainLabel = gain.addRow("IF Gain (dB)", getIFGainCombo());
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
TunerSection options = addSection("Options");
|
||||||
add(getTunerStatusLabel());
|
options.addControl(getBiasTCheckBox());
|
||||||
add(getBiasTButton(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel("Gain Control"), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainCombo());
|
|
||||||
add(getAgcToggleButton(), "wrap");
|
|
||||||
|
|
||||||
add(getIFGainLabel());
|
|
||||||
add(getIFGainCombo(), "wrap");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected String getTunerInfo()
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getTuner().getPreferredName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
DefaultComboBoxModel<Gain> gainModel = new DefaultComboBoxModel<>();
|
|
||||||
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RTL2832TunerController controller = getTuner().getController();
|
|
||||||
|
|
||||||
if(controller.hasGainControl())
|
|
||||||
{
|
|
||||||
for(int gain : controller.getTunerGains())
|
|
||||||
{
|
|
||||||
gainModel.addElement(new Gain(gain));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getGainCombo().setModel(gainModel);
|
|
||||||
|
|
||||||
boolean e4k = isE4K();
|
|
||||||
getIFGainLabel().setVisible(e4k);
|
|
||||||
getIFGainCombo().setVisible(e4k);
|
|
||||||
|
|
||||||
if(hasTuner() && hasConfiguration())
|
|
||||||
{
|
|
||||||
RTL2832TunerConfiguration config = getConfiguration();
|
|
||||||
getBiasTButton().setEnabled(true);
|
|
||||||
getBiasTButton().setSelected(config.isBiasT());
|
|
||||||
getTunerInfoButton().setEnabled(true);
|
|
||||||
getSampleRateCombo().setEnabled(true);
|
|
||||||
getSampleRateCombo().setSelectedItem(config.getSampleRate());
|
|
||||||
RTL2832TunerController controller = getTuner().getController();
|
|
||||||
//The FC2580 always uses its internal AGC and the FC0012 doesn't support AGC
|
|
||||||
boolean agc = controller.hasGainControl() ? controller.hasTunerAGC() && config.isAGC() : true;
|
|
||||||
getAgcToggleButton().setEnabled(controller.hasTunerAGC());
|
|
||||||
getAgcToggleButton().setSelected(agc);
|
|
||||||
getAgcToggleButton().setToolTipText(getAgcToolTip(controller));
|
|
||||||
getGainCombo().setEnabled(!agc && gainModel.getSize() > 0);
|
|
||||||
getGainCombo().setSelectedItem(new Gain(getTuner().getController().getClosestTunerGain(config.getGain())));
|
|
||||||
|
|
||||||
if(e4k && config instanceof E4KTunerConfiguration e4kConfig)
|
|
||||||
{
|
|
||||||
getIFGainCombo().setEnabled(true);
|
|
||||||
getIFGainCombo().setSelectedItem(e4kConfig.getIFGainDb());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getBiasTButton().setEnabled(false);
|
|
||||||
getBiasTButton().setSelected(false);
|
|
||||||
getTunerInfoButton().setEnabled(false);
|
|
||||||
getSampleRateCombo().setEnabled(false);
|
|
||||||
getAgcToggleButton().setEnabled(false);
|
|
||||||
getGainCombo().setEnabled(false);
|
|
||||||
getIFGainCombo().setEnabled(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bias-T toggle button
|
|
||||||
*/
|
|
||||||
private JToggleButton getBiasTButton()
|
|
||||||
{
|
|
||||||
if(mBiasTButton == null)
|
|
||||||
{
|
|
||||||
mBiasTButton = new JToggleButton("Bias-T");
|
|
||||||
mBiasTButton.setEnabled(false);
|
|
||||||
mBiasTButton.addActionListener(e -> {
|
|
||||||
if(!isLoading())
|
|
||||||
{
|
|
||||||
getTuner().getController().setBiasT(mBiasTButton.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBiasTButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button that provides tuner information
|
|
||||||
*/
|
|
||||||
private JButton getTunerInfoButton()
|
|
||||||
{
|
|
||||||
if(mTunerInfoButton == null)
|
|
||||||
{
|
|
||||||
mTunerInfoButton = new JButton("Info");
|
|
||||||
mTunerInfoButton.setEnabled(false);
|
|
||||||
mTunerInfoButton.addActionListener(e -> JOptionPane.showMessageDialog(RTL2832TunerEditor.this,
|
|
||||||
getTunerInfo(), "Tuner Info", JOptionPane.INFORMATION_MESSAGE));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerInfoButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Applies the current AGC and gain settings to the tuner and saves the configuration.
|
|
||||||
*/
|
|
||||||
private void applyGain()
|
|
||||||
{
|
|
||||||
if(isLoading() || !hasTuner())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean agc = getAgcToggleButton().isSelected();
|
|
||||||
Gain gain = (Gain)getGainCombo().getSelectedItem();
|
|
||||||
getGainCombo().setEnabled(!agc && getGainCombo().getItemCount() > 0);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setGain(agc, gain != null ? gain.value() : getConfiguration().getGain());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(RTL2832TunerEditor.this, getLogPrefix() +
|
|
||||||
"couldn't apply the gain setting - " + se.getLocalizedMessage());
|
|
||||||
mLog.error(getLogPrefix() + "couldn't apply gain setting", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tool tip for the AGC button that explains when the tuner doesn't support switching AGC.
|
|
||||||
*/
|
|
||||||
private static String getAgcToolTip(RTL2832TunerController controller)
|
|
||||||
{
|
|
||||||
if(!controller.hasGainControl())
|
|
||||||
{
|
|
||||||
return "The " + controller.getTunerType().getLabel() + " tuner always uses its automatic gain control (AGC)";
|
|
||||||
}
|
|
||||||
else if(!controller.hasTunerAGC())
|
|
||||||
{
|
|
||||||
return "The " + controller.getTunerType().getLabel() + " tuner doesn't support automatic gain control (AGC)";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Turn on the tuner's automatic gain control (AGC)";
|
|
||||||
}
|
|
||||||
|
|
||||||
private JToggleButton getAgcToggleButton()
|
|
||||||
{
|
|
||||||
if(mAgcToggleButton == null)
|
|
||||||
{
|
|
||||||
mAgcToggleButton = new JToggleButton("AGC");
|
|
||||||
mAgcToggleButton.setEnabled(false);
|
|
||||||
mAgcToggleButton.setToolTipText("Turn on the tuner's automatic gain control (AGC)");
|
|
||||||
mAgcToggleButton.addActionListener(e -> applyGain());
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAgcToggleButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JComboBox<Gain> getGainCombo()
|
|
||||||
{
|
|
||||||
if(mGainCombo == null)
|
|
||||||
{
|
|
||||||
mGainCombo = new JComboBox<>();
|
|
||||||
mGainCombo.setEnabled(false);
|
|
||||||
mGainCombo.setToolTipText("Tuner gain. Turn off AGC to enable adjustment.");
|
|
||||||
mGainCombo.addActionListener(e -> applyGain());
|
|
||||||
}
|
|
||||||
|
|
||||||
return mGainCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JLabel getIFGainLabel()
|
|
||||||
{
|
|
||||||
if(mIFGainLabel == null)
|
|
||||||
{
|
|
||||||
mIFGainLabel = new JLabel("IF Gain (dB):");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mIFGainLabel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JComboBox<Integer> getIFGainCombo()
|
|
||||||
{
|
|
||||||
if(mIFGainCombo == null)
|
|
||||||
{
|
|
||||||
mIFGainCombo = new JComboBox<>();
|
|
||||||
|
|
||||||
for(int gain = RTL2832TunerController.E4K_IF_GAIN_MINIMUM; gain <= RTL2832TunerController.E4K_IF_GAIN_MAXIMUM; gain++)
|
|
||||||
{
|
|
||||||
mIFGainCombo.addItem(gain);
|
|
||||||
}
|
|
||||||
|
|
||||||
mIFGainCombo.setEnabled(false);
|
|
||||||
mIFGainCombo.setToolTipText("E4000 IF gain, distributed across the six IF gain stages");
|
|
||||||
mIFGainCombo.addActionListener(e ->
|
|
||||||
{
|
|
||||||
Integer gain = (Integer)mIFGainCombo.getSelectedItem();
|
|
||||||
|
|
||||||
if(!isLoading() && hasTuner() && gain != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setE4KIFGain(gain);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(RTL2832TunerEditor.this, getLogPrefix() +
|
|
||||||
"couldn't apply the IF gain setting - " + se.getLocalizedMessage());
|
|
||||||
mLog.error(getLogPrefix() + "couldn't apply IF gain setting", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mIFGainCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JComboBox<SampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
mSampleRateCombo = new JComboBox<>(SampleRate.values());
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e ->
|
|
||||||
{
|
|
||||||
if(!isLoading())
|
|
||||||
{
|
|
||||||
SampleRate sampleRate = (SampleRate) mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTuner().getController().setSampleRate(sampleRate);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate(sampleRate.getRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(SourceException se)
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(RTL2832TunerEditor.this,
|
|
||||||
getLogPrefix() + "couldn't apply the sample rate setting [" +
|
|
||||||
sampleRate.getLabel() + "] " + se.getLocalizedMessage());
|
|
||||||
|
|
||||||
mLog.error(getLogPrefix() + "couldn't apply sample rate setting [" + sampleRate.getLabel() +
|
|
||||||
"]", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getTunerInfo()
|
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
RTL2832TunerController.Descriptor descriptor = getTuner().getController().getDescriptor();
|
RTL2832TunerController.Descriptor descriptor = getTuner().getController().getDescriptor();
|
||||||
@@ -463,28 +129,242 @@ public class RTL2832TunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerCo
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tunerStatusUpdated()
|
||||||
|
{
|
||||||
|
getGainCombo().getItems().clear();
|
||||||
|
|
||||||
|
if(hasTuner())
|
||||||
|
{
|
||||||
|
RTL2832TunerController controller = getTuner().getController();
|
||||||
|
|
||||||
|
if(controller.hasGainControl())
|
||||||
|
{
|
||||||
|
for(int gain : controller.getTunerGains())
|
||||||
|
{
|
||||||
|
getGainCombo().getItems().add(new Gain(gain));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean e4k = isE4K();
|
||||||
|
mIFGainLabel.setVisible(e4k);
|
||||||
|
getIFGainCombo().setVisible(e4k);
|
||||||
|
|
||||||
|
if(hasTuner() && hasConfiguration())
|
||||||
|
{
|
||||||
|
RTL2832TunerConfiguration config = getConfiguration();
|
||||||
|
RTL2832TunerController controller = getTuner().getController();
|
||||||
|
getBiasTCheckBox().setDisable(false);
|
||||||
|
getBiasTCheckBox().setSelected(config.isBiasT());
|
||||||
|
getSampleRateCombo().setValue(config.getSampleRate());
|
||||||
|
//The FC2580 always uses its internal AGC and the FC0012 doesn't support AGC
|
||||||
|
boolean agc = controller.hasGainControl() ? controller.hasTunerAGC() && config.isAGC() : true;
|
||||||
|
getAgcCheckBox().setDisable(!controller.hasTunerAGC());
|
||||||
|
getAgcCheckBox().setSelected(agc);
|
||||||
|
getAgcCheckBox().setTooltip(new Tooltip(getAgcToolTip(controller)));
|
||||||
|
getGainCombo().setDisable(agc || getGainCombo().getItems().isEmpty());
|
||||||
|
getGainCombo().setValue(new Gain(controller.getClosestTunerGain(config.getGain())));
|
||||||
|
|
||||||
|
if(e4k && config instanceof E4KTunerConfiguration e4kConfig)
|
||||||
|
{
|
||||||
|
getIFGainCombo().setDisable(false);
|
||||||
|
getIFGainCombo().setValue(e4kConfig.getIFGainDb());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getBiasTCheckBox().setDisable(true);
|
||||||
|
getBiasTCheckBox().setSelected(false);
|
||||||
|
getAgcCheckBox().setDisable(true);
|
||||||
|
getGainCombo().setDisable(true);
|
||||||
|
getIFGainCombo().setDisable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSampleRateControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
|
{
|
||||||
|
updateSampleRateControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the sample rate combo's enabled state and tooltip according to the tuner controller's lock state.
|
||||||
|
*/
|
||||||
|
private void updateSampleRateControl()
|
||||||
|
{
|
||||||
|
boolean locked = hasTuner() && getTuner().getTunerController().isLockedSampleRate();
|
||||||
|
getSampleRateCombo().setDisable(!hasTuner() || !hasConfiguration() || locked);
|
||||||
|
|
||||||
|
if(locked)
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("Sample rate is locked. Disable decoding channels to unlock."));
|
||||||
|
}
|
||||||
|
else if(hasTuner())
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("No tuner available"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CheckBox getBiasTCheckBox()
|
||||||
|
{
|
||||||
|
if(mBiasTCheckBox == null)
|
||||||
|
{
|
||||||
|
mBiasTCheckBox = new CheckBox("Bias-T");
|
||||||
|
mBiasTCheckBox.setTooltip(new Tooltip("Provide DC power on the antenna connector (e.g. for an LNA)"));
|
||||||
|
mBiasTCheckBox.setDisable(true);
|
||||||
|
mBiasTCheckBox.setOnAction(e -> {
|
||||||
|
if(!isLoading() && hasTuner())
|
||||||
|
{
|
||||||
|
getTuner().getController().setBiasT(mBiasTCheckBox.isSelected());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mBiasTCheckBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the current AGC and gain settings to the tuner and saves the configuration.
|
||||||
|
*/
|
||||||
|
private void applyGain()
|
||||||
|
{
|
||||||
|
if(isLoading() || !hasTuner())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean agc = getAgcCheckBox().isSelected();
|
||||||
|
Gain gain = getGainCombo().getValue();
|
||||||
|
getGainCombo().setDisable(agc || getGainCombo().getItems().isEmpty());
|
||||||
|
|
||||||
|
if(applyToTuner("gain", () -> getTuner().getController().setGain(agc,
|
||||||
|
gain != null ? gain.value() : getConfiguration().getGain())))
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tool tip for the AGC control that explains when the tuner doesn't support switching AGC.
|
||||||
|
*/
|
||||||
|
private static String getAgcToolTip(RTL2832TunerController controller)
|
||||||
|
{
|
||||||
|
if(!controller.hasGainControl())
|
||||||
|
{
|
||||||
|
return "The " + controller.getTunerType().getLabel() + " tuner always uses its automatic gain control (AGC)";
|
||||||
|
}
|
||||||
|
else if(!controller.hasTunerAGC())
|
||||||
|
{
|
||||||
|
return "The " + controller.getTunerType().getLabel() + " tuner doesn't support automatic gain control (AGC)";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Turn on the tuner's automatic gain control (AGC)";
|
||||||
|
}
|
||||||
|
|
||||||
|
private CheckBox getAgcCheckBox()
|
||||||
|
{
|
||||||
|
if(mAgcCheckBox == null)
|
||||||
|
{
|
||||||
|
mAgcCheckBox = new CheckBox("AGC");
|
||||||
|
mAgcCheckBox.setDisable(true);
|
||||||
|
mAgcCheckBox.setTooltip(new Tooltip("Turn on the tuner's automatic gain control (AGC)"));
|
||||||
|
mAgcCheckBox.setOnAction(e -> applyGain());
|
||||||
|
}
|
||||||
|
|
||||||
|
return mAgcCheckBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComboBox<Gain> getGainCombo()
|
||||||
|
{
|
||||||
|
if(mGainCombo == null)
|
||||||
|
{
|
||||||
|
mGainCombo = new ComboBox<>();
|
||||||
|
mGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
mGainCombo.setDisable(true);
|
||||||
|
mGainCombo.setTooltip(new Tooltip("Tuner gain. Turn off AGC to enable adjustment."));
|
||||||
|
mGainCombo.setOnAction(e -> applyGain());
|
||||||
|
}
|
||||||
|
|
||||||
|
return mGainCombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComboBox<Integer> getIFGainCombo()
|
||||||
|
{
|
||||||
|
if(mIFGainCombo == null)
|
||||||
|
{
|
||||||
|
mIFGainCombo = new ComboBox<>();
|
||||||
|
mIFGainCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
|
||||||
|
for(int gain = RTL2832TunerController.E4K_IF_GAIN_MINIMUM; gain <= RTL2832TunerController.E4K_IF_GAIN_MAXIMUM; gain++)
|
||||||
|
{
|
||||||
|
mIFGainCombo.getItems().add(gain);
|
||||||
|
}
|
||||||
|
|
||||||
|
mIFGainCombo.setDisable(true);
|
||||||
|
mIFGainCombo.setTooltip(new Tooltip("E4000 IF gain, distributed across the six IF gain stages"));
|
||||||
|
mIFGainCombo.setOnAction(e -> {
|
||||||
|
Integer gain = mIFGainCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && gain != null &&
|
||||||
|
applyToTuner("IF gain", () -> getTuner().getController().setE4KIFGain(gain)))
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mIFGainCombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ComboBox<SampleRate> getSampleRateCombo()
|
||||||
|
{
|
||||||
|
if(mSampleRateCombo == null)
|
||||||
|
{
|
||||||
|
mSampleRateCombo = new ComboBox<>(FXCollections.observableArrayList(SampleRate.values()));
|
||||||
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
mSampleRateCombo.setDisable(true);
|
||||||
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
|
SampleRate sampleRate = mSampleRateCombo.getValue();
|
||||||
|
|
||||||
|
if(!isLoading() && hasTuner() && sampleRate != null &&
|
||||||
|
applyToTuner("sample rate [" + sampleRate.getLabel() + "]",
|
||||||
|
() -> getTuner().getController().setSampleRate(sampleRate)))
|
||||||
|
{
|
||||||
|
//Adjust the min/max values for the sample rate.
|
||||||
|
adjustForSampleRate(sampleRate.getRate());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mSampleRateCombo;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save()
|
public void save()
|
||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
RTL2832TunerConfiguration config = getConfiguration();
|
RTL2832TunerConfiguration config = getConfiguration();
|
||||||
|
saveCommonSettings(config);
|
||||||
config.setBiasT(getTuner().getController().isBiasT());
|
config.setBiasT(getTuner().getController().isBiasT());
|
||||||
config.setFrequency(getFrequencyControl().getFrequency());
|
config.setSampleRate(getSampleRateCombo().getValue());
|
||||||
config.setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
config.setAGC(getAgcCheckBox().isSelected());
|
||||||
config.setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
double value = ((SpinnerNumberModel)getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
|
||||||
config.setFrequencyCorrection(value);
|
|
||||||
config.setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
config.setSampleRate((SampleRate)getSampleRateCombo().getSelectedItem());
|
|
||||||
config.setAGC(getAgcToggleButton().isSelected());
|
|
||||||
|
|
||||||
if(getGainCombo().getSelectedItem() instanceof Gain gain)
|
if(getGainCombo().getValue() instanceof Gain gain)
|
||||||
{
|
{
|
||||||
config.setGain(gain.value());
|
config.setGain(gain.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config instanceof E4KTunerConfiguration e4k && getIFGainCombo().getSelectedItem() instanceof Integer ifGain)
|
if(config instanceof E4KTunerConfiguration e4k && getIFGainCombo().getValue() instanceof Integer ifGain)
|
||||||
{
|
{
|
||||||
e4k.setIFGainDb(ifGain);
|
e4k.setIFGainDb(ifGain);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.rtl;
|
package io.github.dsheirer.source.tuner.rtl;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
@@ -24,46 +23,32 @@ import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
|||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerConfiguration;
|
import io.github.dsheirer.source.tuner.rtl.r8x.R8xTunerConfiguration;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tuner editor for RTL2832 tuner that has not been started, or for an unknown tuner type
|
* Editor for an RTL-2832 with an embedded tuner type that sdrtrunk doesn't support. Only shows the tuner status.
|
||||||
*/
|
*/
|
||||||
public class RTL2832UnknownTunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerConfiguration>
|
public class RTL2832UnknownTunerEditor extends TunerEditor<RTL2832Tuner, RTL2832TunerConfiguration>
|
||||||
{
|
{
|
||||||
/**
|
private final Label mUniqueIdLabel = new Label();
|
||||||
* Constructs an instance
|
|
||||||
*
|
|
||||||
* @param userPreferences for starting wide-band recorders
|
|
||||||
* @param tunerManager for requesting configuration saves.
|
|
||||||
* @param discoveredTuner that is not started, or that doesn't have a recognized tuner type
|
|
||||||
*/
|
|
||||||
public RTL2832UnknownTunerEditor(UserPreferences userPreferences, TunerManager tunerManager,
|
public RTL2832UnknownTunerEditor(UserPreferences userPreferences, TunerManager tunerManager,
|
||||||
DiscoveredTuner discoveredTuner)
|
DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection section = addSection("Unsupported Tuner");
|
||||||
tunerStatusUpdated();
|
Label message = new Label("This RTL-2832 device has an embedded tuner type that isn't supported.");
|
||||||
|
message.setWrapText(true);
|
||||||
|
section.addFullRow(message);
|
||||||
|
section.addRow("ID", mUniqueIdLabel);
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
@Override
|
||||||
|
protected boolean hasTuningControls()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
return false;
|
||||||
"[][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -89,22 +74,6 @@ public class RTL2832UnknownTunerEditor extends TunerEditor<RTL2832Tuner, RTL2832
|
|||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected void tunerStatusUpdated()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
mUniqueIdLabel.setText(hasTuner() ? getTuner().getUniqueID() : getDiscoveredTuner().getId());
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId() + (hasTuner() ? " ID:" + getTuner().getUniqueID() : ""));
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
setLoading(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,59 +16,82 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay;
|
package io.github.dsheirer.source.tuner.sdrplay;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
|
||||||
import io.github.dsheirer.sdrplay.Tuner;
|
import io.github.dsheirer.sdrplay.Tuner;
|
||||||
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
|
import io.github.dsheirer.source.tuner.ui.GainSlider;
|
||||||
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
import io.github.dsheirer.source.tuner.ui.TunerEditor;
|
||||||
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.util.ThreadPool;
|
import io.github.dsheirer.util.ThreadPool;
|
||||||
import java.awt.Color;
|
import java.util.ArrayList;
|
||||||
import java.awt.EventQueue;
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import javafx.css.PseudoClass;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.CheckBox;
|
||||||
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.JToggleButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract RSP tuner editor
|
* Base SDRPlay RSP tuner editor. Provides the sample rate control, the gain section (LNA state, IF gain reduction,
|
||||||
|
* IF AGC, gain readout and overload indicator) and helpers for binding the model specific option check boxes and
|
||||||
|
* choices to the device.
|
||||||
*/
|
*/
|
||||||
public abstract class RspTunerEditor<C extends RspTunerConfiguration> extends TunerEditor<RspTuner,C> implements ITunerStatusListener
|
public abstract class RspTunerEditor<C extends RspTunerConfiguration> extends TunerEditor<RspTuner,C>
|
||||||
|
implements ITunerStatusListener
|
||||||
{
|
{
|
||||||
private Logger mLog = LoggerFactory.getLogger(RspTunerEditor.class);
|
private static final Logger mLog = LoggerFactory.getLogger(RspTunerEditor.class);
|
||||||
protected static final String MANUAL = "Manual";
|
private static final PseudoClass OVERLOAD = PseudoClass.getPseudoClass("overload");
|
||||||
protected static final String AUTOMATIC = "Automatic";
|
private static final int IF_GAIN_SLIDER_MAX = 39;
|
||||||
private JToggleButton mAgcButton;
|
private ComboBox<RspSampleRate> mSampleRateCombo;
|
||||||
private JLabel mGainValueLabel;
|
private CheckBox mAgcCheckBox;
|
||||||
private LnaSlider mLNASlider;
|
private Label mGainValueLabel;
|
||||||
private IfGainSlider mIfGainSlider;
|
private Label mGainOverloadLabel;
|
||||||
private JButton mGainOverloadButton;
|
private GainSlider mLNASlider;
|
||||||
private JPanel mGainPanel;
|
private GainSlider mIfGainSlider;
|
||||||
private AtomicBoolean mGainOverloadAlert = new AtomicBoolean();
|
private Label mLnaLabel;
|
||||||
|
private Label mIfGainLabel;
|
||||||
|
private boolean mGainOverloadAlert;
|
||||||
|
private final List<Option> mOptions = new ArrayList<>();
|
||||||
|
private final List<Choice<?>> mChoices = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance. Implementations add their own sections and then call {@link #refresh()}.
|
||||||
* @param userPreferences for preference settings
|
|
||||||
* @param tunerManager to notify for state changes
|
|
||||||
* @param discoveredTuner to be edited.
|
|
||||||
*/
|
*/
|
||||||
public RspTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public RspTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
|
getTuningSection().addRow("Sample Rate", getSampleRateCombo());
|
||||||
|
|
||||||
|
TunerSection gain = addSection("Gain");
|
||||||
|
HBox readout = new HBox(getGainValueLabel(), getGainOverloadLabel());
|
||||||
|
readout.getStyleClass().add("tuner-flow-row");
|
||||||
|
gain.addRow("Gain", readout);
|
||||||
|
mLnaLabel = gain.addRow("LNA", getLNASlider(), new Region());
|
||||||
|
mIfGainLabel = gain.addRow("IF", getIfGainSlider(), getAgcCheckBox());
|
||||||
}
|
}
|
||||||
|
|
||||||
private RspTunerController getTunerController()
|
/**
|
||||||
|
* Discovered RSP tuner
|
||||||
|
*/
|
||||||
|
protected DiscoveredRspTuner getDiscoveredRspTuner()
|
||||||
{
|
{
|
||||||
return (RspTunerController) getTuner().getTunerController();
|
return (DiscoveredRspTuner)getDiscoveredTuner();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Device control for the tuner. Only use when the editor has a tuner.
|
||||||
|
*/
|
||||||
|
protected IControlRsp getControlRsp()
|
||||||
|
{
|
||||||
|
return getTuner().getRspTunerController().getControlRsp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -84,92 +107,201 @@ public abstract class RspTunerEditor<C extends RspTunerConfiguration> extends Tu
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gain controls panel
|
* Sample rates to offer. Defaults to the single tuner sample rates.
|
||||||
* @return gain panel
|
|
||||||
*/
|
*/
|
||||||
protected JPanel getGainPanel()
|
protected Collection<RspSampleRate> getSampleRates()
|
||||||
{
|
{
|
||||||
if(mGainPanel == null)
|
return RspSampleRate.SINGLE_TUNER_SAMPLE_RATES;
|
||||||
{
|
|
||||||
mGainPanel = new JPanel();
|
|
||||||
mGainPanel.setLayout(new MigLayout("insets 0","[][][grow,fill][][]",""));
|
|
||||||
mGainPanel.add(getGainValueLabel());
|
|
||||||
mGainPanel.add(getGainOverloadButton());
|
|
||||||
mGainPanel.add(new JLabel()); //empty label to grow to fill space
|
|
||||||
mGainPanel.add(new JLabel("IF Gain Mode:"));
|
|
||||||
mGainPanel.add(getAgcButton());
|
|
||||||
}
|
|
||||||
|
|
||||||
return mGainPanel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label for displaying current gain index value
|
* Indicates if the user can change the sample rate (when it isn't locked by active channels). Defaults to true.
|
||||||
*/
|
*/
|
||||||
protected JLabel getGainValueLabel()
|
protected boolean isSampleRateChangeable()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation specific updates after the common RSP controls are refreshed. Invoked while loading.
|
||||||
|
*/
|
||||||
|
protected void rspTunerStatusUpdated()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected final void tunerStatusUpdated()
|
||||||
|
{
|
||||||
|
getSampleRateCombo().getItems().setAll(hasTuner() ? getSampleRates() : List.of());
|
||||||
|
getSampleRateCombo().setValue(hasTuner() ? getControlRsp().getSampleRateEnumeration() : null);
|
||||||
|
updateSampleRateControl();
|
||||||
|
|
||||||
|
getAgcCheckBox().setDisable(!hasTuner());
|
||||||
|
|
||||||
|
if(hasTuner())
|
||||||
|
{
|
||||||
|
RspAgcMode current = getControlRsp().getAgcMode();
|
||||||
|
getAgcCheckBox().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
||||||
|
getLNASlider().setRange(0, getControlRsp().getMaximumLNASetting());
|
||||||
|
setLNA(getControlRsp().getLNA());
|
||||||
|
setGainReduction(getControlRsp().getBasebandGainReduction());
|
||||||
|
//Register to receive gain overload notifications
|
||||||
|
getControlRsp().setGainOverloadListener(this);
|
||||||
|
updateGainLabel();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getGainValueLabel().setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
getLNASlider().setDisable(!hasTuner());
|
||||||
|
mLnaLabel.setDisable(!hasTuner());
|
||||||
|
boolean ifManual = hasTuner() && !getAgcCheckBox().isSelected();
|
||||||
|
getIfGainSlider().setDisable(!ifManual);
|
||||||
|
mIfGainLabel.setDisable(!ifManual);
|
||||||
|
getGainValueLabel().setDisable(!hasTuner());
|
||||||
|
|
||||||
|
for(Option option: mOptions)
|
||||||
|
{
|
||||||
|
option.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Choice<?> choice: mChoices)
|
||||||
|
{
|
||||||
|
choice.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
rspTunerStatusUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tunerLockStateUpdated(boolean locked)
|
||||||
|
{
|
||||||
|
updateSampleRateControl();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSampleRateControl()
|
||||||
|
{
|
||||||
|
boolean locked = hasTuner() && getTuner().getTunerController().isLockedSampleRate();
|
||||||
|
getSampleRateCombo().setDisable(!hasTuner() || !isSampleRateChangeable() || locked);
|
||||||
|
|
||||||
|
if(locked)
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("Sample rate is locked. Disable decoding channels to unlock."));
|
||||||
|
}
|
||||||
|
else if(!hasTuner())
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("No tuner available"));
|
||||||
|
}
|
||||||
|
else if(!isSampleRateChangeable())
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("The sample rate is set by the master tuner"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getSampleRateCombo().setTooltip(new Tooltip("Select a sample rate for the tuner"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample rate selection
|
||||||
|
*/
|
||||||
|
protected ComboBox<RspSampleRate> getSampleRateCombo()
|
||||||
|
{
|
||||||
|
if(mSampleRateCombo == null)
|
||||||
|
{
|
||||||
|
mSampleRateCombo = new ComboBox<>();
|
||||||
|
mSampleRateCombo.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
mSampleRateCombo.setDisable(true);
|
||||||
|
mSampleRateCombo.setOnAction(e -> {
|
||||||
|
RspSampleRate selected = mSampleRateCombo.getValue();
|
||||||
|
|
||||||
|
if(hasTuner() && !isLoading() && selected != null &&
|
||||||
|
applyToTuner("sample rate [" + selected + "]",
|
||||||
|
() -> getTuner().getRspTunerController().setSampleRate(selected)))
|
||||||
|
{
|
||||||
|
//Adjust the min/max values for the sample rate.
|
||||||
|
adjustForSampleRate((int)selected.getSampleRate());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return mSampleRateCombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copies the common RSP settings (sample rate and gain) and the base settings to the configuration.
|
||||||
|
*/
|
||||||
|
protected void saveRspSettings(C config)
|
||||||
|
{
|
||||||
|
saveCommonSettings(config);
|
||||||
|
|
||||||
|
if(getSampleRateCombo().getValue() != null)
|
||||||
|
{
|
||||||
|
config.setSampleRate(getSampleRateCombo().getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
config.setLNA(getLNA());
|
||||||
|
config.setBasebandGainReduction(getGainReduction());
|
||||||
|
config.setAgcMode(getAgcCheckBox().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Label getGainValueLabel()
|
||||||
{
|
{
|
||||||
if(mGainValueLabel == null)
|
if(mGainValueLabel == null)
|
||||||
{
|
{
|
||||||
mGainValueLabel = new JLabel("0");
|
mGainValueLabel = new Label();
|
||||||
mGainValueLabel.setEnabled(false);
|
mGainValueLabel.getStyleClass().add("tuner-value-label");
|
||||||
|
mGainValueLabel.setTooltip(new Tooltip("Current overall gain"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return mGainValueLabel;
|
return mGainValueLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Label getGainOverloadLabel()
|
||||||
* IF AGC mode (enable/disable) toggle button
|
|
||||||
*/
|
|
||||||
protected JToggleButton getAgcButton()
|
|
||||||
{
|
{
|
||||||
if(mAgcButton == null)
|
if(mGainOverloadLabel == null)
|
||||||
{
|
{
|
||||||
mAgcButton = new JToggleButton(MANUAL);
|
mGainOverloadLabel = new Label("Overload");
|
||||||
mAgcButton.setEnabled(false);
|
mGainOverloadLabel.getStyleClass().add("tuner-overload-indicator");
|
||||||
mAgcButton.addActionListener(e -> {
|
mGainOverloadLabel.setTooltip(new Tooltip("Lights when the manual gain is set too high and the signal " +
|
||||||
if(hasTuner() && !isLoading())
|
"overloads the tuner. Reduce the gain when this flashes."));
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setAgcMode(mAgcButton.isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting AGC mode on RSP device");
|
|
||||||
}
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
getIfGainSlider().setEnabled(!getAgcButton().isSelected());
|
|
||||||
|
|
||||||
if(mAgcButton.isSelected())
|
|
||||||
{
|
|
||||||
getAgcButton().setText(AUTOMATIC);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getAgcButton().setText(MANUAL);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mAgcButton;
|
return mGainOverloadLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gain overload button. Used in a disabled state to indicate (e.g. flashing color) that gain overload is detected.
|
* IF automatic gain control
|
||||||
*/
|
*/
|
||||||
protected JButton getGainOverloadButton()
|
protected CheckBox getAgcCheckBox()
|
||||||
{
|
{
|
||||||
if(mGainOverloadButton == null)
|
if(mAgcCheckBox == null)
|
||||||
{
|
{
|
||||||
mGainOverloadButton = new JButton("Gain Overload");
|
mAgcCheckBox = new CheckBox("AGC");
|
||||||
mGainOverloadButton.setToolTipText("Notification that manual gain is set too high and causing power overload. Reduce manual gain when this flashes.");
|
mAgcCheckBox.setTooltip(new Tooltip("Automatic IF gain control. Turn off to set the IF gain manually."));
|
||||||
mGainOverloadButton.setEnabled(false);
|
mAgcCheckBox.setDisable(true);
|
||||||
|
mAgcCheckBox.setOnAction(e -> {
|
||||||
|
boolean agc = mAgcCheckBox.isSelected();
|
||||||
|
|
||||||
|
if(hasTuner() && !isLoading())
|
||||||
|
{
|
||||||
|
if(applyToTuner("AGC mode",
|
||||||
|
() -> getControlRsp().setAgcMode(agc ? RspAgcMode.ENABLE : RspAgcMode.DISABLE)))
|
||||||
|
{
|
||||||
|
updateGainLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
getIfGainSlider().setDisable(agc);
|
||||||
|
mIfGainLabel.setDisable(agc);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return mGainOverloadButton;
|
return mAgcCheckBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,210 +309,292 @@ public abstract class RspTunerEditor<C extends RspTunerConfiguration> extends Tu
|
|||||||
{
|
{
|
||||||
if(hasTuner() && getTuner().getRspTunerController().getSdrplayTuner() == tuner)
|
if(hasTuner() && getTuner().getRspTunerController().getSdrplayTuner() == tuner)
|
||||||
{
|
{
|
||||||
//Set overload alert
|
runOnFxThread(() -> setGainOverloadAlert(true));
|
||||||
EventQueue.invokeLater(() -> setGainOverloadAlert(true));
|
ThreadPool.SCHEDULED.schedule(() -> runOnFxThread(() -> setGainOverloadAlert(false)), 600,
|
||||||
|
TimeUnit.MILLISECONDS);
|
||||||
//Schedule a reset to happen 1 second later
|
|
||||||
ThreadPool.SCHEDULED.schedule((Runnable) () -> setGainOverloadAlert(false), 600, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void frequencyUpdated()
|
public void frequencyUpdated()
|
||||||
{
|
{
|
||||||
updateLnaSlider();
|
runOnFxThread(this::updateLnaSlider);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Toggles the alert styling of the disabled gain overload button to indicate an alert condition or a normal
|
|
||||||
* operating condition.
|
|
||||||
* @param alert true to apply alert styling or false to reset.
|
|
||||||
*/
|
|
||||||
private void setGainOverloadAlert(boolean alert)
|
private void setGainOverloadAlert(boolean alert)
|
||||||
{
|
{
|
||||||
if(alert && mGainOverloadAlert.compareAndSet(false, true))
|
if(alert != mGainOverloadAlert)
|
||||||
{
|
{
|
||||||
getGainOverloadButton().setEnabled(true);
|
mGainOverloadAlert = alert;
|
||||||
getGainOverloadButton().setForeground(Color.YELLOW);
|
getGainOverloadLabel().pseudoClassStateChanged(OVERLOAD, alert);
|
||||||
getGainOverloadButton().setBackground(Color.RED);
|
|
||||||
}
|
|
||||||
else if(!alert && mGainOverloadAlert.compareAndSet(true, false))
|
|
||||||
{
|
|
||||||
getGainOverloadButton().setEnabled(false);
|
|
||||||
getGainOverloadButton().setForeground(getForeground());
|
|
||||||
getGainOverloadButton().setBackground(getBackground());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the LNA slider with the number of LNA states available for the current frequency.
|
* Updates the LNA slider range for the current frequency, since the number of LNA states depends on the band.
|
||||||
*/
|
*/
|
||||||
protected void updateLnaSlider()
|
protected void updateLnaSlider()
|
||||||
{
|
{
|
||||||
if(hasTuner())
|
if(hasTuner())
|
||||||
{
|
{
|
||||||
int max = getTunerController().getControlRsp().getMaximumLNASetting();
|
int max = getControlRsp().getMaximumLNASetting();
|
||||||
if(max != getLNASlider().getMaximum())
|
GainSlider slider = getLNASlider();
|
||||||
|
|
||||||
|
if(max != (int)slider.getSlider().getMax())
|
||||||
{
|
{
|
||||||
EventQueue.invokeLater(() -> {
|
boolean wasLoading = isLoading();
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
//Adjust the value if it's less than max
|
int lna = Math.min(getLNA(), max);
|
||||||
getLNASlider().setValue(Math.min(getLNASlider().getValue(), max));
|
slider.setRange(0, max);
|
||||||
getLNASlider().setMaximum(max);
|
setLNA(lna);
|
||||||
setLoading(false);
|
setLoading(wasLoading);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LNA Gain Slider
|
* LNA state slider. The slider is inverted so that moving it right increases the gain: LNA state 0 is the
|
||||||
|
* highest gain.
|
||||||
*/
|
*/
|
||||||
protected LnaSlider getLNASlider()
|
protected GainSlider getLNASlider()
|
||||||
{
|
{
|
||||||
if(mLNASlider == null)
|
if(mLNASlider == null)
|
||||||
{
|
{
|
||||||
mLNASlider = new LnaSlider();
|
mLNASlider = new GainSlider(0, 9, 9);
|
||||||
mLNASlider.setEnabled(true);
|
mLNASlider.setApplyOnRelease(true);
|
||||||
mLNASlider.setMajorTickSpacing(1);
|
mLNASlider.setTooltip("LNA gain. Move right for more gain.");
|
||||||
mLNASlider.setPaintTicks(true);
|
mLNASlider.setFormatter(value -> "State " + ((int)mLNASlider.getSlider().getMax() - value));
|
||||||
mLNASlider.addChangeListener(event ->
|
mLNASlider.setOnChange(value -> updateGain());
|
||||||
{
|
|
||||||
JSlider source = (JSlider)event.getSource();
|
|
||||||
|
|
||||||
if(!source.getValueIsAdjusting())
|
|
||||||
{
|
|
||||||
updateGain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mLNASlider;
|
return mLNASlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the gain settings when the LNA or Baseband gain value is changed by the user.
|
* IF gain slider. The slider is inverted gain reduction, so that moving it right increases the gain.
|
||||||
*/
|
*/
|
||||||
private void updateGain()
|
protected GainSlider getIfGainSlider()
|
||||||
{
|
|
||||||
int lna = getLNASlider().getLNA();
|
|
||||||
int gr = getIfGainSlider().getGR();
|
|
||||||
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setGain(lna, gr);
|
|
||||||
save();
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.error("Couldn't set RSP gain to LNA:" + lna + " Gain Reduction:" + gr, e);
|
|
||||||
JOptionPane.showMessageDialog(mIfGainSlider, "Couldn't set RSP gain value to LNA:" + lna + " Gain Reduction:" + gr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateGainLabel()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
float currentGain = getTunerController().getControlRsp().getCurrentGain();
|
|
||||||
getGainValueLabel().setText((int)currentGain + " dB");
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error accessing current gain value from RSP tuner", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* IF Gain Slider
|
|
||||||
*/
|
|
||||||
protected IfGainSlider getIfGainSlider()
|
|
||||||
{
|
{
|
||||||
if(mIfGainSlider == null)
|
if(mIfGainSlider == null)
|
||||||
{
|
{
|
||||||
mIfGainSlider = new IfGainSlider();
|
mIfGainSlider = new GainSlider(0, IF_GAIN_SLIDER_MAX, 30);
|
||||||
mIfGainSlider.setEnabled(true);
|
mIfGainSlider.setApplyOnRelease(true);
|
||||||
mIfGainSlider.setMajorTickSpacing(1);
|
mIfGainSlider.setTooltip("IF gain. Move right for more gain. Turn off AGC to adjust.");
|
||||||
mIfGainSlider.setPaintTicks(true);
|
mIfGainSlider.setFormatter(value -> (IF_GAIN_SLIDER_MAX - value + 20) + " dB GR");
|
||||||
mIfGainSlider.addChangeListener(event ->
|
mIfGainSlider.setOnChange(value -> updateGain());
|
||||||
{
|
|
||||||
JSlider source = (JSlider)event.getSource();
|
|
||||||
|
|
||||||
if(!source.getValueIsAdjusting())
|
|
||||||
{
|
|
||||||
updateGain();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mIfGainSlider;
|
return mIfGainSlider;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSlider implementation that inverts the scale to support LNA values.
|
* Current LNA state from the slider
|
||||||
*/
|
*/
|
||||||
public class LnaSlider extends JSlider
|
protected int getLNA()
|
||||||
{
|
{
|
||||||
/**
|
return (int)getLNASlider().getSlider().getMax() - getLNASlider().getValue();
|
||||||
* Constructs an instance
|
}
|
||||||
*/
|
|
||||||
public LnaSlider()
|
|
||||||
{
|
|
||||||
super(JSlider.HORIZONTAL, 0,9,9);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
private void setLNA(int lna)
|
||||||
* Slider value converted to the LNA scale.
|
{
|
||||||
* @return lna value.
|
getLNASlider().setValue((int)getLNASlider().getSlider().getMax() - lna);
|
||||||
*/
|
}
|
||||||
public int getLNA()
|
|
||||||
{
|
|
||||||
return getMaximum() - getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the slider with the value converted from the provided LNA value.
|
* Current baseband gain reduction from the IF gain slider
|
||||||
* @param lna value to apply
|
*/
|
||||||
*/
|
protected int getGainReduction()
|
||||||
public void setLNA(int lna)
|
{
|
||||||
|
return IF_GAIN_SLIDER_MAX - getIfGainSlider().getValue() + 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setGainReduction(int gainReduction)
|
||||||
|
{
|
||||||
|
getIfGainSlider().setValue(IF_GAIN_SLIDER_MAX - (gainReduction - 20));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateGain()
|
||||||
|
{
|
||||||
|
int lna = getLNA();
|
||||||
|
int gr = getGainReduction();
|
||||||
|
|
||||||
|
if(hasTuner() && !isLoading() &&
|
||||||
|
applyToTuner("gain (LNA " + lna + ", gain reduction " + gr + ")", () -> getControlRsp().setGain(lna, gr)))
|
||||||
{
|
{
|
||||||
setValue(getMaximum() - lna);
|
save();
|
||||||
|
updateGainLabel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JSlider implementation that inverts the scale to support IF Gain (aka Gain Reduction) values.
|
* Updates the overall gain readout
|
||||||
*/
|
*/
|
||||||
public class IfGainSlider extends JSlider
|
protected void updateGainLabel()
|
||||||
{
|
{
|
||||||
/**
|
try
|
||||||
* Constructs an instance
|
|
||||||
*/
|
|
||||||
public IfGainSlider()
|
|
||||||
{
|
{
|
||||||
super(JSlider.HORIZONTAL, 0, 39, 30);
|
getGainValueLabel().setText((int)getControlRsp().getCurrentGain() + " dB");
|
||||||
|
}
|
||||||
|
catch(Exception se)
|
||||||
|
{
|
||||||
|
mLog.error("Error accessing current gain value from RSP tuner", se);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a device setting
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
protected interface RspGetter<T>
|
||||||
|
{
|
||||||
|
T get() throws Exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a device setting
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
protected interface RspSetter<T>
|
||||||
|
{
|
||||||
|
void set(T value) throws Exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a check box option to the section that's bound to a device setting. The check box is refreshed from the
|
||||||
|
* device when the editor refreshes, and changes are applied to the device and then saved.
|
||||||
|
* @param section to add to
|
||||||
|
* @param text for the check box
|
||||||
|
* @param tooltip or null
|
||||||
|
* @param getter reads the device setting
|
||||||
|
* @param setter applies the device setting
|
||||||
|
* @return the check box
|
||||||
|
*/
|
||||||
|
protected CheckBox addOption(TunerSection section, String text, String tooltip, RspGetter<Boolean> getter,
|
||||||
|
RspSetter<Boolean> setter)
|
||||||
|
{
|
||||||
|
Option option = new Option(text, getter, setter);
|
||||||
|
|
||||||
|
if(tooltip != null)
|
||||||
|
{
|
||||||
|
option.mCheckBox.setTooltip(new Tooltip(tooltip));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
mOptions.add(option);
|
||||||
* Slider value converted to the gain reduction scale.
|
section.addControl(option.mCheckBox);
|
||||||
* @return gain reduction value.
|
return option.mCheckBox;
|
||||||
*/
|
}
|
||||||
public int getGR()
|
|
||||||
|
/**
|
||||||
|
* Adds a choice (combo box) to the section that's bound to a device setting.
|
||||||
|
* @param section to add to
|
||||||
|
* @param label for the row
|
||||||
|
* @param values to choose from
|
||||||
|
* @param getter reads the device setting
|
||||||
|
* @param setter applies the device setting
|
||||||
|
* @return the combo box
|
||||||
|
*/
|
||||||
|
protected <T> ComboBox<T> addChoice(TunerSection section, String label, Collection<T> values, RspGetter<T> getter,
|
||||||
|
RspSetter<T> setter)
|
||||||
|
{
|
||||||
|
Choice<T> choice = new Choice<>(label, values, getter, setter);
|
||||||
|
mChoices.add(choice);
|
||||||
|
section.addRow(label, choice.mComboBox);
|
||||||
|
return choice.mComboBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check box bound to a device setting
|
||||||
|
*/
|
||||||
|
private class Option
|
||||||
|
{
|
||||||
|
private final CheckBox mCheckBox;
|
||||||
|
private final String mText;
|
||||||
|
private final RspGetter<Boolean> mGetter;
|
||||||
|
|
||||||
|
Option(String text, RspGetter<Boolean> getter, RspSetter<Boolean> setter)
|
||||||
{
|
{
|
||||||
return getIfGainSlider().getMaximum() - getIfGainSlider().getValue() + 20;
|
mText = text;
|
||||||
|
mGetter = getter;
|
||||||
|
mCheckBox = new CheckBox(text);
|
||||||
|
mCheckBox.setDisable(true);
|
||||||
|
mCheckBox.setOnAction(e -> {
|
||||||
|
if(hasTuner() && !isLoading())
|
||||||
|
{
|
||||||
|
boolean selected = mCheckBox.isSelected();
|
||||||
|
|
||||||
|
if(applyToTuner(mText, () -> setter.set(selected)))
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void refresh()
|
||||||
* Sets the slider with the value converted from the provided gain reduction value.
|
|
||||||
* @param gainReduction value to apply
|
|
||||||
*/
|
|
||||||
public void setGR(int gainReduction)
|
|
||||||
{
|
{
|
||||||
setValue(getMaximum() - (gainReduction - 20));
|
mCheckBox.setDisable(!hasTuner());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mCheckBox.setSelected(hasTuner() && mGetter.get());
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
mLog.error("Error reading RSP setting [" + mText + "]", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combo box bound to a device setting
|
||||||
|
*/
|
||||||
|
private class Choice<T>
|
||||||
|
{
|
||||||
|
private final ComboBox<T> mComboBox;
|
||||||
|
private final String mLabel;
|
||||||
|
private final RspGetter<T> mGetter;
|
||||||
|
|
||||||
|
Choice(String label, Collection<T> values, RspGetter<T> getter, RspSetter<T> setter)
|
||||||
|
{
|
||||||
|
mLabel = label;
|
||||||
|
mGetter = getter;
|
||||||
|
mComboBox = new ComboBox<>();
|
||||||
|
mComboBox.getItems().addAll(values);
|
||||||
|
mComboBox.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
mComboBox.setDisable(true);
|
||||||
|
mComboBox.setOnAction(e -> {
|
||||||
|
T selected = mComboBox.getValue();
|
||||||
|
|
||||||
|
if(hasTuner() && !isLoading() && selected != null)
|
||||||
|
{
|
||||||
|
if(applyToTuner(mLabel.toLowerCase() + " [" + selected + "]", () -> setter.set(selected)))
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void refresh()
|
||||||
|
{
|
||||||
|
mComboBox.setDisable(!hasTuner());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mComboBox.setValue(hasTuner() ? mGetter.get() : null);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
mLog.error("Error reading RSP setting [" + mLabel + "]", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,138 +16,28 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rsp1;
|
package io.github.dsheirer.source.tuner.sdrplay.rsp1;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSP1 Tuner Editor
|
* RSP1 tuner editor
|
||||||
*/
|
*/
|
||||||
public class Rsp1TunerEditor extends RspTunerEditor<Rsp1TunerConfiguration>
|
public class Rsp1TunerEditor extends RspTunerEditor<Rsp1TunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(Rsp1TunerEditor.class);
|
|
||||||
|
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public Rsp1TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public Rsp1TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
refresh();
|
||||||
tunerStatusUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
|
||||||
{
|
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
|
||||||
"[][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access tuner controller
|
|
||||||
*/
|
|
||||||
private Rsp1TunerController getTunerController()
|
|
||||||
{
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
return (Rsp1TunerController)getTuner().getTunerController();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tunerStatusUpdated()
|
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -155,70 +45,8 @@ public class Rsp1TunerEditor extends RspTunerEditor<Rsp1TunerConfiguration>
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
saveRspSettings(getConfiguration());
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
RspSampleRate[] rspSampleRates = RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.toArray(new RspSampleRate[RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.size()]);
|
|
||||||
mSampleRateCombo = new JComboBox<>(rspSampleRates);
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSP1A tuner", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,179 +16,46 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rsp1a;
|
package io.github.dsheirer.source.tuner.sdrplay.rsp1a;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
import javafx.scene.control.CheckBox;
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSP1A Tuner Editor
|
* RSP1A tuner editor
|
||||||
*/
|
*/
|
||||||
public class Rsp1aTunerEditor extends RspTunerEditor<Rsp1aTunerConfiguration>
|
public class Rsp1aTunerEditor extends RspTunerEditor<Rsp1aTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(Rsp1aTunerEditor.class);
|
private final CheckBox mBiasTCheckBox;
|
||||||
|
private final CheckBox mRfNotchCheckBox;
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
private final CheckBox mRfDabNotchCheckBox;
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
private JCheckBox mRfDabNotchCheckBox;
|
|
||||||
private JCheckBox mRfNotchCheckBox;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public Rsp1aTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public Rsp1aTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection options = addSection("Options");
|
||||||
tunerStatusUpdated();
|
mBiasTCheckBox = addOption(options, "Bias-T power", "Provide DC power on the antenna connector",
|
||||||
|
() -> control().isBiasT(), enabled -> control().setBiasT(enabled));
|
||||||
|
mRfNotchCheckBox = addOption(options, "FM broadcast band filter (77-115 MHz)", null,
|
||||||
|
() -> control().isRfNotch(), enabled -> control().setRfNotch(enabled));
|
||||||
|
mRfDabNotchCheckBox = addOption(options, "DAB broadcast band filter (160-235 MHz)", null,
|
||||||
|
() -> control().isRfDabNotch(), enabled -> control().setRfDabNotch(enabled));
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private IControlRsp1a control()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
return (IControlRsp1a)getControlRsp();
|
||||||
"[][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfDabNotchCheckBox(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access tuner controller
|
|
||||||
*/
|
|
||||||
private Rsp1aTunerController getTunerController()
|
|
||||||
{
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
return (Rsp1aTunerController)getTuner().getTunerController();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tunerStatusUpdated()
|
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getBiasTCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isBiasT());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfDabNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfDabNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfDabNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF DAB Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfNotchCheckBox().setSelected(hasTuner() ? getTunerController().getControlRsp().isRfNotch() : false);
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -196,159 +63,12 @@ public class Rsp1aTunerEditor extends RspTunerEditor<Rsp1aTunerConfiguration>
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
Rsp1aTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveRspSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setBiasT(mBiasTCheckBox.isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setRfNotch(mRfNotchCheckBox.isSelected());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
RspSampleRate[] rspSampleRates = RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.toArray(new RspSampleRate[RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.size()]);
|
|
||||||
mSampleRateCombo = new JComboBox<>(rspSampleRates);
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSP1A tuner", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for Bias-T
|
|
||||||
*/
|
|
||||||
private JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
|
||||||
if(mBiasTCheckBox == null)
|
|
||||||
{
|
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T Power");
|
|
||||||
mBiasTCheckBox.setEnabled(false);
|
|
||||||
mBiasTCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP1A Bias-T enabled to " + mBiasTCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBiasTCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF DAB notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfDabNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfDabNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfDabNotchCheckBox = new JCheckBox("DAB Broadcast Band Filter (160-235 MHz)");
|
|
||||||
mRfDabNotchCheckBox.setEnabled(false);
|
|
||||||
mRfDabNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP1A RF DAB notch enabled to " + mRfDabNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfDabNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfNotchCheckBox = new JCheckBox("FM Broadcast Band Filter (77-115 MHz)");
|
|
||||||
mRfNotchCheckBox.setEnabled(false);
|
|
||||||
mRfNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfNotch(mRfNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP1A RF notch enabled to " + mRfNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,178 +16,46 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rsp1b;
|
package io.github.dsheirer.source.tuner.sdrplay.rsp1b;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
import javafx.scene.control.CheckBox;
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSP1B Tuner Editor
|
* RSP1B tuner editor
|
||||||
*/
|
*/
|
||||||
public class Rsp1bTunerEditor extends RspTunerEditor<Rsp1bTunerConfiguration>
|
public class Rsp1bTunerEditor extends RspTunerEditor<Rsp1bTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(Rsp1bTunerEditor.class);
|
private final CheckBox mBiasTCheckBox;
|
||||||
|
private final CheckBox mRfNotchCheckBox;
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
private final CheckBox mRfDabNotchCheckBox;
|
||||||
private JCheckBox mBiasTCheckBox;
|
|
||||||
private JCheckBox mRfDabNotchCheckBox;
|
|
||||||
private JCheckBox mRfNotchCheckBox;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public Rsp1bTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public Rsp1bTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection options = addSection("Options");
|
||||||
tunerStatusUpdated();
|
mBiasTCheckBox = addOption(options, "Bias-T power", "Provide DC power on the antenna connector",
|
||||||
|
() -> control().isBiasT(), enabled -> control().setBiasT(enabled));
|
||||||
|
mRfNotchCheckBox = addOption(options, "FM broadcast band filter (77-115 MHz)", null,
|
||||||
|
() -> control().isRfNotch(), enabled -> control().setRfNotch(enabled));
|
||||||
|
mRfDabNotchCheckBox = addOption(options, "DAB broadcast band filter (160-235 MHz)", null,
|
||||||
|
() -> control().isRfDabNotch(), enabled -> control().setRfDabNotch(enabled));
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private IControlRsp1b control()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
return (IControlRsp1b)getControlRsp();
|
||||||
"[][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfDabNotchCheckBox(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access tuner controller
|
|
||||||
*/
|
|
||||||
private Rsp1bTunerController getTunerController()
|
|
||||||
{
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
return (Rsp1bTunerController)getTuner().getTunerController();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tunerStatusUpdated()
|
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getBiasTCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isBiasT());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfDabNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfDabNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfDabNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF DAB Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfNotchCheckBox().setSelected(hasTuner() ? getTunerController().getControlRsp().isRfNotch() : false);
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -195,158 +63,12 @@ public class Rsp1bTunerEditor extends RspTunerEditor<Rsp1bTunerConfiguration>
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
Rsp1bTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveRspSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setBiasT(mBiasTCheckBox.isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setRfNotch(mRfNotchCheckBox.isSelected());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
RspSampleRate[] rspSampleRates = RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.toArray(new RspSampleRate[RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.size()]);
|
|
||||||
mSampleRateCombo = new JComboBox<>(rspSampleRates);
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSP1A tuner", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for Bias-T
|
|
||||||
*/
|
|
||||||
private JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
|
||||||
if(mBiasTCheckBox == null)
|
|
||||||
{
|
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T Power");
|
|
||||||
mBiasTCheckBox.setEnabled(false);
|
|
||||||
mBiasTCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP1B Bias-T enabled to " + mBiasTCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBiasTCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF DAB notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfDabNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfDabNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfDabNotchCheckBox = new JCheckBox("DAB Broadcast Band Filter (160-235 MHz)");
|
|
||||||
mRfDabNotchCheckBox.setEnabled(false);
|
|
||||||
mRfDabNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP1B RF DAB notch enabled to " + mRfDabNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfDabNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfNotchCheckBox = new JCheckBox("FM Broadcast Band Filter (77-115 MHz)");
|
|
||||||
mRfNotchCheckBox.setEnabled(false);
|
|
||||||
mRfNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfNotch(mRfNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP1B RF notch enabled to " + mRfNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,192 +16,51 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rsp2;
|
package io.github.dsheirer.source.tuner.sdrplay.rsp2;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
import java.util.List;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.ComboBox;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSP2 Tuner Editor
|
* RSP2 tuner editor
|
||||||
*/
|
*/
|
||||||
public class Rsp2TunerEditor extends RspTunerEditor<Rsp2TunerConfiguration>
|
public class Rsp2TunerEditor extends RspTunerEditor<Rsp2TunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(Rsp2TunerEditor.class);
|
private final ComboBox<Rsp2AntennaSelection> mAntennaCombo;
|
||||||
|
private final CheckBox mBiasTCheckBox;
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
private final CheckBox mExternalReferenceOutputCheckBox;
|
||||||
private JCheckBox mBiasTCheckBox;
|
private final CheckBox mRfNotchCheckBox;
|
||||||
private JCheckBox mExternalReferenceOutputCheckBox;
|
|
||||||
private JCheckBox mRfNotchCheckBox;
|
|
||||||
private JComboBox<Rsp2AntennaSelection> mAntennaSelectionCombo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public Rsp2TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public Rsp2TunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection options = addSection("Options");
|
||||||
tunerStatusUpdated();
|
mAntennaCombo = addChoice(options, "Antenna", List.of(Rsp2AntennaSelection.values()),
|
||||||
|
() -> control().getAntennaSelection(), selection -> control().setAntennaSelection(selection));
|
||||||
|
mBiasTCheckBox = addOption(options, "ANT B Bias-T power", "Provide DC power on the ANT B connector",
|
||||||
|
() -> control().isBiasT(), enabled -> control().setBiasT(enabled));
|
||||||
|
mRfNotchCheckBox = addOption(options, "FM broadcast band filter (77-115 MHz)", null,
|
||||||
|
() -> control().isRfNotch(), enabled -> control().setRfNotch(enabled));
|
||||||
|
mExternalReferenceOutputCheckBox = addOption(options, "External reference output", null,
|
||||||
|
() -> control().isExternalReferenceOutput(), enabled -> control().setExternalReferenceOutput(enabled));
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private IControlRsp2 control()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
return (IControlRsp2)getControlRsp();
|
||||||
"[][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getExternalReferenceOutputCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getAntennaSelectionCombo(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access tuner controller
|
|
||||||
*/
|
|
||||||
private Rsp2TunerController getTunerController()
|
|
||||||
{
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
return (Rsp2TunerController) getTuner().getTunerController();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tunerStatusUpdated()
|
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getBiasTCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isBiasT());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getExternalReferenceOutputCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getExternalReferenceOutputCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isExternalReferenceOutput());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF DAB Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getAntennaSelectionCombo().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getAntennaSelectionCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getAntennaSelection() : null);
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting antenna selection in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -209,188 +68,18 @@ public class Rsp2TunerEditor extends RspTunerEditor<Rsp2TunerConfiguration>
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
Rsp2TunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveRspSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setBiasT(mBiasTCheckBox.isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setRfNotch(mRfNotchCheckBox.isSelected());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setExternalReferenceOutput(mExternalReferenceOutputCheckBox.isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
if(mAntennaCombo.getValue() != null)
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
{
|
||||||
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
|
config.setAntennaSelection(mAntennaCombo.getValue());
|
||||||
getConfiguration().setAntennaSelection((Rsp2AntennaSelection)getAntennaSelectionCombo().getSelectedItem());
|
}
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
RspSampleRate[] rspSampleRates = RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.toArray(new RspSampleRate[RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.size()]);
|
|
||||||
mSampleRateCombo = new JComboBox<>(rspSampleRates);
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSP2 tuner", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for Bias-T
|
|
||||||
*/
|
|
||||||
private JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
|
||||||
if(mBiasTCheckBox == null)
|
|
||||||
{
|
|
||||||
mBiasTCheckBox = new JCheckBox("ANT B Bias-T Power");
|
|
||||||
mBiasTCheckBox.setEnabled(false);
|
|
||||||
mBiasTCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP2 Bias-T enabled to " + mBiasTCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBiasTCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfNotchCheckBox = new JCheckBox("FM Broadcast Band Filter (77-115 MHz)");
|
|
||||||
mRfNotchCheckBox.setEnabled(false);
|
|
||||||
mRfNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfNotch(mRfNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP2 RF notch enabled to " + mRfNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for External Reference Output
|
|
||||||
*/
|
|
||||||
private JCheckBox getExternalReferenceOutputCheckBox()
|
|
||||||
{
|
|
||||||
if(mExternalReferenceOutputCheckBox == null)
|
|
||||||
{
|
|
||||||
mExternalReferenceOutputCheckBox = new JCheckBox("External Reference Output");
|
|
||||||
mExternalReferenceOutputCheckBox.setEnabled(false);
|
|
||||||
mExternalReferenceOutputCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setExternalReferenceOutput(mExternalReferenceOutputCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP2 external reference output notch enabled to " +
|
|
||||||
mExternalReferenceOutputCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mExternalReferenceOutputCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Antenna selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<Rsp2AntennaSelection> getAntennaSelectionCombo()
|
|
||||||
{
|
|
||||||
if(mAntennaSelectionCombo == null)
|
|
||||||
{
|
|
||||||
mAntennaSelectionCombo = new JComboBox<>(Rsp2AntennaSelection.values());
|
|
||||||
mAntennaSelectionCombo.setEnabled(false);
|
|
||||||
mAntennaSelectionCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
Rsp2AntennaSelection selected = (Rsp2AntennaSelection)mAntennaSelectionCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setAntennaSelection(selected);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Antenna selection for RSP2", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAntennaSelectionCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rspDuo;
|
package io.github.dsheirer.source.tuner.sdrplay.rspDuo;
|
||||||
|
|
||||||
import io.github.dsheirer.eventbus.MyEventBus;
|
import io.github.dsheirer.eventbus.MyEventBus;
|
||||||
@@ -27,209 +26,71 @@ import io.github.dsheirer.source.tuner.manager.TunerManager;
|
|||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.List;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.Button;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.LoggerFactory;
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSPduo Tuner 1 Editor
|
* RSPduo tuner 1 editor
|
||||||
*/
|
*/
|
||||||
public class RspDuoTuner1Editor extends RspTunerEditor<RspDuoTuner1Configuration>
|
public class RspDuoTuner1Editor extends RspTunerEditor<RspDuoTuner1Configuration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(RspDuoTuner1Editor.class);
|
private final CheckBox mExternalReferenceOutputCheckBox;
|
||||||
|
private final CheckBox mAmNotchCheckBox;
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
private final CheckBox mRfDabNotchCheckBox;
|
||||||
private JCheckBox mRfDabNotchCheckBox;
|
private final CheckBox mRfNotchCheckBox;
|
||||||
private JCheckBox mRfNotchCheckBox;
|
private final ComboBox<RspDuoAmPortSelection> mAmPortCombo;
|
||||||
private JCheckBox mAmNotchCheckBox;
|
|
||||||
private JCheckBox mExternalReferenceOutputCheckBox;
|
|
||||||
private JComboBox<RspDuoAmPortSelection> mAmPortCombo;
|
|
||||||
private JButton mTunerPreferencesButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public RspDuoTuner1Editor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public RspDuoTuner1Editor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
addHeaderNode(createPreferencesButton());
|
||||||
tunerStatusUpdated();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
TunerSection options = addSection("Options");
|
||||||
{
|
mAmPortCombo = addChoice(options, "AM Port", List.of(RspDuoAmPortSelection.values()),
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
() -> control().getAmPort(), port -> control().setAmPort(port));
|
||||||
"[][][][][][][][][][][][][][][][grow]"));
|
mRfNotchCheckBox = addOption(options, "FM broadcast band filter (78-114 MHz)", null,
|
||||||
|
() -> control().isRfNotch(), enabled -> control().setRfNotch(enabled));
|
||||||
add(new JLabel("Tuner:"));
|
mRfDabNotchCheckBox = addOption(options, "DAB broadcast band filter (157-235 MHz)", null,
|
||||||
JPanel labelAndButtonPanel = new JPanel();
|
() -> control().isRfDabNotch(), enabled -> control().setRfDabNotch(enabled));
|
||||||
labelAndButtonPanel.setLayout(new MigLayout("insets 0"));
|
mAmNotchCheckBox = addOption(options, "AM broadcast band filter (415-1640 kHz)", null,
|
||||||
labelAndButtonPanel.add(getTunerIdLabel());
|
() -> control().isAmNotch(), enabled -> control().setAmNotch(enabled));
|
||||||
labelAndButtonPanel.add(getTunerPreferencesButton());
|
mExternalReferenceOutputCheckBox = addOption(options, "External reference output", null,
|
||||||
add(labelAndButtonPanel, "wrap");
|
() -> control().isExternalReferenceOutput(), enabled -> control().setExternalReferenceOutput(enabled));
|
||||||
add(new JLabel("Status:"));
|
refresh();
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getExternalReferenceOutputCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getAmNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfDabNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel("AM Port:"));
|
|
||||||
add(getAmPortCombo(), "wrap");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access tuner controller
|
* Button that opens the RSPduo (tuner) preferences, where the RSPduo dual tuner mode is chosen.
|
||||||
*/
|
*/
|
||||||
private RspDuoTuner1Controller getTunerController()
|
static Button createPreferencesButton()
|
||||||
{
|
{
|
||||||
if(hasTuner())
|
Button button = new Button("RSPduo Preferences");
|
||||||
{
|
button.setTooltip(new Tooltip("Choose how sdrtrunk uses the RSPduo's two tuners"));
|
||||||
return (RspDuoTuner1Controller) getTuner().getTunerController();
|
button.setOnAction(e -> MyEventBus.getGlobalEventBus()
|
||||||
}
|
.post(new ViewUserPreferenceEditorRequest(PreferenceEditorType.SOURCE_TUNERS)));
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
private IControlRspDuoTuner1 control()
|
||||||
|
{
|
||||||
|
return (IControlRspDuoTuner1)getControlRsp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected Collection<RspSampleRate> getSampleRates()
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
return control().getSupportedSampleRates();
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tunerStatusUpdated()
|
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
clearSampleRates();
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
setSampleRates(getTunerController().getControlRsp().getSupportedSampleRates());
|
|
||||||
}
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
getAmPortCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getAmPortCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getAmPort() : null);
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 1 AM Port in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfDabNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfDabNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfDabNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 1 RF DAB Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 1 RF Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getAmNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getAmNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isAmNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 1 AM Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getExternalReferenceOutputCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getExternalReferenceOutputCheckBox()
|
|
||||||
.setSelected(hasTuner() && getTunerController().getControlRsp().isExternalReferenceOutput());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 1 external reference output enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -237,256 +98,14 @@ public class RspDuoTuner1Editor extends RspTunerEditor<RspDuoTuner1Configuration
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
RspDuoTuner1Configuration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveRspSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setAmNotch(mAmNotchCheckBox.isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setAmPort(mAmPortCombo.getValue());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setExternalReferenceOutput(mExternalReferenceOutputCheckBox.isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
config.setRfNotch(mRfNotchCheckBox.isSelected());
|
||||||
getConfiguration().setAmNotch(getAmNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setAmPort(getAmPortCombo().getSelectedItem() != null ? (RspDuoAmPortSelection)getAmPortCombo().getSelectedItem() : null);
|
|
||||||
getConfiguration().setExternalReferenceOutput(getExternalReferenceOutputCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rates listed in the combobox.
|
|
||||||
* @param sampleRates to use.
|
|
||||||
*/
|
|
||||||
private void setSampleRates(EnumSet<RspSampleRate> sampleRates)
|
|
||||||
{
|
|
||||||
if(!sampleRates.isEmpty())
|
|
||||||
{
|
|
||||||
for(RspSampleRate sampleRate: sampleRates)
|
|
||||||
{
|
|
||||||
getSampleRateCombo().addItem(sampleRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all sample rate options from the combo box.
|
|
||||||
*/
|
|
||||||
private void clearSampleRates()
|
|
||||||
{
|
|
||||||
getSampleRateCombo().removeAllItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
mSampleRateCombo = new JComboBox<>();
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSPduo tuner 1", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AM port selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspDuoAmPortSelection> getAmPortCombo()
|
|
||||||
{
|
|
||||||
if(mAmPortCombo == null)
|
|
||||||
{
|
|
||||||
mAmPortCombo = new JComboBox<>(RspDuoAmPortSelection.values());
|
|
||||||
mAmPortCombo.setEnabled(false);
|
|
||||||
mAmPortCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspDuoAmPortSelection selected = (RspDuoAmPortSelection)mAmPortCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setAmPort(selected);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting AM port for RSPduo tuner 1", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAmPortCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF DAB notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfDabNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfDabNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfDabNotchCheckBox = new JCheckBox("DAB Broadcast Band Filter (157-235 MHz)");
|
|
||||||
mRfDabNotchCheckBox.setEnabled(false);
|
|
||||||
mRfDabNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 1 RF DAB notch enabled to " + mRfDabNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfDabNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfNotchCheckBox = new JCheckBox("FM Broadcast Band Filter (78-114 MHz)");
|
|
||||||
mRfNotchCheckBox.setEnabled(false);
|
|
||||||
mRfNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfNotch(mRfNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 1 RF notch enabled to " + mRfNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for AM notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getAmNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mAmNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mAmNotchCheckBox = new JCheckBox("AM Broadcast Band Filter (415-1640 kHz)");
|
|
||||||
mAmNotchCheckBox.setEnabled(false);
|
|
||||||
mAmNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setAmNotch(mAmNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 1 AM notch enabled to " + mAmNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAmNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for External Reference Output
|
|
||||||
*/
|
|
||||||
private JCheckBox getExternalReferenceOutputCheckBox()
|
|
||||||
{
|
|
||||||
if(mExternalReferenceOutputCheckBox == null)
|
|
||||||
{
|
|
||||||
mExternalReferenceOutputCheckBox = new JCheckBox("External Reference Output");
|
|
||||||
mExternalReferenceOutputCheckBox.setEnabled(false);
|
|
||||||
mExternalReferenceOutputCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setExternalReferenceOutput(mExternalReferenceOutputCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 1 external reference output notch enabled to " +
|
|
||||||
mExternalReferenceOutputCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mExternalReferenceOutputCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button to launch the User Preferences editor to show the RSPduo tuner preference selection.
|
|
||||||
* @return constructed button.
|
|
||||||
*/
|
|
||||||
private JButton getTunerPreferencesButton()
|
|
||||||
{
|
|
||||||
if(mTunerPreferencesButton == null)
|
|
||||||
{
|
|
||||||
mTunerPreferencesButton = new JButton("RSPduo Preferences");
|
|
||||||
mTunerPreferencesButton.addActionListener(e -> MyEventBus.getGlobalEventBus()
|
|
||||||
.post(new ViewUserPreferenceEditorRequest(PreferenceEditorType.SOURCE_TUNERS)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerPreferencesButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,121 +16,60 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rspDuo;
|
package io.github.dsheirer.source.tuner.sdrplay.rspDuo;
|
||||||
|
|
||||||
import io.github.dsheirer.eventbus.MyEventBus;
|
|
||||||
import io.github.dsheirer.gui.preference.PreferenceEditorType;
|
|
||||||
import io.github.dsheirer.gui.preference.ViewUserPreferenceEditorRequest;
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import javafx.scene.control.CheckBox;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.Tooltip;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSPduo Tuner 2 Editor
|
* RSPduo tuner 2 editor. In master/slave mode, tuner 2 is the slave: its sample rate and external reference output
|
||||||
|
* follow the master (tuner 1) and it is enabled or disabled with the master.
|
||||||
*/
|
*/
|
||||||
public class RspDuoTuner2Editor extends RspTunerEditor<RspDuoTuner2Configuration>
|
public class RspDuoTuner2Editor extends RspTunerEditor<RspDuoTuner2Configuration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(RspDuoTuner2Editor.class);
|
private final CheckBox mExternalReferenceOutputCheckBox;
|
||||||
|
private final CheckBox mBiasTCheckBox;
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
private final CheckBox mRfDabNotchCheckBox;
|
||||||
private JCheckBox mBiasTCheckBox;
|
private final CheckBox mRfNotchCheckBox;
|
||||||
private JCheckBox mExternalReferenceOutputCheckBox;
|
|
||||||
private JCheckBox mRfDabNotchCheckBox;
|
|
||||||
private JCheckBox mRfNotchCheckBox;
|
|
||||||
private JButton mTunerPreferencesButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public RspDuoTuner2Editor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public RspDuoTuner2Editor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
addHeaderNode(RspDuoTuner1Editor.createPreferencesButton());
|
||||||
tunerStatusUpdated();
|
|
||||||
|
TunerSection options = addSection("Options");
|
||||||
|
mBiasTCheckBox = addOption(options, "Bias-T power", "Provide DC power on the tuner 2 antenna connector",
|
||||||
|
() -> control().isBiasT(), enabled -> control().setBiasT(enabled));
|
||||||
|
mRfNotchCheckBox = addOption(options, "FM broadcast band filter (78-114 MHz)", null,
|
||||||
|
() -> control().isRfNotch(), enabled -> control().setRfNotch(enabled));
|
||||||
|
mRfDabNotchCheckBox = addOption(options, "DAB broadcast band filter (157-235 MHz)", null,
|
||||||
|
() -> control().isRfDabNotch(), enabled -> control().setRfDabNotch(enabled));
|
||||||
|
mExternalReferenceOutputCheckBox = addOption(options, "External reference output", null,
|
||||||
|
() -> !isSlaveMode() && control().isExternalReferenceOutput(),
|
||||||
|
enabled -> control().setExternalReferenceOutput(enabled));
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private IControlRspDuoTuner2 control()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
return (IControlRspDuoTuner2)getControlRsp();
|
||||||
"[][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
JPanel labelAndButtonPanel = new JPanel();
|
|
||||||
labelAndButtonPanel.setLayout(new MigLayout("insets 0"));
|
|
||||||
labelAndButtonPanel.add(getTunerIdLabel());
|
|
||||||
labelAndButtonPanel.add(getTunerPreferencesButton());
|
|
||||||
add(labelAndButtonPanel, "wrap");
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getExternalReferenceOutputCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfDabNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfNotchCheckBox(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
private DiscoveredRspTuner getDiscoveredRspTuner()
|
|
||||||
{
|
|
||||||
return (DiscoveredRspTuner)getDiscoveredTuner();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access tuner controller
|
* Indicates if the tuner is configured as the slave in master/slave mode.
|
||||||
*/
|
|
||||||
private RspDuoTuner2Controller getTunerController()
|
|
||||||
{
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
return (RspDuoTuner2Controller) getTuner().getTunerController();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Indicates if this editor has a tuner and the tuner is configured for slave mode.
|
|
||||||
*/
|
*/
|
||||||
private boolean isSlaveMode()
|
private boolean isSlaveMode()
|
||||||
{
|
{
|
||||||
@@ -138,106 +77,28 @@ public class RspDuoTuner2Editor extends RspTunerEditor<RspDuoTuner2Configuration
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTunerLockState(boolean locked)
|
protected Collection<RspSampleRate> getSampleRates()
|
||||||
{
|
{
|
||||||
getFrequencyPanel().updateControls();
|
return control().getSupportedSampleRates();
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tunerStatusUpdated()
|
protected boolean isSampleRateChangeable()
|
||||||
{
|
{
|
||||||
setLoading(true);
|
return !isSlaveMode();
|
||||||
|
}
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
@Override
|
||||||
|
protected void rspTunerStatusUpdated()
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
{
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
|
|
||||||
//If master/slave configuration, disable the slave's enable/disable button - user can disable
|
|
||||||
//the tuner via the master device.
|
|
||||||
if(isSlaveMode())
|
if(isSlaveMode())
|
||||||
{
|
{
|
||||||
getEnabledButton().setEnabled(false);
|
//The user disables the slave by disabling the master tuner
|
||||||
|
getEnabledSwitch().setDisable(true);
|
||||||
|
getEnabledSwitch().setTooltip(new Tooltip("Enable or disable the RSPduo with tuner 1 (master)"));
|
||||||
|
mExternalReferenceOutputCheckBox.setDisable(true);
|
||||||
|
mExternalReferenceOutputCheckBox.setTooltip(new Tooltip("Set by tuner 1 (master)"));
|
||||||
}
|
}
|
||||||
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
clearSampleRates();
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
setSampleRates(getTunerController().getControlRsp().getSupportedSampleRates());
|
|
||||||
}
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !isSlaveMode() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
getRfDabNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfDabNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfDabNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 2 RF DAB Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 2 RF Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getBiasTCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isBiasT());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 2 Bias-T enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getExternalReferenceOutputCheckBox().setEnabled(hasTuner() && !isSlaveMode());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getExternalReferenceOutputCheckBox()
|
|
||||||
.setSelected(hasTuner() && !isSlaveMode() && getTunerController().getControlRsp().isExternalReferenceOutput());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RSPduo tuner 2 external reference output enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -245,231 +106,18 @@ public class RspDuoTuner2Editor extends RspTunerEditor<RspDuoTuner2Configuration
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
RspDuoTuner2Configuration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveRspSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setBiasT(mBiasTCheckBox.isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
|
||||||
if(getSampleRateCombo().getSelectedItem() != null)
|
|
||||||
{
|
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
|
||||||
}
|
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
|
||||||
if(hasTuner() && !isSlaveMode())
|
if(hasTuner() && !isSlaveMode())
|
||||||
{
|
{
|
||||||
getConfiguration().setExternalReferenceOutput(getExternalReferenceOutputCheckBox().isSelected());
|
config.setExternalReferenceOutput(mExternalReferenceOutputCheckBox.isSelected());
|
||||||
}
|
}
|
||||||
getConfiguration().setRfDabNotch(getRfDabNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
|
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
|
||||||
|
|
||||||
|
config.setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
||||||
|
config.setRfNotch(mRfNotchCheckBox.isSelected());
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rates listed in the combobox.
|
|
||||||
* @param sampleRates to use.
|
|
||||||
*/
|
|
||||||
private void setSampleRates(EnumSet<RspSampleRate> sampleRates)
|
|
||||||
{
|
|
||||||
if(!sampleRates.isEmpty())
|
|
||||||
{
|
|
||||||
for(RspSampleRate sampleRate: sampleRates)
|
|
||||||
{
|
|
||||||
getSampleRateCombo().addItem(sampleRate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all sample rate options from the combo box.
|
|
||||||
*/
|
|
||||||
private void clearSampleRates()
|
|
||||||
{
|
|
||||||
getSampleRateCombo().removeAllItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
mSampleRateCombo = new JComboBox<>();
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSPduo tuner 2", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF DAB notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfDabNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfDabNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfDabNotchCheckBox = new JCheckBox("DAB Broadcast Band Filter (157-235 MHz)");
|
|
||||||
mRfDabNotchCheckBox.setEnabled(false);
|
|
||||||
mRfDabNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 2 RF DAB notch enabled to " + mRfDabNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfDabNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfNotchCheckBox = new JCheckBox("FM Broadcast Band Filter (78-114 MHz)");
|
|
||||||
mRfNotchCheckBox.setEnabled(false);
|
|
||||||
mRfNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfNotch(mRfNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 2 RF notch enabled to " + mRfNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for Bias-T
|
|
||||||
*/
|
|
||||||
private JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
|
||||||
if(mBiasTCheckBox == null)
|
|
||||||
{
|
|
||||||
mBiasTCheckBox = new JCheckBox("Bias-T Power");
|
|
||||||
mBiasTCheckBox.setEnabled(false);
|
|
||||||
mBiasTCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 2 AM notch enabled to " + mBiasTCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBiasTCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for External Reference Output
|
|
||||||
*/
|
|
||||||
private JCheckBox getExternalReferenceOutputCheckBox()
|
|
||||||
{
|
|
||||||
if(mExternalReferenceOutputCheckBox == null)
|
|
||||||
{
|
|
||||||
mExternalReferenceOutputCheckBox = new JCheckBox("External Reference Output");
|
|
||||||
mExternalReferenceOutputCheckBox.setEnabled(false);
|
|
||||||
mExternalReferenceOutputCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setExternalReferenceOutput(mExternalReferenceOutputCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPduo tuner 2 external reference output notch enabled to " +
|
|
||||||
mExternalReferenceOutputCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mExternalReferenceOutputCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Button to launch the User Preferences editor to show the RSPduo tuner preference selection.
|
|
||||||
* @return constructed button.
|
|
||||||
*/
|
|
||||||
private JButton getTunerPreferencesButton()
|
|
||||||
{
|
|
||||||
if(mTunerPreferencesButton == null)
|
|
||||||
{
|
|
||||||
mTunerPreferencesButton = new JButton("RSPduo Preferences");
|
|
||||||
mTunerPreferencesButton.addActionListener(e -> MyEventBus.getGlobalEventBus()
|
|
||||||
.post(new ViewUserPreferenceEditorRequest(PreferenceEditorType.SOURCE_TUNERS)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return mTunerPreferencesButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2024 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,210 +16,60 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.sdrplay.rspDx;
|
package io.github.dsheirer.source.tuner.sdrplay.rspDx;
|
||||||
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
import io.github.dsheirer.source.tuner.sdrplay.DiscoveredRspTuner;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspSampleRate;
|
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
import io.github.dsheirer.source.tuner.sdrplay.RspTunerEditor;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspException;
|
import io.github.dsheirer.source.tuner.ui.TunerSection;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.RspAgcMode;
|
import java.util.List;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.scene.control.CheckBox;
|
||||||
import org.slf4j.Logger;
|
import javafx.scene.control.ComboBox;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JComboBox;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
import javax.swing.SpinnerNumberModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSPdx Tuner Editor
|
* RSPdx tuner editor
|
||||||
*/
|
*/
|
||||||
public class RspDxTunerEditor extends RspTunerEditor<RspDxTunerConfiguration>
|
public class RspDxTunerEditor extends RspTunerEditor<RspDxTunerConfiguration>
|
||||||
{
|
{
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(RspDxTunerEditor.class);
|
private final ComboBox<RspDxAntennaSelection> mAntennaCombo;
|
||||||
|
private final CheckBox mBiasTCheckBox;
|
||||||
private JComboBox<RspSampleRate> mSampleRateCombo;
|
private final CheckBox mRfNotchCheckBox;
|
||||||
private JCheckBox mBiasTCheckBox;
|
private final CheckBox mRfDabNotchCheckBox;
|
||||||
private JCheckBox mRfDabNotchCheckBox;
|
private final CheckBox mHdrModeCheckBox;
|
||||||
private JCheckBox mRfNotchCheckBox;
|
private final ComboBox<HdrModeBandwidth> mHdrModeBandwidthCombo;
|
||||||
private JComboBox<RspDxAntennaSelection> mAntennaCombo;
|
|
||||||
private JCheckBox mHdrModeCheckBox;
|
|
||||||
private JComboBox<HdrModeBandwidth> mHdrModeBandwidthCombo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param userPreferences for settings
|
* @param userPreferences for preference settings
|
||||||
* @param tunerManager for state updates
|
* @param tunerManager for saving tuner configurations
|
||||||
* @param discoveredTuner to edit or control.
|
* @param discoveredTuner to edit
|
||||||
*/
|
*/
|
||||||
public RspDxTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
public RspDxTunerEditor(UserPreferences userPreferences, TunerManager tunerManager, DiscoveredRspTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
super(userPreferences, tunerManager, discoveredTuner);
|
super(userPreferences, tunerManager, discoveredTuner);
|
||||||
init();
|
TunerSection options = addSection("Options");
|
||||||
tunerStatusUpdated();
|
mAntennaCombo = addChoice(options, "Antenna", List.of(RspDxAntennaSelection.values()),
|
||||||
|
() -> control().getAntenna(), selection -> control().setAntenna(selection));
|
||||||
|
mBiasTCheckBox = addOption(options, "ANT B Bias-T power", "Provide DC power on the ANT B connector",
|
||||||
|
() -> control().isBiasT(), enabled -> control().setBiasT(enabled));
|
||||||
|
mRfNotchCheckBox = addOption(options, "FM broadcast band filter (77-115 MHz)", null,
|
||||||
|
() -> control().isRfNotch(), enabled -> control().setRfNotch(enabled));
|
||||||
|
mRfDabNotchCheckBox = addOption(options, "DAB broadcast band filter (155-235 MHz)", null,
|
||||||
|
() -> control().isRfDabNotch(), enabled -> control().setRfDabNotch(enabled));
|
||||||
|
|
||||||
|
TunerSection hdr = addSection("High Dynamic Range");
|
||||||
|
mHdrModeCheckBox = addOption(hdr, "HDR mode (1 kHz - 2 MHz)", "High dynamic range mode for " +
|
||||||
|
"frequencies below 2 MHz", () -> control().isHighDynamicRange(),
|
||||||
|
enabled -> control().setHighDynamicRange(enabled));
|
||||||
|
mHdrModeBandwidthCombo = addChoice(hdr, "Bandwidth", HdrModeBandwidth.VALID,
|
||||||
|
() -> control().getHdrModeBandwidth(), bandwidth -> control().setHdrModeBandwidth(bandwidth));
|
||||||
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private IControlRspDx control()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("fill,wrap 3", "[right][grow,fill][fill]",
|
return (IControlRspDx)getControlRsp();
|
||||||
"[][][][][][][][][][][][][][][][][][grow]"));
|
|
||||||
|
|
||||||
add(new JLabel("Tuner:"));
|
|
||||||
add(getTunerIdLabel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Status:"));
|
|
||||||
add(getTunerStatusLabel(), "wrap");
|
|
||||||
|
|
||||||
add(getButtonPanel(), "span,align left");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel("Frequency (MHz):"));
|
|
||||||
add(getFrequencyPanel(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Sample Rate:"));
|
|
||||||
add(getSampleRateCombo(), "wrap");
|
|
||||||
|
|
||||||
add(new JLabel("Gain:"));
|
|
||||||
add(getGainPanel(), "wrap");
|
|
||||||
add(new JLabel("LNA:"));
|
|
||||||
add(getLNASlider(), "wrap");
|
|
||||||
add(new JLabel("IF:"));
|
|
||||||
add(getIfGainSlider(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
|
|
||||||
add(new JLabel());
|
|
||||||
add(getAntennaCombo(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getBiasTCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfDabNotchCheckBox(), "wrap");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getRfNotchCheckBox(), "wrap");
|
|
||||||
|
|
||||||
add(new JSeparator(), "span,growx,push");
|
|
||||||
add(new JLabel());
|
|
||||||
add(getHdrModeCheckBox(), "wrap");
|
|
||||||
add(new JLabel("HDR Mode Bandwidth"));
|
|
||||||
add(getHdrModeBandwidthCombo(), "wrap");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Access tuner controller
|
|
||||||
*/
|
|
||||||
private RspDxTunerController getTunerController()
|
|
||||||
{
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
return (RspDxTunerController) getTuner().getTunerController();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTunerLockState(boolean locked)
|
|
||||||
{
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
getSampleRateCombo().setEnabled(!locked);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void tunerStatusUpdated()
|
|
||||||
{
|
|
||||||
setLoading(true);
|
|
||||||
|
|
||||||
getTunerIdLabel().setText(getDiscoveredTuner().getId());
|
|
||||||
|
|
||||||
String status = getDiscoveredTuner().getTunerStatus().toString();
|
|
||||||
if(getDiscoveredTuner().hasErrorMessage())
|
|
||||||
{
|
|
||||||
status += " - " + getDiscoveredTuner().getErrorMessage();
|
|
||||||
}
|
|
||||||
getTunerStatusLabel().setText(status);
|
|
||||||
getButtonPanel().updateControls();
|
|
||||||
getFrequencyPanel().updateControls();
|
|
||||||
|
|
||||||
getSampleRateCombo().setEnabled(hasTuner() && !getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
getSampleRateCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getSampleRateEnumeration() : null);
|
|
||||||
updateSampleRateToolTip();
|
|
||||||
|
|
||||||
getAgcButton().setEnabled(hasTuner());
|
|
||||||
if(hasTuner())
|
|
||||||
{
|
|
||||||
RspAgcMode current = getTunerController().getControlRsp().getAgcMode();
|
|
||||||
getAgcButton().setSelected(current == null || current.equals(RspAgcMode.ENABLE));
|
|
||||||
getAgcButton().setText((current == null || current.equals(RspAgcMode.ENABLE)) ? AUTOMATIC : MANUAL);
|
|
||||||
getLNASlider().setLNA(getTunerController().getControlRsp().getLNA());
|
|
||||||
getIfGainSlider().setGR(getTunerController().getControlRsp().getBasebandGainReduction());
|
|
||||||
|
|
||||||
//Register to receive gain overload notifications
|
|
||||||
getTunerController().getControlRsp().setGainOverloadListener(this);
|
|
||||||
updateGainLabel();
|
|
||||||
}
|
|
||||||
|
|
||||||
getLNASlider().setEnabled(hasTuner());
|
|
||||||
getIfGainSlider().setEnabled(hasTuner() && getTunerController().getControlRsp().getAgcMode() != RspAgcMode.ENABLE);
|
|
||||||
getGainValueLabel().setEnabled(hasTuner());
|
|
||||||
|
|
||||||
getBiasTCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getBiasTCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isBiasT());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Bias-T enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getHdrModeCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getHdrModeCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isHighDynamicRange());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting HDR mode enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getRfDabNotchCheckBox().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getRfDabNotchCheckBox().setSelected(hasTuner() && getTunerController().getControlRsp().isRfDabNotch());
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting RF DAB Notch enabled state in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
getAntennaCombo().setEnabled(hasTuner());
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getAntennaCombo().setSelectedItem(hasTuner() ? getTunerController().getControlRsp().getAntenna() : null);
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting antenna selection in editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -227,247 +77,24 @@ public class RspDxTunerEditor extends RspTunerEditor<RspDxTunerConfiguration>
|
|||||||
{
|
{
|
||||||
if(hasConfiguration() && !isLoading())
|
if(hasConfiguration() && !isLoading())
|
||||||
{
|
{
|
||||||
getConfiguration().setFrequency(getFrequencyControl().getFrequency());
|
RspDxTunerConfiguration config = getConfiguration();
|
||||||
getConfiguration().setMinimumFrequency(getMinimumFrequencyTextField().getFrequency());
|
saveRspSettings(config);
|
||||||
getConfiguration().setMaximumFrequency(getMaximumFrequencyTextField().getFrequency());
|
config.setBiasT(mBiasTCheckBox.isSelected());
|
||||||
double value = ((SpinnerNumberModel) getFrequencyCorrectionSpinner().getModel()).getNumber().doubleValue();
|
config.setHdrMode(mHdrModeCheckBox.isSelected());
|
||||||
getConfiguration().setFrequencyCorrection(value);
|
config.setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
||||||
getConfiguration().setAutoPPMCorrectionEnabled(getAutoPPMCheckBox().isSelected());
|
config.setRfNotch(mRfNotchCheckBox.isSelected());
|
||||||
getConfiguration().setSampleRate((RspSampleRate)getSampleRateCombo().getSelectedItem());
|
|
||||||
getConfiguration().setBiasT(getBiasTCheckBox().isSelected());
|
if(mAntennaCombo.getValue() != null)
|
||||||
getConfiguration().setHdrMode(getHdrModeCheckBox().isSelected());
|
{
|
||||||
getConfiguration().setRfDabNotch(getRfNotchCheckBox().isSelected());
|
config.setAntenna(mAntennaCombo.getValue());
|
||||||
getConfiguration().setRfNotch(getRfNotchCheckBox().isSelected());
|
}
|
||||||
getConfiguration().setAntenna((RspDxAntennaSelection) getAntennaCombo().getSelectedItem());
|
|
||||||
getConfiguration().setLNA(getLNASlider().getLNA());
|
if(mHdrModeBandwidthCombo.getValue() != null)
|
||||||
getConfiguration().setBasebandGainReduction(getIfGainSlider().getGR());
|
{
|
||||||
getConfiguration().setAgcMode(getAgcButton().isSelected() ? RspAgcMode.ENABLE : RspAgcMode.DISABLE);
|
config.setHdrModeBandwidth(mHdrModeBandwidthCombo.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
saveConfiguration();
|
saveConfiguration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sample rate selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspSampleRate> getSampleRateCombo()
|
|
||||||
{
|
|
||||||
if(mSampleRateCombo == null)
|
|
||||||
{
|
|
||||||
RspSampleRate[] rspSampleRates = RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.toArray(new RspSampleRate[RspSampleRate.SINGLE_TUNER_SAMPLE_RATES.size()]);
|
|
||||||
mSampleRateCombo = new JComboBox<>(rspSampleRates);
|
|
||||||
mSampleRateCombo.setEnabled(false);
|
|
||||||
mSampleRateCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspSampleRate selected = (RspSampleRate)mSampleRateCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().setSampleRate(selected);
|
|
||||||
//Adjust the min/max values for the sample rate.
|
|
||||||
adjustForSampleRate((int)selected.getSampleRate());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting sample rate for RSP2 tuner", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mSampleRateCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for Bias-T
|
|
||||||
*/
|
|
||||||
private JCheckBox getBiasTCheckBox()
|
|
||||||
{
|
|
||||||
if(mBiasTCheckBox == null)
|
|
||||||
{
|
|
||||||
mBiasTCheckBox = new JCheckBox("ANT B Bias-T Power");
|
|
||||||
mBiasTCheckBox.setEnabled(false);
|
|
||||||
mBiasTCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setBiasT(mBiasTCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP2 Bias-T enabled to " + mBiasTCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBiasTCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for HDR mode
|
|
||||||
*/
|
|
||||||
private JCheckBox getHdrModeCheckBox()
|
|
||||||
{
|
|
||||||
if(mHdrModeCheckBox == null)
|
|
||||||
{
|
|
||||||
mHdrModeCheckBox = new JCheckBox("HDR Mode (1 kHz - 2 MHz)");
|
|
||||||
mHdrModeCheckBox.setEnabled(false);
|
|
||||||
mHdrModeCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setHighDynamicRange(mHdrModeCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPd HDR mode enabled to " + mHdrModeCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mHdrModeCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfNotchCheckBox = new JCheckBox("FM Broadcast Band Filter (77-115 MHz)");
|
|
||||||
mRfNotchCheckBox.setEnabled(false);
|
|
||||||
mRfNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfNotch(mRfNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSP2 RF notch enabled to " + mRfNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checkbox control for RF DAB notch
|
|
||||||
*/
|
|
||||||
private JCheckBox getRfDabNotchCheckBox()
|
|
||||||
{
|
|
||||||
if(mRfDabNotchCheckBox == null)
|
|
||||||
{
|
|
||||||
mRfDabNotchCheckBox = new JCheckBox("DAB Broadcast Band Filter (155-235 MHz)");
|
|
||||||
mRfDabNotchCheckBox.setEnabled(false);
|
|
||||||
mRfDabNotchCheckBox.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setRfDabNotch(mRfDabNotchCheckBox.isSelected());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Unable to set RSPdx RF DAB notch enabled to " + mRfDabNotchCheckBox.isSelected(), se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRfDabNotchCheckBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Antenna selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<RspDxAntennaSelection> getAntennaCombo()
|
|
||||||
{
|
|
||||||
if(mAntennaCombo == null)
|
|
||||||
{
|
|
||||||
mAntennaCombo = new JComboBox<>(RspDxAntennaSelection.values());
|
|
||||||
mAntennaCombo.setEnabled(false);
|
|
||||||
mAntennaCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
RspDxAntennaSelection selected = (RspDxAntennaSelection) mAntennaCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setAntenna(selected);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting Antenna selection for RSPdx", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAntennaCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HDR mode bandwidth selection combobox control
|
|
||||||
*/
|
|
||||||
private JComboBox<HdrModeBandwidth> getHdrModeBandwidthCombo()
|
|
||||||
{
|
|
||||||
if(mHdrModeBandwidthCombo == null)
|
|
||||||
{
|
|
||||||
mHdrModeBandwidthCombo = new JComboBox<>(HdrModeBandwidth.VALID.toArray(new HdrModeBandwidth[0]));
|
|
||||||
mHdrModeBandwidthCombo.setEnabled(false);
|
|
||||||
mHdrModeBandwidthCombo.addActionListener(e -> {
|
|
||||||
if(hasTuner() && !isLoading())
|
|
||||||
{
|
|
||||||
HdrModeBandwidth selected = (HdrModeBandwidth) mHdrModeBandwidthCombo.getSelectedItem();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTunerController().getControlRsp().setHdrModeBandwidth(selected);
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
catch(RspException se)
|
|
||||||
{
|
|
||||||
mLog.error("Error setting HDR mode bandwidth for RSPdx", se);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mHdrModeBandwidthCombo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the sample rate tooltip according to the tuner controller's lock state.
|
|
||||||
*/
|
|
||||||
private void updateSampleRateToolTip()
|
|
||||||
{
|
|
||||||
if(hasTuner() && getTuner().getTunerController().isLockedSampleRate())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Sample Rate is locked. Disable decoding channels to unlock.");
|
|
||||||
}
|
|
||||||
else if(hasTuner())
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("Select a sample rate for the tuner");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getSampleRateCombo().setToolTipText("No tuner available");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,35 +16,33 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.ui;
|
package io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
import io.github.dsheirer.gui.editor.Editor;
|
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.source.tuner.TunerFactory;
|
import io.github.dsheirer.source.tuner.TunerFactory;
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
import io.github.dsheirer.source.tuner.manager.IDiscoveredTunerStatusListener;
|
import io.github.dsheirer.source.tuner.manager.IDiscoveredTunerStatusListener;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.application.Platform;
|
||||||
|
import javafx.scene.control.ScrollPane;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editor for Discovered Tuners that displays custom tuner editor for the selected discovered tuner
|
* Hosts the tuner editor for the selected discovered tuner, and replaces the editor when the tuner's status changes,
|
||||||
|
* since the tuner (and therefore the editor's controls) can change with the status.
|
||||||
*/
|
*/
|
||||||
public class DiscoveredTunerEditor extends Editor<DiscoveredTuner> implements IDiscoveredTunerStatusListener
|
public class DiscoveredTunerEditor extends StackPane implements IDiscoveredTunerStatusListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(DiscoveredTunerEditor.class);
|
private static final Logger mLog = LoggerFactory.getLogger(DiscoveredTunerEditor.class);
|
||||||
private UserPreferences mUserPreferences;
|
private final UserPreferences mUserPreferences;
|
||||||
private TunerManager mTunerManager;
|
private final TunerManager mTunerManager;
|
||||||
private JPanel mEmptyEditor = new EmptyTunerEditor();
|
private final EmptyTunerEditor mEmptyEditor = new EmptyTunerEditor();
|
||||||
private JPanel mEditor = mEmptyEditor;
|
private final ScrollPane mScrollPane = new ScrollPane();
|
||||||
private JScrollPane mEditorScroller;
|
private DiscoveredTuner mDiscoveredTuner;
|
||||||
|
private TunerEditor<?,?> mEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
@@ -55,83 +53,81 @@ public class DiscoveredTunerEditor extends Editor<DiscoveredTuner> implements ID
|
|||||||
{
|
{
|
||||||
mUserPreferences = userPreferences;
|
mUserPreferences = userPreferences;
|
||||||
mTunerManager = tunerManager;
|
mTunerManager = tunerManager;
|
||||||
init();
|
getStyleClass().add("discovered-tuner-editor");
|
||||||
|
mScrollPane.setFitToWidth(true);
|
||||||
|
mScrollPane.getStyleClass().add("tuner-editor-scroll");
|
||||||
|
mScrollPane.setContent(mEmptyEditor);
|
||||||
|
getChildren().add(mScrollPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the lock state of the tuner editor so that lockable controls are updated
|
* Discovered tuner shown in the editor, or null.
|
||||||
* @param locked true if the tuner is locked and the controls should be locked.
|
|
||||||
*/
|
*/
|
||||||
public void setTunerLockState(boolean locked)
|
public DiscoveredTuner getItem()
|
||||||
{
|
{
|
||||||
if(mEditor instanceof TunerEditor tunerEditor)
|
return mDiscoveredTuner;
|
||||||
{
|
|
||||||
tunerEditor.setTunerLockState(locked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init()
|
/**
|
||||||
|
* Indicates if the editor shows a tuner.
|
||||||
|
*/
|
||||||
|
public boolean hasItem()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
return mDiscoveredTuner != null;
|
||||||
mEditorScroller = new JScrollPane(mEditor);
|
|
||||||
add(mEditorScroller);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void save()
|
* Current tuner editor, or null.
|
||||||
|
*/
|
||||||
|
public TunerEditor<?,?> getEditor()
|
||||||
{
|
{
|
||||||
//Unused
|
return mEditor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void setItem(DiscoveredTuner tuner)
|
* Shows the editor for the discovered tuner, or the empty editor when the tuner is null.
|
||||||
|
*/
|
||||||
|
public void setItem(DiscoveredTuner discoveredTuner)
|
||||||
{
|
{
|
||||||
if(hasItem())
|
if(mDiscoveredTuner != null)
|
||||||
{
|
{
|
||||||
getItem().removeTunerStatusListener(this);
|
mDiscoveredTuner.removeTunerStatusListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Cleanup previously selected tuner
|
if(mEditor != null)
|
||||||
if(hasItem() && mEditor instanceof TunerEditor tunerEditor)
|
|
||||||
{
|
{
|
||||||
tunerEditor.dispose();
|
mEditor.dispose();
|
||||||
|
mEditor = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.setItem(tuner);
|
mDiscoveredTuner = discoveredTuner;
|
||||||
|
|
||||||
mEditorScroller.remove(mEditor);
|
if(discoveredTuner != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
mEditor = TunerFactory.getEditor(mUserPreferences, discoveredTuner, mTunerManager);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
mLog.error("Error creating tuner editor for " + discoveredTuner.getId(), e);
|
||||||
|
}
|
||||||
|
|
||||||
if(hasItem())
|
discoveredTuner.addTunerStatusListener(this);
|
||||||
{
|
|
||||||
mEditor = TunerFactory.getEditor(mUserPreferences, getItem(), mTunerManager);
|
|
||||||
getItem().addTunerStatusListener(this);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mEditor = mEmptyEditor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(mEditorScroller);
|
mScrollPane.setContent(mEditor != null ? mEditor : mEmptyEditor);
|
||||||
mEditorScroller = new JScrollPane(mEditor);
|
|
||||||
add(mEditorScroller);
|
|
||||||
revalidate();
|
|
||||||
repaint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void tunerStatusUpdated(DiscoveredTuner discoveredTuner, TunerStatus previous, TunerStatus current)
|
public void tunerStatusUpdated(DiscoveredTuner discoveredTuner, TunerStatus previous, TunerStatus current)
|
||||||
{
|
{
|
||||||
//If this is the currently displayed tuner, set it again to re-render the editor
|
Platform.runLater(() -> {
|
||||||
if(hasItem() && getItem().equals(discoveredTuner))
|
//If this is the currently displayed tuner, set it again to re-create the editor
|
||||||
{
|
if(mDiscoveredTuner != null && mDiscoveredTuner.equals(discoveredTuner))
|
||||||
if(current == TunerStatus.REMOVED)
|
|
||||||
{
|
{
|
||||||
setItem(null);
|
setItem(current == TunerStatus.REMOVED ? null : discoveredTuner);
|
||||||
}
|
}
|
||||||
else
|
});
|
||||||
{
|
|
||||||
setItem(discoveredTuner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ import io.github.dsheirer.source.tuner.manager.IDiscoveredTunerStatusListener;
|
|||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.rspDuo.DiscoveredRspDuoTuner1;
|
import io.github.dsheirer.source.tuner.sdrplay.rspDuo.DiscoveredRspDuoTuner1;
|
||||||
import io.github.dsheirer.source.tuner.sdrplay.rspDuo.DiscoveredRspDuoTuner2;
|
import io.github.dsheirer.source.tuner.sdrplay.rspDuo.DiscoveredRspDuoTuner2;
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -39,29 +37,18 @@ import java.util.concurrent.locks.ReentrantLock;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for discovered tuners
|
* Model for discovered tuners
|
||||||
*/
|
*/
|
||||||
public class DiscoveredTunerModel extends AbstractTableModel implements Listener<TunerEvent>,
|
public class DiscoveredTunerModel implements Listener<TunerEvent>,
|
||||||
IDiscoveredTunerStatusListener
|
IDiscoveredTunerStatusListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(DiscoveredTunerModel.class);
|
private static final Logger mLog = LoggerFactory.getLogger(DiscoveredTunerModel.class);
|
||||||
|
|
||||||
//Model columns
|
|
||||||
public static final int COLUMN_TUNER_STATUS = 0;
|
|
||||||
public static final int COLUMN_TUNER_CLASS = 1;
|
|
||||||
public static final int COLUMN_TUNER_TYPE = 2;
|
|
||||||
public static final int COLUMN_FREQUENCY = 3;
|
|
||||||
public static final int COLUMN_CHANNEL_COUNT = 4;
|
|
||||||
private static final String MHZ = " MHz";
|
|
||||||
private static final String[] COLUMN_HEADERS = {"Status","Class", "Type", "Frequency", "Channels"};
|
|
||||||
|
|
||||||
private List<DiscoveredTuner> mDiscoveredTuners = new CopyOnWriteArrayList<>();
|
private List<DiscoveredTuner> mDiscoveredTuners = new CopyOnWriteArrayList<>();
|
||||||
private List<Listener<TunerEvent>> mTunerEventListeners = new ArrayList<>();
|
private List<Listener<TunerEvent>> mTunerEventListeners = new ArrayList<>();
|
||||||
private DecimalFormat mFrequencyFormat = new DecimalFormat("0.00000");
|
private List<ModelListener> mModelListeners = new CopyOnWriteArrayList<>();
|
||||||
private Lock mLock = new ReentrantLock();
|
private Lock mLock = new ReentrantLock();
|
||||||
private TunerConfigurationManager mTunerConfigurationManager;
|
private TunerConfigurationManager mTunerConfigurationManager;
|
||||||
|
|
||||||
@@ -177,8 +164,7 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
|||||||
if(!mDiscoveredTuners.contains(discoveredTuner))
|
if(!mDiscoveredTuners.contains(discoveredTuner))
|
||||||
{
|
{
|
||||||
mDiscoveredTuners.add(discoveredTuner);
|
mDiscoveredTuners.add(discoveredTuner);
|
||||||
int index = mDiscoveredTuners.indexOf(discoveredTuner);
|
notifyAdded(discoveredTuner);
|
||||||
EventQueue.invokeLater(() -> fireTableRowsInserted(index, index));
|
|
||||||
if(discoveredTuner.hasTuner())
|
if(discoveredTuner.hasTuner())
|
||||||
{
|
{
|
||||||
discoveredTuner.getTuner().addTunerEventListener(this);
|
discoveredTuner.getTuner().addTunerEventListener(this);
|
||||||
@@ -204,7 +190,11 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
mDiscoveredTuners.clear();
|
mDiscoveredTuners.clear();
|
||||||
fireTableDataChanged();
|
|
||||||
|
for(DiscoveredTuner discoveredTuner: discoveredTuners)
|
||||||
|
{
|
||||||
|
notifyRemoved(discoveredTuner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -230,34 +220,8 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
|||||||
{
|
{
|
||||||
if(mDiscoveredTuners.contains(discoveredTuner))
|
if(mDiscoveredTuners.contains(discoveredTuner))
|
||||||
{
|
{
|
||||||
int index = mDiscoveredTuners.indexOf(discoveredTuner);
|
|
||||||
mDiscoveredTuners.remove(discoveredTuner);
|
mDiscoveredTuners.remove(discoveredTuner);
|
||||||
|
notifyRemoved(discoveredTuner);
|
||||||
if(EventQueue.isDispatchThread())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fireTableRowsDeleted(index, index);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.info("Exception firing table rows deleted for index [" + index + "] on calling event dispatch thread", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
EventQueue.invokeLater(() ->
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fireTableRowsDeleted(index, index);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
mLog.info("Exception firing table rows deleted for index [" + index + "]", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
discoveredTuner.stop();
|
discoveredTuner.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -366,14 +330,12 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
|||||||
if(current == TunerStatus.ENABLED && discoveredTuner.hasTuner())
|
if(current == TunerStatus.ENABLED && discoveredTuner.hasTuner())
|
||||||
{
|
{
|
||||||
discoveredTuner.getTuner().addTunerEventListener(this);
|
discoveredTuner.getTuner().addTunerEventListener(this);
|
||||||
int row = mDiscoveredTuners.indexOf(discoveredTuner);
|
notifyUpdated(discoveredTuner);
|
||||||
EventQueue.invokeLater(() -> fireTableRowsUpdated(row, row));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(current == TunerStatus.DISABLED)
|
else if(current == TunerStatus.DISABLED || current == TunerStatus.ERROR)
|
||||||
{
|
{
|
||||||
int row = mDiscoveredTuners.indexOf(discoveredTuner);
|
notifyUpdated(discoveredTuner);
|
||||||
EventQueue.invokeLater(() -> fireTableRowsUpdated(row, row));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,20 +391,17 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
DiscoveredTuner matchingTuner = getDiscoveredTuner(event.getTuner());
|
DiscoveredTuner matchingTuner = getDiscoveredTuner(event.getTuner());
|
||||||
int index = mDiscoveredTuners.indexOf(matchingTuner);
|
|
||||||
|
|
||||||
if(index >= 0)
|
if(matchingTuner != null)
|
||||||
{
|
{
|
||||||
switch(event.getEvent())
|
switch(event.getEvent())
|
||||||
{
|
{
|
||||||
case UPDATE_CHANNEL_COUNT:
|
case UPDATE_CHANNEL_COUNT:
|
||||||
EventQueue.invokeLater(() -> fireTableCellUpdated(index, COLUMN_CHANNEL_COUNT));
|
|
||||||
break;
|
|
||||||
case UPDATE_FREQUENCY:
|
case UPDATE_FREQUENCY:
|
||||||
EventQueue.invokeLater(() -> fireTableCellUpdated(index, COLUMN_FREQUENCY));
|
case UPDATE_LOCK_STATE:
|
||||||
break;
|
case UPDATE_SAMPLE_RATE:
|
||||||
case NOTIFICATION_ERROR_STATE:
|
case NOTIFICATION_ERROR_STATE:
|
||||||
EventQueue.invokeLater(() -> fireTableRowsUpdated(index, index));
|
notifyUpdated(matchingTuner);
|
||||||
break;
|
break;
|
||||||
case UPDATE_FREQUENCY_ERROR:
|
case UPDATE_FREQUENCY_ERROR:
|
||||||
if(mTunerConfigurationManager != null)
|
if(mTunerConfigurationManager != null)
|
||||||
@@ -468,77 +427,77 @@ public class DiscoveredTunerModel extends AbstractTableModel implements Listener
|
|||||||
broadcast(event);
|
broadcast(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRowCount()
|
/**
|
||||||
|
* Snapshot of the discovered tuners.
|
||||||
|
*/
|
||||||
|
public List<DiscoveredTuner> getDiscoveredTuners()
|
||||||
{
|
{
|
||||||
return mDiscoveredTuners.size();
|
return new ArrayList<>(mDiscoveredTuners);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getColumnCount()
|
|
||||||
{
|
|
||||||
return COLUMN_HEADERS.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object getValueAt(int rowIndex, int columnIndex)
|
|
||||||
{
|
|
||||||
if(rowIndex < mDiscoveredTuners.size())
|
|
||||||
{
|
|
||||||
DiscoveredTuner discoveredTuner = mDiscoveredTuners.get(rowIndex);
|
|
||||||
|
|
||||||
switch(columnIndex)
|
|
||||||
{
|
|
||||||
case COLUMN_TUNER_STATUS:
|
|
||||||
return discoveredTuner.getTunerStatus();
|
|
||||||
case COLUMN_TUNER_CLASS:
|
|
||||||
return discoveredTuner.getTunerClass().toString();
|
|
||||||
case COLUMN_TUNER_TYPE:
|
|
||||||
if(discoveredTuner.hasTuner())
|
|
||||||
{
|
|
||||||
return discoveredTuner.getTuner().getTunerType().getLabel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
case COLUMN_FREQUENCY:
|
|
||||||
if(discoveredTuner.hasTuner())
|
|
||||||
{
|
|
||||||
long frequency = discoveredTuner.getTuner().getTunerController().getFrequency();
|
|
||||||
return mFrequencyFormat.format(frequency / 1E6D) + MHZ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
case COLUMN_CHANNEL_COUNT:
|
|
||||||
if(discoveredTuner.hasTuner())
|
|
||||||
{
|
|
||||||
int channelCount = discoveredTuner.getTuner().getChannelSourceManager().getTunerChannelCount();
|
|
||||||
return channelCount + " (" + (discoveredTuner.getTuner().getTunerController().isLockedSampleRate() ? "LOCKED)" : "UNLOCKED)");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getColumnName(int columnIndex)
|
|
||||||
{
|
|
||||||
return COLUMN_HEADERS[columnIndex];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a diagnostic report for all discovered tuners.
|
* Adds a listener for tuners added to, removed from or updated in the model. Listeners are invoked on the
|
||||||
|
* calling thread, which can be any thread.
|
||||||
*/
|
*/
|
||||||
|
public void addModelListener(ModelListener listener)
|
||||||
|
{
|
||||||
|
mModelListeners.add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the model listener
|
||||||
|
*/
|
||||||
|
public void removeModelListener(ModelListener listener)
|
||||||
|
{
|
||||||
|
mModelListeners.remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyAdded(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
for(ModelListener listener: mModelListeners)
|
||||||
|
{
|
||||||
|
listener.tunerAdded(discoveredTuner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyRemoved(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
for(ModelListener listener: mModelListeners)
|
||||||
|
{
|
||||||
|
listener.tunerRemoved(discoveredTuner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyUpdated(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
for(ModelListener listener: mModelListeners)
|
||||||
|
{
|
||||||
|
listener.tunerUpdated(discoveredTuner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Listener for changes to the discovered tuners in the model.
|
||||||
|
*/
|
||||||
|
public interface ModelListener
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A tuner was added to the model
|
||||||
|
*/
|
||||||
|
void tunerAdded(DiscoveredTuner discoveredTuner);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tuner was removed from the model
|
||||||
|
*/
|
||||||
|
void tunerRemoved(DiscoveredTuner discoveredTuner);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tuner's status, frequency, sample rate, channel count or lock state changed
|
||||||
|
*/
|
||||||
|
void tunerUpdated(DiscoveredTuner discoveredTuner);
|
||||||
|
}
|
||||||
|
|
||||||
public String getDiagnosticReport()
|
public String getDiagnosticReport()
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2022 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,27 +16,25 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.ui;
|
package io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javax.swing.JLabel;
|
import javafx.scene.layout.VBox;
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty tuner editor panel
|
* Placeholder shown when no tuner is selected.
|
||||||
*/
|
*/
|
||||||
public class EmptyTunerEditor extends JPanel
|
public class EmptyTunerEditor extends VBox
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an instance
|
|
||||||
*/
|
|
||||||
public EmptyTunerEditor()
|
public EmptyTunerEditor()
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[center,grow]", "[center,grow]"));
|
getStyleClass().add("empty-tuner-editor");
|
||||||
add(new JLabel("No tuner selected"), "wrap");
|
setAlignment(Pos.CENTER);
|
||||||
|
Label title = new Label("No tuner selected");
|
||||||
|
title.getStyleClass().add("empty-tuner-title");
|
||||||
|
Label hint = new Label("Select a tuner in the list to view and change its settings.");
|
||||||
|
hint.setWrapText(true);
|
||||||
|
getChildren().addAll(title, hint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
172
src/main/java/io/github/dsheirer/source/tuner/ui/GainSlider.java
Normal file
172
src/main/java/io/github/dsheirer/source/tuner/ui/GainSlider.java
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
|
import java.util.function.IntConsumer;
|
||||||
|
import java.util.function.IntFunction;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.Slider;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integer slider with a value label, for gain settings. The change handler is invoked each time the user moves the
|
||||||
|
* slider to a different whole value, but not when the value is set with {@link #setValue(int)}.
|
||||||
|
*/
|
||||||
|
public class GainSlider extends HBox
|
||||||
|
{
|
||||||
|
private final Slider mSlider;
|
||||||
|
private final Label mValueLabel = new Label();
|
||||||
|
private IntConsumer mChangeHandler;
|
||||||
|
private IntFunction<String> mFormatter = String::valueOf;
|
||||||
|
private boolean mUpdating = false;
|
||||||
|
private boolean mApplyOnRelease = false;
|
||||||
|
private int mValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance
|
||||||
|
* @param minimum value
|
||||||
|
* @param maximum value
|
||||||
|
* @param value initial value
|
||||||
|
*/
|
||||||
|
public GainSlider(int minimum, int maximum, int value)
|
||||||
|
{
|
||||||
|
getStyleClass().add("gain-slider");
|
||||||
|
setAlignment(Pos.CENTER_LEFT);
|
||||||
|
mSlider = new Slider(minimum, maximum, value);
|
||||||
|
mSlider.setBlockIncrement(1);
|
||||||
|
mSlider.setMajorTickUnit(1);
|
||||||
|
mSlider.setMinorTickCount(0);
|
||||||
|
mSlider.setShowTickMarks(maximum - minimum <= 30);
|
||||||
|
mSlider.setSnapToTicks(true);
|
||||||
|
mSlider.setMaxWidth(Double.MAX_VALUE);
|
||||||
|
HBox.setHgrow(mSlider, Priority.ALWAYS);
|
||||||
|
mValueLabel.getStyleClass().add("gain-slider-value");
|
||||||
|
mValue = value;
|
||||||
|
updateLabel();
|
||||||
|
|
||||||
|
mSlider.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
int rounded = (int)Math.round(newValue.doubleValue());
|
||||||
|
|
||||||
|
if(rounded != mValue)
|
||||||
|
{
|
||||||
|
mValue = rounded;
|
||||||
|
updateLabel();
|
||||||
|
|
||||||
|
if(!mUpdating && mChangeHandler != null && !(mApplyOnRelease && mSlider.isValueChanging()))
|
||||||
|
{
|
||||||
|
mChangeHandler.accept(rounded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mSlider.valueChangingProperty().addListener((observable, wasChanging, changing) -> {
|
||||||
|
if(mApplyOnRelease && !changing && !mUpdating && mChangeHandler != null)
|
||||||
|
{
|
||||||
|
mChangeHandler.accept(mValue);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
getChildren().addAll(mSlider, mValueLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the handler for user changes.
|
||||||
|
*/
|
||||||
|
public void setOnChange(IntConsumer handler)
|
||||||
|
{
|
||||||
|
mChangeHandler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When true, a drag of the slider thumb invokes the change handler once, when the thumb is released, instead of
|
||||||
|
* at each whole value along the way.
|
||||||
|
*/
|
||||||
|
public void setApplyOnRelease(boolean applyOnRelease)
|
||||||
|
{
|
||||||
|
mApplyOnRelease = applyOnRelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the formatter for the value label, e.g. to append dB.
|
||||||
|
*/
|
||||||
|
public void setFormatter(IntFunction<String> formatter)
|
||||||
|
{
|
||||||
|
mFormatter = formatter;
|
||||||
|
updateLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value without invoking the change handler.
|
||||||
|
*/
|
||||||
|
public void setValue(int value)
|
||||||
|
{
|
||||||
|
mUpdating = true;
|
||||||
|
mValue = value;
|
||||||
|
mSlider.setValue(value);
|
||||||
|
updateLabel();
|
||||||
|
mUpdating = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current value.
|
||||||
|
*/
|
||||||
|
public int getValue()
|
||||||
|
{
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the slider range without invoking the change handler.
|
||||||
|
*/
|
||||||
|
public void setRange(int minimum, int maximum)
|
||||||
|
{
|
||||||
|
mUpdating = true;
|
||||||
|
mSlider.setMin(minimum);
|
||||||
|
mSlider.setMax(maximum);
|
||||||
|
mSlider.setShowTickMarks(maximum - minimum <= 30);
|
||||||
|
mValue = (int)Math.round(mSlider.getValue());
|
||||||
|
updateLabel();
|
||||||
|
mUpdating = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the tooltip on the slider.
|
||||||
|
*/
|
||||||
|
public void setTooltip(String text)
|
||||||
|
{
|
||||||
|
mSlider.setTooltip(new Tooltip(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapped slider.
|
||||||
|
*/
|
||||||
|
public Slider getSlider()
|
||||||
|
{
|
||||||
|
return mSlider;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateLabel()
|
||||||
|
{
|
||||||
|
mValueLabel.setText(mFormatter.apply(mValue));
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,200 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.scene.control.ButtonBar;
|
||||||
|
import javafx.scene.control.ButtonType;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.input.Clipboard;
|
||||||
|
import javafx.scene.input.ClipboardContent;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows tuner information that the tuner editors describe with a small subset of HTML: an optional h3 heading
|
||||||
|
* followed by lines separated by br, where a line is either "<b>Key: </b>value" or plain text.
|
||||||
|
*/
|
||||||
|
public class TunerInfoDialog
|
||||||
|
{
|
||||||
|
private TunerInfoDialog()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A parsed line of tuner information.
|
||||||
|
* @param key bold key text, or null for a plain line
|
||||||
|
* @param value text
|
||||||
|
*/
|
||||||
|
public record Line(String key, String value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parsed tuner information.
|
||||||
|
* @param heading text or null
|
||||||
|
* @param lines of information
|
||||||
|
*/
|
||||||
|
public record Info(String heading, List<Line> lines)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Plain text version for copying to the clipboard.
|
||||||
|
*/
|
||||||
|
public String toText()
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
if(heading != null)
|
||||||
|
{
|
||||||
|
sb.append(heading).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for(Line line: lines)
|
||||||
|
{
|
||||||
|
if(line.key() != null)
|
||||||
|
{
|
||||||
|
sb.append(line.key()).append(": ");
|
||||||
|
}
|
||||||
|
sb.append(line.value()).append("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the tuner information HTML.
|
||||||
|
*/
|
||||||
|
public static Info parse(String html)
|
||||||
|
{
|
||||||
|
String text = html == null ? "" : html.replaceAll("(?i)</?html>", "");
|
||||||
|
String heading = null;
|
||||||
|
|
||||||
|
java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("(?is)<h3>(.*?)</h3>").matcher(text);
|
||||||
|
|
||||||
|
if(matcher.find())
|
||||||
|
{
|
||||||
|
heading = strip(matcher.group(1));
|
||||||
|
text = text.substring(0, matcher.start()) + text.substring(matcher.end());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Line> lines = new ArrayList<>();
|
||||||
|
|
||||||
|
for(String part: text.split("(?i)<br\\s*/?>|\\n"))
|
||||||
|
{
|
||||||
|
java.util.regex.Matcher keyed = java.util.regex.Pattern.compile("(?is)^\\s*<b>(.*?)</b>(.*)$").matcher(part);
|
||||||
|
|
||||||
|
if(keyed.matches())
|
||||||
|
{
|
||||||
|
String key = strip(keyed.group(1)).trim();
|
||||||
|
|
||||||
|
if(key.endsWith(":"))
|
||||||
|
{
|
||||||
|
key = key.substring(0, key.length() - 1).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.add(new Line(key, strip(keyed.group(2)).trim()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
String plain = strip(part).trim();
|
||||||
|
|
||||||
|
if(!plain.isEmpty())
|
||||||
|
{
|
||||||
|
lines.add(new Line(null, plain));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Info(heading, lines);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String strip(String text)
|
||||||
|
{
|
||||||
|
return text.replaceAll("<[^>]+>", "").replace(" ", " ").replace("&", "&")
|
||||||
|
.replace("<", "<").replace(">", ">");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the content node for the information.
|
||||||
|
*/
|
||||||
|
public static Node createContent(Info info)
|
||||||
|
{
|
||||||
|
GridPane grid = new GridPane();
|
||||||
|
grid.getStyleClass().add("tuner-info-grid");
|
||||||
|
grid.setHgap(12);
|
||||||
|
grid.setVgap(4);
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
for(Line line: info.lines())
|
||||||
|
{
|
||||||
|
Label value = new Label(line.value());
|
||||||
|
value.setWrapText(true);
|
||||||
|
|
||||||
|
if(line.key() != null)
|
||||||
|
{
|
||||||
|
Label key = new Label(line.key());
|
||||||
|
key.setStyle("-fx-font-weight: bold;");
|
||||||
|
grid.add(key, 0, row);
|
||||||
|
grid.add(value, 1, row);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
grid.add(value, 0, row, 2, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
|
||||||
|
VBox box = new VBox(8, grid);
|
||||||
|
box.setMinWidth(320);
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shows the tuner information dialog.
|
||||||
|
* @param owner window or null
|
||||||
|
* @param html tuner information
|
||||||
|
*/
|
||||||
|
public static void show(Window owner, String html)
|
||||||
|
{
|
||||||
|
Info info = parse(html);
|
||||||
|
Alert alert = new Alert(Alert.AlertType.INFORMATION);
|
||||||
|
alert.initOwner(owner);
|
||||||
|
alert.setTitle("Tuner Info");
|
||||||
|
alert.setHeaderText(info.heading() != null ? info.heading() : "Tuner Info");
|
||||||
|
alert.getDialogPane().setContent(createContent(info));
|
||||||
|
|
||||||
|
ButtonType copy = new ButtonType("Copy", ButtonBar.ButtonData.LEFT);
|
||||||
|
alert.getButtonTypes().add(copy);
|
||||||
|
alert.getDialogPane().lookupButton(copy).addEventFilter(javafx.event.ActionEvent.ACTION, e -> {
|
||||||
|
ClipboardContent content = new ClipboardContent();
|
||||||
|
content.putString(info.toText());
|
||||||
|
Clipboard.getSystemClipboard().setContent(content);
|
||||||
|
e.consume();
|
||||||
|
});
|
||||||
|
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
|
import javafx.geometry.HPos;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.geometry.VPos;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.ColumnConstraints;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Titled card in a tuner editor that lays out labelled controls in rows: a label column, a control column that
|
||||||
|
* grows, and an optional trailing column (e.g. a value label or a button).
|
||||||
|
*/
|
||||||
|
public class TunerSection extends VBox
|
||||||
|
{
|
||||||
|
private final Label mTitle;
|
||||||
|
private final GridPane mGrid = new GridPane();
|
||||||
|
private int mRow = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance
|
||||||
|
* @param title for the section
|
||||||
|
*/
|
||||||
|
public TunerSection(String title)
|
||||||
|
{
|
||||||
|
getStyleClass().add("tuner-section");
|
||||||
|
mTitle = new Label(title);
|
||||||
|
mTitle.getStyleClass().add("tuner-section-title");
|
||||||
|
|
||||||
|
mGrid.getStyleClass().add("tuner-section-grid");
|
||||||
|
ColumnConstraints labels = new ColumnConstraints();
|
||||||
|
labels.setHalignment(HPos.LEFT);
|
||||||
|
labels.setMinWidth(Label.USE_PREF_SIZE);
|
||||||
|
ColumnConstraints controls = new ColumnConstraints();
|
||||||
|
controls.setHgrow(Priority.ALWAYS);
|
||||||
|
controls.setFillWidth(true);
|
||||||
|
ColumnConstraints trailing = new ColumnConstraints();
|
||||||
|
trailing.setMinWidth(Label.USE_PREF_SIZE);
|
||||||
|
mGrid.getColumnConstraints().addAll(labels, controls, trailing);
|
||||||
|
|
||||||
|
getChildren().addAll(mTitle, mGrid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title label of the section.
|
||||||
|
*/
|
||||||
|
public Label getTitleLabel()
|
||||||
|
{
|
||||||
|
return mTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a row with a text label and a control.
|
||||||
|
* @return the label that was created, so that it can be hidden along with the control
|
||||||
|
*/
|
||||||
|
public Label addRow(String label, Node control)
|
||||||
|
{
|
||||||
|
Label labelNode = createLabel(label);
|
||||||
|
addRow(labelNode, control, null);
|
||||||
|
return labelNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a row with a text label, a control and a trailing node.
|
||||||
|
* @return the label that was created
|
||||||
|
*/
|
||||||
|
public Label addRow(String label, Node control, Node trailing)
|
||||||
|
{
|
||||||
|
Label labelNode = createLabel(label);
|
||||||
|
addRow(labelNode, control, trailing);
|
||||||
|
return labelNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a row with a label node (may be null), a control and an optional trailing node.
|
||||||
|
*/
|
||||||
|
public void addRow(Node label, Node control, Node trailing)
|
||||||
|
{
|
||||||
|
if(label != null)
|
||||||
|
{
|
||||||
|
GridPane.setValignment(label, VPos.CENTER);
|
||||||
|
mGrid.add(label, 0, mRow);
|
||||||
|
bindManaged(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(control != null)
|
||||||
|
{
|
||||||
|
if(trailing == null)
|
||||||
|
{
|
||||||
|
mGrid.add(control, 1, mRow, 2, 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mGrid.add(control, 1, mRow);
|
||||||
|
}
|
||||||
|
|
||||||
|
bindManaged(control);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(trailing != null)
|
||||||
|
{
|
||||||
|
mGrid.add(trailing, 2, mRow);
|
||||||
|
bindManaged(trailing);
|
||||||
|
}
|
||||||
|
|
||||||
|
mRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a control (e.g. a check box) without a label, aligned with the other controls.
|
||||||
|
*/
|
||||||
|
public void addControl(Node control)
|
||||||
|
{
|
||||||
|
addRow((Node)null, control, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a node that spans the full width of the section.
|
||||||
|
*/
|
||||||
|
public void addFullRow(Node node)
|
||||||
|
{
|
||||||
|
mGrid.add(node, 0, mRow, 3, 1);
|
||||||
|
bindManaged(node);
|
||||||
|
mRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a row of nodes laid out left to right, under the control column.
|
||||||
|
*/
|
||||||
|
public HBox addFlowRow(Node... nodes)
|
||||||
|
{
|
||||||
|
HBox box = new HBox(nodes);
|
||||||
|
box.getStyleClass().add("tuner-flow-row");
|
||||||
|
box.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
addRow((Node)null, box, null);
|
||||||
|
return box;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a row label.
|
||||||
|
*/
|
||||||
|
public static Label createLabel(String text)
|
||||||
|
{
|
||||||
|
Label label = new Label(text);
|
||||||
|
label.getStyleClass().add("tuner-row-label");
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hides nodes from the layout when they are not visible.
|
||||||
|
*/
|
||||||
|
private static void bindManaged(Node node)
|
||||||
|
{
|
||||||
|
if(!node.managedProperty().isBound())
|
||||||
|
{
|
||||||
|
node.managedProperty().bind(node.visibleProperty());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
368
src/main/java/io/github/dsheirer/source/tuner/ui/TunerView.java
Normal file
368
src/main/java/io/github/dsheirer/source/tuner/ui/TunerView.java
Normal file
@@ -0,0 +1,368 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
|
import io.github.dsheirer.gui.control.FrequencyEntry;
|
||||||
|
import io.github.dsheirer.gui.table.ColumnConfigurationButton;
|
||||||
|
import io.github.dsheirer.gui.table.TableColumnMonitor;
|
||||||
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
|
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
||||||
|
import io.github.dsheirer.source.tuner.manager.DiscoveredNetworkTuner;
|
||||||
|
import io.github.dsheirer.source.tuner.manager.DiscoveredRecordingTuner;
|
||||||
|
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
||||||
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
|
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
||||||
|
import io.github.dsheirer.source.tuner.network.AddNetworkTunerDialog;
|
||||||
|
import io.github.dsheirer.source.tuner.recording.AddRecordingTunerDialog;
|
||||||
|
import io.github.dsheirer.util.ThreadPool;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.property.ReadOnlyObjectWrapper;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
|
import javafx.collections.ObservableList;
|
||||||
|
import javafx.css.PseudoClass;
|
||||||
|
import javafx.geometry.Orientation;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.ContextMenu;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.MenuButton;
|
||||||
|
import javafx.scene.control.MenuItem;
|
||||||
|
import javafx.scene.control.SelectionMode;
|
||||||
|
import javafx.scene.control.SplitPane;
|
||||||
|
import javafx.scene.control.TableCell;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableRow;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.scene.layout.Priority;
|
||||||
|
import javafx.scene.layout.Region;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tuners tab: the list of discovered tuners on the left and the editor for the selected tuner on the right.
|
||||||
|
*/
|
||||||
|
public class TunerView extends SplitPane implements DiscoveredTunerModel.ModelListener
|
||||||
|
{
|
||||||
|
private static final Logger mLog = LoggerFactory.getLogger(TunerView.class);
|
||||||
|
private static final String TABLE_KEY = "tuner.view";
|
||||||
|
private static final String SWING_TABLE_KEY = "tuner.view.panel";
|
||||||
|
private static final PseudoClass STATUS_ENABLED = PseudoClass.getPseudoClass("enabled");
|
||||||
|
private static final PseudoClass STATUS_DISABLED = PseudoClass.getPseudoClass("disabled-tuner");
|
||||||
|
private static final PseudoClass STATUS_ERROR = PseudoClass.getPseudoClass("error");
|
||||||
|
private static final PseudoClass STATUS_REMOVED = PseudoClass.getPseudoClass("removed");
|
||||||
|
|
||||||
|
private final UserPreferences mUserPreferences;
|
||||||
|
private final DiscoveredTunerModel mDiscoveredTunerModel;
|
||||||
|
private final TunerConfigurationManager mTunerConfigurationManager;
|
||||||
|
private final DiscoveredTunerEditor mDiscoveredTunerEditor;
|
||||||
|
private final ObservableList<DiscoveredTuner> mTuners = FXCollections.observableArrayList();
|
||||||
|
private final TableView<DiscoveredTuner> mTableView = new TableView<>();
|
||||||
|
private final TableColumnMonitor<DiscoveredTuner> mTableColumnMonitor;
|
||||||
|
private final Button mRemoveButton = new Button("Remove");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance. Must be invoked on the JavaFX application thread.
|
||||||
|
* @param tunerManager for tuners
|
||||||
|
* @param userPreferences for tuner editors and column settings
|
||||||
|
*/
|
||||||
|
public TunerView(TunerManager tunerManager, UserPreferences userPreferences)
|
||||||
|
{
|
||||||
|
mUserPreferences = userPreferences;
|
||||||
|
mDiscoveredTunerModel = tunerManager.getDiscoveredTunerModel();
|
||||||
|
mTunerConfigurationManager = tunerManager.getTunerConfigurationManager();
|
||||||
|
mDiscoveredTunerEditor = new DiscoveredTunerEditor(userPreferences, tunerManager);
|
||||||
|
|
||||||
|
getStyleClass().add("tuner-view");
|
||||||
|
URL stylesheet = TunerView.class.getResource("/tuner_editor.css");
|
||||||
|
|
||||||
|
if(stylesheet != null)
|
||||||
|
{
|
||||||
|
getStylesheets().add(stylesheet.toExternalForm());
|
||||||
|
}
|
||||||
|
|
||||||
|
createColumns();
|
||||||
|
mTableColumnMonitor = new TableColumnMonitor<>(mTableView, TABLE_KEY, userPreferences.getSwingPreference(),
|
||||||
|
SWING_TABLE_KEY);
|
||||||
|
|
||||||
|
mTableView.setItems(mTuners);
|
||||||
|
mTableView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
mTableView.setPlaceholder(new Label("No tuners discovered"));
|
||||||
|
mTableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY_FLEX_LAST_COLUMN);
|
||||||
|
mTableView.getSelectionModel().selectedItemProperty().addListener((observable, oldTuner, tuner) -> {
|
||||||
|
if(tuner != mDiscoveredTunerEditor.getItem())
|
||||||
|
{
|
||||||
|
mDiscoveredTunerEditor.setItem(tuner);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateRemoveButton();
|
||||||
|
});
|
||||||
|
mTableView.setRowFactory(table -> {
|
||||||
|
TableRow<DiscoveredTuner> row = new TableRow<>();
|
||||||
|
row.contextMenuProperty().bind(row.itemProperty().map(this::createContextMenu));
|
||||||
|
return row;
|
||||||
|
});
|
||||||
|
VBox.setVgrow(mTableView, Priority.ALWAYS);
|
||||||
|
|
||||||
|
VBox listPane = new VBox(createToolbar(), mTableView);
|
||||||
|
listPane.getStyleClass().add("tuner-list-pane");
|
||||||
|
listPane.setMinWidth(260);
|
||||||
|
|
||||||
|
getItems().addAll(listPane, mDiscoveredTunerEditor);
|
||||||
|
setOrientation(Orientation.HORIZONTAL);
|
||||||
|
setDividerPositions(0.42);
|
||||||
|
SplitPane.setResizableWithParent(listPane, false);
|
||||||
|
|
||||||
|
mDiscoveredTunerModel.addModelListener(this);
|
||||||
|
mTuners.setAll(mDiscoveredTunerModel.getDiscoveredTuners());
|
||||||
|
mTableView.sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
private HBox createToolbar()
|
||||||
|
{
|
||||||
|
MenuItem addRecording = new MenuItem("Recording Tuner ...");
|
||||||
|
addRecording.setOnAction(e -> new AddRecordingTunerDialog(getScene().getWindow(), mUserPreferences,
|
||||||
|
mDiscoveredTunerModel, mTunerConfigurationManager).show());
|
||||||
|
MenuItem addNetwork = new MenuItem("Network Tuner (rtl_tcp) ...");
|
||||||
|
addNetwork.setOnAction(e -> new AddNetworkTunerDialog(getScene().getWindow(), mUserPreferences,
|
||||||
|
mDiscoveredTunerModel, mTunerConfigurationManager).show());
|
||||||
|
MenuButton addButton = new MenuButton("Add Tuner", null, addRecording, addNetwork);
|
||||||
|
addButton.setTooltip(new Tooltip("Add a recording tuner that replays a baseband recording, or an rtl_tcp " +
|
||||||
|
"network tuner"));
|
||||||
|
|
||||||
|
mRemoveButton.setTooltip(new Tooltip("Remove the selected recording or network tuner"));
|
||||||
|
mRemoveButton.setDisable(true);
|
||||||
|
mRemoveButton.setOnAction(e -> removeTuner(mTableView.getSelectionModel().getSelectedItem()));
|
||||||
|
|
||||||
|
Region spacer = new Region();
|
||||||
|
HBox.setHgrow(spacer, Priority.ALWAYS);
|
||||||
|
|
||||||
|
HBox toolbar = new HBox(addButton, mRemoveButton, spacer,
|
||||||
|
new ColumnConfigurationButton(mTableColumnMonitor, "Tuner Columns"));
|
||||||
|
toolbar.getStyleClass().add("tuner-list-toolbar");
|
||||||
|
toolbar.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
return toolbar;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createColumns()
|
||||||
|
{
|
||||||
|
TableColumn<DiscoveredTuner,TunerStatus> status = new TableColumn<>("Status");
|
||||||
|
status.setId("status");
|
||||||
|
status.setCellValueFactory(cell -> new ReadOnlyObjectWrapper<>(cell.getValue().getTunerStatus()));
|
||||||
|
status.setCellFactory(column -> new StatusCell());
|
||||||
|
status.setPrefWidth(90);
|
||||||
|
TableColumnMonitor.setLegacyIndex(status, 0);
|
||||||
|
|
||||||
|
TableColumn<DiscoveredTuner,String> tunerClass = textColumn("tunerClass", "Class",
|
||||||
|
tuner -> tuner.getTunerClass().toString(), 1);
|
||||||
|
tunerClass.setPrefWidth(120);
|
||||||
|
TableColumn<DiscoveredTuner,String> type = textColumn("type", "Type",
|
||||||
|
tuner -> tuner.hasTuner() ? tuner.getTuner().getTunerType().getLabel() : "", 2);
|
||||||
|
type.setPrefWidth(120);
|
||||||
|
|
||||||
|
TableColumn<DiscoveredTuner,Long> frequency = new TableColumn<>("Frequency");
|
||||||
|
frequency.setId("frequency");
|
||||||
|
frequency.setCellValueFactory(cell -> new ReadOnlyObjectWrapper<>(cell.getValue().hasTuner() ?
|
||||||
|
cell.getValue().getTuner().getTunerController().getFrequency() : null));
|
||||||
|
frequency.setCellFactory(column -> new TableCell<>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected void updateItem(Long item, boolean empty)
|
||||||
|
{
|
||||||
|
super.updateItem(item, empty);
|
||||||
|
setText(empty || item == null ? null : FrequencyEntry.format(item) + " MHz");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
frequency.getStyleClass().add("tuner-frequency-column");
|
||||||
|
frequency.setPrefWidth(130);
|
||||||
|
TableColumnMonitor.setLegacyIndex(frequency, 3);
|
||||||
|
|
||||||
|
TableColumn<DiscoveredTuner,String> channels = textColumn("channels", "Channels", tuner -> {
|
||||||
|
if(!tuner.hasTuner())
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = tuner.getTuner().getChannelSourceManager().getTunerChannelCount();
|
||||||
|
boolean locked = tuner.getTuner().getTunerController().isLockedSampleRate();
|
||||||
|
return count + (locked ? " (locked)" : "");
|
||||||
|
}, 4);
|
||||||
|
|
||||||
|
mTableView.getColumns().addAll(status, tunerClass, type, frequency, channels);
|
||||||
|
mTableView.getSortOrder().add(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TableColumn<DiscoveredTuner,String> textColumn(String id, String title,
|
||||||
|
Function<DiscoveredTuner,String> value, int legacyIndex)
|
||||||
|
{
|
||||||
|
TableColumn<DiscoveredTuner,String> column = new TableColumn<>(title);
|
||||||
|
column.setId(id);
|
||||||
|
column.setCellValueFactory(cell -> new ReadOnlyObjectWrapper<>(value.apply(cell.getValue())));
|
||||||
|
TableColumnMonitor.setLegacyIndex(column, legacyIndex);
|
||||||
|
return column;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContextMenu createContextMenu(DiscoveredTuner tuner)
|
||||||
|
{
|
||||||
|
if(tuner == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuItem logState = new MenuItem("Log Tuner State");
|
||||||
|
logState.setOnAction(e -> tuner.logState());
|
||||||
|
|
||||||
|
MenuItem remove = new MenuItem("Remove Tuner");
|
||||||
|
remove.setDisable(!isRemovable(tuner));
|
||||||
|
remove.setOnAction(e -> removeTuner(tuner));
|
||||||
|
|
||||||
|
return new ContextMenu(logState, remove);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isRemovable(DiscoveredTuner tuner)
|
||||||
|
{
|
||||||
|
return tuner instanceof DiscoveredRecordingTuner || tuner instanceof DiscoveredNetworkTuner;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateRemoveButton()
|
||||||
|
{
|
||||||
|
DiscoveredTuner selected = mTableView.getSelectionModel().getSelectedItem();
|
||||||
|
mRemoveButton.setDisable(selected == null || !isRemovable(selected));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeTuner(DiscoveredTuner selected)
|
||||||
|
{
|
||||||
|
if(selected != null && isRemovable(selected))
|
||||||
|
{
|
||||||
|
mLog.info("Removing Tuner: " + selected);
|
||||||
|
|
||||||
|
if(selected == mDiscoveredTunerEditor.getItem())
|
||||||
|
{
|
||||||
|
mDiscoveredTunerEditor.setItem(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Stopping a tuner can block, so do it off of the JavaFX thread
|
||||||
|
ThreadPool.CACHED.submit(() -> {
|
||||||
|
selected.stop();
|
||||||
|
mTunerConfigurationManager.removeTunerConfiguration(selected.getTunerConfiguration());
|
||||||
|
mDiscoveredTunerModel.removeDiscoveredTuner(selected);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tunerAdded(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
if(!mTuners.contains(discoveredTuner))
|
||||||
|
{
|
||||||
|
mTuners.add(discoveredTuner);
|
||||||
|
mTableView.sort();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tunerRemoved(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
mTuners.remove(discoveredTuner);
|
||||||
|
|
||||||
|
if(mDiscoveredTunerEditor.getItem() == discoveredTuner)
|
||||||
|
{
|
||||||
|
mDiscoveredTunerEditor.setItem(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void tunerUpdated(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
mTableView.refresh();
|
||||||
|
updateRemoveButton();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the tuner in the list, e.g. for a request to show a tuner's settings.
|
||||||
|
*/
|
||||||
|
public void select(DiscoveredTuner discoveredTuner)
|
||||||
|
{
|
||||||
|
mTableView.getSelectionModel().select(discoveredTuner);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Discovered tuner editor, for testing.
|
||||||
|
*/
|
||||||
|
DiscoveredTunerEditor getDiscoveredTunerEditor()
|
||||||
|
{
|
||||||
|
return mDiscoveredTunerEditor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table view, for testing.
|
||||||
|
*/
|
||||||
|
TableView<DiscoveredTuner> getTableView()
|
||||||
|
{
|
||||||
|
return mTableView;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Status column cell that shows the status as a colored pill.
|
||||||
|
*/
|
||||||
|
private static class StatusCell extends TableCell<DiscoveredTuner,TunerStatus>
|
||||||
|
{
|
||||||
|
private final Label mPill = new Label();
|
||||||
|
|
||||||
|
StatusCell()
|
||||||
|
{
|
||||||
|
mPill.getStyleClass().add("tuner-status-chip");
|
||||||
|
setAlignment(Pos.CENTER_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateItem(TunerStatus status, boolean empty)
|
||||||
|
{
|
||||||
|
super.updateItem(status, empty);
|
||||||
|
setText(null);
|
||||||
|
|
||||||
|
if(empty || status == null)
|
||||||
|
{
|
||||||
|
setGraphic(null);
|
||||||
|
setTooltip(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mPill.setText(status.toString());
|
||||||
|
mPill.pseudoClassStateChanged(STATUS_ENABLED, status == TunerStatus.ENABLED);
|
||||||
|
mPill.pseudoClassStateChanged(STATUS_DISABLED, status == TunerStatus.DISABLED);
|
||||||
|
mPill.pseudoClassStateChanged(STATUS_ERROR, status == TunerStatus.ERROR);
|
||||||
|
mPill.pseudoClassStateChanged(STATUS_REMOVED, status == TunerStatus.REMOVED);
|
||||||
|
setGraphic(mPill);
|
||||||
|
|
||||||
|
DiscoveredTuner tuner = getTableRow() != null ? getTableRow().getItem() : null;
|
||||||
|
setTooltip(tuner != null && tuner.hasErrorMessage() ? new Tooltip(tuner.getErrorMessage()) : null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* *****************************************************************************
|
* *****************************************************************************
|
||||||
* Copyright (C) 2014-2023 Dennis Sheirer
|
* Copyright (C) 2014-2026 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
|
||||||
@@ -16,65 +16,20 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
* ****************************************************************************
|
* ****************************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.dsheirer.source.tuner.ui;
|
package io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
import com.jidesoft.swing.JideSplitPane;
|
import io.github.dsheirer.gui.theme.ThemeManager;
|
||||||
import io.github.dsheirer.preference.UserPreferences;
|
import io.github.dsheirer.preference.UserPreferences;
|
||||||
import io.github.dsheirer.preference.swing.JTableColumnWidthMonitor;
|
|
||||||
import io.github.dsheirer.source.tuner.configuration.TunerConfigurationManager;
|
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredNetworkTuner;
|
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredRecordingTuner;
|
|
||||||
import io.github.dsheirer.source.tuner.manager.DiscoveredTuner;
|
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
import io.github.dsheirer.source.tuner.manager.TunerManager;
|
||||||
import io.github.dsheirer.source.tuner.manager.TunerStatus;
|
import javafx.application.Platform;
|
||||||
import io.github.dsheirer.source.tuner.network.AddNetworkTunerDialog;
|
import javafx.embed.swing.JFXPanel;
|
||||||
import io.github.dsheirer.source.tuner.recording.AddRecordingTunerDialog;
|
import javafx.scene.Scene;
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.ListSelectionModel;
|
|
||||||
import javax.swing.RowSorter;
|
|
||||||
import javax.swing.SortOrder;
|
|
||||||
import javax.swing.event.TableModelEvent;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
|
||||||
import javax.swing.table.TableCellRenderer;
|
|
||||||
import javax.swing.table.TableRowSorter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Panel containing a discovered tuners table and a tuner editor for a selected tuner.
|
* Swing host for the JavaFX Tuners tab.
|
||||||
*/
|
*/
|
||||||
public class TunerViewPanel extends JPanel
|
public class TunerViewPanel extends JFXPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(TunerViewPanel.class);
|
|
||||||
private static final String TABLE_PREFERENCE_KEY = "tuner.view.panel";
|
|
||||||
|
|
||||||
private UserPreferences mUserPreferences;
|
|
||||||
private DiscoveredTunerModel mDiscoveredTunerModel;
|
|
||||||
private DiscoveredTunerEditor mDiscoveredTunerEditor;
|
|
||||||
private TunerConfigurationManager mTunerConfigurationManager;
|
|
||||||
private JTable mTunerTable;
|
|
||||||
private JTableColumnWidthMonitor mColumnWidthMonitor;
|
|
||||||
private TableRowSorter<DiscoveredTunerModel> mRowSorter;
|
|
||||||
private JideSplitPane mSplitPane;
|
|
||||||
private JButton mAddRecordingButton;
|
|
||||||
private JButton mRemoveTunerButton;
|
|
||||||
private JButton mAddNetworkButton;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs an instance
|
* Constructs an instance
|
||||||
* @param tunerManager for tuners
|
* @param tunerManager for tuners
|
||||||
@@ -82,234 +37,13 @@ public class TunerViewPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
public TunerViewPanel(TunerManager tunerManager, UserPreferences userPreferences)
|
public TunerViewPanel(TunerManager tunerManager, UserPreferences userPreferences)
|
||||||
{
|
{
|
||||||
mDiscoveredTunerModel = tunerManager.getDiscoveredTunerModel();
|
Platform.setImplicitExit(false);
|
||||||
mDiscoveredTunerEditor = new DiscoveredTunerEditor(userPreferences, tunerManager);
|
ThemeManager.getInstance().registerSwing(this);
|
||||||
mTunerConfigurationManager = tunerManager.getTunerConfigurationManager();
|
|
||||||
mUserPreferences = userPreferences;
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init()
|
Platform.runLater(() -> {
|
||||||
{
|
Scene scene = new Scene(new TunerView(tunerManager, userPreferences));
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[fill,grow]", "[fill,grow]"));
|
ThemeManager.getInstance().register(scene);
|
||||||
|
setScene(scene);
|
||||||
mRowSorter = new TableRowSorter<>(mDiscoveredTunerModel);
|
|
||||||
List<RowSorter.SortKey> sortKeys = new ArrayList<>();
|
|
||||||
sortKeys.add(new RowSorter.SortKey(DiscoveredTunerModel.COLUMN_TUNER_TYPE, SortOrder.ASCENDING));
|
|
||||||
mRowSorter.setSortKeys(sortKeys);
|
|
||||||
|
|
||||||
mTunerTable = new JTable(mDiscoveredTunerModel);
|
|
||||||
mTunerTable.setRowSorter(mRowSorter);
|
|
||||||
mTunerTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
|
|
||||||
mTunerTable.getSelectionModel().addListSelectionListener(event ->
|
|
||||||
{
|
|
||||||
getRemoveTunerButton().setEnabled(false);
|
|
||||||
|
|
||||||
if(!event.getValueIsAdjusting())
|
|
||||||
{
|
|
||||||
int row = mTunerTable.getSelectedRow();
|
|
||||||
|
|
||||||
if(row >= 0)
|
|
||||||
{
|
|
||||||
int modelRow = mTunerTable.convertRowIndexToModel(row);
|
|
||||||
|
|
||||||
DiscoveredTuner selected = mDiscoveredTunerModel.getDiscoveredTuner(modelRow);
|
|
||||||
mDiscoveredTunerEditor.setItem(selected);
|
|
||||||
getRemoveTunerButton().setEnabled(selected instanceof DiscoveredRecordingTuner || selected instanceof DiscoveredNetworkTuner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Add support for right-click context menu to the tuner table
|
|
||||||
JPopupMenu popupMenu = new JPopupMenu();
|
|
||||||
JMenuItem logStateMenuItem = new JMenuItem("Log Tuner State");
|
|
||||||
logStateMenuItem.addActionListener(e -> {
|
|
||||||
int viewRow = mTunerTable.getSelectedRow();
|
|
||||||
|
|
||||||
DiscoveredTuner selected = null;
|
|
||||||
|
|
||||||
if(viewRow >= 0)
|
|
||||||
{
|
|
||||||
int modelRow = mTunerTable.convertRowIndexToModel(viewRow);
|
|
||||||
selected = mDiscoveredTunerModel.getDiscoveredTuner(modelRow);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(selected != null)
|
|
||||||
{
|
|
||||||
selected.logState();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mLog.error("Can't log state - tuner not selected");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
popupMenu.add(logStateMenuItem);
|
|
||||||
mTunerTable.setComponentPopupMenu(popupMenu);
|
|
||||||
|
|
||||||
//Monitor for tuner removal events so we can update the editor when our selected tuner is removed
|
|
||||||
mDiscoveredTunerModel.addTableModelListener(e ->
|
|
||||||
{
|
|
||||||
//Detect when status is for the currently selected tuner
|
|
||||||
if(e.getType() == TableModelEvent.DELETE &&
|
|
||||||
mDiscoveredTunerEditor.hasItem() &&
|
|
||||||
!mDiscoveredTunerModel.hasTuner(mDiscoveredTunerEditor.getItem()))
|
|
||||||
{
|
|
||||||
mDiscoveredTunerEditor.setItem(null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mDiscoveredTunerModel.addListener(tunerEvent ->
|
|
||||||
{
|
|
||||||
switch(tunerEvent.getEvent())
|
|
||||||
{
|
|
||||||
case UPDATE_LOCK_STATE:
|
|
||||||
if(tunerEvent.getTuner() != null)
|
|
||||||
{
|
|
||||||
int row = mTunerTable.getSelectedRow();
|
|
||||||
|
|
||||||
if(row >= 0)
|
|
||||||
{
|
|
||||||
int modelRow = mTunerTable.convertRowIndexToModel(row);
|
|
||||||
DiscoveredTuner selectedTuner = mDiscoveredTunerModel.getDiscoveredTuner(modelRow);
|
|
||||||
|
|
||||||
if(selectedTuner != null && selectedTuner.hasTuner() && tunerEvent.getTuner() == selectedTuner.getTuner())
|
|
||||||
{
|
|
||||||
mDiscoveredTunerEditor.setTunerLockState(selectedTuner.getTuner().getTunerController().isLockedSampleRate());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
TableCellRenderer errorCellRenderer = new TunerStatusCellRenderer();
|
|
||||||
mTunerTable.getColumnModel().getColumn(DiscoveredTunerModel.COLUMN_TUNER_STATUS).setCellRenderer(errorCellRenderer);
|
|
||||||
|
|
||||||
mColumnWidthMonitor = new JTableColumnWidthMonitor(mUserPreferences, mTunerTable, TABLE_PREFERENCE_KEY);
|
|
||||||
JScrollPane tunerTableScroller = new JScrollPane(mTunerTable);
|
|
||||||
|
|
||||||
JPanel tunerTablePanel = new JPanel();
|
|
||||||
tunerTablePanel.setLayout(new MigLayout("insets 0", "[fill,grow,align center]", "[fill,grow][]"));
|
|
||||||
tunerTablePanel.add(tunerTableScroller, "span");
|
|
||||||
|
|
||||||
JPanel buttonPanel = new JPanel();
|
|
||||||
buttonPanel.setLayout(new MigLayout("insets 0 1 3 0", "", ""));
|
|
||||||
buttonPanel.add(getAddRecordingButton());
|
|
||||||
buttonPanel.add(getAddNetworkButton());
|
|
||||||
buttonPanel.add(getRemoveTunerButton());
|
|
||||||
tunerTablePanel.add(buttonPanel);
|
|
||||||
|
|
||||||
tunerTablePanel.setPreferredSize(new Dimension(200,200));
|
|
||||||
JScrollPane editorScroller = new JScrollPane(mDiscoveredTunerEditor);
|
|
||||||
editorScroller.setPreferredSize(new Dimension(200, 200));
|
|
||||||
|
|
||||||
mSplitPane = new JideSplitPane();
|
|
||||||
mSplitPane.setOrientation(JideSplitPane.HORIZONTAL_SPLIT);
|
|
||||||
mSplitPane.add(tunerTablePanel);
|
|
||||||
mSplitPane.add(editorScroller);
|
|
||||||
mSplitPane.setProportionalLayout(true);
|
|
||||||
mSplitPane.setProportions(new double[]{0.5});
|
|
||||||
|
|
||||||
add(mSplitPane);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JButton getAddRecordingButton()
|
|
||||||
{
|
|
||||||
if(mAddRecordingButton == null)
|
|
||||||
{
|
|
||||||
mAddRecordingButton = new JButton("Add Recording Tuner");
|
|
||||||
mAddRecordingButton.addActionListener(e ->
|
|
||||||
{
|
|
||||||
AddRecordingTunerDialog dialog = new AddRecordingTunerDialog(mUserPreferences, mDiscoveredTunerModel,
|
|
||||||
mTunerConfigurationManager);
|
|
||||||
dialog.setLocationRelativeTo(TunerViewPanel.this);
|
|
||||||
EventQueue.invokeLater(() -> dialog.setVisible(true));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAddRecordingButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JButton getRemoveTunerButton()
|
|
||||||
{
|
|
||||||
if(mRemoveTunerButton == null)
|
|
||||||
{
|
|
||||||
mRemoveTunerButton = new JButton("Remove Tuner");
|
|
||||||
mRemoveTunerButton.setEnabled(false);
|
|
||||||
mRemoveTunerButton.addActionListener(e -> {
|
|
||||||
int[] indexes = mTunerTable.getSelectionModel().getSelectedIndices();
|
|
||||||
|
|
||||||
//With single selection mode this should always be length one
|
|
||||||
if(indexes.length == 1)
|
|
||||||
{
|
|
||||||
int modelIndex = mTunerTable.convertRowIndexToModel(indexes[0]);
|
|
||||||
DiscoveredTuner selected = mDiscoveredTunerModel.getDiscoveredTuner(modelIndex);
|
|
||||||
|
|
||||||
if(selected instanceof DiscoveredRecordingTuner || selected instanceof DiscoveredNetworkTuner)
|
|
||||||
{
|
|
||||||
mLog.info("Removing Tuner: " + selected);
|
|
||||||
selected.stop();
|
|
||||||
mTunerConfigurationManager.removeTunerConfiguration(selected.getTunerConfiguration());
|
|
||||||
EventQueue.invokeLater(() -> mDiscoveredTunerModel.removeDiscoveredTuner(selected));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mRemoveTunerButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JButton getAddNetworkButton()
|
|
||||||
{
|
|
||||||
if (mAddNetworkButton == null)
|
|
||||||
{
|
|
||||||
mAddNetworkButton = new JButton("Add Network Tuner");
|
|
||||||
mAddNetworkButton.addActionListener(e ->
|
|
||||||
{
|
|
||||||
AddNetworkTunerDialog dialog = new AddNetworkTunerDialog(mUserPreferences, mDiscoveredTunerModel, mTunerConfigurationManager);
|
|
||||||
dialog.setLocationRelativeTo(TunerViewPanel.this);
|
|
||||||
EventQueue.invokeLater(() -> dialog.setVisible(true));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return mAddNetworkButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Custom cell renderer for the TunerStatus enumeration column
|
|
||||||
*/
|
|
||||||
public class TunerStatusCellRenderer extends DefaultTableCellRenderer
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
|
|
||||||
int row, int column)
|
|
||||||
{
|
|
||||||
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
||||||
|
|
||||||
if(value instanceof TunerStatus tunerStatus)
|
|
||||||
{
|
|
||||||
if(tunerStatus == TunerStatus.ERROR)
|
|
||||||
{
|
|
||||||
component.setForeground(Color.RED);
|
|
||||||
}
|
|
||||||
else if(tunerStatus == TunerStatus.DISABLED)
|
|
||||||
{
|
|
||||||
//Use the LAF's disabled-foreground colour so the row reads correctly on any
|
|
||||||
//theme - DARK_GRAY is invisible on dark backgrounds.
|
|
||||||
Color disabled = javax.swing.UIManager.getColor("Label.disabledForeground");
|
|
||||||
component.setForeground(disabled != null ? disabled : table.getForeground());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
component.setForeground(table.getForeground());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
component.setForeground(table.getForeground());
|
|
||||||
}
|
|
||||||
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
162
src/main/resources/frequency_control.css
Normal file
162
src/main/resources/frequency_control.css
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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/>
|
||||||
|
* ****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Frequency control. All colors are derived from the theme's looked-up colors (-fx-control-inner-background,
|
||||||
|
-fx-text-base-color, -fx-accent) so the control follows every application theme. */
|
||||||
|
|
||||||
|
.frequency-control
|
||||||
|
{
|
||||||
|
-fc-face: derive(-fx-control-inner-background, -5%);
|
||||||
|
-fc-edge: derive(-fx-control-inner-background, -28%);
|
||||||
|
-fc-digit: -fx-text-base-color;
|
||||||
|
-fc-dim: ladder(-fc-face, derive(-fc-face, 42%) 49%, derive(-fc-face, -30%) 50%);
|
||||||
|
-fc-hover: -fx-accent;
|
||||||
|
-fx-background-color: -fc-edge, -fc-face;
|
||||||
|
-fx-background-insets: 0, 1;
|
||||||
|
-fx-background-radius: 7, 6;
|
||||||
|
-fx-padding: 0 10 0 8;
|
||||||
|
-fx-spacing: 0;
|
||||||
|
-fx-effect: innershadow(gaussian, rgba(0, 0, 0, 0.30), 6, 0, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control:focused
|
||||||
|
{
|
||||||
|
-fx-background-color: -fx-focus-color, -fc-face;
|
||||||
|
-fx-background-insets: 0, 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control:entry
|
||||||
|
{
|
||||||
|
-fx-background-color: -fx-accent, -fc-face;
|
||||||
|
-fx-background-insets: 0, 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control:invalid
|
||||||
|
{
|
||||||
|
-fx-background-color: #d9443a, -fc-face;
|
||||||
|
-fx-background-insets: 0, 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control:disabled
|
||||||
|
{
|
||||||
|
-fx-opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-digit-text
|
||||||
|
{
|
||||||
|
-fx-font-size: 2.15em;
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
-fx-fill: -fc-digit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-point
|
||||||
|
{
|
||||||
|
-fx-fill: -fc-digit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-group-gap
|
||||||
|
{
|
||||||
|
-fx-min-width: 6;
|
||||||
|
-fx-pref-width: 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-unit
|
||||||
|
{
|
||||||
|
-fx-text-fill: derive(-fc-digit, -25%);
|
||||||
|
-fx-font-size: 1.05em;
|
||||||
|
-fx-padding: 0.9em 0 0 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Leading zeros are dimmed so the significant part of the frequency stands out */
|
||||||
|
.frequency-control .frequency-digit:leading .frequency-digit-text
|
||||||
|
{
|
||||||
|
-fx-fill: -fc-dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Typed entry: typed digits use the accent color, implied digits are dimmed */
|
||||||
|
.frequency-control:entry .frequency-digit .frequency-digit-text
|
||||||
|
{
|
||||||
|
-fx-fill: -fc-dim;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control:entry .frequency-digit:typed .frequency-digit-text
|
||||||
|
{
|
||||||
|
-fx-fill: -fx-accent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-digit-cell
|
||||||
|
{
|
||||||
|
-fx-background-radius: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Up/down halves revealed while the mouse is over a digit */
|
||||||
|
.frequency-control .frequency-half
|
||||||
|
{
|
||||||
|
-fx-background-color: -fc-hover;
|
||||||
|
-fx-background-radius: 3;
|
||||||
|
-fx-opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-digit:hover-up .frequency-half-up,
|
||||||
|
.frequency-control .frequency-digit:hover-down .frequency-half-down
|
||||||
|
{
|
||||||
|
-fx-opacity: 0.22;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-arrow
|
||||||
|
{
|
||||||
|
-fx-background-color: -fc-hover;
|
||||||
|
-fx-scale-shape: true;
|
||||||
|
-fx-opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-arrow-up
|
||||||
|
{
|
||||||
|
-fx-shape: "M0,10 L10,0 L20,10 Z";
|
||||||
|
-fx-translate-y: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-arrow-down
|
||||||
|
{
|
||||||
|
-fx-shape: "M0,0 L20,0 L10,10 Z";
|
||||||
|
-fx-translate-y: -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-digit:hover .frequency-arrow
|
||||||
|
{
|
||||||
|
-fx-opacity: 0.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-digit:hover-up .frequency-arrow-up,
|
||||||
|
.frequency-control .frequency-digit:hover-down .frequency-arrow-down
|
||||||
|
{
|
||||||
|
-fx-opacity: 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.frequency-control .frequency-digit:hover
|
||||||
|
{
|
||||||
|
-fx-cursor: hand;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Keyboard cursor digit */
|
||||||
|
.frequency-control .frequency-digit:cursor .frequency-digit-cell
|
||||||
|
{
|
||||||
|
-fx-border-color: transparent transparent -fx-accent transparent;
|
||||||
|
-fx-border-width: 0 0 2 0;
|
||||||
|
}
|
||||||
292
src/main/resources/tuner_editor.css
Normal file
292
src/main/resources/tuner_editor.css
Normal file
@@ -0,0 +1,292 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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/>
|
||||||
|
* ****************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Tuners tab and tuner editors. Colors are derived from the theme's looked-up colors so they follow every
|
||||||
|
application theme. */
|
||||||
|
|
||||||
|
.tuner-view
|
||||||
|
{
|
||||||
|
-fx-background-color: -fx-background;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-list-pane
|
||||||
|
{
|
||||||
|
-fx-spacing: 6;
|
||||||
|
-fx-padding: 6 0 0 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-list-toolbar
|
||||||
|
{
|
||||||
|
-fx-spacing: 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-frequency-column
|
||||||
|
{
|
||||||
|
-fx-alignment: center-right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Editor */
|
||||||
|
|
||||||
|
.tuner-editor
|
||||||
|
{
|
||||||
|
-fx-padding: 12 14 16 14;
|
||||||
|
-fx-spacing: 12;
|
||||||
|
-fx-max-width: 760;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-editor-scroll,
|
||||||
|
.tuner-editor-scroll > .viewport
|
||||||
|
{
|
||||||
|
-fx-background-color: -fx-background;
|
||||||
|
-fx-background-insets: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-header
|
||||||
|
{
|
||||||
|
-fx-spacing: 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-title-row,
|
||||||
|
.tuner-header-extras
|
||||||
|
{
|
||||||
|
-fx-spacing: 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-titles
|
||||||
|
{
|
||||||
|
-fx-spacing: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-title
|
||||||
|
{
|
||||||
|
-fx-font-size: 1.45em;
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-subtitle
|
||||||
|
{
|
||||||
|
-fx-opacity: 0.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-status-row
|
||||||
|
{
|
||||||
|
-fx-spacing: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-actions
|
||||||
|
{
|
||||||
|
-fx-hgap: 6;
|
||||||
|
-fx-vgap: 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-error
|
||||||
|
{
|
||||||
|
-fx-text-fill: #d9443a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-recording-status
|
||||||
|
{
|
||||||
|
-fx-text-fill: #d9443a;
|
||||||
|
-fx-font-size: 0.95em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-record-button:selected
|
||||||
|
{
|
||||||
|
-fx-base: #c0392b;
|
||||||
|
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border, -fx-inner-border, -fx-body-color;
|
||||||
|
-fx-text-fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-record-button:selected .text
|
||||||
|
{
|
||||||
|
-fx-fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-restart-button
|
||||||
|
{
|
||||||
|
-fx-base: #d9822b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Status chip used in the editor header and the tuner list */
|
||||||
|
.tuner-status-chip
|
||||||
|
{
|
||||||
|
-fx-padding: 1 9 1 9;
|
||||||
|
-fx-background-radius: 10;
|
||||||
|
-fx-border-radius: 10;
|
||||||
|
-fx-font-size: 0.92em;
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
-fx-background-color: derive(-fx-background, -12%);
|
||||||
|
-fx-text-fill: -fx-text-base-color;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-status-chip:enabled
|
||||||
|
{
|
||||||
|
-fx-background-color: #2e9e5b;
|
||||||
|
-fx-text-fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-status-chip:error
|
||||||
|
{
|
||||||
|
-fx-background-color: #d9443a;
|
||||||
|
-fx-text-fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-status-chip:removed
|
||||||
|
{
|
||||||
|
-fx-background-color: #888888;
|
||||||
|
-fx-text-fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-status-chip:enabled .text,
|
||||||
|
.tuner-status-chip:error .text,
|
||||||
|
.tuner-status-chip:removed .text
|
||||||
|
{
|
||||||
|
-fx-fill: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sections */
|
||||||
|
|
||||||
|
.tuner-sections
|
||||||
|
{
|
||||||
|
-fx-spacing: 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-section
|
||||||
|
{
|
||||||
|
-fx-background-color: derive(-fx-background, -10%), ladder(-fx-background, derive(-fx-background, 4%) 49%, derive(-fx-background, 45%) 50%);
|
||||||
|
-fx-background-insets: 0, 1;
|
||||||
|
-fx-background-radius: 8, 7;
|
||||||
|
-fx-padding: 10 14 12 14;
|
||||||
|
-fx-spacing: 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-section-embedded
|
||||||
|
{
|
||||||
|
-fx-background-color: transparent;
|
||||||
|
-fx-padding: 4 0 4 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-section-title
|
||||||
|
{
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
-fx-font-size: 0.95em;
|
||||||
|
-fx-text-fill: -fx-accent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-section-title .text
|
||||||
|
{
|
||||||
|
-fx-fill: -fx-accent;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-section-grid
|
||||||
|
{
|
||||||
|
-fx-hgap: 12;
|
||||||
|
-fx-vgap: 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-row-label
|
||||||
|
{
|
||||||
|
-fx-min-width: 90;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-flow-row
|
||||||
|
{
|
||||||
|
-fx-spacing: 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-frequency-row
|
||||||
|
{
|
||||||
|
-fx-padding: 2 0 4 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-hint
|
||||||
|
{
|
||||||
|
-fx-opacity: 0.75;
|
||||||
|
-fx-font-size: 0.95em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-value-label
|
||||||
|
{
|
||||||
|
-fx-opacity: 0.85;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-locked-notice
|
||||||
|
{
|
||||||
|
-fx-padding: 4 10 4 10;
|
||||||
|
-fx-background-radius: 6;
|
||||||
|
-fx-background-color: derive(#d9a62b, 55%);
|
||||||
|
-fx-text-fill: #5c4300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-locked-notice .text
|
||||||
|
{
|
||||||
|
-fx-fill: #5c4300;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-limits-pane > .content
|
||||||
|
{
|
||||||
|
-fx-padding: 4 14 8 14;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Gain slider */
|
||||||
|
|
||||||
|
.gain-slider
|
||||||
|
{
|
||||||
|
-fx-spacing: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gain-slider-value
|
||||||
|
{
|
||||||
|
-fx-min-width: 5.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RSP gain overload indicator, which lights when the tuner reports an overload */
|
||||||
|
.tuner-overload-indicator
|
||||||
|
{
|
||||||
|
-fx-padding: 1 8 1 8;
|
||||||
|
-fx-background-radius: 4;
|
||||||
|
-fx-background-color: derive(-fx-background, -8%);
|
||||||
|
-fx-opacity: 0.55;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-overload-indicator:overload
|
||||||
|
{
|
||||||
|
-fx-background-color: #d9443a;
|
||||||
|
-fx-text-fill: #ffeb3b;
|
||||||
|
-fx-opacity: 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tuner-overload-indicator:overload .text
|
||||||
|
{
|
||||||
|
-fx-fill: #ffeb3b;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Placeholder when no tuner is selected */
|
||||||
|
.empty-tuner-editor
|
||||||
|
{
|
||||||
|
-fx-padding: 40;
|
||||||
|
-fx-spacing: 6;
|
||||||
|
-fx-opacity: 0.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-tuner-title
|
||||||
|
{
|
||||||
|
-fx-font-size: 1.3em;
|
||||||
|
-fx-font-weight: bold;
|
||||||
|
}
|
||||||
@@ -0,0 +1,206 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.gui.control;
|
||||||
|
|
||||||
|
import io.github.dsheirer.source.SourceEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.input.KeyCode;
|
||||||
|
import javafx.scene.input.KeyEvent;
|
||||||
|
import javafx.scene.input.ScrollEvent;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the frequency control's keyboard and scroll wheel interaction.
|
||||||
|
*/
|
||||||
|
public class FrequencyControlTest
|
||||||
|
{
|
||||||
|
@BeforeAll
|
||||||
|
public static void startToolkit() throws Exception
|
||||||
|
{
|
||||||
|
//Run without a display
|
||||||
|
System.setProperty("glass.platform", "Headless");
|
||||||
|
System.setProperty("prism.order", "sw");
|
||||||
|
CompletableFuture<Void> started = new CompletableFuture<>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Platform.startup(() -> started.complete(null));
|
||||||
|
}
|
||||||
|
catch(IllegalStateException e)
|
||||||
|
{
|
||||||
|
started.complete(null); //Already started
|
||||||
|
}
|
||||||
|
|
||||||
|
started.get(10, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T onFx(java.util.concurrent.Callable<T> callable) throws Exception
|
||||||
|
{
|
||||||
|
CompletableFuture<T> future = new CompletableFuture<>();
|
||||||
|
Platform.runLater(() -> {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
future.complete(callable.call());
|
||||||
|
}
|
||||||
|
catch(Throwable t)
|
||||||
|
{
|
||||||
|
future.completeExceptionally(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return future.get(10, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static FrequencyControl createControl(List<Long> requests)
|
||||||
|
{
|
||||||
|
FrequencyControl control = new FrequencyControl();
|
||||||
|
control.setRange(24_000_000, 1_766_000_000);
|
||||||
|
control.setFrequency(851_012_500);
|
||||||
|
control.addListener(requests::add);
|
||||||
|
Scene scene = new Scene(new StackPane(control), 400, 120);
|
||||||
|
scene.snapshot(null);
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void type(Node node, String text)
|
||||||
|
{
|
||||||
|
for(char c: text.toCharArray())
|
||||||
|
{
|
||||||
|
node.fireEvent(new KeyEvent(KeyEvent.KEY_TYPED, String.valueOf(c), "", KeyCode.UNDEFINED, false, false,
|
||||||
|
false, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void press(Node node, KeyCode code)
|
||||||
|
{
|
||||||
|
node.fireEvent(new KeyEvent(KeyEvent.KEY_PRESSED, "", "", code, false, false, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void typedEntryAppliedWithEnter() throws Exception
|
||||||
|
{
|
||||||
|
List<Long> requests = new ArrayList<>();
|
||||||
|
long frequency = onFx(() -> {
|
||||||
|
FrequencyControl control = createControl(requests);
|
||||||
|
type(control, "462.5625");
|
||||||
|
assertTrue(control.isEntryActive());
|
||||||
|
assertEquals(851_012_500L, control.getFrequency(), "not applied until Enter");
|
||||||
|
press(control, KeyCode.ENTER);
|
||||||
|
return control.getFrequency();
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(462_562_500L, frequency);
|
||||||
|
assertEquals(List.of(462_562_500L), requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void typedEntryCancelledWithEscape() throws Exception
|
||||||
|
{
|
||||||
|
List<Long> requests = new ArrayList<>();
|
||||||
|
long frequency = onFx(() -> {
|
||||||
|
FrequencyControl control = createControl(requests);
|
||||||
|
type(control, "155.0");
|
||||||
|
press(control, KeyCode.ESCAPE);
|
||||||
|
return control.getFrequency();
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(851_012_500L, frequency);
|
||||||
|
assertTrue(requests.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void outOfRangeEntryRejected() throws Exception
|
||||||
|
{
|
||||||
|
List<Long> requests = new ArrayList<>();
|
||||||
|
long frequency = onFx(() -> {
|
||||||
|
FrequencyControl control = createControl(requests);
|
||||||
|
type(control, "2000");
|
||||||
|
press(control, KeyCode.ENTER);
|
||||||
|
return control.getFrequency();
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(851_012_500L, frequency);
|
||||||
|
assertTrue(requests.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void arrowKeysMoveCursorAndStep() throws Exception
|
||||||
|
{
|
||||||
|
List<Long> requests = new ArrayList<>();
|
||||||
|
long frequency = onFx(() -> {
|
||||||
|
FrequencyControl control = createControl(requests);
|
||||||
|
//Cursor starts on the 1 MHz digit: move right to the 100 kHz digit and step up twice
|
||||||
|
assertEquals(6, control.getCursorPosition());
|
||||||
|
press(control, KeyCode.RIGHT);
|
||||||
|
press(control, KeyCode.UP);
|
||||||
|
press(control, KeyCode.UP);
|
||||||
|
//Move left twice to the 10 MHz digit and step down once
|
||||||
|
press(control, KeyCode.LEFT);
|
||||||
|
press(control, KeyCode.LEFT);
|
||||||
|
press(control, KeyCode.DOWN);
|
||||||
|
return control.getFrequency();
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(841_212_500L, frequency);
|
||||||
|
assertEquals(List.of(851_112_500L, 851_212_500L, 841_212_500L), requests);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void scrollWheelStepsDigitUnderMouse() throws Exception
|
||||||
|
{
|
||||||
|
List<Long> requests = new ArrayList<>();
|
||||||
|
long frequency = onFx(() -> {
|
||||||
|
FrequencyControl control = createControl(requests);
|
||||||
|
//Digits are in order from the 1000 MHz digit (position 9) to the 1 Hz digit (position 0)
|
||||||
|
Node digit = control.lookupAll(".frequency-digit").stream().toList().get(9 - 3); //1 kHz digit
|
||||||
|
var bounds = digit.localToScene(digit.getLayoutBounds());
|
||||||
|
//Two wheel notches up, as JFXPanel reports them: 40 per notch with a multiplier of 40
|
||||||
|
digit.fireEvent(new ScrollEvent(ScrollEvent.SCROLL, bounds.getCenterX(), bounds.getCenterY(),
|
||||||
|
bounds.getCenterX(), bounds.getCenterY(), false, false, false, false, false, false, 0, 80, 0, 80,
|
||||||
|
40, 40, ScrollEvent.HorizontalTextScrollUnits.NONE, 0, ScrollEvent.VerticalTextScrollUnits.NONE,
|
||||||
|
0, 0, null));
|
||||||
|
return control.getFrequency();
|
||||||
|
});
|
||||||
|
|
||||||
|
assertEquals(851_014_500L, frequency);
|
||||||
|
assertEquals(List.of(851_014_500L), requests, "one request for both notches");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void tunerNotificationUpdatesWithoutRequest() throws Exception
|
||||||
|
{
|
||||||
|
List<Long> requests = new ArrayList<>();
|
||||||
|
FrequencyControl control = onFx(() -> createControl(requests));
|
||||||
|
control.process(SourceEvent.frequencyChange(null, 155_250_000L));
|
||||||
|
long frequency = onFx(control::getFrequency);
|
||||||
|
assertEquals(155_250_000L, frequency);
|
||||||
|
assertTrue(requests.isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.gui.control;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests the frequency control's digit arithmetic, parsing and typed entry.
|
||||||
|
*/
|
||||||
|
public class FrequencyEntryTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void digits()
|
||||||
|
{
|
||||||
|
long frequency = 851_012_500L;
|
||||||
|
assertEquals(0, FrequencyEntry.getDigit(frequency, 0));
|
||||||
|
assertEquals(5, FrequencyEntry.getDigit(frequency, 2));
|
||||||
|
assertEquals(1, FrequencyEntry.getDigit(frequency, 4));
|
||||||
|
assertEquals(1, FrequencyEntry.getDigit(frequency, 6));
|
||||||
|
assertEquals(8, FrequencyEntry.getDigit(frequency, 8));
|
||||||
|
assertEquals(0, FrequencyEntry.getDigit(frequency, 9));
|
||||||
|
assertTrue(FrequencyEntry.isLeadingZero(frequency, 9));
|
||||||
|
assertFalse(FrequencyEntry.isLeadingZero(frequency, 8));
|
||||||
|
assertFalse(FrequencyEntry.isLeadingZero(0, 6), "1 MHz digit is never a leading zero");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void stepCarriesAndClamps()
|
||||||
|
{
|
||||||
|
assertEquals(852_000_000L, FrequencyEntry.step(851_900_000L, 5, 1, 1, 2_000_000_000L), "carry into MHz");
|
||||||
|
assertEquals(850_900_000L, FrequencyEntry.step(851_000_000L, 5, -1, 1, 2_000_000_000L), "borrow from MHz");
|
||||||
|
assertEquals(1_766_000_000L, FrequencyEntry.step(1_765_500_000L, 6, 3, 24_000_000L, 1_766_000_000L),
|
||||||
|
"clamp at maximum");
|
||||||
|
assertEquals(24_000_000L, FrequencyEntry.step(25_000_000L, 7, -1, 24_000_000L, 1_766_000_000L),
|
||||||
|
"clamp at minimum");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setDigit()
|
||||||
|
{
|
||||||
|
assertEquals(861_012_500L, FrequencyEntry.setDigit(851_012_500L, 7, 6));
|
||||||
|
assertEquals(851_012_509L, FrequencyEntry.setDigit(851_012_500L, 0, 9));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void parse()
|
||||||
|
{
|
||||||
|
assertEquals(851_012_500L, FrequencyEntry.parse("851.0125"));
|
||||||
|
assertEquals(851_012_500L, FrequencyEntry.parse(" 851.012500 MHz "));
|
||||||
|
assertEquals(851_012_500L, FrequencyEntry.parse("851012500"), "large whole number is Hertz");
|
||||||
|
assertEquals(851_012_500L, FrequencyEntry.parse("851,012,500 Hz"));
|
||||||
|
assertEquals(162_550_000L, FrequencyEntry.parse("162550 kHz"));
|
||||||
|
assertEquals(1_296_000_000L, FrequencyEntry.parse("1.296GHz"));
|
||||||
|
assertEquals(9_999_000_000L, FrequencyEntry.parse("9999"), "4 digit whole number is MHz");
|
||||||
|
assertNull(FrequencyEntry.parse("851.0125005"), "finer than 1 Hz");
|
||||||
|
assertNull(FrequencyEntry.parse("abc"));
|
||||||
|
assertNull(FrequencyEntry.parse("-5"));
|
||||||
|
assertNull(FrequencyEntry.parse(""));
|
||||||
|
assertNull(FrequencyEntry.parse(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void format()
|
||||||
|
{
|
||||||
|
assertEquals("851.012500", FrequencyEntry.format(851_012_500L));
|
||||||
|
assertEquals("0.000001", FrequencyEntry.format(1));
|
||||||
|
assertEquals("1296.000000", FrequencyEntry.format(1_296_000_000L));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void typedEntry()
|
||||||
|
{
|
||||||
|
FrequencyEntry.TypedEntry entry = new FrequencyEntry.TypedEntry();
|
||||||
|
assertTrue(entry.isEmpty());
|
||||||
|
|
||||||
|
for(char c: "0851.0125".toCharArray())
|
||||||
|
{
|
||||||
|
assertTrue(entry.type(c));
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(851_012_500L, entry.getFrequency());
|
||||||
|
assertTrue(entry.isTyped(8), "100 MHz digit typed");
|
||||||
|
assertFalse(entry.isTyped(9), "leading zero isn't counted");
|
||||||
|
assertTrue(entry.isTyped(2), "100 Hz digit typed");
|
||||||
|
assertFalse(entry.isTyped(1), "10 Hz digit implied");
|
||||||
|
assertFalse(entry.type('.'), "second decimal point");
|
||||||
|
|
||||||
|
assertTrue(entry.backspace());
|
||||||
|
assertEquals(851_012_000L, entry.getFrequency());
|
||||||
|
|
||||||
|
entry.clear();
|
||||||
|
|
||||||
|
for(char c: "12345".toCharArray())
|
||||||
|
{
|
||||||
|
entry.type(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(1234_000_000L, entry.getFrequency(), "fifth MHz digit is rejected");
|
||||||
|
|
||||||
|
entry.clear();
|
||||||
|
|
||||||
|
for(char c: ".1234567".toCharArray())
|
||||||
|
{
|
||||||
|
entry.type(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(123_456L, entry.getFrequency(), "seventh fractional digit is rejected");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* *****************************************************************************
|
||||||
|
* Copyright (C) 2014-2026 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 io.github.dsheirer.source.tuner.ui;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests parsing the simple HTML tuner information that tuner editors provide.
|
||||||
|
*/
|
||||||
|
public class TunerInfoDialogTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void parsesHeadingAndKeyValueLines()
|
||||||
|
{
|
||||||
|
TunerInfoDialog.Info info = TunerInfoDialog.parse("<html><h3>RTL-2832 with R820T Tuner</h3>" +
|
||||||
|
"<b>USB ID: </b>0bda:2838<br><b>Serial: </b>00000001<br>No EEPROM Descriptor Available");
|
||||||
|
|
||||||
|
assertEquals("RTL-2832 with R820T Tuner", info.heading());
|
||||||
|
assertEquals(List.of(new TunerInfoDialog.Line("USB ID", "0bda:2838"),
|
||||||
|
new TunerInfoDialog.Line("Serial", "00000001"),
|
||||||
|
new TunerInfoDialog.Line(null, "No EEPROM Descriptor Available")), info.lines());
|
||||||
|
assertEquals("RTL-2832 with R820T Tuner\nUSB ID: 0bda:2838\nSerial: 00000001\nNo EEPROM Descriptor Available\n",
|
||||||
|
info.toText());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void handlesMissingHeading()
|
||||||
|
{
|
||||||
|
TunerInfoDialog.Info info = TunerInfoDialog.parse("<b>Host: </b>localhost<br>");
|
||||||
|
assertEquals(null, info.heading());
|
||||||
|
assertEquals(List.of(new TunerInfoDialog.Line("Host", "localhost")), info.lines());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user