diff --git a/plugins/samplesource/fcdproplus/fcdproplusgui.cpp b/plugins/samplesource/fcdproplus/fcdproplusgui.cpp index 32f3b35ee..c4dec99bb 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusgui.cpp +++ b/plugins/samplesource/fcdproplus/fcdproplusgui.cpp @@ -20,7 +20,10 @@ #include "ui_fcdproplusgui.h" #include "plugin/pluginapi.h" #include "gui/colormapper.h" +#include "gui/glspectrum.h" #include "dsp/dspengine.h" +#include "dsp/dspcommands.h" +#include "dsp/filesink.h" #include "fcdproplusgui.h" #include "fcdproplusconst.h" @@ -57,10 +60,19 @@ FCDProPlusGui::FCDProPlusGui(PluginAPI* pluginAPI, QWidget* parent) : m_sampleSource = new FCDProPlusInput(); DSPEngine::instance()->setSource(m_sampleSource); + + char recFileNameCStr[30]; + sprintf(recFileNameCStr, "test_%d.sdriq", m_pluginAPI->getDeviceUID()); + m_fileSink = new FileSink(std::string(recFileNameCStr)); + m_pluginAPI->addSink(m_fileSink); + + connect(m_pluginAPI->getDeviceOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection); } FCDProPlusGui::~FCDProPlusGui() { + m_pluginAPI->removeSink(m_fileSink); + delete m_fileSink; delete ui; } @@ -123,6 +135,35 @@ bool FCDProPlusGui::handleMessage(const Message& message) return false; } +void FCDProPlusGui::handleDSPMessages() +{ + Message* message; + + while ((message = m_pluginAPI->getDeviceOutputMessageQueue()->pop()) != 0) + { + qDebug("RTLSDRGui::handleDSPMessages: message: %s", message->getIdentifier()); + + if (DSPSignalNotification::match(*message)) + { + DSPSignalNotification* notif = (DSPSignalNotification*) message; + m_sampleRate = notif->getSampleRate(); + m_deviceCenterFrequency = notif->getCenterFrequency(); + qDebug("RTLSDRGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); + updateSampleRateAndFrequency(); + m_fileSink->handleMessage(*notif); // forward to file sink + + delete message; + } + } +} + +void FCDProPlusGui::updateSampleRateAndFrequency() +{ + m_pluginAPI->getSpectrum()->setSampleRate(m_sampleRate); + m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); + ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); +} + void FCDProPlusGui::displaySettings() { ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); @@ -260,4 +301,16 @@ void FCDProPlusGui::on_startStop_toggled(bool checked) } } - +void FCDProPlusGui::on_record_toggled(bool checked) +{ + if (checked) + { + ui->record->setStyleSheet("QToolButton { background-color : red; }"); + m_fileSink->startRecording(); + } + else + { + ui->record->setStyleSheet("QToolButton { background:rgb(79,79,79); }"); + m_fileSink->stopRecording(); + } +} diff --git a/plugins/samplesource/fcdproplus/fcdproplusgui.h b/plugins/samplesource/fcdproplus/fcdproplusgui.h index 621eda6e8..5fecab4b8 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusgui.h +++ b/plugins/samplesource/fcdproplus/fcdproplusgui.h @@ -1,13 +1,3 @@ -#ifndef INCLUDE_FCDGUI_H -#define INCLUDE_FCDGUI_H - -#include - -#include "fcdproplusinput.h" -#include "plugin/plugingui.h" - -class PluginAPI; - /////////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2015 Edouard Griffiths, F4EXB // // // @@ -24,6 +14,17 @@ class PluginAPI; // along with this program. If not, see . // /////////////////////////////////////////////////////////////////////////////////// +#ifndef INCLUDE_FCDGUI_H +#define INCLUDE_FCDGUI_H + +#include + +#include "fcdproplusinput.h" +#include "plugin/plugingui.h" + +class PluginAPI; +class FileSink; + namespace Ui { class FCDProPlusGui; } @@ -56,12 +57,17 @@ private: QTimer m_statusTimer; std::vector m_gains; SampleSource* m_sampleSource; + FileSink *m_fileSink; //!< File sink to record device I/Q output + int m_sampleRate; + quint64 m_deviceCenterFrequency; //!< Center frequency in device int m_lastEngineState; void displaySettings(); void sendSettings(); + void updateSampleRateAndFrequency(); private slots: + void handleDSPMessages(); void on_centerFrequency_changed(quint64 value); void on_dcOffset_toggled(bool checked); void on_iqImbalance_toggled(bool checked); @@ -73,6 +79,7 @@ private slots: void on_filterIF_currentIndexChanged(int index); void on_ppm_valueChanged(int value); void on_startStop_toggled(bool checked); + void on_record_toggled(bool checked); void updateHardware(); void updateStatus(); }; diff --git a/plugins/samplesource/fcdproplus/fcdproplusgui.ui b/plugins/samplesource/fcdproplus/fcdproplusgui.ui index c52d152fd..de7401758 100644 --- a/plugins/samplesource/fcdproplus/fcdproplusgui.ui +++ b/plugins/samplesource/fcdproplus/fcdproplusgui.ui @@ -33,21 +33,60 @@ 2 - + - - - start/stop acquisition - - - - - - - :/play.png - :/stop.png:/play.png - - + + + + + + + start/stop acquisition + + + + + + + :/play.png + :/stop.png:/play.png + + + + + + + Toggle record I/Q samples from device + + + + + + + :/record_off.png:/record_off.png + + + + + + + + + + + I/Q sample rate kS/s + + + 00000k + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + +