From 110956ba9c3287c796389224ac192746b526f71f Mon Sep 17 00:00:00 2001 From: f4exb Date: Thu, 6 Aug 2015 01:43:35 +0200 Subject: [PATCH] File sample source plugin now functional --- Readme.md | 4 ++-- .../samplesource/filesource/filesourcegui.cpp | 18 +++++++++++++++--- .../samplesource/filesource/filesourcegui.h | 2 ++ .../filesource/filesourceinput.cpp | 9 +++++++++ .../samplesource/filesource/filesourceinput.h | 17 +++++++++++++++++ 5 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Readme.md b/Readme.md index c35ade14d..80c4f31f7 100644 --- a/Readme.md +++ b/Readme.md @@ -127,8 +127,8 @@ Done since the fork - Spectrum histogram clear - Trigger line display for all trigger modes - Coarse and fine trigger level sliders - - Minimalist recording - - Minimalist file source (recording reader) compilable but untested + - Minimalist recording (no file choice) + - File sample source plugin (recording reader) ===== To Do diff --git a/plugins/samplesource/filesource/filesourcegui.cpp b/plugins/samplesource/filesource/filesourcegui.cpp index 0f3ba46a6..fa3b558f4 100644 --- a/plugins/samplesource/filesource/filesourcegui.cpp +++ b/plugins/samplesource/filesource/filesourcegui.cpp @@ -38,13 +38,15 @@ FileSourceGui::FileSourceGui(PluginAPI* pluginAPI, QWidget* parent) : m_sampleRate(0), m_centerFrequency(0), m_startingTimeStamp(0), - m_samplesCount(0) + m_samplesCount(0), + m_tickCount(0) { ui->setupUi(this); ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold)); ui->centerFrequency->setValueRange(7, 0, pow(10,7)); ui->fileNameText->setText(m_fileName); connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware())); + connect(&(m_pluginAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick())); displaySettings(); m_sampleSource = new FileSourceInput(m_pluginAPI->getMainWindowMessageQueue(), m_pluginAPI->getMainWindow()->getMasterTimer()); @@ -133,15 +135,17 @@ bool FileSourceGui::handleMessage(Message* message) m_sampleRate = ((FileSourceInput::MsgReportFileSourceStreamData*)message)->getSampleRate(); m_centerFrequency = ((FileSourceInput::MsgReportFileSourceStreamData*)message)->getCenterFrequency(); m_startingTimeStamp = ((FileSourceInput::MsgReportFileSourceStreamData*)message)->getStartingTimeStamp(); - updateWithStreamData(); message->completed(); + updateWithStreamData(); return true; } else if(FileSourceInput::MsgReportFileSourceStreamTiming::match(message)) { m_samplesCount = ((FileSourceInput::MsgReportFileSourceStreamTiming*)message)->getSamplesCount(); - std::cerr << "FileSourceGui::handleMessage: MsgReportFileSourceStreamTiming: " << m_samplesCount << std::endl; + //std::cerr << "FileSourceGui::handleMessage: MsgReportFileSourceStreamTiming: " << m_samplesCount << std::endl; + message->completed(); updateWithStreamTime(); + return true; } else { @@ -234,3 +238,11 @@ void FileSourceGui::updateWithStreamTime() QString s_date = dt.toString("yyyyMMdd hh.mm.ss.zzz"); ui->absTimeText->setText(s_date); } + +void FileSourceGui::tick() +{ + if ((++m_tickCount & 0xf) == 0) { + FileSourceInput::MsgConfigureFileSourceStreamTiming* message = FileSourceInput::MsgConfigureFileSourceStreamTiming::create(); + message->submit(m_pluginAPI->getDSPEngineMessageQueue()); + } +} diff --git a/plugins/samplesource/filesource/filesourcegui.h b/plugins/samplesource/filesource/filesourcegui.h index 9c376b828..10f61d808 100644 --- a/plugins/samplesource/filesource/filesourcegui.h +++ b/plugins/samplesource/filesource/filesourcegui.h @@ -62,6 +62,7 @@ private: quint64 m_centerFrequency; std::time_t m_startingTimeStamp; int m_samplesCount; + std::size_t m_tickCount; void displaySettings(); void displayTime(); @@ -76,6 +77,7 @@ private slots: void on_playLoop_toggled(bool checked); void on_play_toggled(bool checked); void on_showFileDialog_clicked(bool checked); + void tick(); }; #endif // INCLUDE_FILESOURCEGUI_H diff --git a/plugins/samplesource/filesource/filesourceinput.cpp b/plugins/samplesource/filesource/filesourceinput.cpp index a5dee5738..37d840d60 100644 --- a/plugins/samplesource/filesource/filesourceinput.cpp +++ b/plugins/samplesource/filesource/filesourceinput.cpp @@ -29,6 +29,7 @@ MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSource, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceName, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceWork, Message) +MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceStreamTiming, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message) MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message) @@ -217,6 +218,14 @@ bool FileSourceInput::handleMessage(Message* message) message->completed(); return true; } + else if (MsgConfigureFileSourceStreamTiming::match(message)) + { + if (m_fileSourceThread != 0) { + MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount())->submit(m_guiMessageQueue); + }else { + MsgReportFileSourceStreamTiming::create(0)->submit(m_guiMessageQueue); + } + } else { return false; diff --git a/plugins/samplesource/filesource/filesourceinput.h b/plugins/samplesource/filesource/filesourceinput.h index 4ac16fabe..98b19ee51 100644 --- a/plugins/samplesource/filesource/filesourceinput.h +++ b/plugins/samplesource/filesource/filesourceinput.h @@ -100,6 +100,23 @@ public: { } }; + class MsgConfigureFileSourceStreamTiming : public Message { + MESSAGE_CLASS_DECLARATION + + public: + + static MsgConfigureFileSourceStreamTiming* create() + { + return new MsgConfigureFileSourceStreamTiming(); + } + + private: + + MsgConfigureFileSourceStreamTiming() : + Message() + { } + }; + class MsgReportFileSourceAcquisition : public Message { MESSAGE_CLASS_DECLARATION