1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2026-07-23 02:24:16 -04:00

Add start/stop all devices button in toolbar. Add device stateChanged signal. Use in RTL SDR GUI for updating device state

This commit is contained in:
Jon Beniston
2022-08-27 10:18:17 +01:00
parent d1a4fca49b
commit d404e9f943
15 changed files with 276 additions and 56 deletions
+71
View File
@@ -43,6 +43,7 @@
#include "device/deviceenumerator.h"
#include "channel/channelapi.h"
#include "channel/channelgui.h"
#include "channel/channelwebapiutils.h"
#include "feature/featureuiset.h"
#include "feature/featureset.h"
#include "feature/feature.h"
@@ -326,6 +327,13 @@ void MainWindow::sampleSourceAdd(Workspace *deviceWorkspace, Workspace *spectrum
&MainWindow::mainSpectrumRequestDeviceCenterFrequency
);
QObject::connect(
deviceAPI,
&DeviceAPI::stateChanged,
this,
&MainWindow::deviceStateChanged
);
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
@@ -549,6 +557,13 @@ void MainWindow::sampleSinkAdd(Workspace *deviceWorkspace, Workspace *spectrumWo
&MainWindow::mainSpectrumRequestDeviceCenterFrequency
);
QObject::connect(
deviceAPI,
&DeviceAPI::stateChanged,
this,
&MainWindow::deviceStateChanged
);
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
@@ -773,6 +788,13 @@ void MainWindow::sampleMIMOAdd(Workspace *deviceWorkspace, Workspace *spectrumWo
[=](int channelPluginIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelPluginIndex); }
);
QObject::connect(
deviceAPI,
&DeviceAPI::stateChanged,
this,
&MainWindow::deviceStateChanged
);
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
@@ -1897,6 +1919,20 @@ void MainWindow::addWorkspace()
&MainWindow::openFeaturePresetsDialog
);
QObject::connect(
m_workspaces.back(),
&Workspace::startAllDevices,
this,
&MainWindow::startAllDevices
);
QObject::connect(
m_workspaces.back(),
&Workspace::stopAllDevices,
this,
&MainWindow::stopAllDevices
);
if (m_workspaces.size() > 1)
{
for (int i = 1; i < m_workspaces.size(); i++) {
@@ -2704,6 +2740,41 @@ void MainWindow::showAllChannels(int deviceSetIndex)
}
}
// Start all devices in the workspace
void MainWindow::startAllDevices(Workspace *workspace)
{
int workspaceIndex = workspace->getIndex();
for (auto deviceUI : m_deviceUIs)
{
if (deviceUI->m_deviceAPI->getWorkspaceIndex() == workspaceIndex)
{
// We use WebAPI rather than call deviceUI->m_deviceAPI->startDeviceEngine();
// so that the start/stop button in the Device GUI is correctly updated
int deviceIndex = deviceUI->m_deviceAPI->getDeviceSetIndex();
ChannelWebAPIUtils::run(deviceIndex);
}
}
}
// Stop all devices in the workspace
void MainWindow::stopAllDevices(Workspace *workspace)
{
int workspaceIndex = workspace->getIndex();
for (auto deviceUI : m_deviceUIs)
{
if (deviceUI->m_deviceAPI->getWorkspaceIndex() == workspaceIndex)
{
int deviceIndex = deviceUI->m_deviceAPI->getDeviceSetIndex();
ChannelWebAPIUtils::stop(deviceIndex);
}
}
}
void MainWindow::deviceStateChanged(DeviceAPI *deviceAPI)
{
emit m_mainCore->deviceStateChanged(deviceAPI->getDeviceSetIndex(), deviceAPI);
}
void MainWindow::openFeaturePresetsDialog(QPoint p, Workspace *workspace)
{
FeaturePresetsDialog dialog;