From 1235f713884c9b83a8bb82bf94c58a489f97f663 Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 5 Nov 2024 10:09:09 +0000 Subject: [PATCH 1/4] Freuqency Scanner: Add multiplex mode. --- plugins/channelrx/freqscanner/freqscanner.cpp | 58 +++++++++++++++++-- plugins/channelrx/freqscanner/freqscanner.h | 3 +- .../channelrx/freqscanner/freqscannergui.cpp | 16 +++++ .../channelrx/freqscanner/freqscannergui.ui | 53 +++++++++-------- .../freqscanner/freqscannersettings.h | 3 +- plugins/channelrx/freqscanner/readme.md | 15 ++++- 6 files changed, 116 insertions(+), 32 deletions(-) diff --git a/plugins/channelrx/freqscanner/freqscanner.cpp b/plugins/channelrx/freqscanner/freqscanner.cpp index e5d62b59f..c2f98796e 100644 --- a/plugins/channelrx/freqscanner/freqscanner.cpp +++ b/plugins/channelrx/freqscanner/freqscanner.cpp @@ -377,6 +377,7 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< bool freqInRange = false; qint64 nextCenterFrequency = m_centerFrequency; int usableBW = (m_scannerSampleRate * 3 / 4) & ~1; + int nextFrequencyIndex = 0; do { if (nextCenterFrequency + usableBW / 2 > m_stepStopFrequency) @@ -398,13 +399,30 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< && (m_settings.m_frequencySettings[i].m_frequency < nextCenterFrequency + usableBW / 2)) { freqInRange = true; + nextFrequencyIndex = i; + + // Do we need to realign for frequencies with wider bandwidths than default + if (!m_settings.m_frequencySettings[i].m_channelBandwidth.isEmpty()) + { + bool ok; + int channelBW = m_settings.m_frequencySettings[i].m_channelBandwidth.toInt(&ok); + if (ok) + { + if (channelBW >= usableBW) { + nextCenterFrequency = m_settings.m_frequencySettings[i].m_frequency; + } else if (m_settings.m_frequencySettings[i].m_frequency - channelBW / 2 < nextCenterFrequency - usableBW / 2) { + nextCenterFrequency = m_settings.m_frequencySettings[i].m_frequency - channelBW / 2; + } + } + } + break; } } } while (!complete && !freqInRange); - if (complete) + if (complete || (m_settings.m_mode == FreqScannerSettings::MULTIPLEX)) { if (m_scanResults.size() > 0) { @@ -421,7 +439,12 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< FreqScannerSettings::FrequencySettings *frequencySettings = nullptr; FreqScannerSettings::FrequencySettings *activeFrequencySettings = nullptr; - if (m_settings.m_priority == FreqScannerSettings::MAX_POWER) + if (m_settings.m_mode == FreqScannerSettings::MULTIPLEX) + { + activeFrequencySettings = &m_settings.m_frequencySettings[nextFrequencyIndex]; + frequency = activeFrequencySettings->m_frequency; + } + else if (m_settings.m_priority == FreqScannerSettings::MAX_POWER) { Real maxPower = -200.0f; @@ -528,6 +551,13 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< } m_state = IDLE; } + else if (m_settings.m_mode == FreqScannerSettings::MULTIPLEX) + { + // Wait for user-specified receive time before moving to next frequency + m_timeoutTimer.setSingleShot(true); + m_timeoutTimer.start((int)(m_settings.m_retransmitTime * 1000.0)); + m_state = WAIT_FOR_RX_TIME; + } else { // Wait for transmission to finish @@ -605,13 +635,33 @@ void FreqScanner::processScanResults(const QDateTime& fftStartTime, const QList< } break; + case WAIT_FOR_RX_TIME: + for (int i = 0; i < results.size(); i++) + { + if (results[i].m_frequency == m_activeFrequency) + { + if (m_guiMessageQueue) { + m_guiMessageQueue->push(MsgReportActivePower::create(results[i].m_power)); + } + } + } + break; + } } void FreqScanner::timeout() { - // Power hasn't returned above threshold - Restart scan - initScan(); + if (m_settings.m_mode == FreqScannerSettings::MULTIPLEX) + { + // Move to next frequency + m_state = SCAN_FOR_MAX_POWER; + } + else + { + // Power hasn't returned above threshold - Restart scan + initScan(); + } } void FreqScanner::calcScannerSampleRate(int channelBW, int basebandSampleRate, int& scannerSampleRate, int& fftSize, int& binsPerChannel) diff --git a/plugins/channelrx/freqscanner/freqscanner.h b/plugins/channelrx/freqscanner/freqscanner.h index f07046736..39c55e9ac 100644 --- a/plugins/channelrx/freqscanner/freqscanner.h +++ b/plugins/channelrx/freqscanner/freqscanner.h @@ -399,7 +399,8 @@ private: START_SCAN, SCAN_FOR_MAX_POWER, WAIT_FOR_END_TX, - WAIT_FOR_RETRANSMISSION + WAIT_FOR_RETRANSMISSION, + WAIT_FOR_RX_TIME } m_state; QTimer m_timeoutTimer; diff --git a/plugins/channelrx/freqscanner/freqscannergui.cpp b/plugins/channelrx/freqscanner/freqscannergui.cpp index 7aa5ead86..b93ced43b 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.cpp +++ b/plugins/channelrx/freqscanner/freqscannergui.cpp @@ -364,6 +364,22 @@ void FreqScannerGUI::on_mode_currentIndexChanged(int index) { m_settings.m_mode = (FreqScannerSettings::Mode)index; applySetting("mode"); + bool multiplex = m_settings.m_mode == FreqScannerSettings::MULTIPLEX; + ui->threshLabel->setEnabled(!multiplex); + ui->thresh->setEnabled(!multiplex); + ui->threshText->setEnabled(!multiplex); + ui->priorityLabel->setEnabled(!multiplex); + ui->priority->setEnabled(!multiplex); + if (multiplex) + { + ui->retransmitTimeLabel->setText("tTX"); + ui->retransmitTime->setToolTip("Time in seconds to listen on each frequency"); + } + else + { + ui->retransmitTimeLabel->setText("tRTX"); + ui->retransmitTime->setToolTip("Time in seconds to wait for frequency to become active again, before restarting scan"); + } } void FreqScannerGUI::onWidgetRolled(QWidget* widget, bool rollDown) diff --git a/plugins/channelrx/freqscanner/freqscannergui.ui b/plugins/channelrx/freqscanner/freqscannergui.ui index dfa4b5ff8..2a611a31b 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.ui +++ b/plugins/channelrx/freqscanner/freqscannergui.ui @@ -29,7 +29,7 @@ - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Frequency Scanner @@ -102,7 +102,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -143,7 +143,7 @@ PointingHandCursor - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Minimum demod shift frequency from center in Hz @@ -160,14 +160,14 @@ - Qt::Vertical + Qt::Orientation::Vertical - Qt::Horizontal + Qt::Orientation::Horizontal @@ -191,13 +191,13 @@ Active frequency power - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft -120.0 - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter @@ -215,7 +215,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -266,7 +266,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -279,7 +279,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -328,7 +328,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -377,7 +377,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -428,7 +428,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -465,7 +465,7 @@ PointingHandCursor - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Channel bandwidth @@ -482,7 +482,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -551,7 +551,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -569,7 +569,7 @@ Run mode - 1 + 0 @@ -586,6 +586,11 @@ Scan-only + + + Multiplex + + @@ -597,7 +602,7 @@ - + :/play.png :/stop.png:/play.png @@ -621,7 +626,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -767,7 +772,7 @@ Leave blank for no adjustment Up - + :/arrow_up.png:/arrow_up.png @@ -781,7 +786,7 @@ Leave blank for no adjustment - + :/arrow_down.png:/arrow_down.png @@ -789,7 +794,7 @@ Leave blank for no adjustment - Qt::Horizontal + Qt::Orientation::Horizontal @@ -808,7 +813,7 @@ Leave blank for no adjustment - + :/bin.png:/bin.png @@ -843,7 +848,7 @@ Leave blank for no adjustment deltaFrequency - + diff --git a/plugins/channelrx/freqscanner/freqscannersettings.h b/plugins/channelrx/freqscanner/freqscannersettings.h index bcd669e97..4d6784029 100644 --- a/plugins/channelrx/freqscanner/freqscannersettings.h +++ b/plugins/channelrx/freqscanner/freqscannersettings.h @@ -64,7 +64,8 @@ struct FreqScannerSettings enum Mode { SINGLE, CONTINUOUS, - SCAN_ONLY + SCAN_ONLY, + MULTIPLEX } m_mode; //!< Whether to run a single or many scans QList m_columnIndexes;//!< How the columns are ordered in the table diff --git a/plugins/channelrx/freqscanner/readme.md b/plugins/channelrx/freqscanner/readme.md index 7bd676b98..934278075 100644 --- a/plugins/channelrx/freqscanner/readme.md +++ b/plugins/channelrx/freqscanner/readme.md @@ -6,6 +6,14 @@ This plugin can be used to scan a range of frequencies looking for a transmissio [Tutorial Video](https://www.youtube.com/watch?v=IpKP3t4Bmmg) +With the Run Mode (11) set to Multiplex, it can also repeatedly cycle through frequencies listening for a fixed period of time. This can be used, for example, to +receive both AIS and ADS-B data via a single SDR. + +Note that when scanning, the device centre frequency will often not be set exactly to the frequencies you enter. +The Frequency Scanner will typically try to set the device centre frequency in order to +scan as many frequencies simultanously as possible, and also avoid having a DC offset within the bandwidth of a scanned frequency. +The demodulator channel's frequency offset option will be used so that it receives at the specified frequency. +

Interface

The top and bottom bars of the channel window are described [here](../../../sdrgui/channel/readme.md) @@ -40,11 +48,13 @@ that corresponds to the set frequency is being received. Specifies the time in seconds that the Frequency Scanner will average its power measurement over. -

7: t_rtx - Retransmission Time

+

7: t_rtx - Retransmission Time / t_rx Receive Time

-Specifies the time in seconds that the Frequency Scanner will wait after the power on the active frequency falls below the threshold, before restarting +t_rtx: When Run Mode (11) is not Multiplex, specifies the time in seconds that the Frequency Scanner will wait after the power on the active frequency falls below the threshold, before restarting scanning. This enables the channel to remain tuned to a single frequency while there is a temporary break in transmission. +t_rx: When Run Mode (11) is Multiplex, specifies the time in seconds the channel will be tuned to each frequency. +

8: Ch BW - Channel Bandwidth

This specifies the bandwidth of the channels to be scanned. @@ -75,6 +85,7 @@ Specifies the run mode: - Single: All frequencies are scanned once. Channel (1) is tuned to the active frequency at the end of the scan. The scan does not repeat. - Continuous: All frequencies scanned, with channel (1) being tuned to active frequency at the end of the scan. Scan repeats once the power on the active frequency falls below the threshold (4) for longer than the retransmission time (7). - Scan only: All frequencies are scanned repeatedly. The channel will not be tuned. This mode is just for counting how often frequencies are active, which can be seen in the Active Count column in the frequency table (14). +- Multiplex: Frequencies will be stepped through sequentially and repeatedly, with the channel (1) being tuned for the time specified by t_rx (7).

12: Start/Stop Scanning

From a9f25b36420d9fcd26f3ec960eec25de3aac64c9 Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 5 Nov 2024 10:09:34 +0000 Subject: [PATCH 2/4] AIS Demod: Remove spacing around messages, to make better use of available space. --- plugins/channelrx/demodais/aisdemodgui.ui | 68 +++++++++++++---------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/plugins/channelrx/demodais/aisdemodgui.ui b/plugins/channelrx/demodais/aisdemodgui.ui index 33f560373..19f4c6358 100644 --- a/plugins/channelrx/demodais/aisdemodgui.ui +++ b/plugins/channelrx/demodais/aisdemodgui.ui @@ -29,7 +29,7 @@ - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus AIS Demodulator @@ -110,7 +110,7 @@ PointingHandCursor - Qt::StrongFocus + Qt::FocusPolicy::StrongFocus Demod shift frequency from center in Hz @@ -127,14 +127,14 @@ - Qt::Vertical + Qt::Orientation::Vertical - Qt::Horizontal + Qt::Orientation::Horizontal @@ -152,7 +152,7 @@ Channel power - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft 0.0 @@ -209,7 +209,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -252,7 +252,7 @@ 100 - Qt::Horizontal + Qt::Orientation::Horizontal @@ -268,14 +268,14 @@ 10.0k - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter
- Qt::Vertical + Qt::Orientation::Vertical @@ -316,7 +316,7 @@ 24 - Qt::Horizontal + Qt::Orientation::Horizontal @@ -332,14 +332,14 @@ ±2.4k - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter - Qt::Vertical + Qt::Orientation::Vertical @@ -390,7 +390,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -409,7 +409,7 @@ Send packets via UDP - Qt::RightToLeft + Qt::LayoutDirection::RightToLeft @@ -425,7 +425,7 @@ - Qt::ClickFocus + Qt::FocusPolicy::ClickFocus Destination UDP address @@ -444,7 +444,7 @@ : - Qt::AlignCenter + Qt::AlignmentFlag::AlignCenter @@ -463,7 +463,7 @@ - Qt::ClickFocus + Qt::FocusPolicy::ClickFocus Destination UDP port @@ -509,7 +509,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -524,7 +524,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -547,7 +547,7 @@ - Qt::Horizontal + Qt::Orientation::Horizontal @@ -695,10 +695,22 @@ Received Messages + + 0 + + + 0 + + + 0 + + + 0 + - Qt::Vertical + Qt::Orientation::Vertical @@ -738,10 +750,10 @@ Slot map - QFrame::Panel + QFrame::Shape::Panel - QFrame::Sunken + QFrame::Shadow::Sunken @@ -750,7 +762,7 @@ true - Qt::AlignCenter + Qt::AlignmentFlag::AlignCenter @@ -776,7 +788,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -800,7 +812,7 @@ - Qt::Vertical + Qt::Orientation::Vertical @@ -830,7 +842,7 @@ Received packets - QAbstractItemView::NoEditTriggers + QAbstractItemView::EditTrigger::NoEditTriggers @@ -1012,7 +1024,7 @@ - + From 28faddea1d45610c162110054f0e4aedbdf4b58a Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 5 Nov 2024 10:31:32 +0000 Subject: [PATCH 3/4] ADS-B: Use settings keys. --- plugins/channelrx/demodadsb/adsbdemod.cpp | 146 ++----- plugins/channelrx/demodadsb/adsbdemod.h | 15 +- .../channelrx/demodadsb/adsbdemodbaseband.cpp | 17 +- .../channelrx/demodadsb/adsbdemodbaseband.h | 11 +- .../demodadsb/adsbdemoddisplaydialog.cpp | 135 +++++-- .../demodadsb/adsbdemoddisplaydialog.h | 3 + plugins/channelrx/demodadsb/adsbdemodgui.cpp | 226 +++++++---- plugins/channelrx/demodadsb/adsbdemodgui.h | 9 +- .../channelrx/demodadsb/adsbdemodsettings.cpp | 372 ++++++++++++++++++ .../channelrx/demodadsb/adsbdemodsettings.h | 2 + plugins/channelrx/demodadsb/adsbdemodsink.cpp | 24 +- plugins/channelrx/demodadsb/adsbdemodsink.h | 2 +- .../demodadsb/adsbdemodsinkworker.cpp | 20 +- .../channelrx/demodadsb/adsbdemodsinkworker.h | 9 +- .../channelrx/demodadsb/adsbdemodworker.cpp | 28 +- plugins/channelrx/demodadsb/adsbdemodworker.h | 11 +- 16 files changed, 755 insertions(+), 275 deletions(-) diff --git a/plugins/channelrx/demodadsb/adsbdemod.cpp b/plugins/channelrx/demodadsb/adsbdemod.cpp index ef23daeff..96089730f 100644 --- a/plugins/channelrx/demodadsb/adsbdemod.cpp +++ b/plugins/channelrx/demodadsb/adsbdemod.cpp @@ -71,7 +71,7 @@ ADSBDemod::ADSBDemod(DeviceAPI *devieAPI) : m_worker = new ADSBDemodWorker(); m_basebandSink->setMessageQueueToWorker(m_worker->getInputMessageQueue()); - applySettings(m_settings, true); + applySettings(m_settings, QStringList(), true); m_deviceAPI->addChannelSink(this); m_deviceAPI->addChannelSinkAPI(this); @@ -147,7 +147,7 @@ void ADSBDemod::start() m_basebandSink->startWork(); m_thread->start(); - ADSBDemodWorker::MsgConfigureADSBDemodWorker *msg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(m_settings, true); + ADSBDemodWorker::MsgConfigureADSBDemodWorker *msg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(m_settings, QStringList(), true); m_worker->getInputMessageQueue()->push(msg); } @@ -169,7 +169,7 @@ bool ADSBDemod::handleMessage(const Message& cmd) MsgConfigureADSBDemod& cfg = (MsgConfigureADSBDemod&) cmd; qDebug() << "ADSBDemod::handleMessage: MsgConfigureADSBDemod"; - applySettings(cfg.getSettings(), cfg.getForce()); + applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce()); return true; } @@ -200,112 +200,12 @@ bool ADSBDemod::handleMessage(const Message& cmd) } } -void ADSBDemod::applySettings(const ADSBDemodSettings& settings, bool force) +void ADSBDemod::applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { qDebug() << "ADSBDemod::applySettings:" - << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset - << " m_rfBandwidth: " << settings.m_rfBandwidth - << " m_streamIndex: " << settings.m_streamIndex - << " m_useReverseAPI: " << settings.m_useReverseAPI - << " m_reverseAPIAddress: " << settings.m_reverseAPIAddress - << " m_reverseAPIPort: " << settings.m_reverseAPIPort - << " m_reverseAPIDeviceIndex: " << settings.m_reverseAPIDeviceIndex - << " m_reverseAPIChannelIndex: " << settings.m_reverseAPIChannelIndex + << settings.getDebugString(settingsKeys, force) << " force: " << force; - QList reverseAPIKeys; - - if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) { - reverseAPIKeys.append("inputFrequencyOffset"); - } - if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) { - reverseAPIKeys.append("rfBandwidth"); - } - if ((settings.m_correlationThreshold != m_settings.m_correlationThreshold) || force) { - reverseAPIKeys.append("correlationThreshold"); - } - if ((settings.m_samplesPerBit != m_settings.m_samplesPerBit) || force) { - reverseAPIKeys.append("samplesPerBit"); - } - if ((settings.m_correlateFullPreamble != m_settings.m_correlateFullPreamble) || force) { - reverseAPIKeys.append("correlateFullPreamble"); - } - if ((settings.m_demodModeS != m_settings.m_demodModeS) || force) { - reverseAPIKeys.append("demodModeS"); - } - if ((settings.m_interpolatorPhaseSteps != m_settings.m_interpolatorPhaseSteps) || force) { - reverseAPIKeys.append("interpolatorPhaseSteps"); - } - if ((settings.m_interpolatorTapsPerPhase != m_settings.m_interpolatorTapsPerPhase) || force) { - reverseAPIKeys.append("interpolatorTapsPerPhase"); - } - if ((settings.m_removeTimeout != m_settings.m_removeTimeout) || force) { - reverseAPIKeys.append("removeTimeout"); - } - if ((settings.m_feedEnabled != m_settings.m_feedEnabled) || force) { - reverseAPIKeys.append("feedEnabled"); - } - if ((settings.m_exportClientEnabled != m_settings.m_exportClientEnabled) || force) { - reverseAPIKeys.append("exportClientEnabled"); - } - if ((settings.m_exportClientHost != m_settings.m_exportClientHost) || force) { - reverseAPIKeys.append("exportClientHost"); - } - if ((settings.m_exportClientPort != m_settings.m_exportClientPort) || force) { - reverseAPIKeys.append("exportClientPort"); - } - if ((settings.m_exportClientFormat != m_settings.m_exportClientFormat) || force) { - reverseAPIKeys.append("exportClientFormat"); - } - if ((settings.m_exportServerEnabled != m_settings.m_exportServerEnabled) || force) { - reverseAPIKeys.append("exportServerEnabled"); - } - if ((settings.m_exportServerPort != m_settings.m_exportServerPort) || force) { - reverseAPIKeys.append("exportServerPort"); - } - if ((settings.m_importEnabled != m_settings.m_importEnabled) || force) { - reverseAPIKeys.append("importEnabled"); - } - if ((settings.m_importHost != m_settings.m_importHost) || force) { - reverseAPIKeys.append("importHost"); - } - if ((settings.m_importUsername != m_settings.m_importUsername) || force) { - reverseAPIKeys.append("importUsername"); - } - if ((settings.m_importPassword != m_settings.m_importPassword) || force) { - reverseAPIKeys.append("importPassword"); - } - if ((settings.m_importParameters != m_settings.m_importParameters) || force) { - reverseAPIKeys.append("importParameters"); - } - if ((settings.m_importPeriod != m_settings.m_importPeriod) || force) { - reverseAPIKeys.append("importPeriod"); - } - if ((settings.m_importMinLatitude != m_settings.m_importMinLatitude) || force) { - reverseAPIKeys.append("importMinLatitude"); - } - if ((settings.m_importMaxLatitude != m_settings.m_importMaxLatitude) || force) { - reverseAPIKeys.append("importMaxLatitude"); - } - if ((settings.m_importMinLongitude != m_settings.m_importMinLongitude) || force) { - reverseAPIKeys.append("importMinLongitude"); - } - if ((settings.m_importMaxLongitude != m_settings.m_importMaxLongitude) || force) { - reverseAPIKeys.append("importMaxLongitude"); - } - if ((settings.m_logFilename != m_settings.m_logFilename) || force) { - reverseAPIKeys.append("logFilename"); - } - if ((settings.m_logEnabled != m_settings.m_logEnabled) || force) { - reverseAPIKeys.append("logEnabled"); - } - if ((settings.m_title != m_settings.m_title) || force) { - reverseAPIKeys.append("title"); - } - if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) || force) { - reverseAPIKeys.append("rfBandwidth"); - } - if (m_settings.m_streamIndex != settings.m_streamIndex) { if (m_deviceAPI->getSampleMIMO()) // change of stream is possible for MIMO devices only @@ -317,38 +217,40 @@ void ADSBDemod::applySettings(const ADSBDemodSettings& settings, bool force) m_settings.m_streamIndex = settings.m_streamIndex; // make sure ChannelAPI::getStreamIndex() is consistent emit streamIndexChanged(settings.m_streamIndex); } - - reverseAPIKeys.append("streamIndex"); } - ADSBDemodBaseband::MsgConfigureADSBDemodBaseband *msg = ADSBDemodBaseband::MsgConfigureADSBDemodBaseband::create(settings, force); + ADSBDemodBaseband::MsgConfigureADSBDemodBaseband *msg = ADSBDemodBaseband::MsgConfigureADSBDemodBaseband::create(settings, settingsKeys, force); m_basebandSink->getInputMessageQueue()->push(msg); - ADSBDemodWorker::MsgConfigureADSBDemodWorker *workerMsg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(settings, force); + ADSBDemodWorker::MsgConfigureADSBDemodWorker *workerMsg = ADSBDemodWorker::MsgConfigureADSBDemodWorker::create(settings, settingsKeys, force); m_worker->getInputMessageQueue()->push(workerMsg); if (settings.m_useReverseAPI) { - bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) || - (m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) || - (m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) || - (m_settings.m_reverseAPIDeviceIndex != settings.m_reverseAPIDeviceIndex) || - (m_settings.m_reverseAPIChannelIndex != settings.m_reverseAPIChannelIndex); - webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force); + bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) || + settingsKeys.contains("reverseAPIAddress") || + settingsKeys.contains("reverseAPIPort") || + settingsKeys.contains("reverseAPIDeviceIndex") || + settingsKeys.contains("reverseAPIChannelIndex"); + webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force); } - m_settings = settings; + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } } void ADSBDemod::setCenterFrequency(qint64 frequency) { ADSBDemodSettings settings = m_settings; settings.m_inputFrequencyOffset = frequency; - applySettings(settings); + applySettings(settings, {"inputFrequencyOffset"}, false); if (m_guiMessageQueue) // forward to GUI if any { - MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, false); + MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, {"inputFrequencyOffset"}, false); m_guiMessageQueue->push(msgToGUI); } } @@ -368,7 +270,7 @@ bool ADSBDemod::deserialize(const QByteArray& data) success = false; } - MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(m_settings, true); + MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(m_settings, QStringList(), true); m_inputMessageQueue.push(msg); return success; @@ -404,12 +306,12 @@ int ADSBDemod::webapiSettingsPutPatch( ADSBDemodSettings settings = m_settings; webapiUpdateChannelSettings(settings, channelSettingsKeys, response); - MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(settings, force); + MsgConfigureADSBDemod *msg = MsgConfigureADSBDemod::create(settings, channelSettingsKeys, force); m_inputMessageQueue.push(msg); if (m_guiMessageQueue) // forward to GUI if any { - MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, force); + MsgConfigureADSBDemod *msgToGUI = MsgConfigureADSBDemod::create(settings, channelSettingsKeys, force); m_guiMessageQueue->push(msgToGUI); } @@ -661,7 +563,7 @@ void ADSBDemod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& respons } } -void ADSBDemod::webapiReverseSendSettings(QList& channelSettingsKeys, const ADSBDemodSettings& settings, bool force) +void ADSBDemod::webapiReverseSendSettings(const QList& channelSettingsKeys, const ADSBDemodSettings& settings, bool force) { SWGSDRangel::SWGChannelSettings *swgChannelSettings = new SWGSDRangel::SWGChannelSettings(); swgChannelSettings->setDirection(0); // single sink (Rx) diff --git a/plugins/channelrx/demodadsb/adsbdemod.h b/plugins/channelrx/demodadsb/adsbdemod.h index aa514e784..41b82030f 100644 --- a/plugins/channelrx/demodadsb/adsbdemod.h +++ b/plugins/channelrx/demodadsb/adsbdemod.h @@ -20,8 +20,6 @@ #ifndef INCLUDE_ADSBDEMOD_H #define INCLUDE_ADSBDEMOD_H -#include - #include #include "dsp/basebandsamplesink.h" @@ -44,20 +42,23 @@ public: public: const ADSBDemodSettings& getSettings() const { return m_settings; } + const QStringList& getSettingsKeys() const { return m_settingsKeys; } bool getForce() const { return m_force; } - static MsgConfigureADSBDemod* create(const ADSBDemodSettings& settings, bool force) + static MsgConfigureADSBDemod* create(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { - return new MsgConfigureADSBDemod(settings, force); + return new MsgConfigureADSBDemod(settings, settingsKeys, force); } private: ADSBDemodSettings m_settings; + QStringList m_settingsKeys; bool m_force; - MsgConfigureADSBDemod(const ADSBDemodSettings& settings, bool force) : + MsgConfigureADSBDemod(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) : Message(), m_settings(settings), + m_settingsKeys(settingsKeys), m_force(force) { } }; @@ -184,9 +185,9 @@ private: QNetworkRequest m_networkRequest; virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed - void applySettings(const ADSBDemodSettings& settings, bool force = false); + void applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force = false); void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response); - void webapiReverseSendSettings(QList& channelSettingsKeys, const ADSBDemodSettings& settings, bool force); + void webapiReverseSendSettings(const QList& channelSettingsKeys, const ADSBDemodSettings& settings, bool force); private slots: void networkManagerFinished(QNetworkReply *reply); diff --git a/plugins/channelrx/demodadsb/adsbdemodbaseband.cpp b/plugins/channelrx/demodadsb/adsbdemodbaseband.cpp index 0db76f974..cc586310f 100644 --- a/plugins/channelrx/demodadsb/adsbdemodbaseband.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodbaseband.cpp @@ -117,7 +117,7 @@ bool ADSBDemodBaseband::handleMessage(const Message& cmd) MsgConfigureADSBDemodBaseband& cfg = (MsgConfigureADSBDemodBaseband&) cmd; qDebug() << "ADSBDemodBaseband::handleMessage: MsgConfigureADSBDemodBaseband"; - applySettings(cfg.getSettings(), cfg.getForce()); + applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce()); return true; } @@ -138,19 +138,24 @@ bool ADSBDemodBaseband::handleMessage(const Message& cmd) } } -void ADSBDemodBaseband::applySettings(const ADSBDemodSettings& settings, bool force) +void ADSBDemodBaseband::applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { - if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) - || (settings.m_samplesPerBit != m_settings.m_samplesPerBit) || force) + if ( (settingsKeys.contains("inputFrequencyOffset") && (settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset)) + || (settingsKeys.contains("samplesPerBit") && (settings.m_samplesPerBit != m_settings.m_samplesPerBit)) + || force) { int requestedRate = ADS_B_BITS_PER_SECOND * settings.m_samplesPerBit; m_channelizer->setChannelization(requestedRate, settings.m_inputFrequencyOffset); m_sink.applyChannelSettings(m_channelizer->getChannelSampleRate(), m_channelizer->getChannelFrequencyOffset()); } - m_sink.applySettings(settings, force); + m_sink.applySettings(settings, settingsKeys, force); - m_settings = settings; + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } } int ADSBDemodBaseband::getChannelSampleRate() const diff --git a/plugins/channelrx/demodadsb/adsbdemodbaseband.h b/plugins/channelrx/demodadsb/adsbdemodbaseband.h index d54c027b0..bdc63c5f1 100644 --- a/plugins/channelrx/demodadsb/adsbdemodbaseband.h +++ b/plugins/channelrx/demodadsb/adsbdemodbaseband.h @@ -39,20 +39,23 @@ public: public: const ADSBDemodSettings& getSettings() const { return m_settings; } + const QStringList& getSettingsKeys() const { return m_settingsKeys; } bool getForce() const { return m_force; } - static MsgConfigureADSBDemodBaseband* create(const ADSBDemodSettings& settings, bool force) + static MsgConfigureADSBDemodBaseband* create(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { - return new MsgConfigureADSBDemodBaseband(settings, force); + return new MsgConfigureADSBDemodBaseband(settings, settingsKeys, force); } private: ADSBDemodSettings m_settings; + QStringList m_settingsKeys; bool m_force; - MsgConfigureADSBDemodBaseband(const ADSBDemodSettings& settings, bool force) : + MsgConfigureADSBDemodBaseband(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) : Message(), m_settings(settings), + m_settingsKeys(settingsKeys), m_force(force) { } }; @@ -80,7 +83,7 @@ private: QRecursiveMutex m_mutex; bool handleMessage(const Message& cmd); - void applySettings(const ADSBDemodSettings& settings, bool force = false); + void applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force = false); private slots: void handleInputMessages(); diff --git a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp index 06653e7b4..44129f423 100644 --- a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp +++ b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.cpp @@ -82,35 +82,124 @@ ADSBDemodDisplayDialog::~ADSBDemodDisplayDialog() void ADSBDemodDisplayDialog::accept() { - m_settings->m_removeTimeout = ui->timeout->value(); - m_settings->m_aircraftMinZoom = ui->aircraftMinZoom->value(); - m_settings->m_airportRange = ui->airportRange->value(); - m_settings->m_airportMinimumSize = (ADSBDemodSettings::AirportType)ui->airportSize->currentIndex(); - m_settings->m_displayHeliports = ui->heliports->isChecked(); - m_settings->m_siUnits = ui->units->currentIndex() == 0 ? false : true; - m_settings->m_displayDemodStats = ui->displayStats->isChecked(); - m_settings->m_autoResizeTableColumns = ui->autoResizeTableColumns->isChecked(); - m_settings->m_aviationstackAPIKey = ui->aviationstackAPIKey->text(); - m_settings->m_checkWXAPIKey = ui->checkWXAPIKey->text(); - m_settings->m_airspaces = QStringList(); + if (m_settings->m_removeTimeout != ui->timeout->value()) + { + m_settings->m_removeTimeout = ui->timeout->value(); + m_settingsKeys.append("removeTimeout"); + } + if (m_settings->m_aircraftMinZoom != ui->aircraftMinZoom->value()) + { + m_settings->m_aircraftMinZoom = ui->aircraftMinZoom->value(); + m_settingsKeys.append("aircraftMinZoom"); + } + if (m_settings->m_airportRange != ui->airportRange->value()) + { + m_settings->m_airportRange = ui->airportRange->value(); + m_settingsKeys.append("airportRange"); + } + if (m_settings->m_airportMinimumSize != (ADSBDemodSettings::AirportType)ui->airportSize->currentIndex()) + { + m_settings->m_airportMinimumSize = (ADSBDemodSettings::AirportType)ui->airportSize->currentIndex(); + m_settingsKeys.append("airportMinimumSize"); + } + if (m_settings->m_displayHeliports != ui->heliports->isChecked()) + { + m_settings->m_displayHeliports = ui->heliports->isChecked(); + m_settingsKeys.append("displayHeliports"); + } + if (m_settings->m_siUnits != ui->units->currentIndex() == 0 ? false : true) + { + m_settings->m_siUnits = ui->units->currentIndex() == 0 ? false : true; + m_settingsKeys.append("siUnits"); + } + if (m_settings->m_displayDemodStats != ui->displayStats->isChecked()) + { + m_settings->m_displayDemodStats = ui->displayStats->isChecked(); + m_settingsKeys.append("displayDemodStats"); + } + if (m_settings->m_autoResizeTableColumns != ui->autoResizeTableColumns->isChecked()) + { + m_settings->m_autoResizeTableColumns = ui->autoResizeTableColumns->isChecked(); + m_settingsKeys.append("autoResizeTableColumns"); + } + if (m_settings->m_aviationstackAPIKey != ui->aviationstackAPIKey->text()) + { + m_settings->m_aviationstackAPIKey = ui->aviationstackAPIKey->text(); + m_settingsKeys.append("aviationstackAPIKey"); + } + if (m_settings->m_checkWXAPIKey != ui->checkWXAPIKey->text()) + { + m_settings->m_checkWXAPIKey = ui->checkWXAPIKey->text(); + m_settingsKeys.append("checkWXAPIKey"); + } + QStringList airspaces; for (int i = 0; i < ui->airspaces->count(); i++) { QListWidgetItem *item = ui->airspaces->item(i); if (item->checkState() == Qt::Checked) { - m_settings->m_airspaces.append(item->text()); + airspaces.append(item->text()); } } - m_settings->m_airspaceRange = ui->airspaceRange->value(); - m_settings->m_mapProvider = ui->mapProvider->currentText(); - m_settings->m_mapType = (ADSBDemodSettings::MapType)ui->mapType->currentIndex(); - m_settings->m_displayNavAids = ui->navAids->isChecked(); - m_settings->m_atcCallsigns = ui->atcCallsigns->isChecked(); - m_settings->m_displayPhotos = ui->photos->isChecked(); - m_settings->m_verboseModelMatching = ui->verboseModelMatching->isChecked(); - m_settings->m_airfieldElevation = ui->airfieldElevation->value(); - m_settings->m_transitionAlt = ui->transitionAltitude->value(); - m_settings->m_tableFontName = m_fontName; - m_settings->m_tableFontSize = m_fontSize; + if (m_settings->m_airspaces != airspaces) + { + m_settings->m_airspaces = airspaces; + m_settingsKeys.append("airspaces"); + } + if (m_settings->m_airspaceRange != ui->airspaceRange->value()) + { + m_settings->m_airspaceRange = ui->airspaceRange->value(); + m_settingsKeys.append("airspaceRange"); + } + if (m_settings->m_mapProvider != ui->mapProvider->currentText()) + { + m_settings->m_mapProvider = ui->mapProvider->currentText(); + m_settingsKeys.append("mapProvider"); + } + if (m_settings->m_mapType != (ADSBDemodSettings::MapType)ui->mapType->currentIndex()) + { + m_settings->m_mapType = (ADSBDemodSettings::MapType)ui->mapType->currentIndex(); + m_settingsKeys.append("mapType"); + } + if (m_settings->m_displayNavAids != ui->navAids->isChecked()) + { + m_settings->m_displayNavAids = ui->navAids->isChecked(); + m_settingsKeys.append("displayNavAids"); + } + if (m_settings->m_atcCallsigns != ui->atcCallsigns->isChecked()) + { + m_settings->m_atcCallsigns = ui->atcCallsigns->isChecked(); + m_settingsKeys.append("atcCallsigns"); + } + if (m_settings->m_displayPhotos != ui->photos->isChecked()) + { + m_settings->m_displayPhotos = ui->photos->isChecked(); + m_settingsKeys.append("displayPhotos"); + } + if (m_settings->m_verboseModelMatching != ui->verboseModelMatching->isChecked()) + { + m_settings->m_verboseModelMatching = ui->verboseModelMatching->isChecked(); + m_settingsKeys.append("verboseModelMatching"); + } + if (m_settings->m_airfieldElevation != ui->airfieldElevation->value()) + { + m_settings->m_airfieldElevation = ui->airfieldElevation->value(); + m_settingsKeys.append("airfieldElevation"); + } + if (m_settings->m_transitionAlt != ui->transitionAltitude->value()) + { + m_settings->m_transitionAlt = ui->transitionAltitude->value(); + m_settingsKeys.append("transitionAlt"); + } + if (m_settings->m_tableFontName != m_fontName) + { + m_settings->m_tableFontName = m_fontName; + m_settingsKeys.append("tableFontName"); + } + if (m_settings->m_tableFontSize != m_fontSize) + { + m_settings->m_tableFontSize = m_fontSize; + m_settingsKeys.append("tableFontSize"); + } QDialog::accept(); } diff --git a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.h b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.h index d83b6bc70..fbb461fca 100644 --- a/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.h +++ b/plugins/channelrx/demodadsb/adsbdemoddisplaydialog.h @@ -28,6 +28,8 @@ public: explicit ADSBDemodDisplayDialog(ADSBDemodSettings *settings, QWidget* parent = 0); ~ADSBDemodDisplayDialog(); + const QStringList& getSettingsKeys() const { return m_settingsKeys; }; + private slots: void accept(); void on_font_clicked(); @@ -35,6 +37,7 @@ private slots: private: Ui::ADSBDemodDisplayDialog* ui; ADSBDemodSettings *m_settings; + QStringList m_settingsKeys; QString m_fontName; int m_fontSize; }; diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.cpp b/plugins/channelrx/demodadsb/adsbdemodgui.cpp index 2db523921..aab087585 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodgui.cpp @@ -146,8 +146,8 @@ void ADSBDemodGUI::destroy() void ADSBDemodGUI::resetToDefaults() { m_settings.resetToDefaults(); - displaySettings(); - applySettings(); + displaySettings(QStringList(), true); + applyAllSettings(); } QByteArray ADSBDemodGUI::serialize() const @@ -160,8 +160,8 @@ bool ADSBDemodGUI::deserialize(const QByteArray& data) if(m_settings.deserialize(data)) { updateChannelList(); - displaySettings(); - applySettings(true); + displaySettings(QStringList(), true); + applyAllSettings(); return true; } else @@ -3471,10 +3471,19 @@ bool ADSBDemodGUI::handleMessage(const Message& message) { qDebug("ADSBDemodGUI::handleMessage: ADSBDemod::MsgConfigureADSBDemod"); const ADSBDemod::MsgConfigureADSBDemod& cfg = (ADSBDemod::MsgConfigureADSBDemod&) message; - m_settings = cfg.getSettings(); + const ADSBDemodSettings settings = cfg.getSettings(); + const QStringList settingsKeys = cfg.getSettingsKeys(); + bool force = cfg.getForce(); + + if (force) { + m_settings = cfg.getSettings(); + } else { + m_settings.applySettings(settingsKeys, settings); + } + blockApplySettings(true); m_channelMarker.updateSettings(static_cast(m_settings.m_channelMarker)); - displaySettings(); + displaySettings(settingsKeys, force); blockApplySettings(false); return true; } @@ -3499,7 +3508,7 @@ void ADSBDemodGUI::channelMarkerChangedByCursor() { ui->deltaFrequency->setValue(m_channelMarker.getCenterFrequency()); m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); - applySettings(); + applySetting("inputFrequencyOffset"); } void ADSBDemodGUI::channelMarkerHighlightedByCursor() @@ -3512,7 +3521,7 @@ void ADSBDemodGUI::on_deltaFrequency_changed(qint64 value) m_channelMarker.setCenterFrequency(value); m_settings.m_inputFrequencyOffset = m_channelMarker.getCenterFrequency(); updateAbsoluteCenterFrequency(); - applySettings(); + applySetting("inputFrequencyOffset"); } void ADSBDemodGUI::on_rfBW_valueChanged(int value) @@ -3521,7 +3530,7 @@ void ADSBDemodGUI::on_rfBW_valueChanged(int value) ui->rfBWText->setText(QString("%1M").arg(bw / 1000000.0, 0, 'f', 1)); m_channelMarker.setBandwidth(bw); m_settings.m_rfBandwidth = bw; - applySettings(); + applySetting("rfBandwidth"); } void ADSBDemodGUI::on_threshold_valueChanged(int value) @@ -3529,14 +3538,14 @@ void ADSBDemodGUI::on_threshold_valueChanged(int value) Real thresholddB = ((Real)value)/10.0f; ui->thresholdText->setText(QString("%1").arg(thresholddB, 0, 'f', 1)); m_settings.m_correlationThreshold = thresholddB; - applySettings(); + applySetting("correlationThreshold"); } void ADSBDemodGUI::on_phaseSteps_valueChanged(int value) { ui->phaseStepsText->setText(QString("%1").arg(value)); m_settings.m_interpolatorPhaseSteps = value; - applySettings(); + applySetting("interpolatorPhaseSteps"); } void ADSBDemodGUI::on_tapsPerPhase_valueChanged(int value) @@ -3544,14 +3553,14 @@ void ADSBDemodGUI::on_tapsPerPhase_valueChanged(int value) Real tapsPerPhase = ((Real)value)/10.0f; ui->tapsPerPhaseText->setText(QString("%1").arg(tapsPerPhase, 0, 'f', 1)); m_settings.m_interpolatorTapsPerPhase = tapsPerPhase; - applySettings(); + applySetting("interpolatorTapsPerPhase"); } void ADSBDemodGUI::on_feed_clicked(bool checked) { m_settings.m_feedEnabled = checked; // Don't disable host/port - so they can be entered before connecting - applySettings(); + applySetting("feedEnabled"); applyImportSettings(); } @@ -3561,7 +3570,7 @@ void ADSBDemodGUI::on_notifications_clicked() if (dialog.exec() == QDialog::Accepted) { enableSpeechIfNeeded(); - applySettings(); + applySetting("notificationSettings"); } } @@ -3829,19 +3838,19 @@ QAction *ADSBDemodGUI::createCheckableItem(QString &text, int idx, bool checked) void ADSBDemodGUI::on_spb_currentIndexChanged(int value) { m_settings.m_samplesPerBit = (value + 1) * 2; - applySettings(); + applySetting("samplesPerBi"); } void ADSBDemodGUI::on_correlateFullPreamble_clicked(bool checked) { m_settings.m_correlateFullPreamble = checked; - applySettings(); + applySetting("correlateFullPreamble"); } void ADSBDemodGUI::on_demodModeS_clicked(bool checked) { m_settings.m_demodModeS = checked; - applySettings(); + applySetting("demodModeS"); } void ADSBDemodGUI::on_getOSNDB_clicked() @@ -3897,7 +3906,7 @@ void ADSBDemodGUI::on_atcLabels_clicked(bool checked) { m_settings.m_atcLabels = checked; m_aircraftModel.setSettings(&m_settings); - applySettings(); + applySetting("atcLabels"); } QString ADSBDemodGUI::getDataDir() @@ -3914,7 +3923,7 @@ void ADSBDemodGUI::onWidgetRolled(QWidget* widget, bool rollDown) (void) rollDown; getRollupContents()->saveState(m_rollupState); - applySettings(); + applySetting("rollupState"); } void ADSBDemodGUI::onMenuDialogCalled(const QPoint &p) @@ -3951,6 +3960,16 @@ void ADSBDemodGUI::onMenuDialogCalled(const QPoint &p) setTitle(m_channelMarker.getTitle()); setTitleColor(m_settings.m_rgbColor); + QStringList settingsKeys({ + "rgbColor", + "title", + "useReverseAPI", + "reverseAPIAddress", + "reverseAPIPort", + "reverseAPIDeviceIndex", + "reverseAPIChannelIndex" + }); + if (m_deviceUISet->m_deviceMIMOEngine) { m_settings.m_streamIndex = dialog.getSelectedStreamIndex(); @@ -3959,7 +3978,7 @@ void ADSBDemodGUI::onMenuDialogCalled(const QPoint &p) updateIndexLabel(); } - applySettings(); + applySettings(settingsKeys); } resetContextMenuType(); @@ -4000,7 +4019,7 @@ void ADSBDemodGUI::on_amDemod_currentIndexChanged(int index) if (index >= 0) { m_settings.m_amDemod = ui->amDemod->currentText(); - applySettings(); + applySetting("amDemod"); } } @@ -4687,7 +4706,24 @@ void ADSBDemodGUI::feedSelect(const QPoint& p) if (dialog.exec() == QDialog::Accepted) { - applySettings(); + applySettings({ + "exportClientEnabled", + "exportClientHost", + "exportClientPort", + "exportClientFormat", + "exportServerEnabled", + "exportServerPort", + "importEnabled", + "importHost", + "importUsername", + "importPassword", + "importParameters", + "importPeriod", + "importMinLatitude", + "importMaxLatitude", + "importMinLongitude", + "importMaxLongitude" + }); applyImportSettings(); } } @@ -4704,8 +4740,8 @@ void ADSBDemodGUI::on_displaySettings_clicked() if (unitsChanged) { m_aircraftModel.allAircraftUpdated(); } - displaySettings(); - applySettings(); + displaySettings(dialog.getSettingsKeys(), false); + applySettings(dialog.getSettingsKeys()); } } @@ -5055,9 +5091,9 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb connect(MainCore::instance(), &MainCore::channelRemoved, this, &ADSBDemodGUI::updateChannelList); updateChannelList(); - displaySettings(); + displaySettings(QStringList(), true); makeUIConnections(); - applySettings(true); + applyAllSettings(); connect(&m_importTimer, &QTimer::timeout, this, &ADSBDemodGUI::import); m_networkManager = new QNetworkAccessManager(); @@ -5111,18 +5147,30 @@ ADSBDemodGUI::~ADSBDemodGUI() delete m_networkManager; } -void ADSBDemodGUI::applySettings(bool force) +void ADSBDemodGUI::applySetting(const QString& settingsKey) { + applySettings({settingsKey}); +} + +void ADSBDemodGUI::applySettings(const QStringList& settingsKeys, bool force) +{ + m_settingsKeys.append(settingsKeys); if (m_doApplySettings) { qDebug() << "ADSBDemodGUI::applySettings"; - ADSBDemod::MsgConfigureADSBDemod* message = ADSBDemod::MsgConfigureADSBDemod::create(m_settings, force); + ADSBDemod::MsgConfigureADSBDemod* message = ADSBDemod::MsgConfigureADSBDemod::create(m_settings, m_settingsKeys, force); m_adsbDemod->getInputMessageQueue()->push(message); } } -void ADSBDemodGUI::displaySettings() +void ADSBDemodGUI::applyAllSettings() +{ + applySettings(QStringList(), true); +} + +// All settings are valid - we just use settingsKeys here to avoid updating things that are slow to update +void ADSBDemodGUI::displaySettings(const QStringList& settingsKeys, bool force) { m_channelMarker.blockSignals(true); m_channelMarker.setCenterFrequency(m_settings.m_inputFrequencyOffset); @@ -5175,74 +5223,104 @@ void ADSBDemodGUI::displaySettings() updateIndexLabel(); - QFont font(m_settings.m_tableFontName, m_settings.m_tableFontSize); - ui->adsbData->setFont(font); + if (settingsKeys.contains("tableFontName") || settingsKeys.contains("tableFontSize") || force) + { + QFont font(m_settings.m_tableFontName, m_settings.m_tableFontSize); + ui->adsbData->setFont(font); + } // Set units in column headers - if (m_settings.m_siUnits) + if (settingsKeys.contains("siUnits") || force) { - ui->adsbData->horizontalHeaderItem(ADSB_COL_ALTITUDE)->setText("Alt (m)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_VERTICALRATE)->setText("VR (m/s)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_SEL_ALTITUDE)->setText("Sel Alt (m)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_GROUND_SPEED)->setText("GS (kph)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_TRUE_AIRSPEED)->setText("TAS (kph)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_INDICATED_AIRSPEED)->setText("IAS (kph)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_HEADWIND)->setText("H Wnd (kph)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_WIND_SPEED)->setText("Wnd (kph)"); - } - else - { - ui->adsbData->horizontalHeaderItem(ADSB_COL_ALTITUDE)->setText("Alt (ft)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_VERTICALRATE)->setText("VR (ft/m)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_SEL_ALTITUDE)->setText("Sel Alt (ft)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_GROUND_SPEED)->setText("GS (kn)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_TRUE_AIRSPEED)->setText("TAS (kn)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_INDICATED_AIRSPEED)->setText("IAS (kn)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_HEADWIND)->setText("H Wnd (kn)"); - ui->adsbData->horizontalHeaderItem(ADSB_COL_WIND_SPEED)->setText("Wnd (kn)"); + if (m_settings.m_siUnits) + { + ui->adsbData->horizontalHeaderItem(ADSB_COL_ALTITUDE)->setText("Alt (m)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_VERTICALRATE)->setText("VR (m/s)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_SEL_ALTITUDE)->setText("Sel Alt (m)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_GROUND_SPEED)->setText("GS (kph)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_TRUE_AIRSPEED)->setText("TAS (kph)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_INDICATED_AIRSPEED)->setText("IAS (kph)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_HEADWIND)->setText("H Wnd (kph)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_WIND_SPEED)->setText("Wnd (kph)"); + } + else + { + ui->adsbData->horizontalHeaderItem(ADSB_COL_ALTITUDE)->setText("Alt (ft)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_VERTICALRATE)->setText("VR (ft/m)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_SEL_ALTITUDE)->setText("Sel Alt (ft)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_GROUND_SPEED)->setText("GS (kn)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_TRUE_AIRSPEED)->setText("TAS (kn)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_INDICATED_AIRSPEED)->setText("IAS (kn)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_HEADWIND)->setText("H Wnd (kn)"); + ui->adsbData->horizontalHeaderItem(ADSB_COL_WIND_SPEED)->setText("Wnd (kn)"); + } } // Order and size columns - QHeaderView *header = ui->adsbData->horizontalHeader(); - for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) + if (settingsKeys.contains("columnSizes") || settingsKeys.contains("columnIndexes") || force) { - bool hidden = m_settings.m_columnSizes[i] == 0; - header->setSectionHidden(i, hidden); - menu->actions().at(i)->setChecked(!hidden); - if (m_settings.m_columnSizes[i] > 0) - ui->adsbData->setColumnWidth(i, m_settings.m_columnSizes[i]); - header->moveSection(header->visualIndex(i), m_settings.m_columnIndexes[i]); + QHeaderView* header = ui->adsbData->horizontalHeader(); + for (int i = 0; i < ADSBDEMOD_COLUMNS; i++) + { + bool hidden = m_settings.m_columnSizes[i] == 0; + header->setSectionHidden(i, hidden); + menu->actions().at(i)->setChecked(!hidden); + if (m_settings.m_columnSizes[i] > 0) + ui->adsbData->setColumnWidth(i, m_settings.m_columnSizes[i]); + header->moveSection(header->visualIndex(i), m_settings.m_columnIndexes[i]); + } } // Only update airports on map if settings have changed if ((m_airportInfo != nullptr) - && ((m_settings.m_airportRange != m_currentAirportRange) - || (m_settings.m_airportMinimumSize != m_currentAirportMinimumSize) - || (m_settings.m_displayHeliports != m_currentDisplayHeliports))) + && (((settingsKeys.contains("airportRange") || force) && (m_settings.m_airportRange != m_currentAirportRange)) + || ((settingsKeys.contains("airportMinimumSize") || force) && (m_settings.m_airportMinimumSize != m_currentAirportMinimumSize)) + || ((settingsKeys.contains("displayHeliports") || force) && (m_settings.m_displayHeliports != m_currentDisplayHeliports)))) { updateAirports(); + } - updateAirspaces(); - updateNavAids(); + if (settingsKeys.contains("airspaces") || force) { + updateAirspaces(); + } + if (settingsKeys.contains("displayNavAids") || settingsKeys.contains("airspaceRange") || force) { + updateNavAids(); + } if (!m_settings.m_displayDemodStats) ui->stats->setText(""); - initFlightInformation(); - initAviationWeather(); + if (settingsKeys.contains("aviationstackAPIKey") || force) { + initFlightInformation(); + } + if (settingsKeys.contains("checkWXAPIKey") || force) { + initAviationWeather(); + } - applyImportSettings(); + if (settingsKeys.contains("importPeriod") + || settingsKeys.contains("feedEnabled") + || settingsKeys.contains("importEnabled") + || force) { + applyImportSettings(); + } getRollupContents()->restoreState(m_rollupState); blockApplySettings(false); enableSpeechIfNeeded(); + + if (settingsKeys.contains("mapProvider") + || settingsKeys.contains("aircraftMinZoom") + || settingsKeys.contains("mapType") + || force) + { #ifdef __EMSCRIPTEN__ - // FIXME: If we don't have this delay, tile server requests get deleted - QTimer::singleShot(250, [this] { - applyMapSettings(); - }); + // FIXME: If we don't have this delay, tile server requests get deleted + QTimer::singleShot(250, [this] { + applyMapSettings(); + }); #else - applyMapSettings(); + applyMapSettings(); #endif + } } void ADSBDemodGUI::leaveEvent(QEvent* event) @@ -5536,7 +5614,7 @@ void ADSBDemodGUI::photoClicked() void ADSBDemodGUI::on_logEnable_clicked(bool checked) { m_settings.m_logEnabled = checked; - applySettings(); + applySetting("logEnabled"); } void ADSBDemodGUI::on_logFilename_clicked() @@ -5551,7 +5629,7 @@ void ADSBDemodGUI::on_logFilename_clicked() { m_settings.m_logFilename = fileNames[0]; ui->logFilename->setToolTip(QString(".csv log filename: %1").arg(m_settings.m_logFilename)); - applySettings(); + applySetting("logFilename"); } } } diff --git a/plugins/channelrx/demodadsb/adsbdemodgui.h b/plugins/channelrx/demodadsb/adsbdemodgui.h index 89793713e..9957f3c57 100644 --- a/plugins/channelrx/demodadsb/adsbdemodgui.h +++ b/plugins/channelrx/demodadsb/adsbdemodgui.h @@ -811,7 +811,7 @@ public: { m_aircraftRegExp.optimize(); } - + virtual ~ModelMatch() = default; virtual bool match(const QString &aircraft, const QString &manufacturer, QString &model) @@ -911,6 +911,7 @@ private: ChannelMarker m_channelMarker; RollupState m_rollupState; ADSBDemodSettings m_settings; + QStringList m_settingsKeys; qint64 m_deviceCenterFrequency; int m_basebandSampleRate; bool m_basicSettingsShown; @@ -981,8 +982,10 @@ private: virtual ~ADSBDemodGUI(); void blockApplySettings(bool block); - void applySettings(bool force = false); - void displaySettings(); + void applySetting(const QString& settingsKey); + void applySettings(const QStringList& settingsKeys, bool force = false); + void applyAllSettings(); + void displaySettings(const QStringList& settingsKeys, bool force); bool handleMessage(const Message& message); void makeUIConnections(); void updateAbsoluteCenterFrequency(); diff --git a/plugins/channelrx/demodadsb/adsbdemodsettings.cpp b/plugins/channelrx/demodadsb/adsbdemodsettings.cpp index e7dfa9ac2..c8aac3be6 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsettings.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodsettings.cpp @@ -401,3 +401,375 @@ void ADSBDemodSettings::NotificationSettings::updateRegularExpression() qDebug() << "ADSBDemod: Regular expression is not valid: " << m_regExp; } } + +void ADSBDemodSettings::applySettings(const QStringList& settingsKeys, const ADSBDemodSettings& settings) +{ + if (settingsKeys.contains("inputFrequencyOffset")) { + m_inputFrequencyOffset = settings.m_inputFrequencyOffset; + } + if (settingsKeys.contains("rfBandwidth")) { + m_rfBandwidth = settings.m_rfBandwidth; + } + if (settingsKeys.contains("correlationThreshold")) { + m_correlationThreshold = settings.m_correlationThreshold; + } + if (settingsKeys.contains("samplesPerBit")) { + m_samplesPerBit = settings.m_samplesPerBit; + } + if (settingsKeys.contains("removeTimeout")) { + m_removeTimeout = settings.m_removeTimeout; + } + if (settingsKeys.contains("feedEnabled")) { + m_feedEnabled = settings.m_feedEnabled; + } + if (settingsKeys.contains("exportClientEnabled")) { + m_exportClientEnabled = settings.m_exportClientEnabled; + } + if (settingsKeys.contains("exportClientHost")) { + m_exportClientHost = settings.m_exportClientHost; + } + if (settingsKeys.contains("exportClientPort")) { + m_exportClientPort = settings.m_exportClientPort; + } + if (settingsKeys.contains("exportClientFormat")) { + m_exportClientFormat = settings.m_exportClientFormat; + } + if (settingsKeys.contains("exportServerEnabled")) { + m_exportServerEnabled = settings.m_exportServerEnabled; + } + if (settingsKeys.contains("exportServerPort")) { + m_exportServerPort = settings.m_exportServerPort; + } + if (settingsKeys.contains("importEnabled")) { + m_importEnabled = settings.m_importEnabled; + } + if (settingsKeys.contains("importHost")) { + m_importHost = settings.m_importHost; + } + if (settingsKeys.contains("importUsername")) { + m_importUsername = settings.m_importUsername; + } + if (settingsKeys.contains("importPassword")) { + m_importPassword = settings.m_importPassword; + } + if (settingsKeys.contains("importParameters")) { + m_importParameters = settings.m_importParameters; + } + if (settingsKeys.contains("importPeriod")) { + m_importPeriod = settings.m_importPeriod; + } + if (settingsKeys.contains("importMinLatitude")) { + m_importMinLatitude = settings.m_importMinLatitude; + } + if (settingsKeys.contains("importMaxLatitude")) { + m_importMaxLatitude = settings.m_importMaxLatitude; + } + if (settingsKeys.contains("importMinLongitude")) { + m_importMinLongitude = settings.m_importMinLongitude; + } + if (settingsKeys.contains("importMaxLongitude")) { + m_importMaxLongitude = settings.m_importMaxLongitude; + } + if (settingsKeys.contains("rgbColor")) { + m_rgbColor = settings.m_rgbColor; + } + if (settingsKeys.contains("title")) { + m_title = settings.m_title; + } + if (settingsKeys.contains("useReverseAPI")) { + m_useReverseAPI = settings.m_useReverseAPI; + } + if (settingsKeys.contains("reverseAPIAddress")) { + m_reverseAPIAddress = settings.m_reverseAPIAddress; + } + if (settingsKeys.contains("reverseAPIPort")) { + m_reverseAPIPort = settings.m_reverseAPIPort; + } + if (settingsKeys.contains("reverseAPIDeviceIndex")) { + m_reverseAPIDeviceIndex = settings.m_reverseAPIDeviceIndex; + } + if (settingsKeys.contains("columnIndexes")) { + std::copy(std::begin(settings.m_columnIndexes), std::end(settings.m_columnIndexes), std::begin(m_columnIndexes)); + } + if (settingsKeys.contains("columnSizes")) { + std::copy(std::begin(settings.m_columnSizes), std::end(settings.m_columnIndexes), std::begin(m_columnSizes)); + } + if (settingsKeys.contains("airportRange")) { + m_airportRange = settings.m_airportRange; + } + if (settingsKeys.contains("airportMinimumSize")) { + m_airportMinimumSize = settings.m_airportMinimumSize; + } + if (settingsKeys.contains("displayHeliports")) { + m_displayHeliports = settings.m_displayHeliports; + } + if (settingsKeys.contains("flightPaths")) { + m_flightPaths = settings.m_flightPaths; + } + if (settingsKeys.contains("allFlightPaths")) { + m_allFlightPaths = settings.m_allFlightPaths; + } + if (settingsKeys.contains("siUnits")) { + m_siUnits = settings.m_siUnits; + } + if (settingsKeys.contains("tableFontName")) { + m_tableFontName = settings.m_tableFontName; + } + if (settingsKeys.contains("tableFontSize")) { + m_tableFontSize = settings.m_tableFontSize; + } + if (settingsKeys.contains("displayDemodStats")) { + m_displayDemodStats = settings.m_displayDemodStats; + } + if (settingsKeys.contains("correlateFullPreamble")) { + m_correlateFullPreamble = settings.m_correlateFullPreamble; + } + if (settingsKeys.contains("demodModeS")) { + m_demodModeS = settings.m_demodModeS; + } + if (settingsKeys.contains("amDemod")) { + m_amDemod = settings.m_amDemod; + } + if (settingsKeys.contains("autoResizeTableColumns")) { + m_autoResizeTableColumns = settings.m_autoResizeTableColumns; + } + if (settingsKeys.contains("interpolatorPhaseSteps")) { + m_interpolatorPhaseSteps = settings.m_interpolatorPhaseSteps; + } + if (settingsKeys.contains("interpolatorTapsPerPhase")) { + m_interpolatorTapsPerPhase = settings.m_interpolatorTapsPerPhase; + } + if (settingsKeys.contains("notificationSettings")) { + m_notificationSettings = settings.m_notificationSettings; + } + if (settingsKeys.contains("aviationstackAPIKey")) { + m_aviationstackAPIKey = settings.m_aviationstackAPIKey; + } + if (settingsKeys.contains("checkWXAPIKey")) { + m_checkWXAPIKey = settings.m_checkWXAPIKey; + } + if (settingsKeys.contains("logFilename")) { + m_logFilename = settings.m_logFilename; + } + if (settingsKeys.contains("logEnabled")) { + m_logEnabled = settings.m_logEnabled; + } + if (settingsKeys.contains("airspaces")) { + m_airspaces = settings.m_airspaces; + } + if (settingsKeys.contains("airspaceRange")) { + m_airspaceRange = settings.m_airspaceRange; + } + if (settingsKeys.contains("mapProvider")) { + m_mapProvider = settings.m_mapProvider; + } + if (settingsKeys.contains("mapType")) { + m_mapType = settings.m_mapType; + } + if (settingsKeys.contains("displayNavAids")) { + m_displayNavAids = settings.m_displayNavAids; + } + if (settingsKeys.contains("displayPhotos")) { + m_displayPhotos = settings.m_displayPhotos; + } + if (settingsKeys.contains("verboseModelMatching")) { + m_verboseModelMatching = settings.m_verboseModelMatching; + } + if (settingsKeys.contains("airfieldElevation")) { + m_airfieldElevation = settings.m_airfieldElevation; + } + if (settingsKeys.contains("aircraftMinZoom")) { + m_aircraftMinZoom = settings.m_aircraftMinZoom; + } + if (settingsKeys.contains("atcLabels")) { + m_atcLabels = settings.m_atcLabels; + } + if (settingsKeys.contains("atcCallsigns")) { + m_atcCallsigns = settings.m_atcCallsigns; + } + if (settingsKeys.contains("transitionAlt")) { + m_transitionAlt = settings.m_transitionAlt; + } +} + +QString ADSBDemodSettings::getDebugString(const QStringList& settingsKeys, bool force) const +{ + std::ostringstream ostr; + + if (settingsKeys.contains("inputFrequencyOffset") || force) { + ostr << " m_inputFrequencyOffset: " << m_inputFrequencyOffset; + } + if (settingsKeys.contains("rfBandwidth") || force) { + ostr << " m_rfBandwidth: " << m_rfBandwidth; + } + if (settingsKeys.contains("correlationThreshold") || force) { + ostr << " m_correlationThreshold: " << m_correlationThreshold; + } + if (settingsKeys.contains("samplesPerBit") || force) { + ostr << " m_samplesPerBit: " << m_samplesPerBit; + } + if (settingsKeys.contains("removeTimeout") || force) { + ostr << " m_removeTimeout: " << m_removeTimeout; + } + if (settingsKeys.contains("feedEnabled") || force) { + ostr << " m_feedEnabled: " << m_feedEnabled; + } + if (settingsKeys.contains("exportClientEnabled") || force) { + ostr << " m_exportClientEnabled: " << m_exportClientEnabled; + } + if (settingsKeys.contains("exportClientHost") || force) { + ostr << " m_exportClientHost: " << m_exportClientHost.toStdString(); + } + if (settingsKeys.contains("exportClientPort") || force) { + ostr << " m_exportClientPort: " << m_exportClientPort; + } + if (settingsKeys.contains("exportClientFormat") || force) { + ostr << " m_exportClientFormat: " << m_exportClientFormat; + } + if (settingsKeys.contains("exportServerEnabled") || force) { + ostr << " m_exportServerEnabled: " << m_exportServerEnabled; + } + if (settingsKeys.contains("exportServerPort") || force) { + ostr << " m_exportServerPort: " << m_exportServerPort; + } + if (settingsKeys.contains("importEnabled") || force) { + ostr << " m_importEnabled: " << m_importEnabled; + } + if (settingsKeys.contains("importHost") || force) { + ostr << " m_importHost: " << m_importHost.toStdString(); + } + if (settingsKeys.contains("importUsername") || force) { + ostr << " m_importUsername: " << m_importUsername.toStdString(); + } + if (settingsKeys.contains("importPassword") || force) { + ostr << " m_importPassword: " << m_importPassword.toStdString(); + } + if (settingsKeys.contains("importParameters") || force) { + ostr << " m_importParameters: " << m_importParameters.toStdString(); + } + if (settingsKeys.contains("importPeriod") || force) { + ostr << " m_importPeriod: " << m_importPeriod; + } + if (settingsKeys.contains("importMinLatitude") || force) { + ostr << " m_importMinLatitude: " << m_importMinLatitude.toStdString(); + } + if (settingsKeys.contains("importMaxLatitude") || force) { + ostr << " m_importMaxLatitude: " << m_importMaxLatitude.toStdString(); + } + if (settingsKeys.contains("importMinLongitude") || force) { + ostr << " m_importMinLongitude: " << m_importMinLongitude.toStdString(); + } + if (settingsKeys.contains("importMaxLongitude") || force) { + ostr << " m_importMaxLongitude: " << m_importMaxLongitude.toStdString(); + } + if (settingsKeys.contains("title") || force) { + ostr << " m_title: " << m_title.toStdString(); + } + if (settingsKeys.contains("useReverseAPI") || force) { + ostr << " m_useReverseAPI: " << m_useReverseAPI; + } + if (settingsKeys.contains("reverseAPIAddress") || force) { + ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString(); + } + if (settingsKeys.contains("reverseAPIPort") || force) { + ostr << " m_reverseAPIPort: " << m_reverseAPIPort; + } + if (settingsKeys.contains("reverseAPIDeviceIndex") || force) { + ostr << " m_reverseAPIDeviceIndex: " << m_reverseAPIDeviceIndex; + } + if (settingsKeys.contains("airportRange") || force) { + ostr << " m_airportRange: " << m_airportRange; + } + if (settingsKeys.contains("airportMinimumSize") || force) { + ostr << " m_airportMinimumSize: " << m_airportMinimumSize; + } + if (settingsKeys.contains("displayHeliports") || force) { + ostr << " m_displayHeliports: " << m_displayHeliports; + } + if (settingsKeys.contains("flightPaths") || force) { + ostr << " m_flightPaths: " << m_flightPaths; + } + if (settingsKeys.contains("allFlightPaths") || force) { + ostr << " m_allFlightPaths: " << m_allFlightPaths; + } + if (settingsKeys.contains("siUnits") || force) { + ostr << " m_siUnits: " << m_siUnits; + } + if (settingsKeys.contains("tableFontName") || force) { + ostr << " m_tableFontName: " << m_tableFontName.toStdString(); + } + if (settingsKeys.contains("tableFontSize") || force) { + ostr << " m_tableFontSize: " << m_tableFontSize; + } + if (settingsKeys.contains("displayDemodStats") || force) { + ostr << " m_displayDemodStats: " << m_displayDemodStats; + } + if (settingsKeys.contains("correlateFullPreamble") || force) { + ostr << " m_correlateFullPreamble: " << m_correlateFullPreamble; + } + if (settingsKeys.contains("demodModeS") || force) { + ostr << " m_demodModeS: " << m_demodModeS; + } + if (settingsKeys.contains("amDemod") || force) { + ostr << " m_amDemod: " << m_amDemod.toStdString(); + } + if (settingsKeys.contains("autoResizeTableColumns") || force) { + ostr << " m_autoResizeTableColumns: " << m_autoResizeTableColumns; + } + if (settingsKeys.contains("interpolatorPhaseSteps") || force) { + ostr << " m_interpolatorPhaseSteps: " << m_interpolatorPhaseSteps; + } + if (settingsKeys.contains("notificationSettings") || force) { + //ostr << " m_notificationSettings: " << m_notificationSettings.join(",").toStdString(); + } + if (settingsKeys.contains("aviationstackAPIKey") || force) { + ostr << " m_aviationstackAPIKey: " << m_aviationstackAPIKey.toStdString(); + } + if (settingsKeys.contains("checkWXAPIKey") || force) { + ostr << " m_checkWXAPIKey: " << m_checkWXAPIKey.toStdString(); + } + if (settingsKeys.contains("logFilename") || force) { + ostr << " m_logFilename: " << m_logFilename.toStdString(); + } + if (settingsKeys.contains("logEnabled") || force) { + ostr << " m_logEnabled: " << m_logEnabled; + } + if (settingsKeys.contains("airspaces") || force) { + ostr << " m_airspaces: " << m_airspaces.join(",").toStdString(); + } + if (settingsKeys.contains("airspaceRange") || force) { + ostr << " m_airspaceRange: " << m_airspaceRange; + } + if (settingsKeys.contains("mapProvider") || force) { + ostr << " m_mapProvider: " << m_mapProvider.toStdString(); + } + if (settingsKeys.contains("mapType") || force) { + ostr << " m_mapType: " << m_mapType; + } + if (settingsKeys.contains("displayNavAids") || force) { + ostr << " m_displayNavAids: " << m_displayNavAids; + } + if (settingsKeys.contains("displayPhotos") || force) { + ostr << " m_displayPhotos: " << m_displayPhotos; + } + if (settingsKeys.contains("verboseModelMatching") || force) { + ostr << " m_verboseModelMatching: " << m_verboseModelMatching; + } + if (settingsKeys.contains("airfieldElevation") || force) { + ostr << " m_airfieldElevation: " << m_airfieldElevation; + } + if (settingsKeys.contains("aircraftMinZoom") || force) { + ostr << " m_aircraftMinZoom: " << m_aircraftMinZoom; + } + if (settingsKeys.contains("atcLabels") || force) { + ostr << " m_atcLabels: " << m_atcLabels; + } + if (settingsKeys.contains("atcCallsigns") || force) { + ostr << " m_atcCallsigns: " << m_atcCallsigns; + } + if (settingsKeys.contains("transitionAlt") || force) { + ostr << " m_transitionAlt: " << m_transitionAlt; + } + + return QString(ostr.str().c_str()); +} diff --git a/plugins/channelrx/demodadsb/adsbdemodsettings.h b/plugins/channelrx/demodadsb/adsbdemodsettings.h index 5187ea3da..b7909d816 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsettings.h +++ b/plugins/channelrx/demodadsb/adsbdemodsettings.h @@ -201,6 +201,8 @@ struct ADSBDemodSettings bool deserialize(const QByteArray& data); QByteArray serializeNotificationSettings(QList notificationSettings) const; void deserializeNotificationSettings(const QByteArray& data, QList& notificationSettings); + void applySettings(const QStringList& settingsKeys, const ADSBDemodSettings& settings); + QString getDebugString(const QStringList& settingsKeys, bool force = false) const; }; #endif /* PLUGINS_CHANNELRX_DEMODADSB_ADSBDEMODSETTINGS_H_ */ diff --git a/plugins/channelrx/demodadsb/adsbdemodsink.cpp b/plugins/channelrx/demodadsb/adsbdemodsink.cpp index 6b9da6eae..e4792392d 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsink.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodsink.cpp @@ -37,7 +37,7 @@ ADSBDemodSink::ADSBDemodSink() : m_magsqCount(0), m_messageQueueToGUI(nullptr) { - applySettings(m_settings, true); + applySettings(m_settings, QStringList(), true); applyChannelSettings(m_channelSampleRate, m_channelFrequencyOffset, true); for (int i = 0; i < m_buffers; i++) m_bufferWrite[i].release(1); @@ -247,7 +247,7 @@ void ADSBDemodSink::applyChannelSettings(int channelSampleRate, int channelFrequ m_channelFrequencyOffset = channelFrequencyOffset; } -void ADSBDemodSink::applySettings(const ADSBDemodSettings& settings, bool force) +void ADSBDemodSink::applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { qDebug() << "ADSBDemodSink::applySettings:" << " m_inputFrequencyOffset: " << settings.m_inputFrequencyOffset @@ -258,26 +258,30 @@ void ADSBDemodSink::applySettings(const ADSBDemodSettings& settings, bool force) << " m_samplesPerBit: " << settings.m_samplesPerBit << " force: " << force; - if ((settings.m_rfBandwidth != m_settings.m_rfBandwidth) - || (settings.m_samplesPerBit != m_settings.m_samplesPerBit) - || (settings.m_interpolatorPhaseSteps != m_settings.m_interpolatorPhaseSteps) - || (settings.m_interpolatorTapsPerPhase != m_settings.m_interpolatorTapsPerPhase) + if ((settingsKeys.contains("rfBandwidth") && (settings.m_rfBandwidth != m_settings.m_rfBandwidth)) + || (settingsKeys.contains("samplesPerBit") && (settings.m_samplesPerBit != m_settings.m_samplesPerBit)) + || (settingsKeys.contains("interpolatorPhaseSteps") && (settings.m_interpolatorPhaseSteps != m_settings.m_interpolatorPhaseSteps)) + || (settingsKeys.contains("interpolatorTapsPerPhase") && (settings.m_interpolatorTapsPerPhase != m_settings.m_interpolatorTapsPerPhase)) || force) { m_interpolator.create(m_settings.m_interpolatorPhaseSteps, m_channelSampleRate, settings.m_rfBandwidth / 2.2, m_settings.m_interpolatorTapsPerPhase); m_interpolatorDistanceRemain = 0; - m_interpolatorDistance = (Real) m_channelSampleRate / (Real) (ADS_B_BITS_PER_SECOND * settings.m_samplesPerBit); + m_interpolatorDistance = (Real) m_channelSampleRate / (Real) (ADS_B_BITS_PER_SECOND * settings.m_samplesPerBit); } - if ((settings.m_samplesPerBit != m_settings.m_samplesPerBit) || force) + if ((settingsKeys.contains("samplesPerBit") && (settings.m_samplesPerBit != m_settings.m_samplesPerBit)) || force) { init(settings.m_samplesPerBit); } // Forward to worker ADSBDemodSinkWorker::MsgConfigureADSBDemodSinkWorker *msg = ADSBDemodSinkWorker::MsgConfigureADSBDemodSinkWorker::create( - settings, force); + settings, settingsKeys, force); m_worker.getInputMessageQueue()->push(msg); - m_settings = settings; + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } } diff --git a/plugins/channelrx/demodadsb/adsbdemodsink.h b/plugins/channelrx/demodadsb/adsbdemodsink.h index 82f28db01..163a857ee 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsink.h +++ b/plugins/channelrx/demodadsb/adsbdemodsink.h @@ -55,7 +55,7 @@ public: } void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false); - void applySettings(const ADSBDemodSettings& settings, bool force = false); + void applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force = false); void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; } void setMessageQueueToWorker(MessageQueue *messageQueue) { m_messageQueueToWorker = messageQueue; } void startWorker(); diff --git a/plugins/channelrx/demodadsb/adsbdemodsinkworker.cpp b/plugins/channelrx/demodadsb/adsbdemodsinkworker.cpp index 4a6060a76..1157eb743 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsinkworker.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodsinkworker.cpp @@ -357,22 +357,30 @@ void ADSBDemodSinkWorker::handleInputMessages() MsgConfigureADSBDemodSinkWorker* cfg = (MsgConfigureADSBDemodSinkWorker*)message; ADSBDemodSettings settings = cfg->getSettings(); + QStringList settingsKeys = cfg->getSettingsKeys(); bool force = cfg->getForce(); - if (settings.m_correlateFullPreamble) { - m_correlationScale = 3.0; - } else { - m_correlationScale = 2.0; + if (settingsKeys.contains("correlateFullPreamble") || force) + { + if (settings.m_correlateFullPreamble) { + m_correlationScale = 3.0; + } else { + m_correlationScale = 2.0; + } } - if ((m_settings.m_correlationThreshold != settings.m_correlationThreshold) || force) + if ((settingsKeys.contains("correlationThreshold") && (m_settings.m_correlationThreshold != settings.m_correlationThreshold)) || force) { m_correlationThresholdLinear = CalcDb::powerFromdB(settings.m_correlationThreshold); m_correlationThresholdLinear /= m_correlationScale; qDebug() << "m_correlationThresholdLinear: " << m_correlationThresholdLinear; } - m_settings = settings; + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } delete message; } } diff --git a/plugins/channelrx/demodadsb/adsbdemodsinkworker.h b/plugins/channelrx/demodadsb/adsbdemodsinkworker.h index 4c907040f..4c2170243 100644 --- a/plugins/channelrx/demodadsb/adsbdemodsinkworker.h +++ b/plugins/channelrx/demodadsb/adsbdemodsinkworker.h @@ -40,20 +40,23 @@ public: public: const ADSBDemodSettings& getSettings() const { return m_settings; } + const QStringList& getSettingsKeys() const { return m_settingsKeys; } bool getForce() const { return m_force; } - static MsgConfigureADSBDemodSinkWorker* create(const ADSBDemodSettings& settings, bool force) + static MsgConfigureADSBDemodSinkWorker* create(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { - return new MsgConfigureADSBDemodSinkWorker(settings, force); + return new MsgConfigureADSBDemodSinkWorker(settings, settingsKeys, force); } private: ADSBDemodSettings m_settings; + QStringList m_settingsKeys; bool m_force; - MsgConfigureADSBDemodSinkWorker(const ADSBDemodSettings& settings, bool force) : + MsgConfigureADSBDemodSinkWorker(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) : Message(), m_settings(settings), + m_settingsKeys(settingsKeys), m_force(force) { } }; diff --git a/plugins/channelrx/demodadsb/adsbdemodworker.cpp b/plugins/channelrx/demodadsb/adsbdemodworker.cpp index 5feb986a7..9df02e160 100644 --- a/plugins/channelrx/demodadsb/adsbdemodworker.cpp +++ b/plugins/channelrx/demodadsb/adsbdemodworker.cpp @@ -150,7 +150,7 @@ bool ADSBDemodWorker::handleMessage(const Message& message) QMutexLocker mutexLocker(&m_mutex); MsgConfigureADSBDemodWorker& cfg = (MsgConfigureADSBDemodWorker&) message; - applySettings(cfg.getSettings(), cfg.getForce()); + applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce()); return true; } else if (ADSBDemodReport::MsgReportADSB::match(message)) @@ -165,7 +165,7 @@ bool ADSBDemodWorker::handleMessage(const Message& message) } } -void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, bool force) +void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { qDebug() << "ADSBDemodWorker::applySettings:" << " m_feedEnabled: " << settings.m_feedEnabled @@ -179,10 +179,10 @@ void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, bool forc << " m_logFilename: " << settings.m_logFilename << " force: " << force; - if ((settings.m_feedEnabled != m_settings.m_feedEnabled) - || (settings.m_exportClientEnabled != m_settings.m_exportClientEnabled) - || (settings.m_exportClientHost != m_settings.m_exportClientHost) - || (settings.m_exportClientPort != m_settings.m_exportClientPort) + if ((settingsKeys.contains("feedEnabled") && (settings.m_feedEnabled != m_settings.m_feedEnabled)) + || (settingsKeys.contains("exportClientEnabled") && (settings.m_exportClientEnabled != m_settings.m_exportClientEnabled)) + || (settingsKeys.contains("exportClientHost") && (settings.m_exportClientHost != m_settings.m_exportClientHost)) + || (settingsKeys.contains("exportClientPort") && (settings.m_exportClientPort != m_settings.m_exportClientPort)) || force) { // Close any existing connection @@ -195,9 +195,9 @@ void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, bool forc } } - if ((settings.m_feedEnabled != m_settings.m_feedEnabled) - || (settings.m_exportServerEnabled != m_settings.m_exportServerEnabled) - || (settings.m_exportServerPort != m_settings.m_exportServerPort) + if ((settingsKeys.contains("feedEnabled") && (settings.m_feedEnabled != m_settings.m_feedEnabled)) + || (settingsKeys.contains("exportServerEnabled") && (settings.m_exportServerEnabled != m_settings.m_exportServerEnabled)) + || (settingsKeys.contains("exportServerPort") && (settings.m_exportServerPort != m_settings.m_exportServerPort)) || force) { if (m_beastServer.isListening()) { @@ -208,8 +208,8 @@ void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, bool forc } } - if ((settings.m_logEnabled != m_settings.m_logEnabled) - || (settings.m_logFilename != m_settings.m_logFilename) + if ((settingsKeys.contains("logEnabled") && (settings.m_logEnabled != m_settings.m_logEnabled)) + || (settingsKeys.contains("logFilename") && (settings.m_logFilename != m_settings.m_logFilename)) || force) { if (m_logFile.isOpen()) @@ -238,7 +238,11 @@ void ADSBDemodWorker::applySettings(const ADSBDemodSettings& settings, bool forc } } - m_settings = settings; + if (force) { + m_settings = settings; + } else { + m_settings.applySettings(settingsKeys, settings); + } } void ADSBDemodWorker::connected() diff --git a/plugins/channelrx/demodadsb/adsbdemodworker.h b/plugins/channelrx/demodadsb/adsbdemodworker.h index 16a96e8e5..0f04240be 100644 --- a/plugins/channelrx/demodadsb/adsbdemodworker.h +++ b/plugins/channelrx/demodadsb/adsbdemodworker.h @@ -61,20 +61,23 @@ public: public: const ADSBDemodSettings& getSettings() const { return m_settings; } + const QStringList& getSettingsKeys() const { return m_settingsKeys; } bool getForce() const { return m_force; } - static MsgConfigureADSBDemodWorker* create(const ADSBDemodSettings& settings, bool force) + static MsgConfigureADSBDemodWorker* create(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) { - return new MsgConfigureADSBDemodWorker(settings, force); + return new MsgConfigureADSBDemodWorker(settings, settingsKeys, force); } private: ADSBDemodSettings m_settings; + QStringList m_settingsKeys; bool m_force; - MsgConfigureADSBDemodWorker(const ADSBDemodSettings& settings, bool force) : + MsgConfigureADSBDemodWorker(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force) : Message(), m_settings(settings), + m_settingsKeys(settingsKeys), m_force(force) { } }; @@ -101,7 +104,7 @@ private: ADSBBeastServer m_beastServer; bool handleMessage(const Message& cmd); - void applySettings(const ADSBDemodSettings& settings, bool force = false); + void applySettings(const ADSBDemodSettings& settings, const QStringList& settingsKeys, bool force = false); void send(const char *data, int length); char *escape(char *p, char c); void handleADSB(QByteArray data, const QDateTime dateTime, float correlation); From 98481a96e9058e32a45ebe270c21b3d29a00ffb3 Mon Sep 17 00:00:00 2001 From: srcejon Date: Tue, 5 Nov 2024 10:38:13 +0000 Subject: [PATCH 4/4] Fix path to resources. --- plugins/channelrx/freqscanner/freqscannergui.ui | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/channelrx/freqscanner/freqscannergui.ui b/plugins/channelrx/freqscanner/freqscannergui.ui index 2a611a31b..f61bd1b19 100644 --- a/plugins/channelrx/freqscanner/freqscannergui.ui +++ b/plugins/channelrx/freqscanner/freqscannergui.ui @@ -602,7 +602,7 @@ - + :/play.png :/stop.png:/play.png @@ -772,7 +772,7 @@ Leave blank for no adjustment Up - + :/arrow_up.png:/arrow_up.png @@ -786,7 +786,7 @@ Leave blank for no adjustment - + :/arrow_down.png:/arrow_down.png @@ -813,7 +813,7 @@ Leave blank for no adjustment - + :/bin.png:/bin.png @@ -848,7 +848,7 @@ Leave blank for no adjustment deltaFrequency - +