mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-13 03:41:47 -05:00
Multi device support: Apply previous changes to RTL-SDR.
This commit is contained in:
parent
e25c465b82
commit
e750acc7da
@ -156,10 +156,8 @@ void BladerfGui::handleDSPMessages()
|
||||
m_sampleRate = notif->getSampleRate();
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
qDebug("BladerfGui::handleDSPMessages: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
// updateCenterFreqDisplay();
|
||||
updateSampleRateAndFrequency();
|
||||
// qDebug() << "MainWindow::handleDSPMessages: forward to file sink";
|
||||
// m_fileSink->handleMessage(*notif);
|
||||
m_fileSink->handleMessage(*notif); // forward to file sink
|
||||
|
||||
delete message;
|
||||
}
|
||||
|
@ -55,6 +55,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="record">
|
||||
<property name="toolTip">
|
||||
<string>Record I/Q samples from device</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
@ -72,7 +75,7 @@
|
||||
<item>
|
||||
<widget class="QLabel" name="deviceRateLabel">
|
||||
<property name="toolTip">
|
||||
<string>Sample rate kS/s</string>
|
||||
<string>I/Q sample rate kS/s</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>00000k</string>
|
||||
|
@ -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 <QMessageBox>
|
||||
|
||||
@ -5,7 +21,10 @@
|
||||
#include "ui_rtlsdrgui.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"
|
||||
|
||||
RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
@ -35,10 +54,19 @@ RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
|
||||
m_sampleSource = new RTLSDRInput();
|
||||
connect(m_sampleSource->getOutputMessageQueueToGUI(), SIGNAL(messageEnqueued()), this, SLOT(handleSourceMessages()));
|
||||
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()
|
||||
{
|
||||
m_pluginAPI->removeSink(m_fileSink);
|
||||
delete m_fileSink;
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
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()
|
||||
{
|
||||
RTLSDRInput::MsgConfigureRTLSDR* message = RTLSDRInput::MsgConfigureRTLSDR::create(m_settings);
|
||||
|
@ -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
|
||||
#define INCLUDE_RTLSDRGUI_H
|
||||
|
||||
@ -6,6 +22,7 @@
|
||||
#include "rtlsdrinput.h"
|
||||
|
||||
class PluginAPI;
|
||||
class FileSink;
|
||||
|
||||
namespace Ui {
|
||||
class RTLSDRGui;
|
||||
@ -39,12 +56,17 @@ private:
|
||||
QTimer m_statusTimer;
|
||||
std::vector<int> 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);
|
||||
@ -55,6 +77,7 @@ private slots:
|
||||
void on_sampleRate_currentIndexChanged(int index);
|
||||
void on_checkBox_stateChanged(int state);
|
||||
void on_startStop_toggled(bool checked);
|
||||
void on_record_toggled(bool checked);
|
||||
void updateHardware();
|
||||
void updateStatus();
|
||||
void handleSourceMessages();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>298</width>
|
||||
<height>271</height>
|
||||
<height>189</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -35,19 +35,59 @@
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_freq">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="startStop">
|
||||
<property name="toolTip">
|
||||
<string>start/stop acquisition</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../../sdrbase/resources/res.qrc">
|
||||
<normaloff>:/play.png</normaloff>
|
||||
<normalon>:/stop.png</normalon>:/play.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="deviceUILayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="deviceButtonsLayout">
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="startStop">
|
||||
<property name="toolTip">
|
||||
<string>start/stop acquisition</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<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>
|
||||
<spacer name="horizontalSpacer">
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "gui/audiodialog.h"
|
||||
#include "dsp/dspengine.h"
|
||||
#include "dsp/spectrumvis.h"
|
||||
//#include "dsp/filesink.h"
|
||||
#include "dsp/dspcommands.h"
|
||||
#include "plugin/plugingui.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:
|
||||
|
||||
DSPDeviceEngine *dspDeviceEngine = m_dspEngine->getDeviceEngineByIndex(0);
|
||||
|
||||
// connect(dspDeviceEngine->getOutputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleDSPMessages()), Qt::QueuedConnection);
|
||||
dspDeviceEngine->start();
|
||||
|
||||
m_deviceUIs.push_back(new DeviceUISet(m_masterTimer));
|
||||
@ -123,9 +120,6 @@ MainWindow::MainWindow(QWidget* parent) :
|
||||
m_deviceUIs.back()->m_sampleSource->blockSignals(sampleSourceSignalsBlocked);
|
||||
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...";
|
||||
|
||||
loadSettings();
|
||||
@ -174,10 +168,6 @@ MainWindow::~MainWindow()
|
||||
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;
|
||||
|
||||
m_dspEngine->stopAllDeviceEngines();
|
||||
@ -193,8 +183,6 @@ void MainWindow::addChannelCreateAction(QAction* action)
|
||||
void MainWindow::addChannelRollup(QWidget* widget)
|
||||
{
|
||||
m_deviceUIs.back()->m_channelWindow->addRollupWidget(widget);
|
||||
//((ChannelWindow*)ui->rxChannels)->addRollupWidget(widget);
|
||||
//((ChannelWindow*)ui->channelDock->widget())->addRollupWidget(widget);
|
||||
ui->channelDock->show();
|
||||
ui->channelDock->raise();
|
||||
}
|
||||
@ -206,13 +194,11 @@ void MainWindow::addViewAction(QAction* action)
|
||||
|
||||
void MainWindow::addChannelMarker(ChannelMarker* channelMarker)
|
||||
{
|
||||
//ui->rxSpectrum->addChannelMarker(channelMarker);
|
||||
m_deviceUIs.back()->m_spectrum->addChannelMarker(channelMarker);
|
||||
}
|
||||
|
||||
void MainWindow::removeChannelMarker(ChannelMarker* channelMarker)
|
||||
{
|
||||
//ui->rxSpectrum->removeChannelMarker(channelMarker);
|
||||
m_deviceUIs.back()->m_spectrum->removeChannelMarker(channelMarker);
|
||||
}
|
||||
|
||||
@ -243,7 +229,6 @@ void MainWindow::loadPresetSettings(const Preset* preset)
|
||||
qPrintable(preset->getGroup()),
|
||||
qPrintable(preset->getDescription()));
|
||||
|
||||
//ui->rxSpectrumGUI->deserialize(preset->getSpectrumConfig());
|
||||
m_deviceUIs.back()->m_spectrumGUI->deserialize(preset->getSpectrumConfig());
|
||||
m_pluginManager->loadSettings(preset);
|
||||
|
||||
@ -265,7 +250,6 @@ void MainWindow::savePresetSettings(Preset* preset)
|
||||
qPrintable(preset->getGroup()),
|
||||
qPrintable(preset->getDescription()));
|
||||
|
||||
//preset->setSpectrumConfig(ui->rxSpectrumGUI->serialize());
|
||||
preset->setSpectrumConfig(m_deviceUIs.back()->m_spectrumGUI->serialize());
|
||||
preset->clearChannels();
|
||||
m_pluginManager->saveSettings(preset);
|
||||
@ -290,13 +274,11 @@ void MainWindow::closeEvent(QCloseEvent*)
|
||||
|
||||
void MainWindow::updateCenterFreqDisplay()
|
||||
{
|
||||
//ui->rxSpectrum->setCenterFrequency(m_centerFrequency);
|
||||
m_deviceUIs.back()->m_spectrum->setCenterFrequency(m_centerFrequency);
|
||||
}
|
||||
|
||||
void MainWindow::updateSampleRate()
|
||||
{
|
||||
//ui->rxSpectrum->setSampleRate(m_sampleRate);
|
||||
m_deviceUIs.back()->m_spectrum->setSampleRate(m_sampleRate);
|
||||
m_sampleRateWidget->setText(tr("Rate: %1 kHz").arg((float)m_sampleRate / 1000));
|
||||
}
|
||||
@ -358,30 +340,6 @@ void MainWindow::applySettings()
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
if(checked)
|
||||
@ -535,8 +481,6 @@ void MainWindow::on_presetImport_clicked()
|
||||
preset->setGroup(group); // override with current group
|
||||
|
||||
ui->presetTree->setCurrentItem(addPresetToTree(preset));
|
||||
// loadPresetSettings(preset);
|
||||
// applySettings();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -652,8 +596,6 @@ void MainWindow::on_action_DV_Serial_triggered(bool checked)
|
||||
void MainWindow::on_sampleSource_currentIndexChanged(int index)
|
||||
{
|
||||
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_settings.setSourceIndex(m_deviceUIs.back()->m_sampleSource->currentIndex());
|
||||
m_pluginManager->loadSourceSettings(m_settings.getWorkingPreset());
|
||||
|
@ -37,7 +37,6 @@ class SpectrumVis;
|
||||
class GLSpectrum;
|
||||
class GLSpectrumGUI;
|
||||
class ChannelWindow;
|
||||
//class FileSink;
|
||||
class SampleSource;
|
||||
class PluginAPI;
|
||||
class PluginGUI;
|
||||
@ -96,7 +95,6 @@ private:
|
||||
MainSettings m_settings;
|
||||
|
||||
SpectrumVis* m_rxSpectrumVis;
|
||||
// FileSink *m_fileSink;
|
||||
|
||||
std::vector<DeviceUISet*> m_deviceUIs;
|
||||
|
||||
@ -133,10 +131,7 @@ private:
|
||||
void createDevice();
|
||||
|
||||
private slots:
|
||||
void handleDSPMessages();
|
||||
void handleMessages();
|
||||
// void on_action_Start_Recording_triggered();
|
||||
// void on_action_Stop_Recording_triggered();
|
||||
void on_action_View_Fullscreen_toggled(bool checked);
|
||||
void on_presetSave_clicked();
|
||||
void on_presetUpdate_clicked();
|
||||
|
Loading…
Reference in New Issue
Block a user