diff --git a/plugins/samplesource/filesource/filesourcegui.cpp b/plugins/samplesource/filesource/filesourcegui.cpp index 879c93fd7..2a6cb267e 100644 --- a/plugins/samplesource/filesource/filesourcegui.cpp +++ b/plugins/samplesource/filesource/filesourcegui.cpp @@ -195,9 +195,9 @@ void FileSourceGui::handleSourceMessages() void FileSourceGui::updateSampleRateAndFrequency() { - m_pluginAPI->getSpectrum()->setSampleRate(m_sampleRate); + m_pluginAPI->getSpectrum()->setSampleRate(m_deviceSampleRate); m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); - ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000)); + ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); } void FileSourceGui::displaySettings() diff --git a/plugins/samplesource/sdrdaemon/sdrdaemongui.cpp b/plugins/samplesource/sdrdaemon/sdrdaemongui.cpp index e50c98113..c760b14d9 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemongui.cpp +++ b/plugins/samplesource/sdrdaemon/sdrdaemongui.cpp @@ -32,7 +32,10 @@ #include "ui_sdrdaemongui.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 "mainwindow.h" #include "util/simpleserializer.h" @@ -92,10 +95,19 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) : displaySettings(); ui->applyButton->setEnabled(false); ui->sendButton->setEnabled(false); + + 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); } SDRdaemonGui::~SDRdaemonGui() { + m_pluginAPI->removeSink(m_fileSink); + delete m_fileSink; delete ui; } @@ -319,6 +331,28 @@ bool SDRdaemonGui::handleMessage(const Message& message) } } +void SDRdaemonGui::handleDSPMessages() +{ + Message* message; + + while ((message = m_pluginAPI->getDeviceOutputMessageQueue()->pop()) != 0) + { + qDebug("SDRdaemonGui::handleDSPMessages: message: %s", message->getIdentifier()); + + if (DSPSignalNotification::match(*message)) + { + DSPSignalNotification* notif = (DSPSignalNotification*) message; + m_deviceSampleRate = notif->getSampleRate(); + m_deviceCenterFrequency = notif->getCenterFrequency(); + qDebug("SDRdaemonGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); + updateSampleRateAndFrequency(); + m_fileSink->handleMessage(*notif); // forward to file sink + + delete message; + } + } +} + void SDRdaemonGui::handleSourceMessages() { Message* message; @@ -334,6 +368,13 @@ void SDRdaemonGui::handleSourceMessages() } } +void SDRdaemonGui::updateSampleRateAndFrequency() +{ + m_pluginAPI->getSpectrum()->setSampleRate(m_deviceSampleRate); + m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency); + ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000)); +} + void SDRdaemonGui::displaySettings() { ui->address->setText(m_address); @@ -557,6 +598,20 @@ void SDRdaemonGui::on_startStop_toggled(bool checked) } } +void SDRdaemonGui::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(); + } +} + void SDRdaemonGui::configureUDPLink() { qDebug() << "SDRdaemonGui::configureUDPLink: " << m_address.toStdString().c_str() diff --git a/plugins/samplesource/sdrdaemon/sdrdaemongui.h b/plugins/samplesource/sdrdaemon/sdrdaemongui.h index 40e357453..47f59692e 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemongui.h +++ b/plugins/samplesource/sdrdaemon/sdrdaemongui.h @@ -24,6 +24,7 @@ #include "sdrdaemoninput.h" class PluginAPI; +class FileSink; namespace Ui { class SDRdaemonGui; @@ -55,6 +56,9 @@ private: QTimer m_statusTimer; SampleSource* m_sampleSource; bool m_acquisition; + FileSink *m_fileSink; //!< File sink to record device I/Q output + int m_deviceSampleRate; + quint64 m_deviceCenterFrequency; //!< Center frequency in device int m_lastEngineState; int m_sampleRate; @@ -103,8 +107,10 @@ private: void updateWithStreamData(); void updateWithStreamTime(); void sendConfiguration(); + void updateSampleRateAndFrequency(); private slots: + void handleDSPMessages(); void handleSourceMessages(); void on_applyButton_clicked(bool checked); void on_dcOffset_toggled(bool checked); @@ -122,6 +128,7 @@ private slots: void on_decim_currentIndexChanged(int index); void on_fcPos_currentIndexChanged(int index); void on_startStop_toggled(bool checked); + void on_record_toggled(bool checked); void updateStatus(); void tick(); }; diff --git a/plugins/samplesource/sdrdaemon/sdrdaemongui.ui b/plugins/samplesource/sdrdaemon/sdrdaemongui.ui index 937643888..05a3e1234 100644 --- a/plugins/samplesource/sdrdaemon/sdrdaemongui.ui +++ b/plugins/samplesource/sdrdaemon/sdrdaemongui.ui @@ -35,19 +35,58 @@ - - - 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 + + + + + +