diff --git a/plugins/feature/afc/afc.cpp b/plugins/feature/afc/afc.cpp index 21801de97..a74572c4c 100644 --- a/plugins/feature/afc/afc.cpp +++ b/plugins/feature/afc/afc.cpp @@ -37,6 +37,8 @@ MESSAGE_CLASS_DEFINITION(AFC::MsgConfigureAFC, Message) MESSAGE_CLASS_DEFINITION(AFC::MsgStartStop, Message) +MESSAGE_CLASS_DEFINITION(AFC::MsgDeviceTrack, Message) +MESSAGE_CLASS_DEFINITION(AFC::MsgDevicesApply, Message) const QString AFC::m_featureIdURI = "sdrangel.feature.afc"; const QString AFC::m_featureId = "AFC"; @@ -125,6 +127,26 @@ bool AFC::handleMessage(const Message& cmd) return true; } } + else if (MsgDeviceTrack::match(cmd)) + { + if (m_worker->isRunning()) + { + AFCWorker::MsgDeviceTrack *msg = AFCWorker::MsgDeviceTrack::create(); + m_worker->getInputMessageQueue()->push(msg); + } + + return true; + } + else if (MsgDevicesApply::match(cmd)) + { + if (m_worker->isRunning()) + { + AFCWorker::MsgDevicesApply *msg = AFCWorker::MsgDevicesApply::create(); + m_worker->getInputMessageQueue()->push(msg); + } + + return true; + } return false; } diff --git a/plugins/feature/afc/afc.h b/plugins/feature/afc/afc.h index 9ac4c1850..d29ba0ff8 100644 --- a/plugins/feature/afc/afc.h +++ b/plugins/feature/afc/afc.h @@ -81,6 +81,32 @@ public: { } }; + class MsgDeviceTrack : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgDeviceTrack* create() { + return new MsgDeviceTrack(); + } + protected: + MsgDeviceTrack() : + Message() + { } + }; + + class MsgDevicesApply : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgDevicesApply* create() { + return new MsgDevicesApply(); + } + protected: + MsgDevicesApply() : + Message() + { } + }; + AFC(WebAPIAdapterInterface *webAPIAdapterInterface); virtual ~AFC(); virtual void destroy() { delete this; } diff --git a/plugins/feature/afc/afcgui.cpp b/plugins/feature/afc/afcgui.cpp index cba3a803d..fc4f3cf7b 100644 --- a/plugins/feature/afc/afcgui.cpp +++ b/plugins/feature/afc/afcgui.cpp @@ -303,12 +303,6 @@ void AFCGUI::on_startStop_toggled(bool checked) } } -void AFCGUI::on_devicesRefresh_clicked() -{ - updateDeviceSetLists(); - displaySettings(); -} - void AFCGUI::on_hasTargetFrequency_toggled(bool checked) { m_settings.m_hasTargetFrequency = checked; @@ -327,6 +321,25 @@ void AFCGUI::on_transverterTarget_toggled(bool checked) applySettings(); } + +void AFCGUI::on_toleranceFrequency_changed(quint64 value) +{ + m_settings.m_freqTolerance = value; + applySettings(); +} + +void AFCGUI::on_deviceTrack_clicked() +{ + AFC::MsgDeviceTrack *msg = AFC::MsgDeviceTrack::create(); + m_afc->getInputMessageQueue()->push(msg); +} + +void AFCGUI::on_devicesRefresh_clicked() +{ + updateDeviceSetLists(); + displaySettings(); +} + void AFCGUI::on_trackerDevice_currentIndexChanged(int index) { if (index >= 0) @@ -345,11 +358,9 @@ void AFCGUI::on_trackedDevice_currentIndexChanged(int index) } } - -void AFCGUI::on_toleranceFrequency_changed(quint64 value) +void AFCGUI::on_devicesApply_clicked() { - m_settings.m_freqTolerance = value; - applySettings(); + } void AFCGUI::updateStatus() diff --git a/plugins/feature/afc/afcgui.h b/plugins/feature/afc/afcgui.h index 7b04f6382..83e469f8d 100644 --- a/plugins/feature/afc/afcgui.h +++ b/plugins/feature/afc/afcgui.h @@ -75,12 +75,14 @@ private slots: void handleInputMessages(); void on_startStop_toggled(bool checked); void on_hasTargetFrequency_toggled(bool checked); - void on_devicesRefresh_clicked(); - void on_transverterTarget_toggled(bool checked); void on_targetFrequency_changed(quint64 value); + void on_transverterTarget_toggled(bool checked); + void on_toleranceFrequency_changed(quint64 value); + void on_deviceTrack_clicked(); + void on_devicesRefresh_clicked(); void on_trackerDevice_currentIndexChanged(int index); void on_trackedDevice_currentIndexChanged(int index); - void on_toleranceFrequency_changed(quint64 value); + void on_devicesApply_clicked(); void updateStatus(); }; diff --git a/plugins/feature/afc/afcgui.ui b/plugins/feature/afc/afcgui.ui index cef53c7ce..6bd30d584 100644 --- a/plugins/feature/afc/afcgui.ui +++ b/plugins/feature/afc/afcgui.ui @@ -137,96 +137,7 @@ - - - - - - 24 - 16777215 - - - - Refresh indexes of available device sets - - - - - - - :/recycle.png:/recycle.png - - - - - - - Tracker - - - - - - - - 55 - 0 - - - - - 50 - 16777215 - - - - Tracker deviceset index - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Tracked - - - - - - - - 55 - 0 - - - - - 50 - 16777215 - - - - Tracked deviceset index - - - - - - - + @@ -275,6 +186,26 @@ + + + + + 24 + 24 + + + + Force device tracking update + + + + + + + :/arrow_left.png:/arrow_left.png + + + @@ -315,6 +246,115 @@ + + + + + + + 24 + 16777215 + + + + Refresh indexes of available device sets + + + + + + + :/recycle.png:/recycle.png + + + + + + + Tracker + + + + + + + + 55 + 0 + + + + + 50 + 16777215 + + + + Tracker deviceset index + + + + + + + Tracked + + + + + + + + 55 + 0 + + + + + 50 + 16777215 + + + + Tracked deviceset index + + + + + + + + 24 + 24 + + + + Reinitialization of device data + + + + + + + :/arrow_left.png:/arrow_left.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + diff --git a/plugins/feature/afc/afcworker.cpp b/plugins/feature/afc/afcworker.cpp index 731765e3d..cec3f59e4 100644 --- a/plugins/feature/afc/afcworker.cpp +++ b/plugins/feature/afc/afcworker.cpp @@ -36,6 +36,8 @@ MESSAGE_CLASS_DEFINITION(AFCWorker::MsgConfigureAFCWorker, Message) MESSAGE_CLASS_DEFINITION(AFCWorker::MsgTrackedDeviceChange, Message) +MESSAGE_CLASS_DEFINITION(AFCWorker::MsgDeviceTrack, Message) +MESSAGE_CLASS_DEFINITION(AFCWorker::MsgDevicesApply, Message) AFCWorker::AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface) : m_webAPIAdapterInterface(webAPIAdapterInterface), @@ -101,15 +103,28 @@ bool AFCWorker::handleMessage(const Message& cmd) } else if (Feature::MsgChannelSettings::match(cmd)) { - qDebug() << "AFCWorker::handleMessage: Feature::MsgChannelSettings"; QMutexLocker mutexLocker(&m_mutex); Feature::MsgChannelSettings& cfg = (Feature::MsgChannelSettings&) cmd; SWGSDRangel::SWGChannelSettings *swgChannelSettings = cfg.getSWGSettings(); + qDebug() << "AFCWorker::handleMessage: Feature::MsgChannelSettings:" << *swgChannelSettings->getChannelType(); processChannelSettings(cfg.getChannelAPI(), cfg.getChannelSettingsKeys(), swgChannelSettings); delete swgChannelSettings; return true; } + else if (MsgDeviceTrack::match(cmd)) + { + QMutexLocker mutexLocker(&m_mutex); + updateTarget(); + return true; + } + else if (MsgDevicesApply::match(cmd)) + { + QMutexLocker mutexLocker(&m_mutex); + initTrackerDeviceSet(m_settings.m_trackerDeviceSetIndex); + initTrackedDeviceSet(m_settings.m_trackedDeviceSetIndex); + return true; + } else { return false; @@ -286,7 +301,7 @@ void AFCWorker::processChannelSettings( } } -bool AFCWorker::updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset) +bool AFCWorker::updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset, unsigned int blockCount) { SWGSDRangel::SWGChannelSettings swgChannelSettings; SWGSDRangel::SWGErrorResponse errorResponse; @@ -306,6 +321,7 @@ bool AFCWorker::updateChannelOffset(ChannelAPI *channelAPI, int direction, int o .arg(jsonSettingsStr); swgChannelSettings.fromJson(jsonStr); + channelAPI->setFeatureSettingsFeedbackBlockCount(1); int httpRC = m_webAPIAdapterInterface->devicesetChannelSettingsPutPatch( m_trackedDeviceSet->getIndex(), channelAPI->getIndexInDeviceSet(), @@ -344,20 +360,20 @@ void AFCWorker::updateTarget() } else { - qDebug() << "AFCWorker::initTrackerDeviceSet: cannot find device frequency"; + qDebug() << "AFCWorker::updateTarget: cannot find device frequency"; return; } } else { - qDebug() << "AFCWorker::initTrackerDeviceSet: devicesetDeviceSettingsGet error" << rc << ":" << *error.getMessage(); + qDebug() << "AFCWorker::updateTarget: devicesetDeviceSettingsGet error" << rc << ":" << *error.getMessage(); return; } int64_t trackerFrequency = m_trackerDeviceFrequency + m_trackerChannelOffset; int64_t correction = m_settings.m_targetFrequency - trackerFrequency; int64_t tolerance = m_settings.m_freqTolerance; - qDebug() << "AFCWorker::initTrackerDeviceSet: correction:" << correction << "tolerance:" << tolerance; + qDebug() << "AFCWorker::updateTarget: correction:" << correction << "tolerance:" << tolerance; if ((correction > -tolerance) && (correction < tolerance)) { return; @@ -376,12 +392,12 @@ void AFCWorker::updateTarget() } else { - qDebug() << "AFCWorker::initTrackerDeviceSet: cannot find device transverter frequency"; + qDebug() << "AFCWorker::updateTarget: cannot find device transverter frequency"; return; } // adjust tracker offset - if (updateChannelOffset(m_freqTracker, 0, m_trackerChannelOffset + correction)) { + if (updateChannelOffset(m_freqTracker, 0, m_trackerChannelOffset + correction, 1)) { m_trackerChannelOffset += correction; } } @@ -397,7 +413,7 @@ void AFCWorker::updateTarget() } else { - qDebug() << "AFCWorker::initTrackerDeviceSet: cannot find device transverter frequency"; + qDebug() << "AFCWorker::updateTarget: cannot find device transverter frequency"; return; } } @@ -415,6 +431,10 @@ bool AFCWorker::updateDeviceFrequency(DeviceSet *deviceSet, const QString& key, QString jsonSettingsStr = tr("\"%1\":%2").arg(key).arg(frequency); QString deviceSettingsKey; getDeviceSettingsKey(deviceAPI, deviceSettingsKey); + qDebug() << "AFCWorker::updateDeviceFrequency:" + << deviceAPI->getHardwareId() + << ":" << key + << ":" << frequency; QString jsonStr = tr("{ \"deviceHwType\": \"%1\", \"direction\": \"%2\", \"%3\": {%4}}") .arg(deviceAPI->getHardwareId()) @@ -422,7 +442,6 @@ bool AFCWorker::updateDeviceFrequency(DeviceSet *deviceSet, const QString& key, .arg(deviceSettingsKey) .arg(jsonSettingsStr); swgDeviceSettings.fromJson(jsonStr); - qDebug() << "AFCWorker::updateDeviceFrequency:" << jsonStr; int httpRC = m_webAPIAdapterInterface->devicesetDeviceSettingsPutPatch ( diff --git a/plugins/feature/afc/afcworker.h b/plugins/feature/afc/afcworker.h index 38bf4df24..3035f11aa 100644 --- a/plugins/feature/afc/afcworker.h +++ b/plugins/feature/afc/afcworker.h @@ -78,6 +78,32 @@ public: { } }; + class MsgDeviceTrack : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgDeviceTrack* create() { + return new MsgDeviceTrack(); + } + protected: + MsgDeviceTrack() : + Message() + { } + }; + + class MsgDevicesApply : public Message { + MESSAGE_CLASS_DECLARATION + + public: + static MsgDevicesApply* create() { + return new MsgDevicesApply(); + } + protected: + MsgDevicesApply() : + Message() + { } + }; + AFCWorker(WebAPIAdapterInterface *webAPIAdapterInterface); ~AFCWorker(); void reset(); @@ -136,7 +162,7 @@ private: const QList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings *swgChannelSettings ); - bool updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset); + bool updateChannelOffset(ChannelAPI *channelAPI, int direction, int offset, unsigned int blockCount = 0); void updateTarget(); bool updateDeviceFrequency(DeviceSet *deviceSet, const QString& key, int64_t frequency); int getDeviceDirection(DeviceAPI *deviceAPI);