1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-20 11:56:36 -04:00

Multi device support: Apply previous changes to RTL-SDR.

This commit is contained in:
f4exb 2016-05-12 11:10:10 +02:00
parent e25c465b82
commit e750acc7da
7 changed files with 153 additions and 81 deletions

View File

@ -156,10 +156,8 @@ void BladerfGui::handleDSPMessages()
m_sampleRate = notif->getSampleRate(); m_sampleRate = notif->getSampleRate();
m_deviceCenterFrequency = notif->getCenterFrequency(); m_deviceCenterFrequency = notif->getCenterFrequency();
qDebug("BladerfGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency()); qDebug("BladerfGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
// updateCenterFreqDisplay();
updateSampleRateAndFrequency(); updateSampleRateAndFrequency();
// qDebug() << "MainWindow::handleDSPMessages: forward to file sink"; m_fileSink->handleMessage(*notif); // forward to file sink
// m_fileSink->handleMessage(*notif);
delete message; delete message;
} }

View File

@ -55,6 +55,9 @@
</item> </item>
<item> <item>
<widget class="ButtonSwitch" name="record"> <widget class="ButtonSwitch" name="record">
<property name="toolTip">
<string>Record I/Q samples from device</string>
</property>
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -72,7 +75,7 @@
<item> <item>
<widget class="QLabel" name="deviceRateLabel"> <widget class="QLabel" name="deviceRateLabel">
<property name="toolTip"> <property name="toolTip">
<string>Sample rate kS/s</string> <string>I/Q sample rate kS/s</string>
</property> </property>
<property name="text"> <property name="text">
<string>00000k</string> <string>00000k</string>

View File

@ -1,3 +1,19 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug> #include <QDebug>
#include <QMessageBox> #include <QMessageBox>
@ -5,7 +21,10 @@
#include "ui_rtlsdrgui.h" #include "ui_rtlsdrgui.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
#include "gui/colormapper.h" #include "gui/colormapper.h"
#include "gui/glspectrum.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/dspcommands.h"
#include "dsp/filesink.h"
RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) : RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
QWidget(parent), QWidget(parent),
@ -35,10 +54,19 @@ RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
m_sampleSource = new RTLSDRInput(); m_sampleSource = new RTLSDRInput();
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages())); connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
DSPEngine::instance()->setSource(m_sampleSource); 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);
} }
RTLSDRGui::~RTLSDRGui() RTLSDRGui::~RTLSDRGui()
{ {
m_pluginAPI->removeSink(m_fileSink);
delete m_fileSink;
delete ui; delete ui;
} }
@ -123,6 +151,28 @@ bool RTLSDRGui::handleMessage(const Message& message)
} }
} }
void RTLSDRGui::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 RTLSDRGui::handleSourceMessages() void RTLSDRGui::handleSourceMessages()
{ {
Message* message; Message* message;
@ -138,6 +188,13 @@ void RTLSDRGui::handleSourceMessages()
} }
} }
void RTLSDRGui::updateSampleRateAndFrequency()
{
m_pluginAPI->getSpectrum()->setSampleRate(m_sampleRate);
m_pluginAPI->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
ui->deviceRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000));
}
void RTLSDRGui::displaySettings() void RTLSDRGui::displaySettings()
{ {
ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000); ui->centerFrequency->setValue(m_settings.m_centerFrequency / 1000);
@ -269,6 +326,20 @@ void RTLSDRGui::on_startStop_toggled(bool checked)
} }
} }
void RTLSDRGui::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 RTLSDRGui::updateHardware() void RTLSDRGui::updateHardware()
{ {
RTLSDRInput::MsgConfigureRTLSDR* message = RTLSDRInput::MsgConfigureRTLSDR::create(m_settings); RTLSDRInput::MsgConfigureRTLSDR* message = RTLSDRInput::MsgConfigureRTLSDR::create(m_settings);

View File

@ -1,3 +1,19 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_RTLSDRGUI_H #ifndef INCLUDE_RTLSDRGUI_H
#define INCLUDE_RTLSDRGUI_H #define INCLUDE_RTLSDRGUI_H
@ -6,6 +22,7 @@
#include "rtlsdrinput.h" #include "rtlsdrinput.h"
class PluginAPI; class PluginAPI;
class FileSink;
namespace Ui { namespace Ui {
class RTLSDRGui; class RTLSDRGui;
@ -39,12 +56,17 @@ private:
QTimer m_statusTimer; QTimer m_statusTimer;
std::vector<int> m_gains; std::vector<int> m_gains;
SampleSource* m_sampleSource; 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; int m_lastEngineState;
void displaySettings(); void displaySettings();
void sendSettings(); void sendSettings();
void updateSampleRateAndFrequency();
private slots: private slots:
void handleDSPMessages();
void on_centerFrequency_changed(quint64 value); void on_centerFrequency_changed(quint64 value);
void on_dcOffset_toggled(bool checked); void on_dcOffset_toggled(bool checked);
void on_iqImbalance_toggled(bool checked); void on_iqImbalance_toggled(bool checked);
@ -55,6 +77,7 @@ private slots:
void on_sampleRate_currentIndexChanged(int index); void on_sampleRate_currentIndexChanged(int index);
void on_checkBox_stateChanged(int state); void on_checkBox_stateChanged(int state);
void on_startStop_toggled(bool checked); void on_startStop_toggled(bool checked);
void on_record_toggled(bool checked);
void updateHardware(); void updateHardware();
void updateStatus(); void updateStatus();
void handleSourceMessages(); void handleSourceMessages();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>298</width> <width>298</width>
<height>271</height> <height>189</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -35,19 +35,59 @@
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_freq"> <layout class="QHBoxLayout" name="horizontalLayout_freq">
<item> <item>
<widget class="ButtonSwitch" name="startStop"> <layout class="QVBoxLayout" name="deviceUILayout">
<property name="toolTip"> <item>
<string>start/stop acquisition</string> <layout class="QHBoxLayout" name="deviceButtonsLayout">
</property> <item>
<property name="text"> <widget class="ButtonSwitch" name="startStop">
<string/> <property name="toolTip">
</property> <string>start/stop acquisition</string>
<property name="icon"> </property>
<iconset resource="../../../sdrbase/resources/res.qrc"> <property name="text">
<normaloff>:/play.png</normaloff> <string/>
<normalon>:/stop.png</normalon>:/play.png</iconset> </property>
</property> <property name="icon">
</widget> <iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/play.png</normaloff>
<normalon>:/stop.png</normalon>:/play.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="ButtonSwitch" name="record">
<property name="toolTip">
<string>Record I/Q samples from device</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../sdrbase/resources/res.qrc">
<normaloff>:/record_off.png</normaloff>
<normalon>:/record_on.png</normalon>:/record_off.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="deviceRateLayout">
<item>
<widget class="QLabel" name="deviceRateText">
<property name="toolTip">
<string>I/Q sample rate kS/s</string>
</property>
<property name="text">
<string>00000k</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">

View File

@ -38,7 +38,6 @@
#include "gui/audiodialog.h" #include "gui/audiodialog.h"
#include "dsp/dspengine.h" #include "dsp/dspengine.h"
#include "dsp/spectrumvis.h" #include "dsp/spectrumvis.h"
//#include "dsp/filesink.h"
#include "dsp/dspcommands.h" #include "dsp/dspcommands.h"
#include "plugin/plugingui.h" #include "plugin/plugingui.h"
#include "plugin/pluginapi.h" #include "plugin/pluginapi.h"
@ -104,8 +103,6 @@ MainWindow::MainWindow(QWidget* parent) :
// TODO: This will go in a create new device and device tab method: // TODO: This will go in a create new device and device tab method:
DSPDeviceEngine *dspDeviceEngine = m_dspEngine->getDeviceEngineByIndex(0); DSPDeviceEngine *dspDeviceEngine = m_dspEngine->getDeviceEngineByIndex(0);
// connect(dspDeviceEngine->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
dspDeviceEngine->start(); dspDeviceEngine->start();
m_deviceUIs.push_back(new DeviceUISet(m_masterTimer)); m_deviceUIs.push_back(new DeviceUISet(m_masterTimer));
@ -123,9 +120,6 @@ MainWindow::MainWindow(QWidget* parent) :
m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked); m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked);
ui->tabInputs->addTab(m_deviceUIs.back()->m_sampleSource, "X0"); ui->tabInputs->addTab(m_deviceUIs.back()->m_sampleSource, "X0");
// m_fileSink = new FileSink();
// dspDeviceEngine->addSink(m_fileSink); // TODO: one file sink per device engine
qDebug() << "MainWindow::MainWindow: loadSettings..."; qDebug() << "MainWindow::MainWindow: loadSettings...";
loadSettings(); loadSettings();
@ -174,10 +168,6 @@ MainWindow::~MainWindow()
delete m_deviceUIs[i]; delete m_deviceUIs[i];
} }
// m_dspEngine->removeSink(m_fileSink); // TODO: one file sink per device engine
// //m_dspEngine->removeSink(m_rxSpectrumVis);
// delete m_fileSink;
//delete m_rxSpectrumVis;
delete m_pluginManager; delete m_pluginManager;
m_dspEngine->stopAllDeviceEngines(); m_dspEngine->stopAllDeviceEngines();
@ -193,8 +183,6 @@ void MainWindow::addChannelCreateAction(QAction* action)
void MainWindow::addChannelRollup(QWidget* widget) void MainWindow::addChannelRollup(QWidget* widget)
{ {
m_deviceUIs.back()->m_channelWindow->addRollupWidget(widget); m_deviceUIs.back()->m_channelWindow->addRollupWidget(widget);
//((ChannelWindow*)ui->rxChannels)->addRollupWidget(widget);
//((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
ui->channelDock->show(); ui->channelDock->show();
ui->channelDock->raise(); ui->channelDock->raise();
} }
@ -206,13 +194,11 @@ void MainWindow::addViewAction(QAction* action)
void MainWindow::addChannelMarker(ChannelMarker* channelMarker) void MainWindow::addChannelMarker(ChannelMarker* channelMarker)
{ {
//ui->rxSpectrum->addChannelMarker(channelMarker);
m_deviceUIs.back()->m_spectrum->addChannelMarker(channelMarker); m_deviceUIs.back()->m_spectrum->addChannelMarker(channelMarker);
} }
void MainWindow::removeChannelMarker(ChannelMarker* channelMarker) void MainWindow::removeChannelMarker(ChannelMarker* channelMarker)
{ {
//ui->rxSpectrum->removeChannelMarker(channelMarker);
m_deviceUIs.back()->m_spectrum->removeChannelMarker(channelMarker); m_deviceUIs.back()->m_spectrum->removeChannelMarker(channelMarker);
} }
@ -243,7 +229,6 @@ void MainWindow::loadPresetSettings(const Preset* preset)
qPrintable(preset->getGroup()), qPrintable(preset->getGroup()),
qPrintable(preset->getDescription())); qPrintable(preset->getDescription()));
//ui->rxSpectrumGUI->deserialize(preset->getSpectrumConfig());
m_deviceUIs.back()->m_spectrumGUI->deserialize(preset->getSpectrumConfig()); m_deviceUIs.back()->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
m_pluginManager->loadSettings(preset); m_pluginManager->loadSettings(preset);
@ -265,7 +250,6 @@ void MainWindow::savePresetSettings(Preset* preset)
qPrintable(preset->getGroup()), qPrintable(preset->getGroup()),
qPrintable(preset->getDescription())); qPrintable(preset->getDescription()));
//preset->setSpectrumConfig(ui->rxSpectrumGUI->serialize());
preset->setSpectrumConfig(m_deviceUIs.back()->m_spectrumGUI->serialize()); preset->setSpectrumConfig(m_deviceUIs.back()->m_spectrumGUI->serialize());
preset->clearChannels(); preset->clearChannels();
m_pluginManager->saveSettings(preset); m_pluginManager->saveSettings(preset);
@ -290,13 +274,11 @@ void MainWindow::closeEvent(QCloseEvent*)
void MainWindow::updateCenterFreqDisplay() void MainWindow::updateCenterFreqDisplay()
{ {
//ui->rxSpectrum->setCenterFrequency(m_centerFrequency);
m_deviceUIs.back()->m_spectrum->setCenterFrequency(m_centerFrequency); m_deviceUIs.back()->m_spectrum->setCenterFrequency(m_centerFrequency);
} }
void MainWindow::updateSampleRate() void MainWindow::updateSampleRate()
{ {
//ui->rxSpectrum->setSampleRate(m_sampleRate);
m_deviceUIs.back()->m_spectrum->setSampleRate(m_sampleRate); m_deviceUIs.back()->m_spectrum->setSampleRate(m_sampleRate);
m_sampleRateWidget->setText(tr("Rate: %1 kHz").arg((float)m_sampleRate / 1000)); m_sampleRateWidget->setText(tr("Rate: %1 kHz").arg((float)m_sampleRate / 1000));
} }
@ -358,30 +340,6 @@ void MainWindow::applySettings()
updateSampleRate(); updateSampleRate();
} }
void MainWindow::handleDSPMessages()
{
Message* message;
while ((message = m_dspEngine->getOutputMessageQueue()->pop()) != 0)
{
qDebug("MainWindow::handleDSPMessages: message: %s", message->getIdentifier());
if (DSPSignalNotification::match(*message))
{
DSPSignalNotification* notif = (DSPSignalNotification*) message;
m_sampleRate = notif->getSampleRate();
m_centerFrequency = notif->getCenterFrequency();
qDebug("SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
updateCenterFreqDisplay();
updateSampleRate();
// qDebug() << "MainWindow::handleDSPMessages: forward to file sink";
// m_fileSink->handleMessage(*notif);
delete message;
}
}
}
void MainWindow::handleMessages() void MainWindow::handleMessages()
{ {
Message* message; Message* message;
@ -397,18 +355,6 @@ void MainWindow::handleMessages()
} }
} }
//void MainWindow::on_action_Start_Recording_triggered()
//{
// m_recording->setColor(Qt::red);
// m_fileSink->startRecording();
//}
//
//void MainWindow::on_action_Stop_Recording_triggered()
//{
// m_recording->setColor(Qt::gray);
// m_fileSink->stopRecording();
//}
void MainWindow::on_action_View_Fullscreen_toggled(bool checked) void MainWindow::on_action_View_Fullscreen_toggled(bool checked)
{ {
if(checked) if(checked)
@ -535,8 +481,6 @@ void MainWindow::on_presetImport_clicked()
preset->setGroup(group); // override with current group preset->setGroup(group); // override with current group
ui->presetTree->setCurrentItem(addPresetToTree(preset)); ui->presetTree->setCurrentItem(addPresetToTree(preset));
// loadPresetSettings(preset);
// applySettings();
} }
else else
{ {
@ -652,8 +596,6 @@ void MainWindow::on_action_DV_Serial_triggered(bool checked)
void MainWindow::on_sampleSource_currentIndexChanged(int index) void MainWindow::on_sampleSource_currentIndexChanged(int index)
{ {
m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset()); m_pluginManager->saveSourceSettings(m_settings.getWorkingPreset());
//m_pluginManager->selectSampleSourceByIndex(ui->sampleSource->currentIndex());
//m_settings.setSourceIndex(ui->sampleSource->currentIndex());
m_pluginManager->selectSampleSourceByIndex(m_deviceUIs.back()->m_sampleSource->currentIndex()); m_pluginManager->selectSampleSourceByIndex(m_deviceUIs.back()->m_sampleSource->currentIndex());
m_settings.setSourceIndex(m_deviceUIs.back()->m_sampleSource->currentIndex()); m_settings.setSourceIndex(m_deviceUIs.back()->m_sampleSource->currentIndex());
m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset()); m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());

View File

@ -37,7 +37,6 @@ class SpectrumVis;
class GLSpectrum; class GLSpectrum;
class GLSpectrumGUI; class GLSpectrumGUI;
class ChannelWindow; class ChannelWindow;
//class FileSink;
class SampleSource; class SampleSource;
class PluginAPI; class PluginAPI;
class PluginGUI; class PluginGUI;
@ -96,7 +95,6 @@ private:
MainSettings m_settings; MainSettings m_settings;
SpectrumVis* m_rxSpectrumVis; SpectrumVis* m_rxSpectrumVis;
// FileSink *m_fileSink;
std::vector<DeviceUISet*> m_deviceUIs; std::vector<DeviceUISet*> m_deviceUIs;
@ -133,10 +131,7 @@ private:
void createDevice(); void createDevice();
private slots: private slots:
void handleDSPMessages();
void handleMessages(); void handleMessages();
// void on_action_Start_Recording_triggered();
// void on_action_Stop_Recording_triggered();
void on_action_View_Fullscreen_toggled(bool checked); void on_action_View_Fullscreen_toggled(bool checked);
void on_presetSave_clicked(); void on_presetSave_clicked();
void on_presetUpdate_clicked(); void on_presetUpdate_clicked();