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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -37,7 +37,6 @@ AFCWorker::AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface) :
m_mutex(QMutex::Recursive) m_mutex(QMutex::Recursive)
{ {
qDebug("AFCWorker::AFCWorker"); qDebug("AFCWorker::AFCWorker");
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
} }
AFCWorker::~AFCWorker() AFCWorker::~AFCWorker()
@ -90,15 +89,6 @@ bool AFCWorker::handleMessage(const Message& cmd)
return true; return true;
} }
else if (MsgPTT::match(cmd))
{
MsgPTT& cfg = (MsgPTT&) cmd;
qDebug() << "AFCWorker::handleMessage: MsgPTT";
sendPTT(cfg.getTx());
return true;
}
else else
{ {
return false; return false;
@ -110,101 +100,12 @@ void AFCWorker::applySettings(const AFCSettings& settings, bool force)
qDebug() << "AFCWorker::applySettings:" qDebug() << "AFCWorker::applySettings:"
<< " m_title: " << settings.m_title << " m_title: " << settings.m_title
<< " m_rgbColor: " << settings.m_rgbColor << " m_rgbColor: " << settings.m_rgbColor
<< " m_rxDeviceSetIndex: " << settings.m_rxDeviceSetIndex << " m_trackerDeviceSetIndex: " << settings.m_trackerDeviceSetIndex
<< " m_txDeviceSetIndex: " << settings.m_txDeviceSetIndex << " m_trackedDeviceSetIndex: " << settings.m_trackedDeviceSetIndex
<< " m_rx2TxDelayMs: " << settings.m_rx2TxDelayMs << " m_hasTargetFrequency: " << settings.m_hasTargetFrequency
<< " m_tx2RxDelayMs: " << settings.m_tx2RxDelayMs << " m_transverterTarget: " << settings.m_transverterTarget
<< " m_targetFrequency: " << settings.m_targetFrequency
<< " m_freqTolerance: " << settings.m_freqTolerance
<< " force: " << force; << " force: " << force;
m_settings = settings; 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); bool handleMessage(const Message& cmd);
void applySettings(const AFCSettings& settings, bool force = false); void applySettings(const AFCSettings& settings, bool force = false);
void sendPTT(bool tx);
bool turnDevice(bool on);
private slots: private slots:
void handleInputMessages(); void handleInputMessages();
void updateHardware();
}; };
#endif // INCLUDE_FEATURE_SIMPLEPTTWORKER_H_ #endif // INCLUDE_FEATURE_SIMPLEPTTWORKER_H_