From 4032d62b3df74092e9d9dac97a0d916103c1ce73 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 9 Oct 2018 18:52:39 +0200 Subject: [PATCH] FileRecord improvement: added visual indicator for CRC check in the GUI --- .../samplesource/filesource/filesourcegui.cpp | 13 +++++++++++ .../samplesource/filesource/filesourcegui.ui | 22 +++++++++++++++++++ .../filesource/filesourceinput.cpp | 6 +++++ .../samplesource/filesource/filesourceinput.h | 19 ++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/plugins/samplesource/filesource/filesourcegui.cpp b/plugins/samplesource/filesource/filesourcegui.cpp index 8bcedc3af..de56a6d5f 100644 --- a/plugins/samplesource/filesource/filesourcegui.cpp +++ b/plugins/samplesource/filesource/filesourcegui.cpp @@ -57,6 +57,7 @@ FileSourceGui::FileSourceGui(DeviceUISet *deviceUISet, QWidget* parent) : ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::GrayGold)); ui->centerFrequency->setValueRange(7, 0, pow(10,7)); ui->fileNameText->setText(m_fileName); + ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); connect(&(m_deviceUISet->m_deviceSourceAPI->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus())); @@ -198,6 +199,17 @@ bool FileSourceGui::handleMessage(const Message& message) return true; } + else if (FileSourceInput::MsgReportHeaderCRC::match(message)) + { + FileSourceInput::MsgReportHeaderCRC& notif = (FileSourceInput::MsgReportHeaderCRC&) message; + if (notif.isOK()) { + ui->crcLabel->setStyleSheet("QLabel { background-color : green; }"); + } else { + ui->crcLabel->setStyleSheet("QLabel { background-color : red; }"); + } + + return true; + } else { return false; @@ -292,6 +304,7 @@ void FileSourceGui::on_showFileDialog_clicked(bool checked __attribute__((unused { m_fileName = fileName; ui->fileNameText->setText(m_fileName); + ui->crcLabel->setStyleSheet("QLabel { background:rgb(79,79,79); }"); configureFileName(); } } diff --git a/plugins/samplesource/filesource/filesourcegui.ui b/plugins/samplesource/filesource/filesourcegui.ui index f6a01558a..a634995e8 100644 --- a/plugins/samplesource/filesource/filesourcegui.ui +++ b/plugins/samplesource/filesource/filesourcegui.ui @@ -287,6 +287,28 @@ + + + + Qt::Vertical + + + + + + + + 8 + + + + CRC status: Green: OK Red: KO Grey: undefined + + + CRC + + + diff --git a/plugins/samplesource/filesource/filesourceinput.cpp b/plugins/samplesource/filesource/filesourceinput.cpp index 636a9577b..053eadac8 100644 --- a/plugins/samplesource/filesource/filesourceinput.cpp +++ b/plugins/samplesource/filesource/filesourceinput.cpp @@ -43,6 +43,7 @@ MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgStartStop, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message) +MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportHeaderCRC, Message) FileSourceInput::FileSourceInput(DeviceSourceAPI *deviceAPI) : m_deviceAPI(deviceAPI), @@ -105,6 +106,11 @@ void FileSourceInput::openFileStream() qCritical("FileSourceInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex)); m_recordLength = 0; } + + if (getMessageQueueToGUI()) { + MsgReportHeaderCRC *report = MsgReportHeaderCRC::create(crcOK); + getMessageQueueToGUI()->push(report); + } } else { diff --git a/plugins/samplesource/filesource/filesourceinput.h b/plugins/samplesource/filesource/filesourceinput.h index 38c160261..4f149da7e 100644 --- a/plugins/samplesource/filesource/filesourceinput.h +++ b/plugins/samplesource/filesource/filesourceinput.h @@ -228,6 +228,25 @@ public: { } }; + class MsgReportHeaderCRC : public Message { + MESSAGE_CLASS_DECLARATION + + public: + bool isOK() const { return m_ok; } + + static MsgReportHeaderCRC* create(bool ok) { + return new MsgReportHeaderCRC(ok); + } + + protected: + bool m_ok; + + MsgReportHeaderCRC(bool ok) : + Message(), + m_ok(ok) + { } + }; + FileSourceInput(DeviceSourceAPI *deviceAPI); virtual ~FileSourceInput(); virtual void destroy();