diff --git a/plugins/channelrx/demodft8/ft8demod.cpp b/plugins/channelrx/demodft8/ft8demod.cpp index 6672c6a20..163b1f043 100644 --- a/plugins/channelrx/demodft8/ft8demod.cpp +++ b/plugins/channelrx/demodft8/ft8demod.cpp @@ -104,6 +104,15 @@ void FT8Demod::setDeviceAPI(DeviceAPI *deviceAPI) } } +void FT8Demod::setMessageQueueToGUI(MessageQueue *queue) +{ + ChannelAPI::setMessageQueueToGUI(queue); + + if (m_basebandSink) { + m_basebandSink->setMessageQueueToGUI(queue); + } +} + uint32_t FT8Demod::getNumberOfDeviceStreams() const { return m_deviceAPI->getNbSourceStreams(); @@ -136,6 +145,7 @@ void FT8Demod::start() ); m_basebandSink->setSpectrumSink(&m_spectrumVis); m_basebandSink->setChannel(this); + qDebug("FT8Demod::start: setMessageQueueToGUI: %p", getMessageQueueToGUI()); m_basebandSink->setMessageQueueToGUI(getMessageQueueToGUI()); m_basebandSink->moveToThread(m_thread); diff --git a/plugins/channelrx/demodft8/ft8demod.h b/plugins/channelrx/demodft8/ft8demod.h index a92f208cb..2bb711e2b 100644 --- a/plugins/channelrx/demodft8/ft8demod.h +++ b/plugins/channelrx/demodft8/ft8demod.h @@ -95,7 +95,7 @@ public: return m_settings.m_inputFrequencyOffset; } - void setMessageQueueToGUI(MessageQueue* queue) override { ChannelAPI::setMessageQueueToGUI(queue); } + void setMessageQueueToGUI(MessageQueue* queue) override; uint32_t getChannelSampleRate() const { return m_running ? m_basebandSink->getChannelSampleRate() : 0; } double getMagSq() const { return m_running ? m_basebandSink->getMagSq() : 0.0; } diff --git a/plugins/channelrx/demodft8/ft8demodbaseband.cpp b/plugins/channelrx/demodft8/ft8demodbaseband.cpp index 9b3156778..ee7e694bb 100644 --- a/plugins/channelrx/demodft8/ft8demodbaseband.cpp +++ b/plugins/channelrx/demodft8/ft8demodbaseband.cpp @@ -31,7 +31,8 @@ MESSAGE_CLASS_DEFINITION(FT8DemodBaseband::MsgConfigureFT8DemodBaseband, Message FT8DemodBaseband::FT8DemodBaseband() : m_channelizer(&m_sink), m_messageQueueToGUI(nullptr), - m_spectrumVis(nullptr) + m_spectrumVis(nullptr), + m_deviceCenterFrequency(0) { qDebug("FT8DemodBaseband::FT8DemodBaseband"); m_sampleFifo.setSize(SampleSinkFifo::getSizePolicy(48000)); @@ -39,7 +40,6 @@ FT8DemodBaseband::FT8DemodBaseband() : m_workerThread = new QThread(); m_ft8DemodWorker = new FT8DemodWorker(); - m_ft8DemodWorker->moveToThread(m_workerThread); QObject::connect( @@ -93,6 +93,12 @@ void FT8DemodBaseband::reset() m_channelSampleRate = 0; } +void FT8DemodBaseband::setMessageQueueToGUI(MessageQueue *messageQueue) +{ + m_messageQueueToGUI = messageQueue; + m_ft8DemodWorker->setReportingMessageQueue(m_messageQueueToGUI); +} + void FT8DemodBaseband::setChannel(ChannelAPI *channel) { m_sink.setChannel(channel); @@ -174,6 +180,12 @@ bool FT8DemodBaseband::handleMessage(const Message& cmd) m_channelSampleRate = m_channelizer.getChannelSampleRate(); } + if (notif.getCenterFrequency() != m_deviceCenterFrequency) + { + m_ft8DemodWorker->invalidateSequence(); + m_deviceCenterFrequency = notif.getCenterFrequency(); + } + return true; } else @@ -186,6 +198,7 @@ void FT8DemodBaseband::applySettings(const FT8DemodSettings& settings, bool forc { if ((settings.m_inputFrequencyOffset != m_settings.m_inputFrequencyOffset) || force) { + m_ft8DemodWorker->invalidateSequence(); m_channelizer.setChannelization(FT8DemodSettings::m_ft8SampleRate, settings.m_inputFrequencyOffset); m_sink.applyChannelSettings(m_channelizer.getChannelSampleRate(), m_channelizer.getChannelFrequencyOffset()); diff --git a/plugins/channelrx/demodft8/ft8demodbaseband.h b/plugins/channelrx/demodft8/ft8demodbaseband.h index 1da9d968d..4f2e2f67b 100644 --- a/plugins/channelrx/demodft8/ft8demodbaseband.h +++ b/plugins/channelrx/demodft8/ft8demodbaseband.h @@ -74,7 +74,7 @@ public: void getMagSqLevels(double& avg, double& peak, int& nbSamples) { m_sink.getMagSqLevels(avg, peak, nbSamples); } bool getAudioActive() const { return m_sink.getAudioActive(); } void setBasebandSampleRate(int sampleRate); - void setMessageQueueToGUI(MessageQueue *messageQueue) { m_messageQueueToGUI = messageQueue; } + void setMessageQueueToGUI(MessageQueue *messageQueue); void setChannel(ChannelAPI *channel); void setFifoLabel(const QString& label) { m_sampleFifo.setLabel(label); } @@ -102,6 +102,7 @@ private: QThread *m_workerThread; FT8DemodWorker *m_ft8DemodWorker; int16_t *m_ft8WorkerBuffer; + qint64 m_deviceCenterFrequency; QRecursiveMutex m_mutex; bool handleMessage(const Message& cmd); diff --git a/plugins/channelrx/demodft8/ft8demodgui.cpp b/plugins/channelrx/demodft8/ft8demodgui.cpp index e9ff7e396..b8682eb85 100644 --- a/plugins/channelrx/demodft8/ft8demodgui.cpp +++ b/plugins/channelrx/demodft8/ft8demodgui.cpp @@ -15,6 +15,7 @@ // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// #include +#include #include "plugin/pluginapi.h" #include "device/deviceuiset.h" @@ -106,6 +107,12 @@ bool FT8DemodGUI::handleMessage(const Message& message) updateAbsoluteCenterFrequency(); return true; } + else if (MsgReportFT8Messages::match(message)) + { + MsgReportFT8Messages& notif = (MsgReportFT8Messages&) message; + messagesReceived(notif.getFT8Messages()); + return true; + } else { return false; @@ -204,6 +211,11 @@ void FT8DemodGUI::on_filterIndex_valueChanged(int value) applyBandwidths(m_settings.m_filterBank[m_settings.m_filterIndex].m_spanLog2, true); // does applySettings(true) } +void FT8DemodGUI::on_clearMessages_clicked() +{ + ui->messages->setRowCount(0); +} + void FT8DemodGUI::on_recordWav_toggled(bool checked) { m_settings.m_recordWav = checked; @@ -585,6 +597,7 @@ void FT8DemodGUI::makeUIConnections() QObject::connect(ui->spanLog2, &QSlider::valueChanged, this, &FT8DemodGUI::on_spanLog2_valueChanged); QObject::connect(ui->fftWindow, QOverload::of(&QComboBox::currentIndexChanged), this, &FT8DemodGUI::on_fftWindow_currentIndexChanged); QObject::connect(ui->filterIndex, &QDial::valueChanged, this, &FT8DemodGUI::on_filterIndex_valueChanged); + QObject::connect(ui->clearMessages, &QPushButton::clicked, this, &FT8DemodGUI::on_clearMessages_clicked); QObject::connect(ui->recordWav, &ButtonSwitch::toggled, this, &FT8DemodGUI::on_recordWav_toggled); QObject::connect(ui->logMessages, &ButtonSwitch::toggled, this, &FT8DemodGUI::on_logMessages_toggled); QObject::connect(ui->nbThreads, &QDial::valueChanged, this, &FT8DemodGUI::on_nbThreads_valueChanged); @@ -606,12 +619,68 @@ void FT8DemodGUI::resizeMessageTable() ui->messages->setItem(row, MESSAGE_COL_N, new QTableWidgetItem("0")); ui->messages->setItem(row, MESSAGE_COL_SNR, new QTableWidgetItem("-24")); ui->messages->setItem(row, MESSAGE_COL_DEC, new QTableWidgetItem("174")); - ui->messages->setItem(row, MESSAGE_COL_DT, new QTableWidgetItem("0.0")); + ui->messages->setItem(row, MESSAGE_COL_DT, new QTableWidgetItem("-0.0")); ui->messages->setItem(row, MESSAGE_COL_DF, new QTableWidgetItem("0000")); ui->messages->setItem(row, MESSAGE_COL_CALL1, new QTableWidgetItem("123456789ABCD")); ui->messages->setItem(row, MESSAGE_COL_CALL2, new QTableWidgetItem("HF7SIEMA")); - ui->messages->setItem(row, MESSAGE_COL_LOC, new QTableWidgetItem("JN00")); - ui->messages->setItem(row, MESSAGE_COL_INFO, new QTableWidgetItem("hint1")); + ui->messages->setItem(row, MESSAGE_COL_LOC, new QTableWidgetItem("JN000")); + ui->messages->setItem(row, MESSAGE_COL_INFO, new QTableWidgetItem("OSD-0-73")); ui->messages->resizeColumnsToContents(); ui->messages->removeRow(row); } + +void FT8DemodGUI::messagesReceived(const QList& messages) +{ + ui->nbDecodesText->setText(tr("%1").arg(messages.size())); + + // Is scroll bar at bottom + QScrollBar *sb = ui->messages->verticalScrollBar(); + bool scrollToBottom = sb->value() == sb->maximum(); + + // Add to messages table + int row = ui->messages->rowCount(); + + for (const auto& message : messages) + { + ui->messages->setRowCount(row + 1); + + QTableWidgetItem *utcItem = new QTableWidgetItem(); + QTableWidgetItem *passItem = new QTableWidgetItem(); + QTableWidgetItem *snrItem = new QTableWidgetItem(); + QTableWidgetItem *correctItem = new QTableWidgetItem(); + QTableWidgetItem *dtItem = new QTableWidgetItem(); + QTableWidgetItem *dfItem = new QTableWidgetItem(); + QTableWidgetItem *call1Item = new QTableWidgetItem(); + QTableWidgetItem *call2Item = new QTableWidgetItem(); + QTableWidgetItem *locItem = new QTableWidgetItem(); + QTableWidgetItem *infoItem = new QTableWidgetItem(); + + ui->messages->setItem(row, MESSAGE_COL_UTC, utcItem); + ui->messages->setItem(row, MESSAGE_COL_N, passItem); + ui->messages->setItem(row, MESSAGE_COL_SNR, snrItem); + ui->messages->setItem(row, MESSAGE_COL_DEC, correctItem); + ui->messages->setItem(row, MESSAGE_COL_DT, dtItem); + ui->messages->setItem(row, MESSAGE_COL_DF, dfItem); + ui->messages->setItem(row, MESSAGE_COL_CALL1, call1Item); + ui->messages->setItem(row, MESSAGE_COL_CALL2, call2Item); + ui->messages->setItem(row, MESSAGE_COL_LOC, locItem); + ui->messages->setItem(row, MESSAGE_COL_INFO, infoItem); + + utcItem->setText(message.ts.toString("HHmmss")); + passItem->setText(tr("%1").arg(message.pass)); + snrItem->setText(tr("%1").arg(message.snr)); + correctItem->setText(tr("%1").arg(message.nbCorrectBits)); + dtItem->setText(tr("%1").arg(message.dt, 0, 'f', 1)); + dfItem->setText(tr("%1").arg((int) message.df)); + call1Item->setText(message.call1); + call2Item->setText(message.call2); + locItem->setText(message.loc); + infoItem->setText(message.decoderInfo); + + row++; + } + + if (scrollToBottom) { + ui->messages->scrollToBottom(); + } +} diff --git a/plugins/channelrx/demodft8/ft8demodgui.h b/plugins/channelrx/demodft8/ft8demodgui.h index 22d3bfe89..590f242a0 100644 --- a/plugins/channelrx/demodft8/ft8demodgui.h +++ b/plugins/channelrx/demodft8/ft8demodgui.h @@ -21,6 +21,7 @@ #include "dsp/channelmarker.h" #include "dsp/movingaverage.h" #include "util/messagequeue.h" +#include "util/ft8message.h" #include "settings/rollupstate.h" #include "ft8demodsettings.h" @@ -101,6 +102,7 @@ private: void enterEvent(EnterEventType*); void resizeMessageTable(); + void messagesReceived(const QList& messages); enum MessageCol { MESSAGE_COL_UTC, @@ -124,6 +126,7 @@ private slots: void on_spanLog2_valueChanged(int value); void on_fftWindow_currentIndexChanged(int index); void on_filterIndex_valueChanged(int value); + void on_clearMessages_clicked(); void on_recordWav_toggled(bool checked); void on_logMessages_toggled(bool checked); void on_nbThreads_valueChanged(int value); diff --git a/plugins/channelrx/demodft8/ft8demodgui.ui b/plugins/channelrx/demodft8/ft8demodgui.ui index 04be3935e..e49166cbc 100644 --- a/plugins/channelrx/demodft8/ft8demodgui.ui +++ b/plugins/channelrx/demodft8/ft8demodgui.ui @@ -6,19 +6,19 @@ 0 0 - 414 + 500 731 - + 0 0 - 414 + 500 0 @@ -36,7 +36,7 @@ 0 0 - 412 + 481 181 @@ -742,7 +742,7 @@ 0 460 - 412 + 481 251 @@ -907,6 +907,32 @@ + + + + + 0 + 0 + + + + + 32 + 0 + + + + Clear messages from table + + + + + + + :/bin.png:/bin.png + + + diff --git a/plugins/channelrx/demodft8/ft8demodworker.cpp b/plugins/channelrx/demodft8/ft8demodworker.cpp index 6df37fb8f..feabd68fc 100644 --- a/plugins/channelrx/demodft8/ft8demodworker.cpp +++ b/plugins/channelrx/demodft8/ft8demodworker.cpp @@ -58,7 +58,6 @@ int FT8DemodWorker::FT8Callback::hcb( } cycle_already[msg] = true; - cycle_mu.unlock(); QList& ft8Messages = m_msgReportFT8Messages->getFT8Messages(); ft8Messages.push_back(FT8Message()); @@ -74,6 +73,7 @@ int FT8DemodWorker::FT8Callback::hcb( ft8Message.call2 = QString(call2.c_str()); ft8Message.loc = QString(loc.c_str()); ft8Message.decoderInfo = QString(comment); + cycle_mu.unlock(); qDebug("FT8DemodWorker::FT8Callback::hcb: %d %3d %3d %5.2f %6.1f %s [%s:%s:%s] (%s)", pass, @@ -114,6 +114,13 @@ void FT8DemodWorker::processBuffer(int16_t *buffer, QDateTime periodTS) qDebug("FT8DemodWorker::processBuffer: %s %d:%f [%d:%d]", qPrintable(periodTS.toString("yyyy-MM-dd HH:mm:ss")), m_nbDecoderThreads, m_decoderTimeBudget, m_lowFreq, m_highFreq); + if (m_invalidSequence) + { + qDebug("FT8DemodWorker::processBuffer: invalid sequence"); + m_invalidSequence = false; + return; + } + if (m_recordSamples) { WavFileRecord *wavFileRecord = new WavFileRecord(FT8DemodSettings::m_ft8SampleRate); diff --git a/plugins/channelrx/demodft8/ft8demodworker.h b/plugins/channelrx/demodft8/ft8demodworker.h index 811f5ad27..bb0eed212 100644 --- a/plugins/channelrx/demodft8/ft8demodworker.h +++ b/plugins/channelrx/demodft8/ft8demodworker.h @@ -42,6 +42,7 @@ public: void setLowFrequency(int lowFreq) { m_lowFreq = lowFreq; } void setHighFrequency(int highFreq) { m_highFreq = highFreq; } void setReportingMessageQueue(MessageQueue *messageQueue) { m_reportingMessageQueue = messageQueue; } + void invalidateSequence() { m_invalidSequence = true; } private: class FT8Callback : public FT8::CallbackInterface @@ -78,6 +79,7 @@ private: float m_decoderTimeBudget; int m_lowFreq; int m_highFreq; + bool m_invalidSequence; FT8::FT8Decoder m_ft8Decoder; FT8::Packing m_packing; MessageQueue *m_reportingMessageQueue;