1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00

AFC: settings fix

This commit is contained in:
f4exb 2020-10-17 23:43:20 +02:00
parent 4ac114a924
commit 1c1eade408
8 changed files with 295 additions and 353 deletions

View File

@ -147,10 +147,12 @@ void AFC::applySettings(const AFCSettings& settings, bool force)
qDebug() << "AFC::applySettings:"
<< " m_title: " << settings.m_title
<< " m_rgbColor: " << settings.m_rgbColor
<< " m_rxDeviceSetIndex: " << settings.m_rxDeviceSetIndex
<< " m_txDeviceSetIndex: " << settings.m_txDeviceSetIndex
<< " m_rx2TxDelayMs: " << settings.m_rx2TxDelayMs
<< " m_tx2RxDelayMs: " << settings.m_tx2RxDelayMs
<< " m_trackerDeviceSetIndex: " << settings.m_trackerDeviceSetIndex
<< " m_trackedDeviceSetIndex: " << settings.m_trackedDeviceSetIndex
<< " m_hasTargetFrequency: " << settings.m_hasTargetFrequency
<< " m_transverterTarget: " << settings.m_transverterTarget
<< " m_targetFrequency: " << settings.m_targetFrequency
<< " m_freqTolerance: " << settings.m_freqTolerance
<< " force: " << force;
QList<QString> reverseAPIKeys;
@ -161,17 +163,23 @@ void AFC::applySettings(const AFCSettings& settings, bool force)
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
reverseAPIKeys.append("rgbColor");
}
if ((m_settings.m_rxDeviceSetIndex != settings.m_rxDeviceSetIndex) || force) {
reverseAPIKeys.append("rxDeviceSetIndex");
if ((m_settings.m_trackerDeviceSetIndex != settings.m_trackerDeviceSetIndex) || force) {
reverseAPIKeys.append("trackerDeviceSetIndex");
}
if ((m_settings.m_txDeviceSetIndex != settings.m_txDeviceSetIndex) || force) {
reverseAPIKeys.append("txDeviceSetIndex");
if ((m_settings.m_trackedDeviceSetIndex != settings.m_trackedDeviceSetIndex) || force) {
reverseAPIKeys.append("trackedDeviceSetIndex");
}
if ((m_settings.m_rx2TxDelayMs != settings.m_rx2TxDelayMs) || force) {
reverseAPIKeys.append("rx2TxDelayMs");
if ((m_settings.m_hasTargetFrequency != settings.m_hasTargetFrequency) || force) {
reverseAPIKeys.append("hasTargetFrequency");
}
if ((m_settings.m_tx2RxDelayMs != settings.m_tx2RxDelayMs) || force) {
reverseAPIKeys.append("tx2RxDelayMs");
if ((m_settings.m_transverterTarget != settings.m_transverterTarget) || force) {
reverseAPIKeys.append("transverterTarget");
}
if ((m_settings.m_targetFrequency != settings.m_targetFrequency) || force) {
reverseAPIKeys.append("targetFrequency");
}
if ((m_settings.m_freqTolerance != settings.m_freqTolerance) || force) {
reverseAPIKeys.append("freqTolerance");
}
AFCWorker::MsgConfigureAFCWorker *msg = AFCWorker::MsgConfigureAFCWorker::create(
@ -292,10 +300,12 @@ void AFC::webapiFormatFeatureSettings(
}
response.getAfcSettings()->setRgbColor(settings.m_rgbColor);
response.getAfcSettings()->setRxDeviceSetIndex(settings.m_rxDeviceSetIndex);
response.getAfcSettings()->setTxDeviceSetIndex(settings.m_txDeviceSetIndex);
response.getAfcSettings()->setRx2TxDelayMs(settings.m_rx2TxDelayMs);
response.getAfcSettings()->setTx2RxDelayMs(settings.m_tx2RxDelayMs);
response.getAfcSettings()->setTrackerDeviceSetIndex(settings.m_trackerDeviceSetIndex);
response.getAfcSettings()->setTrackedDeviceSetIndex(settings.m_trackedDeviceSetIndex);
response.getAfcSettings()->setHasTargetFrequency(settings.m_hasTargetFrequency);
response.getAfcSettings()->setTransverterTarget(settings.m_transverterTarget);
response.getAfcSettings()->setTargetFrequency(settings.m_targetFrequency);
response.getAfcSettings()->setFreqTolerance(settings.m_freqTolerance);
response.getAfcSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
@ -321,17 +331,23 @@ void AFC::webapiUpdateFeatureSettings(
if (featureSettingsKeys.contains("rgbColor")) {
settings.m_rgbColor = response.getAfcSettings()->getRgbColor();
}
if (featureSettingsKeys.contains("rxDeviceSetIndex")) {
settings.m_rxDeviceSetIndex = response.getAfcSettings()->getRxDeviceSetIndex();
if (featureSettingsKeys.contains("trackerDeviceSetIndex")) {
settings.m_trackerDeviceSetIndex = response.getAfcSettings()->getTrackerDeviceSetIndex();
}
if (featureSettingsKeys.contains("txDeviceSetIndex")) {
settings.m_txDeviceSetIndex = response.getAfcSettings()->getTxDeviceSetIndex();
if (featureSettingsKeys.contains("trackedDeviceSetIndex")) {
settings.m_trackedDeviceSetIndex = response.getAfcSettings()->getTrackedDeviceSetIndex();
}
if (featureSettingsKeys.contains("rx2TxDelayMs")) {
settings.m_rx2TxDelayMs = response.getAfcSettings()->getRx2TxDelayMs();
if (featureSettingsKeys.contains("hasTargetFrequency")) {
settings.m_hasTargetFrequency = response.getAfcSettings()->getHasTargetFrequency() != 0;
}
if (featureSettingsKeys.contains("tx2RxDelayMs")) {
settings.m_tx2RxDelayMs = response.getAfcSettings()->getTx2RxDelayMs();
if (featureSettingsKeys.contains("hasTargetFrequency")) {
settings.m_hasTargetFrequency = response.getAfcSettings()->getHasTargetFrequency() != 0;
}
if (featureSettingsKeys.contains("targetFrequency")) {
settings.m_targetFrequency = response.getAfcSettings()->getTargetFrequency();
}
if (featureSettingsKeys.contains("freqTolerance")) {
settings.m_freqTolerance = response.getAfcSettings()->getFreqTolerance();
}
if (featureSettingsKeys.contains("useReverseAPI")) {
settings.m_useReverseAPI = response.getAfcSettings()->getUseReverseApi() != 0;
@ -372,17 +388,23 @@ void AFC::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const A
if (channelSettingsKeys.contains("rgbColor") || force) {
swgAFCSettings->setRgbColor(settings.m_rgbColor);
}
if (channelSettingsKeys.contains("rxDeviceSetIndex") || force) {
swgAFCSettings->setRxDeviceSetIndex(settings.m_rxDeviceSetIndex);
if (channelSettingsKeys.contains("trackerDeviceSetIndex") || force) {
swgAFCSettings->setTrackerDeviceSetIndex(settings.m_trackerDeviceSetIndex);
}
if (channelSettingsKeys.contains("txDeviceSetIndex") || force) {
swgAFCSettings->setTxDeviceSetIndex(settings.m_txDeviceSetIndex);
if (channelSettingsKeys.contains("trackedDeviceSetIndex") || force) {
swgAFCSettings->setTrackedDeviceSetIndex(settings.m_trackedDeviceSetIndex);
}
if (channelSettingsKeys.contains("rx2TxDelayMs") || force) {
swgAFCSettings->setRx2TxDelayMs(settings.m_rx2TxDelayMs);
if (channelSettingsKeys.contains("hasTargetFrequency") || force) {
swgAFCSettings->setHasTargetFrequency(settings.m_hasTargetFrequency ? 1 : 0);
}
if (channelSettingsKeys.contains("tx2RxDelayMs") || force) {
swgAFCSettings->setTx2RxDelayMs(settings.m_tx2RxDelayMs);
if (channelSettingsKeys.contains("targetFrequency") || force) {
swgAFCSettings->setTargetFrequency(settings.m_targetFrequency ? 1 : 0);
}
if (channelSettingsKeys.contains("targetFrequency") || force) {
swgAFCSettings->setTargetFrequency(settings.m_targetFrequency);
}
if (channelSettingsKeys.contains("freqTolerance") || force) {
swgAFCSettings->setFreqTolerance(settings.m_freqTolerance);
}
QString channelSettingsURL = QString("http://%1:%2/sdrangel/featureset/%3/feature/%4/settings")

View File

@ -18,8 +18,9 @@
#include <QMessageBox>
#include "feature/featureuiset.h"
#include "gui/basicfeaturesettingsdialog.h"
#include "device/deviceset.h"
#include "channel/channelapi.h"
#include "gui/basicfeaturesettingsdialog.h"
#include "maincore.h"
#include "ui_afcgui.h"
@ -89,17 +90,6 @@ bool AFCGUI::handleMessage(const Message& message)
return true;
}
else if (AFC::MsgPTT::match(message))
{
qDebug("AFCGUI::handleMessage: AFC::MsgPTT");
const AFC::MsgPTT& cfg = (AFC::MsgPTT&) message;
bool ptt = cfg.getTx();
blockApplySettings(true);
ui->ptt->setChecked(ptt);
blockApplySettings(false);
return true;
}
return false;
}
@ -132,10 +122,17 @@ AFCGUI::AFCGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet, Feature *featur
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose, true);
ui->targetFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold));
ui->targetFrequency->setValueRange(11, 0, 99999999999L);
ui->toleranceFrequency->setColorMapper(ColorMapper(ColorMapper::GrayYellow));
ui->toleranceFrequency->setValueRange(5, 0, 99999L);
setChannelWidget(false);
connect(this, SIGNAL(widgetRolled(QWidget*,bool)), this, SLOT(onWidgetRolled(QWidget*,bool)));
m_simplePTT = reinterpret_cast<AFC*>(feature);
m_simplePTT->setMessageQueueToGUI(&m_inputMessageQueue);
m_afc = reinterpret_cast<AFC*>(feature);
m_afc->setMessageQueueToGUI(&m_inputMessageQueue);
m_featureUISet->addRollupWidget(this);
@ -173,8 +170,10 @@ void AFCGUI::displaySettings()
setTitleColor(m_settings.m_rgbColor);
setWindowTitle(m_settings.m_title);
blockApplySettings(true);
ui->rxtxDelay->setValue(m_settings.m_rx2TxDelayMs);
ui->txrxDelay->setValue(m_settings.m_tx2RxDelayMs);
ui->hasTargetFrequency->setChecked(m_settings.m_hasTargetFrequency);
ui->transverterTarget->setChecked(m_settings.m_transverterTarget);
ui->targetFrequency->setValue(m_settings.m_targetFrequency);
ui->toleranceFrequency->setValue(m_settings.m_freqTolerance);
blockApplySettings(false);
}
@ -184,77 +183,74 @@ void AFCGUI::updateDeviceSetLists()
std::vector<DeviceSet*>& deviceSets = mainCore->getDeviceSets();
std::vector<DeviceSet*>::const_iterator it = deviceSets.begin();
ui->rxDevice->blockSignals(true);
ui->txDevice->blockSignals(true);
ui->trackerDevice->blockSignals(true);
ui->trackedDevice->blockSignals(true);
ui->trackerDevice->clear();
ui->trackedDevice->clear();
ui->rxDevice->clear();
ui->txDevice->clear();
unsigned int deviceIndex = 0;
unsigned int rxIndex = 0;
unsigned int txIndex = 0;
for (; it != deviceSets.end(); ++it, deviceIndex++)
{
DSPDeviceSourceEngine *deviceSourceEngine = (*it)->m_deviceSourceEngine;
DSPDeviceSinkEngine *deviceSinkEngine = (*it)->m_deviceSinkEngine;
if (deviceSourceEngine)
{
ui->rxDevice->addItem(QString("R%1").arg(deviceIndex), deviceIndex);
rxIndex++;
if (deviceSourceEngine) {
ui->trackedDevice->addItem(QString("R%1").arg(deviceIndex), deviceIndex);
} else if (deviceSinkEngine) {
ui->trackedDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex);
}
else if (deviceSinkEngine)
for (int chi = 0; chi < (*it)->getNumberOfChannels(); chi++)
{
ui->txDevice->addItem(QString("T%1").arg(deviceIndex), deviceIndex);
txIndex++;
ChannelAPI *channel = (*it)->getChannelAt(chi);
if (channel->getURI() == "sdrangel.channel.freqtracker")
{
ui->trackerDevice->addItem(QString("R%1").arg(deviceIndex), deviceIndex);
break;
}
}
}
int rxDeviceIndex;
int txDeviceIndex;
int trackedDeviceIndex;
int trackerDeviceIndex;
if (rxIndex > 0)
if (deviceIndex > 0)
{
if (m_settings.m_rxDeviceSetIndex < 0) {
ui->rxDevice->setCurrentIndex(0);
if (m_settings.m_trackedDeviceSetIndex < 0) {
ui->trackedDevice->setCurrentIndex(0);
} else {
ui->rxDevice->setCurrentIndex(m_settings.m_rxDeviceSetIndex);
ui->trackedDevice->setCurrentIndex(m_settings.m_trackedDeviceSetIndex);
}
rxDeviceIndex = ui->rxDevice->currentData().toInt();
if (m_settings.m_trackerDeviceSetIndex < 0) {
ui->trackerDevice->setCurrentIndex(0);
} else {
ui->trackerDevice->setCurrentIndex(m_settings.m_trackerDeviceSetIndex);
}
trackedDeviceIndex = ui->trackedDevice->currentData().toInt();
trackerDeviceIndex = ui->trackerDevice->currentData().toInt();
}
else
{
rxDeviceIndex = -1;
trackedDeviceIndex = -1;
trackerDeviceIndex = -1;
}
if (txIndex > 0)
if ((trackedDeviceIndex != m_settings.m_trackedDeviceSetIndex) ||
(trackerDeviceIndex != m_settings.m_trackerDeviceSetIndex))
{
if (m_settings.m_txDeviceSetIndex < 0) {
ui->txDevice->setCurrentIndex(0);
} else {
ui->txDevice->setCurrentIndex(m_settings.m_txDeviceSetIndex);
}
txDeviceIndex = ui->txDevice->currentData().toInt();
}
else
{
txDeviceIndex = -1;
}
if ((rxDeviceIndex != m_settings.m_rxDeviceSetIndex) ||
(txDeviceIndex != m_settings.m_txDeviceSetIndex))
{
qDebug("AFCGUI::updateDeviceSetLists: device index changed: %d:%d", rxDeviceIndex, txDeviceIndex);
m_settings.m_rxDeviceSetIndex = rxDeviceIndex;
m_settings.m_txDeviceSetIndex = txDeviceIndex;
qDebug("AFCGUI::updateDeviceSetLists: device index changed: %d:%d", trackerDeviceIndex, trackedDeviceIndex);
m_settings.m_trackerDeviceSetIndex = trackerDeviceIndex;
m_settings.m_trackedDeviceSetIndex = trackedDeviceIndex;
applySettings();
}
ui->rxDevice->blockSignals(false);
ui->txDevice->blockSignals(false);
ui->trackerDevice->blockSignals(false);
ui->trackedDevice->blockSignals(false);
}
void AFCGUI::leaveEvent(QEvent*)
@ -303,7 +299,7 @@ void AFCGUI::on_startStop_toggled(bool checked)
if (m_doApplySettings)
{
AFC::MsgStartStop *message = AFC::MsgStartStop::create(checked);
m_simplePTT->getInputMessageQueue()->push(message);
m_afc->getInputMessageQueue()->push(message);
}
}
@ -313,45 +309,52 @@ void AFCGUI::on_devicesRefresh_clicked()
displaySettings();
}
void AFCGUI::on_rxDevice_currentIndexChanged(int index)
void AFCGUI::on_hasTargetFrequency_toggled(bool checked)
{
m_settings.m_hasTargetFrequency = checked;
applySettings();
}
void AFCGUI::on_targetFrequency_changed(quint64 value)
{
m_settings.m_targetFrequency = value;
applySettings();
}
void AFCGUI::on_transverterTarget_toggled(bool checked)
{
m_settings.m_transverterTarget = checked;
applySettings();
}
void AFCGUI::on_trackerDevice_currentIndexChanged(int index)
{
if (index >= 0)
{
m_settings.m_rxDeviceSetIndex = index;
m_settings.m_trackerDeviceSetIndex = index;
applySettings();
}
}
void AFCGUI::on_txDevice_currentIndexChanged(int index)
void AFCGUI::on_trackedDevice_currentIndexChanged(int index)
{
if (index >= 0)
{
m_settings.m_txDeviceSetIndex = index;
m_settings.m_trackedDeviceSetIndex = index;
applySettings();
}
}
void AFCGUI::on_rxtxDelay_valueChanged(int value)
void AFCGUI::on_toleranceFrequency_changed(quint64 value)
{
m_settings.m_rx2TxDelayMs = value;
m_settings.m_freqTolerance = value;
applySettings();
}
void AFCGUI::on_txrxDelay_valueChanged(int value)
{
m_settings.m_tx2RxDelayMs = value;
applySettings();
}
void AFCGUI::on_ptt_toggled(bool checked)
{
applyPTT(checked);
}
void AFCGUI::updateStatus()
{
int state = m_simplePTT->getState();
int state = m_afc->getState();
if (m_lastFeatureState != state)
{
@ -368,7 +371,7 @@ void AFCGUI::updateStatus()
break;
case Feature::StError:
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
QMessageBox::information(this, tr("Message"), m_simplePTT->getErrorMessage());
QMessageBox::information(this, tr("Message"), m_afc->getErrorMessage());
break;
default:
break;
@ -383,15 +386,6 @@ void AFCGUI::applySettings(bool force)
if (m_doApplySettings)
{
AFC::MsgConfigureAFC* message = AFC::MsgConfigureAFC::create( m_settings, force);
m_simplePTT->getInputMessageQueue()->push(message);
}
}
void AFCGUI::applyPTT(bool tx)
{
if (m_doApplySettings)
{
AFC::MsgPTT* message = AFC::MsgPTT::create(tx);
m_simplePTT->getInputMessageQueue()->push(message);
m_afc->getInputMessageQueue()->push(message);
}
}

View File

@ -50,7 +50,7 @@ private:
AFCSettings m_settings;
bool m_doApplySettings;
AFC* m_simplePTT;
AFC* m_afc;
MessageQueue m_inputMessageQueue;
QTimer m_statusTimer;
int m_lastFeatureState;
@ -62,7 +62,6 @@ private:
void blockApplySettings(bool block);
void applySettings(bool force = false);
void applyPTT(bool tx);
void displaySettings();
void updateDeviceSetLists();
bool handleMessage(const Message& message);
@ -75,12 +74,13 @@ private slots:
void onWidgetRolled(QWidget* widget, bool rollDown);
void handleInputMessages();
void on_startStop_toggled(bool checked);
void on_hasTargetFrequency_toggled(bool checked);
void on_devicesRefresh_clicked();
void on_rxDevice_currentIndexChanged(int index);
void on_txDevice_currentIndexChanged(int index);
void on_rxtxDelay_valueChanged(int value);
void on_txrxDelay_valueChanged(int value);
void on_ptt_toggled(bool checked);
void on_transverterTarget_toggled(bool checked);
void on_targetFrequency_changed(quint64 value);
void on_trackerDevice_currentIndexChanged(int index);
void on_trackedDevice_currentIndexChanged(int index);
void on_toleranceFrequency_changed(quint64 value);
void updateStatus();
};

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<width>340</width>
<height>181</height>
</rect>
</property>
@ -18,16 +18,10 @@
</property>
<property name="minimumSize">
<size>
<width>320</width>
<width>340</width>
<height>100</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>320</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Sans</family>
@ -42,7 +36,7 @@
<rect>
<x>10</x>
<y>10</y>
<width>301</width>
<width>311</width>
<height>151</height>
</rect>
</property>
@ -66,7 +60,7 @@
<number>2</number>
</property>
<item>
<layout class="QHBoxLayout" name="pttLayout">
<layout class="QHBoxLayout" name="mainLayout">
<item>
<widget class="ButtonSwitch" name="startStop">
<property name="toolTip">
@ -83,30 +77,17 @@
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="ptt">
<property name="minimumSize">
<size>
<width>200</width>
<height>50</height>
</size>
</property>
<property name="font">
<font>
<pointsize>20</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<widget class="ButtonSwitch" name="hasTargetFrequency">
<property name="toolTip">
<string>Push To Talk</string>
<string>Adjust device frequency to match tracker frequency</string>
</property>
<property name="text">
<string>PTT</string>
<string>T</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="statusIndicator">
<widget class="ValueDial" name="targetFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
@ -115,25 +96,48 @@
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>Idle</string>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">QLabel { background-color: gray; border-radius: 12px; }</string>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Tracker frequency in Hz</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="targetFrequencyUnits">
<property name="text">
<string>Hz</string>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="transverterTarget">
<property name="toolTip">
<string>Use transverter or device frequency for tracker frequency adjustment</string>
</property>
<property name="text">
<string/>
<string>X</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="localDeviceLayout">
<layout class="QHBoxLayout" name="devicesLayout">
<item>
<widget class="QPushButton" name="devicesRefresh">
<property name="maximumSize">
@ -155,14 +159,14 @@
</widget>
</item>
<item>
<widget class="QLabel" name="rxDeviceLabel">
<widget class="QLabel" name="trackerLabel">
<property name="text">
<string>Rx dev</string>
<string>Tracker</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="rxDevice">
<widget class="QComboBox" name="trackerDevice">
<property name="minimumSize">
<size>
<width>55</width>
@ -176,7 +180,7 @@
</size>
</property>
<property name="toolTip">
<string>Receiver deviceset index</string>
<string>Tracker deviceset index</string>
</property>
</widget>
</item>
@ -194,14 +198,14 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="txDeviceLabel">
<widget class="QLabel" name="trackedLabel">
<property name="text">
<string>Tx dev</string>
<string>Tracked</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="txDevice">
<widget class="QComboBox" name="trackedDevice">
<property name="minimumSize">
<size>
<width>55</width>
@ -215,7 +219,7 @@
</size>
</property>
<property name="toolTip">
<string>Transmitter deviceset index</string>
<string>Tracked deviceset index</string>
</property>
</widget>
</item>
@ -224,32 +228,50 @@
<item>
<layout class="QHBoxLayout" name="DelaysLayout">
<item>
<widget class="QLabel" name="rxtxDelayLabel">
<property name="text">
<string>Rx-Tx </string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="rxtxDelay">
<widget class="QLabel" name="toleranceLabel">
<property name="toolTip">
<string>Rx to Tx transition delay (ms)</string>
<string/>
</property>
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="singleStep">
<number>100</number>
<property name="text">
<string>Tol</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="rxtxDelayUnits">
<widget class="ValueDial" name="toleranceFrequency" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>32</width>
<height>16</height>
</size>
</property>
<property name="font">
<font>
<family>Liberation Mono</family>
<pointsize>12</pointsize>
</font>
</property>
<property name="cursor">
<cursorShape>PointingHandCursor</cursorShape>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="toolTip">
<string>Frequency tolerance before device frequency is changed (Hz)</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="toleranceUnits">
<property name="text">
<string>ms</string>
<string>Hz</string>
</property>
</widget>
</item>
@ -267,36 +289,28 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="txrxDelayLabel">
<widget class="QLabel" name="statusIndicator">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>Idle</string>
</property>
<property name="styleSheet">
<string notr="true">QLabel { background-color: gray; border-radius: 8px; }</string>
</property>
<property name="text">
<string/>
</property>
<property name="text">
<string>Tx-Rx</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="txrxDelay">
<property name="toolTip">
<string>Tx to Rx transition delay (ms)</string>
</property>
<property name="minimum">
<number>100</number>
</property>
<property name="maximum">
<number>5000</number>
</property>
<property name="singleStep">
<number>100</number>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="txrxDelayUnits">
<property name="text">
<string>ms</string>
</property>
</widget>
</item>
</layout>
@ -316,6 +330,12 @@
<extends>QToolButton</extends>
<header>gui/buttonswitch.h</header>
</customwidget>
<customwidget>
<class>ValueDial</class>
<extends>QWidget</extends>
<header>gui/valuedial.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../../sdrgui/resources/res.qrc"/>

View File

@ -31,10 +31,12 @@ void AFCSettings::resetToDefaults()
{
m_title = "AFC";
m_rgbColor = QColor(255, 255, 0).rgb();
m_rxDeviceSetIndex = -1;
m_txDeviceSetIndex = -1;
m_rx2TxDelayMs = 100;
m_tx2RxDelayMs = 100;
m_trackerDeviceSetIndex = -1;
m_trackedDeviceSetIndex = -1;
m_hasTargetFrequency = false;
m_transverterTarget = false;
m_targetFrequency = 0;
m_freqTolerance = 1000;
m_useReverseAPI = false;
m_reverseAPIAddress = "127.0.0.1";
m_reverseAPIPort = 8888;
@ -48,15 +50,17 @@ QByteArray AFCSettings::serialize() const
s.writeString(1, m_title);
s.writeU32(2, m_rgbColor);
s.writeS32(3, m_rxDeviceSetIndex);
s.writeS32(4, m_txDeviceSetIndex);
s.writeU32(5, m_rx2TxDelayMs);
s.writeU32(6, m_tx2RxDelayMs);
s.writeBool(7, m_useReverseAPI);
s.writeString(8, m_reverseAPIAddress);
s.writeU32(9, m_reverseAPIPort);
s.writeU32(10, m_reverseAPIFeatureSetIndex);
s.writeU32(11, m_reverseAPIFeatureIndex);
s.writeS32(3, m_trackerDeviceSetIndex);
s.writeS32(5, m_trackedDeviceSetIndex);
s.writeBool(6, m_hasTargetFrequency);
s.writeBool(7, m_transverterTarget);
s.writeU64(8, m_targetFrequency);
s.writeU64(9, m_freqTolerance);
s.writeBool(10, m_useReverseAPI);
s.writeString(11, m_reverseAPIAddress);
s.writeU32(12, m_reverseAPIPort);
s.writeU32(13, m_reverseAPIFeatureSetIndex);
s.writeU32(14, m_reverseAPIFeatureIndex);
return s.final();
}
@ -80,13 +84,15 @@ bool AFCSettings::deserialize(const QByteArray& data)
d.readString(1, &m_title, "AFC");
d.readU32(2, &m_rgbColor, QColor(255, 255, 0).rgb());
d.readS32(3, &m_rxDeviceSetIndex, -1);
d.readS32(4, &m_txDeviceSetIndex, -1);
d.readU32(5, &m_rx2TxDelayMs, 100);
d.readU32(6, &m_tx2RxDelayMs, 100);
d.readBool(7, &m_useReverseAPI, false);
d.readString(8, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(9, &utmp, 0);
d.readS32(3, &m_trackerDeviceSetIndex, -1);
d.readS32(5, &m_trackedDeviceSetIndex, -1);
d.readBool(6, &m_hasTargetFrequency, false);
d.readBool(7, &m_transverterTarget, false);
d.readU64(8, &m_targetFrequency, 0);
d.readU64(9, &m_freqTolerance, 1000);
d.readBool(10, &m_useReverseAPI, false);
d.readString(11, &m_reverseAPIAddress, "127.0.0.1");
d.readU32(12, &utmp, 0);
if ((utmp > 1023) && (utmp < 65535)) {
m_reverseAPIPort = utmp;
@ -94,9 +100,9 @@ bool AFCSettings::deserialize(const QByteArray& data)
m_reverseAPIPort = 8888;
}
d.readU32(10, &utmp, 0);
d.readU32(13, &utmp, 0);
m_reverseAPIFeatureSetIndex = utmp > 99 ? 99 : utmp;
d.readU32(11, &utmp, 0);
d.readU32(14, &utmp, 0);
m_reverseAPIFeatureIndex = utmp > 99 ? 99 : utmp;
return true;

View File

@ -27,10 +27,12 @@ struct AFCSettings
{
QString m_title;
quint32 m_rgbColor;
int m_rxDeviceSetIndex;
int m_txDeviceSetIndex;
unsigned int m_rx2TxDelayMs;
unsigned int m_tx2RxDelayMs;
int m_trackerDeviceSetIndex; //!< will take the first instance of freq tracker in the list of channels
int m_trackedDeviceSetIndex;
bool m_hasTargetFrequency;
bool m_transverterTarget;
quint64 m_targetFrequency;
quint64 m_freqTolerance;
bool m_useReverseAPI;
QString m_reverseAPIAddress;
uint16_t m_reverseAPIPort;

View File

@ -37,7 +37,6 @@ AFCWorker::AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface) :
m_mutex(QMutex::Recursive)
{
qDebug("AFCWorker::AFCWorker");
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
}
AFCWorker::~AFCWorker()
@ -90,15 +89,6 @@ bool AFCWorker::handleMessage(const Message& cmd)
return true;
}
else if (MsgPTT::match(cmd))
{
MsgPTT& cfg = (MsgPTT&) cmd;
qDebug() << "AFCWorker::handleMessage: MsgPTT";
sendPTT(cfg.getTx());
return true;
}
else
{
return false;
@ -110,101 +100,12 @@ void AFCWorker::applySettings(const AFCSettings& settings, bool force)
qDebug() << "AFCWorker::applySettings:"
<< " m_title: " << settings.m_title
<< " m_rgbColor: " << settings.m_rgbColor
<< " m_rxDeviceSetIndex: " << settings.m_rxDeviceSetIndex
<< " m_txDeviceSetIndex: " << settings.m_txDeviceSetIndex
<< " m_rx2TxDelayMs: " << settings.m_rx2TxDelayMs
<< " m_tx2RxDelayMs: " << settings.m_tx2RxDelayMs
<< " m_trackerDeviceSetIndex: " << settings.m_trackerDeviceSetIndex
<< " m_trackedDeviceSetIndex: " << settings.m_trackedDeviceSetIndex
<< " m_hasTargetFrequency: " << settings.m_hasTargetFrequency
<< " m_transverterTarget: " << settings.m_transverterTarget
<< " m_targetFrequency: " << settings.m_targetFrequency
<< " m_freqTolerance: " << settings.m_freqTolerance
<< " force: " << force;
m_settings = settings;
}
void AFCWorker::sendPTT(bool tx)
{
if (!m_updateTimer.isActive())
{
bool switchedOff = false;
m_mutex.lock();
if (tx)
{
if (m_settings.m_rxDeviceSetIndex >= 0)
{
m_tx = false;
switchedOff = turnDevice(false);
}
if (m_settings.m_txDeviceSetIndex >= 0)
{
m_tx = true;
m_updateTimer.start(m_settings.m_rx2TxDelayMs);
}
}
else
{
if (m_settings.m_txDeviceSetIndex >= 0)
{
m_tx = true;
switchedOff = turnDevice(false);
}
if (m_settings.m_rxDeviceSetIndex >= 0)
{
m_tx = false;
m_updateTimer.start(m_settings.m_tx2RxDelayMs);
}
}
if (switchedOff && (m_msgQueueToGUI))
{
AFCReport::MsgRadioState *msg = AFCReport::MsgRadioState::create(AFCReport::RadioIdle);
m_msgQueueToGUI->push(msg);
}
}
}
void AFCWorker::updateHardware()
{
SWGSDRangel::SWGSuccessResponse response;
SWGSDRangel::SWGErrorResponse error;
m_updateTimer.stop();
m_mutex.unlock();
if (turnDevice(true))
{
m_webAPIAdapterInterface->devicesetFocusPatch(
m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error);
if (m_msgQueueToGUI)
{
AFCReport::MsgRadioState *msg = AFCReport::MsgRadioState::create(
m_tx ? AFCReport::RadioTx : AFCReport::RadioRx
);
m_msgQueueToGUI->push(msg);
}
}
}
bool AFCWorker::turnDevice(bool on)
{
SWGSDRangel::SWGDeviceState response;
SWGSDRangel::SWGErrorResponse error;
int httpCode;
if (on) {
httpCode = m_webAPIAdapterInterface->devicesetDeviceRunPost(
m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error);
} else {
httpCode = m_webAPIAdapterInterface->devicesetDeviceRunDelete(
m_tx ? m_settings.m_txDeviceSetIndex : m_settings.m_rxDeviceSetIndex, response, error);
}
if (httpCode/100 == 2)
{
return true;
}
else
{
qWarning("AFCWorker::turnDevice: error: %s", qPrintable(*error.getMessage()));
return false;
}
}

View File

@ -95,12 +95,9 @@ private:
bool handleMessage(const Message& cmd);
void applySettings(const AFCSettings& settings, bool force = false);
void sendPTT(bool tx);
bool turnDevice(bool on);
private slots:
void handleInputMessages();
void updateHardware();
};
#endif // INCLUDE_FEATURE_SIMPLEPTTWORKER_H_