diff --git a/plugins/feature/afc/afc.cpp b/plugins/feature/afc/afc.cpp index 5f33e1a76..54aaba6a9 100644 --- a/plugins/feature/afc/afc.cpp +++ b/plugins/feature/afc/afc.cpp @@ -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 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& 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") diff --git a/plugins/feature/afc/afcgui.cpp b/plugins/feature/afc/afcgui.cpp index 9d7ae8353..cba3a803d 100644 --- a/plugins/feature/afc/afcgui.cpp +++ b/plugins/feature/afc/afcgui.cpp @@ -18,8 +18,9 @@ #include #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(feature); - m_simplePTT->setMessageQueueToGUI(&m_inputMessageQueue); + m_afc = reinterpret_cast(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& deviceSets = mainCore->getDeviceSets(); std::vector::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); } } diff --git a/plugins/feature/afc/afcgui.h b/plugins/feature/afc/afcgui.h index 0faa09d7d..7b04f6382 100644 --- a/plugins/feature/afc/afcgui.h +++ b/plugins/feature/afc/afcgui.h @@ -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(); }; diff --git a/plugins/feature/afc/afcgui.ui b/plugins/feature/afc/afcgui.ui index d11eb6964..bfbef1f4c 100644 --- a/plugins/feature/afc/afcgui.ui +++ b/plugins/feature/afc/afcgui.ui @@ -6,7 +6,7 @@ 0 0 - 320 + 340 181 @@ -18,16 +18,10 @@ - 320 + 340 100 - - - 320 - 16777215 - - Liberation Sans @@ -42,7 +36,7 @@ 10 10 - 301 + 311 151 @@ -66,7 +60,7 @@ 2 - + @@ -83,30 +77,17 @@ - - - - 200 - 50 - - - - - 20 - 75 - true - - + - Push To Talk + Adjust device frequency to match tracker frequency - PTT + T - + 0 @@ -115,25 +96,48 @@ - 24 - 24 + 32 + 16 - - Idle + + + Liberation Mono + 12 + - - QLabel { background-color: gray; border-radius: 12px; } + + PointingHandCursor + + + Qt::StrongFocus + + + Tracker frequency in Hz + + + + + + + Hz + + + + + + + Use transverter or device frequency for tracker frequency adjustment - + X - + @@ -155,14 +159,14 @@ - + - Rx dev + Tracker - + 55 @@ -176,7 +180,7 @@ - Receiver deviceset index + Tracker deviceset index @@ -194,14 +198,14 @@ - + - Tx dev + Tracked - + 55 @@ -215,7 +219,7 @@ - Transmitter deviceset index + Tracked deviceset index @@ -224,32 +228,50 @@ - - - Rx-Tx - - - - - + - Rx to Tx transition delay (ms) + - - 100 - - - 5000 - - - 100 + + Tol - + + + + 0 + 0 + + + + + 32 + 16 + + + + + Liberation Mono + 12 + + + + PointingHandCursor + + + Qt::StrongFocus + + + Frequency tolerance before device frequency is changed (Hz) + + + + + - ms + Hz @@ -267,36 +289,28 @@ - + + + + 0 + 0 + + + + + 16 + 16 + + + Idle + + + QLabel { background-color: gray; border-radius: 8px; } + + - - Tx-Rx - - - - - - - Tx to Rx transition delay (ms) - - - 100 - - - 5000 - - - 100 - - - - - - - ms - @@ -316,6 +330,12 @@ QToolButton
gui/buttonswitch.h
+ + ValueDial + QWidget +
gui/valuedial.h
+ 1 +
diff --git a/plugins/feature/afc/afcsettings.cpp b/plugins/feature/afc/afcsettings.cpp index 8ab695009..4ca1bf8c4 100644 --- a/plugins/feature/afc/afcsettings.cpp +++ b/plugins/feature/afc/afcsettings.cpp @@ -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; diff --git a/plugins/feature/afc/afcsettings.h b/plugins/feature/afc/afcsettings.h index 8dcf0c8b1..e633e612f 100644 --- a/plugins/feature/afc/afcsettings.h +++ b/plugins/feature/afc/afcsettings.h @@ -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; diff --git a/plugins/feature/afc/afcworker.cpp b/plugins/feature/afc/afcworker.cpp index 1891b4a77..dfd7fb339 100644 --- a/plugins/feature/afc/afcworker.cpp +++ b/plugins/feature/afc/afcworker.cpp @@ -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; - } -} diff --git a/plugins/feature/afc/afcworker.h b/plugins/feature/afc/afcworker.h index 86ef75b22..bc074bfd4 100644 --- a/plugins/feature/afc/afcworker.h +++ b/plugins/feature/afc/afcworker.h @@ -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_