1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-06-03 06:24:48 -04:00

Multi device support: moved DSPDeviceEngine start/stop actions and status from main window to each source plugin GUI

This commit is contained in:
f4exb
2016-05-11 23:35:16 +02:00
parent 7992f3f428
commit ecd05096ad
31 changed files with 649 additions and 78 deletions
+53 -1
View File
@@ -1,4 +1,6 @@
#include <QDebug>
#include <QMessageBox>
#include "rtlsdrgui.h"
#include "ui_rtlsdrgui.h"
#include "plugin/pluginapi.h"
@@ -10,7 +12,8 @@ RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::RTLSDRGui),
m_pluginAPI(pluginAPI),
m_settings(),
m_sampleSource(0)
m_sampleSource(0),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@@ -24,6 +27,9 @@ RTLSDRGui::RTLSDRGui(PluginAPI* pluginAPI, QWidget* parent) :
}
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
displaySettings();
m_sampleSource = new RTLSDRInput();
@@ -246,6 +252,23 @@ void RTLSDRGui::on_sampleRate_currentIndexChanged(int index)
sendSettings();
}
void RTLSDRGui::on_startStop_toggled(bool checked)
{
if (checked)
{
if (m_pluginAPI->initAcquisition())
{
m_pluginAPI->startAcquisition();
DSPEngine::instance()->startAudio();
}
}
else
{
m_pluginAPI->stopAcquistion();
DSPEngine::instance()->stopAudio();
}
}
void RTLSDRGui::updateHardware()
{
RTLSDRInput::MsgConfigureRTLSDR* message = RTLSDRInput::MsgConfigureRTLSDR::create(m_settings);
@@ -253,6 +276,35 @@ void RTLSDRGui::updateHardware()
m_updateTimer.stop();
}
void RTLSDRGui::updateStatus()
{
int state = m_pluginAPI->state();
if(m_lastEngineState != state)
{
switch(state)
{
case DSPDeviceEngine::StNotStarted:
ui->startStop->setStyleSheet("QToolButton { background:rgb(79,79,79); }");
break;
case DSPDeviceEngine::StIdle:
ui->startStop->setStyleSheet("QToolButton { background-color : cyan; }");
break;
case DSPDeviceEngine::StRunning:
ui->startStop->setStyleSheet("QToolButton { background-color : green; }");
break;
case DSPDeviceEngine::StError:
ui->startStop->setStyleSheet("QToolButton { background-color : red; }");
QMessageBox::information(this, tr("Message"), m_pluginAPI->errorMessage());
break;
default:
break;
}
m_lastEngineState = state;
}
}
void RTLSDRGui::on_checkBox_stateChanged(int state)
{
if (state == Qt::Checked)
+4
View File
@@ -36,8 +36,10 @@ private:
PluginAPI* m_pluginAPI;
RTLSDRSettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<int> m_gains;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void sendSettings();
@@ -52,7 +54,9 @@ private slots:
void on_gain_valueChanged(int value);
void on_sampleRate_currentIndexChanged(int index);
void on_checkBox_stateChanged(int state);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
void handleSourceMessages();
};
+1 -1
View File
@@ -35,7 +35,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<item>
<widget class="ButtonSwitch" name="startStopButton">
<widget class="ButtonSwitch" name="startStop">
<property name="text">
<string/>
</property>