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

View File

@ -15,6 +15,8 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMessageBox>
#include <libairspy/airspy.h>
#include "airspygui.h"
@ -28,12 +30,17 @@ AirspyGui::AirspyGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::AirspyGui),
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));
ui->centerFrequency->setValueRange(7, 24000U, 1900000U);
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
displaySettings();
m_sampleSource = new AirspyInput();
@ -294,6 +301,23 @@ void AirspyGui::on_vga_valueChanged(int value)
sendSettings();
}
void AirspyGui::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 AirspyGui::updateHardware()
{
qDebug() << "AirspyGui::updateHardware";
@ -302,6 +326,35 @@ void AirspyGui::updateHardware()
m_updateTimer.stop();
}
void AirspyGui::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;
}
}
uint32_t AirspyGui::getDevSampleRate(unsigned int rate_index)
{
if (rate_index < m_rates.size())

View File

@ -57,8 +57,10 @@ private:
PluginAPI* m_pluginAPI;
AirspySettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<uint32_t> m_rates;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void displaySampleRates();
@ -78,7 +80,9 @@ private slots:
void on_vga_valueChanged(int value);
void on_lnaAGC_stateChanged(int state);
void on_mixAGC_stateChanged(int state);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
void handleSourceMessages();
};

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>

View File

@ -15,6 +15,8 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMessageBox>
#include <libbladeRF.h>
#include "ui_bladerfgui.h"
@ -28,7 +30,8 @@ BladerfGui::BladerfGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::BladerfGui),
m_pluginAPI(pluginAPI),
m_settings(),
m_sampleSource(NULL)
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@ -47,6 +50,9 @@ BladerfGui::BladerfGui(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 BladerfInput();
@ -302,6 +308,23 @@ void BladerfGui::on_xb200_currentIndexChanged(int index)
sendSettings();
}
void BladerfGui::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 BladerfGui::updateHardware()
{
qDebug() << "BladerfGui::updateHardware";
@ -310,6 +333,35 @@ void BladerfGui::updateHardware()
m_updateTimer.stop();
}
void BladerfGui::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 : blue; }");
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;
}
}
unsigned int BladerfGui::getXb200Index(bool xb_200, bladerf_xb200_path xb200Path, bladerf_xb200_filter xb200Filter)
{
if (xb_200)

View File

@ -53,8 +53,10 @@ private:
PluginAPI* m_pluginAPI;
BladeRFSettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<int> m_gains;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void sendSettings();
@ -72,7 +74,9 @@ private slots:
void on_vga2_valueChanged(int value);
void on_xb200_currentIndexChanged(int index);
void on_fcPos_currentIndexChanged(int index);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
};
class BladerfSampleRates {

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>

View File

@ -1,3 +1,21 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 <QMessageBox>
#include "ui_fcdprogui.h"
#include "plugin/pluginapi.h"
#include "gui/colormapper.h"
@ -10,7 +28,8 @@ FCDProGui::FCDProGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::FCDProGui),
m_pluginAPI(pluginAPI),
m_settings(),
m_sampleSource(NULL)
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
@ -113,6 +132,9 @@ FCDProGui::FCDProGui(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 FCDProInput();
@ -357,6 +379,52 @@ void FCDProGui::on_setDefaults_clicked(bool checked)
sendSettings();
}
void FCDProGui::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 FCDProGui::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 FCDProGui::updateHardware()
{
FCDProInput::MsgConfigureFCD* message = FCDProInput::MsgConfigureFCD::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_FCDPROGUI_H
#define INCLUDE_FCDPROGUI_H
@ -37,8 +53,10 @@ private:
PluginAPI* m_pluginAPI;
FCDProSettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<int> m_gains;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void sendSettings();
@ -66,7 +84,9 @@ private slots:
void on_gain5_currentIndexChanged(int index);
void on_gain6_currentIndexChanged(int index);
void on_setDefaults_clicked(bool checked);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
};
#endif // INCLUDE_FCDPROGUI_H

View File

@ -35,7 +35,7 @@
<item>
<layout class="QHBoxLayout" name="layoutFrequency">
<item>
<widget class="ButtonSwitch" name="startStopButton">
<widget class="ButtonSwitch" name="startStop">
<property name="text">
<string/>
</property>

View File

@ -1,4 +1,22 @@
///////////////////////////////////////////////////////////////////////////////////
// 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>
#include "ui_fcdproplusgui.h"
#include "plugin/pluginapi.h"
#include "gui/colormapper.h"
@ -11,7 +29,8 @@ FCDProPlusGui::FCDProPlusGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::FCDProPlusGui),
m_pluginAPI(pluginAPI),
m_settings(),
m_sampleSource(NULL)
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
@ -31,6 +50,9 @@ FCDProPlusGui::FCDProPlusGui(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 FCDProPlusInput();
@ -148,6 +170,35 @@ void FCDProPlusGui::updateHardware()
m_updateTimer.stop();
}
void FCDProPlusGui::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 FCDProPlusGui::on_checkBoxG_stateChanged(int state)
{
m_settings.m_lnaGain = (state == Qt::Checked);
@ -192,3 +243,21 @@ void FCDProPlusGui::on_ppm_valueChanged(int value)
sendSettings();
}
void FCDProPlusGui::on_startStop_toggled(bool checked)
{
if (checked)
{
if (m_pluginAPI->initAcquisition())
{
m_pluginAPI->startAcquisition();
DSPEngine::instance()->startAudio();
}
}
else
{
m_pluginAPI->stopAcquistion();
DSPEngine::instance()->stopAudio();
}
}

View File

@ -8,6 +8,22 @@
class PluginAPI;
///////////////////////////////////////////////////////////////////////////////////
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
namespace Ui {
class FCDProPlusGui;
}
@ -37,8 +53,10 @@ private:
PluginAPI* m_pluginAPI;
FCDProPlusSettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<int> m_gains;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void sendSettings();
@ -54,7 +72,9 @@ private slots:
void on_filterRF_currentIndexChanged(int index);
void on_filterIF_currentIndexChanged(int index);
void on_ppm_valueChanged(int value);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
};
#endif // INCLUDE_FCDGUI_H

View File

@ -35,7 +35,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="ButtonSwitch" name="startStopButton">
<widget class="ButtonSwitch" name="startStop">
<property name="text">
<string/>
</property>

View File

@ -20,6 +20,8 @@
#include <QDateTime>
#include <QString>
#include <QFileDialog>
#include <QMessageBox>
#include "ui_filesourcegui.h"
#include "plugin/pluginapi.h"
#include "gui/colormapper.h"
@ -42,15 +44,20 @@ FileSourceGui::FileSourceGui(PluginAPI* pluginAPI, QWidget* parent) :
m_startingTimeStamp(0),
m_samplesCount(0),
m_tickCount(0),
m_enableNavTime(false)
m_enableNavTime(false),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
ui->fileNameText->setText(m_fileName);
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&(m_pluginAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
displaySettings();
ui->navTimeSlider->setEnabled(false);
ui->playLoop->setChecked(true); // FIXME: always play in a loop
ui->playLoop->setEnabled(false);
@ -168,15 +175,57 @@ void FileSourceGui::sendSettings()
{
}
void FileSourceGui::updateHardware()
{
}
void FileSourceGui::on_playLoop_toggled(bool checked)
{
// TODO: do something about it!
}
void FileSourceGui::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 FileSourceGui::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 FileSourceGui::on_play_toggled(bool checked)
{
FileSourceInput::MsgConfigureFileSourceWork* message = FileSourceInput::MsgConfigureFileSourceWork::create(checked);

View File

@ -51,7 +51,7 @@ private:
PluginAPI* m_pluginAPI;
FileSourceInput::Settings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
std::vector<int> m_gains;
SampleSource* m_sampleSource;
bool m_acquisition;
@ -63,11 +63,11 @@ private:
int m_samplesCount;
std::size_t m_tickCount;
bool m_enableNavTime;
int m_lastEngineState;
void displaySettings();
void displayTime();
void sendSettings();
void updateHardware();
void configureFileName();
void updateWithAcquisition();
void updateWithStreamData();
@ -75,10 +75,12 @@ private:
private slots:
void handleSourceMessages();
void on_startStop_toggled(bool checked);
void on_playLoop_toggled(bool checked);
void on_play_toggled(bool checked);
void on_navTimeSlider_valueChanged(int value);
void on_showFileDialog_clicked(bool checked);
void updateStatus();
void tick();
};

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>

View File

@ -15,6 +15,8 @@
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include <QMessageBox>
#include <libhackrf/hackrf.h>
#include "plugin/pluginapi.h"
@ -28,12 +30,17 @@ HackRFGui::HackRFGui(PluginAPI* pluginAPI, QWidget* parent) :
ui(new Ui::HackRFGui),
m_pluginAPI(pluginAPI),
m_settings(),
m_sampleSource(NULL)
m_sampleSource(NULL),
m_lastEngineState((DSPDeviceEngine::State)-1)
{
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->centerFrequency->setValueRange(7, 0U, 7250000U);
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
displaySettings();
m_sampleSource = new HackRFInput();
@ -277,6 +284,23 @@ void HackRFGui::on_vga_valueChanged(int value)
sendSettings();
}
void HackRFGui::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 HackRFGui::updateHardware()
{
qDebug() << "HackRFGui::updateHardware";
@ -285,6 +309,35 @@ void HackRFGui::updateHardware()
m_updateTimer.stop();
}
void HackRFGui::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;
}
}
unsigned int HackRFSampleRates::m_rates_k[] = {2400, 3200, 4800, 5600, 6400, 8000, 9600, 12800, 19200};
unsigned int HackRFSampleRates::getRate(unsigned int rate_index)

View File

@ -62,7 +62,9 @@ private:
PluginAPI* m_pluginAPI;
HackRFSettings m_settings;
QTimer m_updateTimer;
QTimer m_statusTimer;
SampleSource* m_sampleSource;
int m_lastEngineState;
void displaySettings();
void displaySampleRates();
@ -82,7 +84,9 @@ private slots:
void on_lna_valueChanged(int value);
void on_bbFilter_currentIndexChanged(int index);
void on_vga_valueChanged(int value);
void on_startStop_toggled(bool checked);
void updateHardware();
void updateStatus();
};
class HackRFSampleRates {

View File

@ -41,7 +41,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_freq">
<item>
<widget class="ButtonSwitch" name="startStopButton">
<widget class="ButtonSwitch" name="startStop">
<property name="text">
<string/>
</property>

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)

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();
};

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>

View File

@ -44,6 +44,7 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
m_pluginAPI(pluginAPI),
m_sampleSource(NULL),
m_acquisition(false),
m_lastEngineState((DSPDeviceEngine::State)-1),
m_sampleRate(0),
m_sampleRateStream(0),
m_centerFrequency(0),
@ -78,7 +79,10 @@ SDRdaemonGui::SDRdaemonGui(PluginAPI* pluginAPI, QWidget* parent) :
ui->setupUi(this);
ui->centerFrequency->setColorMapper(ColorMapper(ColorMapper::ReverseGold));
ui->centerFrequency->setValueRange(7, 0, pow(10,7));
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateHardware()));
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
connect(&(m_pluginAPI->getMainWindow()->getMasterTimer()), SIGNAL(timeout()), this, SLOT(tick()));
m_sampleSource = new SDRdaemonInput(m_pluginAPI->getMainWindow()->getMasterTimer());
@ -536,6 +540,22 @@ void SDRdaemonGui::on_fcPos_currentIndexChanged(int index)
ui->sendButton->setEnabled(true);
}
void SDRdaemonGui::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 SDRdaemonGui::configureUDPLink()
{
@ -622,6 +642,35 @@ void SDRdaemonGui::updateWithStreamTime()
ui->bufferGaugePositive->setValue((m_bufferGauge < 0 ? 0 : 50 - m_bufferGauge));
}
void SDRdaemonGui::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 SDRdaemonGui::tick()
{
if ((++m_tickCount & 0xf) == 0) {

View File

@ -52,8 +52,10 @@ private:
PluginAPI* m_pluginAPI;
QTimer m_updateTimer;
QTimer m_statusTimer;
SampleSource* m_sampleSource;
bool m_acquisition;
int m_lastEngineState;
int m_sampleRate;
int m_sampleRateStream;
@ -119,6 +121,8 @@ private slots:
void on_specificParms_textEdited(const QString& arg1);
void on_decim_currentIndexChanged(int index);
void on_fcPos_currentIndexChanged(int index);
void on_startStop_toggled(bool checked);
void updateStatus();
void tick();
};

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>

View File

@ -20,7 +20,8 @@
#include "dsp/dspengine.h"
DSPEngine::DSPEngine() :
m_audioSampleRate(48000) // Use default output device at 48 kHz
m_audioSampleRate(48000), // Use default output device at 48 kHz
m_audioUsageCount(0)
{
m_deviceEngines.push_back(new DSPDeviceEngine(0)); // TODO: multi device support
m_dvSerialSupport = false;
@ -86,6 +87,30 @@ bool DSPEngine::startAcquisition(uint deviceIndex)
return started;
}
void DSPEngine::startAudio()
{
if (m_audioUsageCount == 0)
{
m_audioOutput.start(-1, m_audioSampleRate);
m_audioSampleRate = m_audioOutput.getRate(); // update with actual rate
}
m_audioUsageCount++;
}
void DSPEngine::stopAudio()
{
if (m_audioUsageCount > 0)
{
m_audioUsageCount--;
if (m_audioUsageCount == 0)
{
m_audioOutput.stop();
}
}
}
void DSPEngine::stopAcquistion(uint deviceIndex)
{
qDebug("DSPEngine::stopAcquistion(%d)", deviceIndex);

View File

@ -50,6 +50,9 @@ public:
bool startAcquisition(uint deviceIndex = 0); //!< Start acquisition sequence
void stopAcquistion(uint deviceIndex = 0); //!< Stop acquisition sequence
void startAudio();
void stopAudio();
void setSource(SampleSource* source, uint deviceIndex = 0); //!< Set the sample source type
void setSourceSequence(int sequence, uint deviceIndex = 0); //!< Set the sample source sequence in type
@ -103,6 +106,7 @@ private:
AudioOutput m_audioOutput;
uint m_audioSampleRate;
bool m_dvSerialSupport;
uint m_audioUsageCount;
#ifdef DSD_USE_SERIALDV
DVSerialEngine m_dvSerialEngine;
#endif

View File

@ -96,8 +96,8 @@ MainWindow::MainWindow(QWidget* parent) :
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
m_statusTimer.start(500);
// connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
// m_statusTimer.start(500);
m_masterTimer.start(50);
@ -418,55 +418,55 @@ void MainWindow::handleMessages()
}
}
void MainWindow::updateStatus()
{
int state = m_dspEngine->state();
if(m_lastEngineState != state) {
switch(state) {
case DSPDeviceEngine::StNotStarted:
m_engineIdle->setColor(Qt::gray);
m_engineRunning->setColor(Qt::gray);
m_engineError->setColor(Qt::gray);
statusBar()->clearMessage();
break;
//void MainWindow::updateStatus()
//{
// int state = m_dspEngine->state();
// if(m_lastEngineState != state) {
// switch(state) {
// case DSPDeviceEngine::StNotStarted:
// m_engineIdle->setColor(Qt::gray);
// m_engineRunning->setColor(Qt::gray);
// m_engineError->setColor(Qt::gray);
// statusBar()->clearMessage();
// break;
//
// case DSPDeviceEngine::StIdle:
// m_engineIdle->setColor(Qt::cyan);
// m_engineRunning->setColor(Qt::gray);
// m_engineError->setColor(Qt::gray);
// statusBar()->clearMessage();
// break;
//
// case DSPDeviceEngine::StRunning:
// m_engineIdle->setColor(Qt::gray);
// m_engineRunning->setColor(Qt::green);
// m_engineError->setColor(Qt::gray);
// statusBar()->showMessage(tr("Sampling from %1").arg(m_dspEngine->sourceDeviceDescription()));
// break;
//
// case DSPDeviceEngine::StError:
// m_engineIdle->setColor(Qt::gray);
// m_engineRunning->setColor(Qt::gray);
// m_engineError->setColor(Qt::red);
// statusBar()->showMessage(tr("Error: %1").arg(m_dspEngine->errorMessage()));
// break;
// }
// m_lastEngineState = state;
// }
//}
case DSPDeviceEngine::StIdle:
m_engineIdle->setColor(Qt::cyan);
m_engineRunning->setColor(Qt::gray);
m_engineError->setColor(Qt::gray);
statusBar()->clearMessage();
break;
case DSPDeviceEngine::StRunning:
m_engineIdle->setColor(Qt::gray);
m_engineRunning->setColor(Qt::green);
m_engineError->setColor(Qt::gray);
statusBar()->showMessage(tr("Sampling from %1").arg(m_dspEngine->sourceDeviceDescription()));
break;
case DSPDeviceEngine::StError:
m_engineIdle->setColor(Qt::gray);
m_engineRunning->setColor(Qt::gray);
m_engineError->setColor(Qt::red);
statusBar()->showMessage(tr("Error: %1").arg(m_dspEngine->errorMessage()));
break;
}
m_lastEngineState = state;
}
}
void MainWindow::on_action_Start_triggered()
{
if (m_dspEngine->initAcquisition())
{
m_dspEngine->startAcquisition();
}
}
void MainWindow::on_action_Stop_triggered()
{
m_dspEngine->stopAcquistion();
}
//void MainWindow::on_action_Start_triggered()
//{
// if (m_dspEngine->initAcquisition())
// {
// m_dspEngine->startAcquisition();
// }
//}
//
//void MainWindow::on_action_Stop_triggered()
//{
// m_dspEngine->stopAcquistion();
//}
void MainWindow::on_action_Start_Recording_triggered()
{

View File

@ -103,7 +103,7 @@ private:
DSPEngine* m_dspEngine;
QTimer m_masterTimer;
QTimer m_statusTimer;
//QTimer m_statusTimer;
int m_lastEngineState;
QLabel* m_sampleRateWidget;
@ -138,9 +138,9 @@ private:
private slots:
void handleDSPMessages();
void handleMessages();
void updateStatus();
void on_action_Start_triggered();
void on_action_Stop_triggered();
//void updateStatus();
//void on_action_Start_triggered();
//void on_action_Stop_triggered();
void on_action_Start_Recording_triggered();
void on_action_Stop_Recording_triggered();
void on_action_View_Fullscreen_toggled(bool checked);

View File

@ -2,7 +2,6 @@
#include "plugin/pluginapi.h"
#include "plugin/pluginmanager.h"
#include "mainwindow.h"
#include "dsp/dspengine.h"
QDockWidget* PluginAPI::createMainWindowDock(Qt::DockWidgetArea dockWidgetArea, const QString& title)
{
@ -69,6 +68,31 @@ void PluginAPI::removeThreadedSink(ThreadedSampleSink* sink)
m_pluginManager->removeThreadedSink(sink);
}
bool PluginAPI::initAcquisition()
{
return m_pluginManager->initAcquisition();
}
bool PluginAPI::startAcquisition()
{
return m_pluginManager->startAcquisition();
}
void PluginAPI::stopAcquistion()
{
m_pluginManager->stopAcquistion();
}
DSPDeviceEngine::State PluginAPI::state() const
{
return m_pluginManager->state();
}
QString PluginAPI::errorMessage()
{
return m_pluginManager->errorMessage();
}
PluginAPI::PluginAPI(PluginManager* pluginManager, MainWindow* mainWindow) :
QObject(mainWindow),
m_pluginManager(pluginManager),

View File

@ -3,6 +3,7 @@
#include <QObject>
#include "util/export.h"
#include "dsp/dspdeviceengine.h"
class QDockWidget;
class QAction;
@ -43,6 +44,11 @@ public:
// Device engine stuff
void addThreadedSink(ThreadedSampleSink* sink);
void removeThreadedSink(ThreadedSampleSink* sink);
bool initAcquisition(); //!< Initialize device engine acquisition sequence
bool startAcquisition(); //!< Start device engine acquisition sequence
void stopAcquistion(); //!< Stop device engine acquisition sequence
DSPDeviceEngine::State state() const; //!< device engine state
QString errorMessage(); //!< Return the current device engine error message
// R/O access to main window
const MainWindow* getMainWindow() const { return m_mainWindow; }

View File

@ -51,6 +51,11 @@ public:
void addThreadedSink(ThreadedSampleSink* sink);
void removeThreadedSink(ThreadedSampleSink* sink);
bool initAcquisition() { return m_dspDeviceEngine->initAcquisition(); } //!< Initialize device engine acquisition sequence
bool startAcquisition() { return m_dspDeviceEngine->startAcquisition(); } //!< Start device engine acquisition sequence
void stopAcquistion() { m_dspDeviceEngine->stopAcquistion(); } //!< Stop device engine acquisition sequence
DSPDeviceEngine::State state() const { return m_dspDeviceEngine->state(); }
QString errorMessage() { return m_dspDeviceEngine->errorMessage(); } //!< Return the current device engine error message
void loadSettings(const Preset* preset);
void loadSourceSettings(const Preset* preset);