Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop device while loading device set. #2342

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions sdrgui/device/deviceuiset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "channel/channelutils.h"
#include "channel/channelapi.h"
#include "channel/channelgui.h"
#include "channel/channelwebapiutils.h"
#include "mainspectrum/mainspectrumgui.h"
#include "settings/preset.h"
#include "util/simpleserializer.h"
Expand Down Expand Up @@ -258,12 +259,47 @@ void DeviceUISet::loadDeviceSetSettings(
m_mainSpectrumGUI->hide();
}

if (m_deviceSourceEngine) { // source device
loadRxChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
} else if (m_deviceSinkEngine) { // sink device
loadTxChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
} else if (m_deviceMIMOEngine) { // MIMO device
loadMIMOChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
// Stop device while changing channels
if (m_deviceAPI->state() == DeviceAPI::EngineState::StRunning)
{
int deviceIndex = m_deviceAPI->getDeviceSetIndex();

// Load settings after stopping device
auto connection = new QMetaObject::Connection();
*connection = connect(m_deviceAPI, &DeviceAPI::stateChanged, this, [=]() {
if (m_deviceAPI->state() != DeviceAPI::EngineState::StRunning)
{
// Load channel settings
if (m_deviceSourceEngine) {
loadRxChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
} else if (m_deviceSinkEngine) {
loadTxChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
} else if (m_deviceMIMOEngine) {
loadMIMOChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
}

// Restart device
ChannelWebAPIUtils::run(deviceIndex);

QObject::disconnect(*connection);
delete connection;
}
});

// We use WebAPI rather than m_deviceAPI->stopDeviceEngine();
// so that the start/stop button in the Device GUI is correctly updated
ChannelWebAPIUtils::stop(deviceIndex);
}
else
{
// Load channel settings
if (m_deviceSourceEngine) {
loadRxChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
} else if (m_deviceSinkEngine) {
loadTxChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
} else if (m_deviceMIMOEngine) {
loadMIMOChannelSettings(preset, pluginAPI, workspaces, currentWorkspace);
}
}
}

Expand Down
Loading