2017-10-22 13:12:43 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
|
|
|
|
// written by Christian Daniel //
|
|
|
|
// //
|
|
|
|
// 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 //
|
2019-04-11 08:43:33 -04:00
|
|
|
// (at your option) any later version. //
|
2017-10-22 13:12:43 -04:00
|
|
|
// //
|
|
|
|
// 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 <QInputDialog>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QSysInfo>
|
2018-01-04 23:05:12 -05:00
|
|
|
#include <QKeyEvent>
|
2018-02-18 17:01:02 -05:00
|
|
|
#include <QResource>
|
2018-05-06 21:14:18 -04:00
|
|
|
#include <QFontDatabase>
|
2021-10-31 06:16:17 -04:00
|
|
|
#include <QStandardPaths>
|
2021-11-24 06:31:51 -05:00
|
|
|
#include <QDesktopServices>
|
2022-04-04 10:13:42 -04:00
|
|
|
#include <QProcess>
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
#include <QAction>
|
|
|
|
#include <QMenuBar>
|
|
|
|
#include <QStatusBar>
|
|
|
|
|
2020-10-09 02:52:30 -04:00
|
|
|
#include "device/devicegui.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2017-10-24 12:34:39 -04:00
|
|
|
#include "device/deviceuiset.h"
|
2020-10-11 02:27:58 -04:00
|
|
|
#include "device/deviceset.h"
|
2017-11-01 22:30:54 -04:00
|
|
|
#include "device/deviceenumerator.h"
|
2020-10-02 23:16:19 -04:00
|
|
|
#include "channel/channelapi.h"
|
2020-10-04 00:16:15 -04:00
|
|
|
#include "channel/channelgui.h"
|
2022-08-27 05:18:17 -04:00
|
|
|
#include "channel/channelwebapiutils.h"
|
2020-09-19 19:06:34 -04:00
|
|
|
#include "feature/featureuiset.h"
|
2020-10-10 18:22:42 -04:00
|
|
|
#include "feature/featureset.h"
|
2020-10-02 23:26:07 -04:00
|
|
|
#include "feature/feature.h"
|
2022-04-04 04:23:52 -04:00
|
|
|
#include "feature/featuregui.h"
|
2022-04-09 07:38:22 -04:00
|
|
|
#include "mainspectrum/mainspectrumgui.h"
|
2022-01-06 16:47:41 -05:00
|
|
|
#include "commands/commandkeyreceiver.h"
|
2017-10-22 13:12:43 -04:00
|
|
|
#include "gui/indicator.h"
|
|
|
|
#include "gui/presetitem.h"
|
|
|
|
#include "gui/addpresetdialog.h"
|
|
|
|
#include "gui/pluginsdialog.h"
|
|
|
|
#include "gui/aboutdialog.h"
|
|
|
|
#include "gui/rollupwidget.h"
|
|
|
|
#include "gui/audiodialog.h"
|
2022-06-18 07:35:44 -04:00
|
|
|
#include "gui/graphicsdialog.h"
|
2017-11-11 13:26:23 -05:00
|
|
|
#include "gui/loggingdialog.h"
|
2019-06-12 12:50:53 -04:00
|
|
|
#include "gui/deviceuserargsdialog.h"
|
2019-05-14 13:23:13 -04:00
|
|
|
#include "gui/sdrangelsplash.h"
|
2017-10-22 13:12:43 -04:00
|
|
|
#include "gui/mypositiondialog.h"
|
2021-11-01 20:04:43 -04:00
|
|
|
#include "gui/fftwisdomdialog.h"
|
2022-04-04 04:23:52 -04:00
|
|
|
#include "gui/workspace.h"
|
|
|
|
#include "gui/featurepresetsdialog.h"
|
2022-04-13 12:43:37 -04:00
|
|
|
#include "gui/devicesetpresetsdialog.h"
|
2022-04-04 10:13:42 -04:00
|
|
|
#include "gui/commandsdialog.h"
|
2022-04-05 10:26:57 -04:00
|
|
|
#include "gui/configurationsdialog.h"
|
2017-10-22 13:12:43 -04:00
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/spectrumvis.h"
|
|
|
|
#include "dsp/dspcommands.h"
|
|
|
|
#include "dsp/devicesamplesource.h"
|
|
|
|
#include "dsp/devicesamplesink.h"
|
2019-05-18 05:59:56 -04:00
|
|
|
#include "dsp/devicesamplemimo.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "dsp/dspdevicesourceengine.h"
|
|
|
|
#include "dsp/dspdevicesinkengine.h"
|
2019-05-18 05:59:56 -04:00
|
|
|
#include "dsp/dspdevicemimoengine.h"
|
2017-10-22 13:12:43 -04:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "gui/glspectrum.h"
|
|
|
|
#include "gui/glspectrumgui.h"
|
2017-11-11 20:23:55 -05:00
|
|
|
#include "loggerwithfile.h"
|
2017-11-17 02:52:15 -05:00
|
|
|
#include "webapi/webapirequestmapper.h"
|
|
|
|
#include "webapi/webapiserver.h"
|
2020-10-11 06:39:30 -04:00
|
|
|
#include "webapi/webapiadapter.h"
|
2018-01-04 05:11:53 -05:00
|
|
|
#include "commands/command.h"
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2017-10-24 12:34:39 -04:00
|
|
|
#include "mainwindow.h"
|
2018-03-23 13:08:38 -04:00
|
|
|
|
|
|
|
#include <audio/audiodevicemanager.h>
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
//#include "ui_mainwindow.h"
|
|
|
|
#include <QtWidgets/QApplication>
|
2017-10-24 12:34:39 -04:00
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
#include <string>
|
|
|
|
#include <QDebug>
|
2019-05-14 13:23:13 -04:00
|
|
|
#include <QSplashScreen>
|
2022-04-12 10:20:45 -04:00
|
|
|
#include <QProgressDialog>
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2017-10-24 07:45:10 -04:00
|
|
|
MainWindow *MainWindow::m_instance = 0;
|
|
|
|
|
2017-11-17 23:06:43 -05:00
|
|
|
MainWindow::MainWindow(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QWidget* parent) :
|
2017-10-22 13:12:43 -04:00
|
|
|
QMainWindow(parent),
|
2022-04-04 04:23:52 -04:00
|
|
|
// ui(new Ui::MainWindow),
|
|
|
|
m_currentWorkspace(nullptr),
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore(MainCore::instance()),
|
2017-10-22 13:12:43 -04:00
|
|
|
m_dspEngine(DSPEngine::instance()),
|
2019-05-08 16:11:53 -04:00
|
|
|
m_lastEngineState(DeviceAPI::StNotStarted),
|
2021-11-01 20:04:43 -04:00
|
|
|
m_fftWisdomProcess(nullptr)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
|
|
|
qDebug() << "MainWindow::MainWindow: start";
|
2022-04-27 18:19:54 -04:00
|
|
|
setWindowTitle("SDRangel");
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2017-10-24 07:45:10 -04:00
|
|
|
m_instance = this;
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->m_logger = logger;
|
|
|
|
m_mainCore->m_masterTabIndex = 0;
|
|
|
|
m_mainCore->m_mainMessageQueue = &m_inputMessageQueue;
|
|
|
|
m_mainCore->m_settings.setAudioDeviceManager(m_dspEngine->getAudioDeviceManager());
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2018-05-06 21:14:18 -04:00
|
|
|
QFontDatabase::addApplicationFont(":/LiberationSans-Regular.ttf");
|
|
|
|
QFontDatabase::addApplicationFont(":/LiberationMono-Regular.ttf");
|
|
|
|
|
|
|
|
QFont font("Liberation Sans");
|
|
|
|
font.setPointSize(9);
|
|
|
|
qApp->setFont(font);
|
|
|
|
|
2019-05-14 13:23:13 -04:00
|
|
|
QPixmap logoPixmap(":/sdrangel_logo.png");
|
|
|
|
SDRangelSplash *splash = new SDRangelSplash(logoPixmap);
|
2019-06-09 17:10:12 -04:00
|
|
|
splash->setMessageRect(QRect(10, 80, 350, 16));
|
2019-05-14 13:23:13 -04:00
|
|
|
splash->show();
|
2019-08-11 19:46:27 -04:00
|
|
|
splash->showStatusMessage("starting...", Qt::white);
|
2019-05-14 13:23:13 -04:00
|
|
|
splash->showStatusMessage("starting...", Qt::white);
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
setWindowIcon(QIcon(":/sdrangel_icon.png"));
|
|
|
|
createMenuBar();
|
2017-10-22 13:12:43 -04:00
|
|
|
createStatusBar();
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::West);
|
|
|
|
setTabPosition(Qt::RightDockWidgetArea, QTabWidget::East);
|
2017-10-22 13:12:43 -04:00
|
|
|
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
|
|
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
|
|
|
setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
|
|
|
|
setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
|
|
|
|
|
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
|
|
|
|
|
|
|
connect(&m_statusTimer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
|
|
|
m_statusTimer.start(1000);
|
|
|
|
|
2020-03-12 01:27:38 -04:00
|
|
|
splash->showStatusMessage("allocate FFTs...", Qt::white);
|
|
|
|
splash->showStatusMessage("allocate FFTs...", Qt::white);
|
2021-10-31 06:16:17 -04:00
|
|
|
|
|
|
|
if (parser.getFFTWFWisdomFileName().length() != 0)
|
|
|
|
{
|
|
|
|
m_dspEngine->createFFTFactory(parser.getFFTWFWisdomFileName());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-11-04 14:19:17 -04:00
|
|
|
QString filePath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
|
|
filePath += QDir::separator();
|
|
|
|
filePath += "fftw-wisdom";
|
|
|
|
QFileInfo fileInfo = QFileInfo(filePath);
|
|
|
|
|
|
|
|
if (fileInfo.exists()) {
|
|
|
|
m_dspEngine->createFFTFactory(filePath);
|
|
|
|
} else {
|
|
|
|
m_dspEngine->createFFTFactory("");
|
2021-10-31 06:16:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-12 01:27:38 -04:00
|
|
|
m_dspEngine->preAllocateFFTs();
|
|
|
|
|
2019-05-14 13:23:13 -04:00
|
|
|
splash->showStatusMessage("load settings...", Qt::white);
|
2017-10-22 13:12:43 -04:00
|
|
|
qDebug() << "MainWindow::MainWindow: load settings...";
|
|
|
|
|
2020-09-19 19:06:34 -04:00
|
|
|
loadSettings();
|
|
|
|
|
2019-05-14 13:23:13 -04:00
|
|
|
splash->showStatusMessage("load plugins...", Qt::white);
|
2018-02-22 00:42:41 -05:00
|
|
|
qDebug() << "MainWindow::MainWindow: load plugins...";
|
|
|
|
|
|
|
|
m_pluginManager = new PluginManager(this);
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_pluginManager = m_pluginManager;
|
2022-04-30 06:52:25 -04:00
|
|
|
m_pluginManager->setEnableSoapy(parser.getSoapy());
|
2018-02-22 00:42:41 -05:00
|
|
|
m_pluginManager->loadPlugins(QString("plugins"));
|
2020-10-10 14:08:11 -04:00
|
|
|
m_pluginManager->loadPluginsNonDiscoverable(m_mainCore->m_settings.getDeviceUserArgs());
|
2018-02-22 00:42:41 -05:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
splash->showStatusMessage("Add unique feature set...", Qt::white);
|
2022-04-15 04:04:24 -04:00
|
|
|
addFeatureSet(); // Create the uniuefeature set
|
2020-10-11 06:39:30 -04:00
|
|
|
m_apiAdapter = new WebAPIAdapter();
|
2022-04-13 21:49:32 -04:00
|
|
|
|
2022-05-19 09:48:14 -04:00
|
|
|
if (parser.getScratch())
|
2022-04-13 21:49:32 -04:00
|
|
|
{
|
2022-05-19 09:48:14 -04:00
|
|
|
qDebug() << "MainWindow::MainWindow: scratch mode: do not load current configuration";
|
2022-04-13 21:49:32 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-19 09:48:14 -04:00
|
|
|
splash->showStatusMessage("load current configuration...", Qt::white);
|
|
|
|
qDebug() << "MainWindow::MainWindow: load current configuration...";
|
|
|
|
loadConfiguration(m_mainCore->m_settings.getWorkingConfiguration());
|
|
|
|
|
|
|
|
if (m_workspaces.size() == 0)
|
|
|
|
{
|
|
|
|
qDebug() << "MainWindow::MainWindow: no or empty current configuration, creating empty workspace...";
|
|
|
|
addWorkspace();
|
|
|
|
}
|
2022-04-13 21:49:32 -04:00
|
|
|
}
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2019-05-14 13:23:13 -04:00
|
|
|
splash->showStatusMessage("finishing...", Qt::white);
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2018-02-18 17:01:02 -05:00
|
|
|
QString applicationDirPath = qApp->applicationDirPath();
|
|
|
|
|
2019-06-02 14:34:49 -04:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
if (QResource::registerResource(applicationDirPath + "/sdrbase.rcc")) {
|
|
|
|
qDebug("MainWindow::MainWindow: registered resource file %s/%s", qPrintable(applicationDirPath), "sdrbase.rcc");
|
|
|
|
} else {
|
|
|
|
qWarning("MainWindow::MainWindow: could not register resource file %s/%s", qPrintable(applicationDirPath), "sdrbase.rcc");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-12-17 18:00:21 -05:00
|
|
|
m_requestMapper = new WebAPIRequestMapper(this);
|
2017-11-18 13:34:47 -05:00
|
|
|
m_requestMapper->setAdapter(m_apiAdapter);
|
2018-01-11 18:57:05 -05:00
|
|
|
m_apiHost = parser.getServerAddress();
|
|
|
|
m_apiPort = parser.getServerPort();
|
|
|
|
m_apiServer = new WebAPIServer(m_apiHost, m_apiPort, m_requestMapper);
|
2017-11-17 02:52:15 -05:00
|
|
|
m_apiServer->start();
|
|
|
|
|
2018-01-04 23:05:12 -05:00
|
|
|
m_commandKeyReceiver = new CommandKeyReceiver();
|
|
|
|
m_commandKeyReceiver->setRelease(true);
|
|
|
|
this->installEventFilter(m_commandKeyReceiver);
|
|
|
|
|
2022-04-13 21:49:32 -04:00
|
|
|
m_dspEngine->setMIMOSupport(true);
|
2019-05-12 04:25:55 -04:00
|
|
|
|
2019-05-14 13:23:13 -04:00
|
|
|
delete splash;
|
|
|
|
|
2021-07-01 10:28:43 -04:00
|
|
|
// Restore window size and position
|
|
|
|
QSettings s;
|
2021-07-01 11:07:25 -04:00
|
|
|
restoreGeometry(qUncompress(QByteArray::fromBase64(s.value("mainWindowGeometry").toByteArray())));
|
|
|
|
restoreState(qUncompress(QByteArray::fromBase64(s.value("mainWindowState").toByteArray())));
|
2021-07-01 10:28:43 -04:00
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
qDebug() << "MainWindow::MainWindow: end";
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug() << "MainWindow::~MainWindow";
|
|
|
|
|
2022-09-13 12:04:51 -04:00
|
|
|
m_statusTimer.stop();
|
2022-04-05 10:26:57 -04:00
|
|
|
m_mainCore->m_settings.save();
|
2017-11-17 02:52:15 -05:00
|
|
|
m_apiServer->stop();
|
|
|
|
delete m_apiServer;
|
|
|
|
delete m_requestMapper;
|
2017-11-18 13:34:47 -05:00
|
|
|
delete m_apiAdapter;
|
2017-11-17 02:52:15 -05:00
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
delete m_pluginManager;
|
|
|
|
delete m_dateTimeWidget;
|
|
|
|
delete m_showSystemWidget;
|
|
|
|
|
2020-09-19 19:06:34 -04:00
|
|
|
removeAllFeatureSets();
|
|
|
|
|
2018-02-15 04:52:34 -05:00
|
|
|
delete m_commandKeyReceiver;
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
for (const auto& workspace : m_workspaces) {
|
|
|
|
delete workspace;
|
|
|
|
}
|
2022-04-07 10:32:03 -04:00
|
|
|
|
|
|
|
qDebug() << "MainWindow::~MainWindow: end";
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-13 21:07:33 -04:00
|
|
|
void MainWindow::sampleSourceAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
|
|
|
DSPDeviceSourceEngine *dspDeviceSourceEngine = m_dspEngine->addDeviceSourceEngine();
|
|
|
|
dspDeviceSourceEngine->start();
|
|
|
|
|
|
|
|
uint dspDeviceSourceEngineUID = dspDeviceSourceEngine->getUID();
|
|
|
|
char uidCStr[16];
|
|
|
|
sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID);
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceSetIndex = m_deviceUIs.size();
|
2020-09-13 11:50:24 -04:00
|
|
|
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->appendDeviceSet(0);
|
2022-04-07 10:32:03 -04:00
|
|
|
m_deviceUIs.push_back(new DeviceUISet(deviceSetIndex, m_mainCore->m_deviceSets.back()));
|
2017-10-22 13:12:43 -04:00
|
|
|
m_deviceUIs.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
|
2019-12-14 12:45:25 -05:00
|
|
|
m_deviceUIs.back()->m_deviceSinkEngine = nullptr;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = nullptr;
|
2019-12-14 12:45:25 -05:00
|
|
|
m_deviceUIs.back()->m_deviceMIMOEngine = nullptr;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleRx, deviceSetIndex, dspDeviceSourceEngine, nullptr, nullptr);
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceAPI = deviceAPI;
|
2017-11-01 03:32:44 -04:00
|
|
|
QList<QString> channelNames;
|
|
|
|
m_pluginManager->listRxChannels(channelNames);
|
2020-09-12 04:37:16 -04:00
|
|
|
m_deviceUIs.back()->setNumberOfAvailableRxChannels(channelNames.size());
|
2017-10-22 13:12:43 -04:00
|
|
|
|
|
|
|
dspDeviceSourceEngine->addSink(m_deviceUIs.back()->m_spectrumVis);
|
|
|
|
|
2017-12-25 03:10:19 -05:00
|
|
|
// Create a file source instance by default if requested device was not enumerated (index = -1)
|
|
|
|
if (deviceIndex < 0) {
|
2019-07-07 18:59:04 -04:00
|
|
|
deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
|
2017-12-25 03:10:19 -05:00
|
|
|
}
|
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
sampleSourceCreate(deviceSetIndex, deviceIndex, m_deviceUIs.back());
|
2022-04-13 21:07:33 -04:00
|
|
|
m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(deviceWorkspace->getIndex());
|
|
|
|
m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(spectrumWorkspace->getIndex());
|
|
|
|
MainSpectrumGUI *mainSpectrumGUI = m_deviceUIs.back()->m_mainSpectrumGUI;
|
2022-04-09 07:38:22 -04:00
|
|
|
|
|
|
|
QObject::connect(
|
2022-04-13 21:07:33 -04:00
|
|
|
mainSpectrumGUI,
|
2022-04-09 07:38:22 -04:00
|
|
|
&MainSpectrumGUI::moveToWorkspace,
|
|
|
|
this,
|
2022-04-13 21:07:33 -04:00
|
|
|
[=](int wsIndexDest){ this->mainSpectrumMove(mainSpectrumGUI, wsIndexDest); }
|
2022-04-09 07:38:22 -04:00
|
|
|
);
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_deviceUIs.back()->m_deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
2022-04-15 12:59:29 -04:00
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelPluginIndex); }
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
|
|
|
|
2022-06-24 16:52:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
mainSpectrumGUI,
|
|
|
|
&MainSpectrumGUI::requestCenterFrequency,
|
|
|
|
this,
|
|
|
|
&MainWindow::mainSpectrumRequestDeviceCenterFrequency
|
|
|
|
);
|
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceAPI,
|
|
|
|
&DeviceAPI::stateChanged,
|
|
|
|
this,
|
|
|
|
&MainWindow::deviceStateChanged
|
|
|
|
);
|
|
|
|
|
2022-04-13 21:07:33 -04:00
|
|
|
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
|
|
|
|
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
|
2022-04-07 10:32:03 -04:00
|
|
|
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
|
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
void MainWindow::sampleSourceCreate(
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceSetIndex,
|
|
|
|
int deviceIndex,
|
2022-04-09 07:38:22 -04:00
|
|
|
DeviceUISet *deviceUISet
|
2022-04-07 10:32:03 -04:00
|
|
|
)
|
|
|
|
{
|
2022-04-14 14:41:32 -04:00
|
|
|
DeviceAPI *deviceAPI = deviceUISet->m_deviceAPI;
|
2022-04-07 10:32:03 -04:00
|
|
|
int selectedDeviceIndex = deviceIndex;
|
|
|
|
DeviceEnumerator::instance()->changeRxSelection(deviceSetIndex, deviceIndex);
|
2019-05-08 19:12:40 -04:00
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
|
2020-10-11 02:27:58 -04:00
|
|
|
deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
|
2017-11-01 22:30:54 -04:00
|
|
|
|
2022-05-14 05:18:09 -04:00
|
|
|
qDebug() << "MainWindow::sampleSourceCreate:"
|
|
|
|
<< "deviceSetIndex:" << deviceSetIndex
|
2022-04-07 10:32:03 -04:00
|
|
|
<< "deviceIndex:" << deviceIndex
|
|
|
|
<< "hardwareId:" << samplingDevice->hardwareId
|
|
|
|
<< "sequence:" << samplingDevice->sequence
|
|
|
|
<< "id:" << samplingDevice->id
|
|
|
|
<< "serial:" << samplingDevice->serial
|
|
|
|
<< "displayedName:" << samplingDevice->displayedName;
|
|
|
|
|
|
|
|
if (deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
|
|
|
|
{
|
2022-05-14 05:18:09 -04:00
|
|
|
qDebug("MainWindow::sampleSourceCreate: non existent device replaced by File Input");
|
2022-04-07 10:32:03 -04:00
|
|
|
int fileInputDeviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
|
|
|
|
selectedDeviceIndex = fileInputDeviceIndex;
|
|
|
|
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileInputDeviceIndex);
|
|
|
|
deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileInputDeviceIndex));
|
|
|
|
}
|
|
|
|
|
2020-10-10 14:08:11 -04:00
|
|
|
QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
2019-06-13 12:43:06 -04:00
|
|
|
|
|
|
|
if (userArgs.size() > 0) {
|
2020-10-11 02:27:58 -04:00
|
|
|
deviceAPI->setHardwareUserArguments(userArgs);
|
2019-06-13 12:43:06 -04:00
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
// add to buddies list
|
|
|
|
std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin();
|
|
|
|
int nbOfBuddies = 0;
|
2017-10-29 21:15:59 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
for (; it != m_deviceUIs.end(); ++it)
|
|
|
|
{
|
|
|
|
if (*it != deviceUISet) // do not add to itself
|
|
|
|
{
|
|
|
|
if ((*it)->m_deviceSourceEngine) // it is a source device
|
|
|
|
{
|
|
|
|
if ((deviceUISet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceUISet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
|
|
|
{
|
|
|
|
(*it)->m_deviceAPI->addSourceBuddy(deviceUISet->m_deviceAPI);
|
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
|
|
|
{
|
|
|
|
if ((deviceUISet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceUISet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
|
|
|
{
|
|
|
|
(*it)->m_deviceAPI->addSourceBuddy(deviceUISet->m_deviceAPI);
|
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbOfBuddies == 0) {
|
|
|
|
deviceUISet->m_deviceAPI->setBuddyLeader(true);
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
// DeviceGUI *oldDeviceGUI = deviceUISet->m_deviceGUI; // store old GUI pointer for later
|
2017-11-01 22:30:54 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
// constructs new GUI and input object
|
2020-10-11 02:27:58 -04:00
|
|
|
DeviceSampleSource *source = deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
|
|
|
|
deviceAPI->getSamplingDeviceId(), deviceAPI);
|
|
|
|
deviceAPI->setSampleSource(source);
|
2017-10-22 13:12:43 -04:00
|
|
|
QWidget *gui;
|
2022-04-07 10:32:03 -04:00
|
|
|
DeviceGUI *deviceGUI = deviceAPI->getPluginInterface()->createSampleSourcePluginInstanceGUI(
|
2020-10-11 02:27:58 -04:00
|
|
|
deviceAPI->getSamplingDeviceId(),
|
2017-10-29 19:02:28 -04:00
|
|
|
&gui,
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->deviceMove(deviceGUI, wsIndexDest); }
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::deviceChange,
|
|
|
|
this,
|
2022-04-15 04:04:24 -04:00
|
|
|
[=](int newDeviceIndex){ this->samplingDeviceChangeHandler(deviceGUI, newDeviceIndex); }
|
2022-04-07 10:32:03 -04:00
|
|
|
);
|
2022-04-09 18:11:23 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::showSpectrum,
|
|
|
|
this,
|
2022-04-27 18:01:08 -04:00
|
|
|
&MainWindow::mainSpectrumShow
|
2022-04-09 18:11:23 -04:00
|
|
|
);
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::showAllChannels,
|
|
|
|
this,
|
|
|
|
&MainWindow::showAllChannels
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::closing,
|
|
|
|
this,
|
|
|
|
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
|
|
|
);
|
2022-04-13 12:43:37 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::deviceSetPresetsDialogRequested,
|
|
|
|
this,
|
|
|
|
&MainWindow::openDeviceSetPresetsDialog
|
|
|
|
);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceAPI->getSampleSource()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
|
|
|
deviceUISet->m_deviceGUI = deviceGUI;
|
2022-04-09 07:38:22 -04:00
|
|
|
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
|
|
|
deviceUISet->m_selectedDeviceId = selectedDevice->id;
|
|
|
|
deviceUISet->m_selectedDeviceSerial = selectedDevice->serial;
|
|
|
|
deviceUISet->m_selectedDeviceSequence = selectedDevice->sequence;
|
|
|
|
deviceUISet->m_selectedDeviceItemImdex = selectedDevice->deviceItemIndex;
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->getSampleSource()->init();
|
|
|
|
// Finalize GUI setup and add it to workspace MDI
|
|
|
|
deviceGUI->setDeviceType(DeviceGUI::DeviceRx);
|
|
|
|
deviceGUI->setIndex(deviceSetIndex);
|
|
|
|
deviceGUI->setToolTip(samplingDevice->displayedName);
|
|
|
|
deviceGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
|
|
|
|
deviceGUI->setCurrentDeviceIndex(selectedDeviceIndex);
|
2022-04-12 10:20:45 -04:00
|
|
|
QStringList channelNames;
|
|
|
|
m_pluginManager->listRxChannels(channelNames);
|
|
|
|
deviceGUI->setChannelNames(channelNames);
|
2022-04-09 07:38:22 -04:00
|
|
|
MainSpectrumGUI *mainSpectrumGUI = deviceUISet->m_mainSpectrumGUI;
|
|
|
|
mainSpectrumGUI->setDeviceType(MainSpectrumGUI::DeviceRx);
|
|
|
|
mainSpectrumGUI->setIndex(deviceSetIndex);
|
|
|
|
mainSpectrumGUI->setToolTip(samplingDevice->displayedName);
|
|
|
|
mainSpectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-13 21:07:33 -04:00
|
|
|
void MainWindow::sampleSinkAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
|
|
|
DSPDeviceSinkEngine *dspDeviceSinkEngine = m_dspEngine->addDeviceSinkEngine();
|
|
|
|
dspDeviceSinkEngine->start();
|
|
|
|
|
|
|
|
uint dspDeviceSinkEngineUID = dspDeviceSinkEngine->getUID();
|
|
|
|
char uidCStr[16];
|
|
|
|
sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID);
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceSetIndex = m_deviceUIs.size();
|
2020-09-13 11:50:24 -04:00
|
|
|
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->appendDeviceSet(1);
|
2022-04-07 10:32:03 -04:00
|
|
|
m_deviceUIs.push_back(new DeviceUISet(deviceSetIndex, m_mainCore->m_deviceSets.back()));
|
2019-12-14 12:45:25 -05:00
|
|
|
m_deviceUIs.back()->m_deviceSourceEngine = nullptr;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = nullptr;
|
2017-10-22 13:12:43 -04:00
|
|
|
m_deviceUIs.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
|
2019-12-14 12:45:25 -05:00
|
|
|
m_deviceUIs.back()->m_deviceMIMOEngine = nullptr;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleTx, deviceSetIndex, nullptr, dspDeviceSinkEngine, nullptr);
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceAPI = deviceAPI;
|
2017-11-01 03:32:44 -04:00
|
|
|
QList<QString> channelNames;
|
|
|
|
m_pluginManager->listTxChannels(channelNames);
|
2020-09-12 04:37:16 -04:00
|
|
|
m_deviceUIs.back()->setNumberOfAvailableTxChannels(channelNames.size());
|
2017-10-22 13:12:43 -04:00
|
|
|
|
|
|
|
dspDeviceSinkEngine->addSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
|
2019-05-30 12:38:10 -04:00
|
|
|
m_deviceUIs.back()->m_spectrum->setDisplayedStream(false, 0);
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
if (deviceIndex < 0) {
|
|
|
|
deviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex(); // create a file output by default
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
sampleSinkCreate(deviceSetIndex, deviceIndex, m_deviceUIs.back());
|
2022-04-13 21:07:33 -04:00
|
|
|
m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(deviceWorkspace->getIndex());
|
|
|
|
m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(spectrumWorkspace->getIndex());
|
|
|
|
MainSpectrumGUI *mainSpectrumGUI = m_deviceUIs.back()->m_mainSpectrumGUI;
|
2022-04-09 07:38:22 -04:00
|
|
|
|
|
|
|
QObject::connect(
|
2022-04-13 21:07:33 -04:00
|
|
|
mainSpectrumGUI,
|
2022-04-09 07:38:22 -04:00
|
|
|
&MainSpectrumGUI::moveToWorkspace,
|
|
|
|
this,
|
2022-04-13 21:07:33 -04:00
|
|
|
[=](int wsIndexDest){ this->mainSpectrumMove(mainSpectrumGUI, wsIndexDest); }
|
2022-04-09 07:38:22 -04:00
|
|
|
);
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_deviceUIs.back()->m_deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
2022-04-15 12:59:29 -04:00
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelPluginIndex); }
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
|
|
|
|
2022-06-24 16:52:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
mainSpectrumGUI,
|
|
|
|
&MainSpectrumGUI::requestCenterFrequency,
|
|
|
|
this,
|
|
|
|
&MainWindow::mainSpectrumRequestDeviceCenterFrequency
|
|
|
|
);
|
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceAPI,
|
|
|
|
&DeviceAPI::stateChanged,
|
|
|
|
this,
|
|
|
|
&MainWindow::deviceStateChanged
|
|
|
|
);
|
|
|
|
|
2022-04-13 21:07:33 -04:00
|
|
|
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
|
|
|
|
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
|
2022-04-07 10:32:03 -04:00
|
|
|
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
|
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
void MainWindow::sampleSinkCreate(
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceSetIndex,
|
|
|
|
int deviceIndex,
|
2022-04-09 07:38:22 -04:00
|
|
|
DeviceUISet *deviceUISet
|
2022-04-07 10:32:03 -04:00
|
|
|
)
|
|
|
|
{
|
2022-04-14 14:41:32 -04:00
|
|
|
DeviceAPI *deviceAPI = deviceUISet->m_deviceAPI;
|
2022-04-07 10:32:03 -04:00
|
|
|
int selectedDeviceIndex = deviceIndex;
|
|
|
|
DeviceEnumerator::instance()->changeTxSelection(deviceSetIndex, deviceIndex);
|
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(deviceIndex);
|
2020-10-11 02:27:58 -04:00
|
|
|
deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(deviceIndex));
|
|
|
|
|
2022-05-14 05:18:09 -04:00
|
|
|
qDebug() << "MainWindow::sampleSinkCreate:"
|
|
|
|
<< "deviceSetIndex:" << deviceSetIndex
|
2022-04-07 10:32:03 -04:00
|
|
|
<< "newDeviceIndex:" << deviceIndex
|
|
|
|
<< "hardwareId:" << samplingDevice->hardwareId
|
|
|
|
<< "sequence:" << samplingDevice->sequence
|
|
|
|
<< "id:" << samplingDevice->id
|
|
|
|
<< "serial:" << samplingDevice->serial
|
|
|
|
<< "displayedName:" << samplingDevice->displayedName;
|
|
|
|
|
|
|
|
if (deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
|
|
|
|
{
|
2022-05-14 05:18:09 -04:00
|
|
|
qDebug("MainWindow::sampleSinkCreate: non existent device replaced by File Sink");
|
2022-04-07 10:32:03 -04:00
|
|
|
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex();
|
|
|
|
selectedDeviceIndex = fileSinkDeviceIndex;
|
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
|
|
|
deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
|
|
|
}
|
2017-11-01 22:30:54 -04:00
|
|
|
|
2020-10-10 14:08:11 -04:00
|
|
|
QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
2019-06-13 12:43:06 -04:00
|
|
|
|
|
|
|
if (userArgs.size() > 0) {
|
2020-10-11 02:27:58 -04:00
|
|
|
deviceAPI->setHardwareUserArguments(userArgs);
|
2019-06-13 12:43:06 -04:00
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
// add to buddies list
|
|
|
|
std::vector<DeviceUISet*>::iterator it = m_deviceUIs.begin();
|
|
|
|
int nbOfBuddies = 0;
|
|
|
|
|
|
|
|
for (; it != m_deviceUIs.end(); ++it)
|
|
|
|
{
|
|
|
|
if (*it != deviceUISet) // do not add to itself
|
|
|
|
{
|
|
|
|
if ((*it)->m_deviceSourceEngine) // it is a source device
|
|
|
|
{
|
|
|
|
if ((deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
|
|
|
{
|
|
|
|
(*it)->m_deviceAPI->addSinkBuddy(deviceAPI);
|
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
|
|
|
{
|
|
|
|
if ((deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
|
|
|
{
|
|
|
|
(*it)->m_deviceAPI->addSinkBuddy(deviceAPI);
|
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbOfBuddies == 0) {
|
|
|
|
deviceAPI->setBuddyLeader(true);
|
|
|
|
}
|
2017-10-29 21:23:06 -04:00
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
// DeviceGUI *oldDeviceGUI = deviceUISet->m_deviceGUI; // store old GUI pointer for later
|
2017-10-29 21:23:06 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
// constructs new GUI and output object
|
2020-10-11 02:27:58 -04:00
|
|
|
DeviceSampleSink *sink = deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
|
|
|
|
deviceAPI->getSamplingDeviceId(), deviceAPI);
|
|
|
|
deviceAPI->setSampleSink(sink);
|
2017-10-22 13:12:43 -04:00
|
|
|
QWidget *gui;
|
2022-04-07 10:32:03 -04:00
|
|
|
DeviceGUI *deviceGUI = deviceAPI->getPluginInterface()->createSampleSinkPluginInstanceGUI(
|
2020-10-11 02:27:58 -04:00
|
|
|
deviceAPI->getSamplingDeviceId(),
|
2017-10-29 20:11:35 -04:00
|
|
|
&gui,
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->deviceMove(deviceGUI, wsIndexDest); }
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::deviceChange,
|
|
|
|
this,
|
2022-04-15 04:04:24 -04:00
|
|
|
[=](int newDeviceIndex){ this->samplingDeviceChangeHandler(deviceGUI, newDeviceIndex); }
|
2022-04-07 10:32:03 -04:00
|
|
|
);
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::showSpectrum,
|
|
|
|
this,
|
2022-04-27 18:01:08 -04:00
|
|
|
&MainWindow::mainSpectrumShow
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::showAllChannels,
|
|
|
|
this,
|
|
|
|
&MainWindow::showAllChannels
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::closing,
|
|
|
|
this,
|
|
|
|
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
|
|
|
);
|
2022-04-13 12:43:37 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::deviceSetPresetsDialogRequested,
|
|
|
|
this,
|
|
|
|
&MainWindow::openDeviceSetPresetsDialog
|
|
|
|
);
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceAPI->getSampleSink()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
|
|
|
deviceUISet->m_deviceGUI = deviceGUI;
|
2022-04-09 07:38:22 -04:00
|
|
|
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
|
|
|
deviceUISet->m_selectedDeviceId = selectedDevice->id;
|
|
|
|
deviceUISet->m_selectedDeviceSerial = selectedDevice->serial;
|
|
|
|
deviceUISet->m_selectedDeviceSequence = selectedDevice->sequence;
|
|
|
|
deviceUISet->m_selectedDeviceItemImdex = selectedDevice->deviceItemIndex;
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->getSampleSink()->init();
|
|
|
|
// Finalize GUI setup and add it to workspace MDI
|
|
|
|
deviceGUI->setDeviceType(DeviceGUI::DeviceTx);
|
|
|
|
deviceGUI->setIndex(deviceSetIndex);
|
|
|
|
deviceGUI->setToolTip(samplingDevice->displayedName);
|
|
|
|
deviceGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
|
|
|
|
deviceGUI->setCurrentDeviceIndex(selectedDeviceIndex);
|
2022-04-12 10:20:45 -04:00
|
|
|
QStringList channelNames;
|
|
|
|
m_pluginManager->listTxChannels(channelNames);
|
|
|
|
deviceGUI->setChannelNames(channelNames);
|
2022-04-09 07:38:22 -04:00
|
|
|
MainSpectrumGUI *spectrumGUI = deviceUISet->m_mainSpectrumGUI;
|
|
|
|
spectrumGUI->setDeviceType(MainSpectrumGUI::DeviceTx);
|
|
|
|
spectrumGUI->setIndex(deviceSetIndex);
|
|
|
|
spectrumGUI->setToolTip(samplingDevice->displayedName);
|
|
|
|
spectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-13 21:07:33 -04:00
|
|
|
void MainWindow::sampleMIMOAdd(Workspace *deviceWorkspace, Workspace *spectrumWorkspace, int deviceIndex)
|
2020-11-10 06:08:58 -05:00
|
|
|
{
|
|
|
|
DSPDeviceMIMOEngine *dspDeviceMIMOEngine = m_dspEngine->addDeviceMIMOEngine();
|
|
|
|
dspDeviceMIMOEngine->start();
|
|
|
|
|
|
|
|
uint dspDeviceMIMOEngineUID = dspDeviceMIMOEngine->getUID();
|
|
|
|
char uidCStr[16];
|
|
|
|
sprintf(uidCStr, "UID:%d", dspDeviceMIMOEngineUID);
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceSetIndex = m_deviceUIs.size();
|
2020-11-10 06:08:58 -05:00
|
|
|
|
|
|
|
m_mainCore->appendDeviceSet(2);
|
2022-04-07 10:32:03 -04:00
|
|
|
m_deviceUIs.push_back(new DeviceUISet(deviceSetIndex, m_mainCore->m_deviceSets.back()));
|
2020-11-10 06:08:58 -05:00
|
|
|
m_deviceUIs.back()->m_deviceSourceEngine = nullptr;
|
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceSourceEngine = nullptr;
|
|
|
|
m_deviceUIs.back()->m_deviceSinkEngine = nullptr;
|
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceSinkEngine = nullptr;
|
|
|
|
m_deviceUIs.back()->m_deviceMIMOEngine = dspDeviceMIMOEngine;
|
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceMIMOEngine = dspDeviceMIMOEngine;
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamMIMO, deviceSetIndex, nullptr, nullptr, dspDeviceMIMOEngine);
|
2020-11-10 06:08:58 -05:00
|
|
|
|
|
|
|
m_deviceUIs.back()->m_deviceAPI = deviceAPI;
|
|
|
|
m_mainCore->m_deviceSets.back()->m_deviceAPI = deviceAPI;
|
|
|
|
// add MIMO channels
|
|
|
|
QList<QString> mimoChannelNames;
|
|
|
|
m_pluginManager->listMIMOChannels(mimoChannelNames);
|
|
|
|
m_deviceUIs.back()->setNumberOfAvailableMIMOChannels(mimoChannelNames.size());
|
|
|
|
// Add Rx channels
|
|
|
|
QList<QString> rxChannelNames;
|
|
|
|
m_pluginManager->listRxChannels(rxChannelNames);
|
|
|
|
m_deviceUIs.back()->setNumberOfAvailableRxChannels(rxChannelNames.size());
|
|
|
|
// Add Tx channels
|
|
|
|
QList<QString> txChannelNames;
|
|
|
|
m_pluginManager->listTxChannels(txChannelNames);
|
|
|
|
m_deviceUIs.back()->setNumberOfAvailableTxChannels(txChannelNames.size());
|
|
|
|
|
|
|
|
dspDeviceMIMOEngine->addSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
if (deviceIndex < 0) {
|
|
|
|
deviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex(); // create a test MIMO by default
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
sampleMIMOCreate(deviceSetIndex, deviceIndex, m_deviceUIs.back());
|
2022-04-13 21:07:33 -04:00
|
|
|
m_deviceUIs.back()->m_deviceGUI->setWorkspaceIndex(deviceWorkspace->getIndex());
|
|
|
|
m_deviceUIs.back()->m_mainSpectrumGUI->setWorkspaceIndex(spectrumWorkspace->getIndex());
|
|
|
|
MainSpectrumGUI *mainSpectrumGUI = m_deviceUIs.back()->m_mainSpectrumGUI;
|
2022-04-09 07:38:22 -04:00
|
|
|
|
|
|
|
QObject::connect(
|
2022-04-13 21:07:33 -04:00
|
|
|
mainSpectrumGUI,
|
2022-04-09 07:38:22 -04:00
|
|
|
&MainSpectrumGUI::moveToWorkspace,
|
|
|
|
this,
|
2022-04-13 21:07:33 -04:00
|
|
|
[=](int wsIndexDest){ this->mainSpectrumMove(mainSpectrumGUI, wsIndexDest); }
|
2022-04-09 07:38:22 -04:00
|
|
|
);
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_deviceUIs.back()->m_deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
2022-04-15 12:59:29 -04:00
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(deviceWorkspace, deviceSetIndex, channelPluginIndex); }
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceAPI,
|
|
|
|
&DeviceAPI::stateChanged,
|
|
|
|
this,
|
|
|
|
&MainWindow::deviceStateChanged
|
|
|
|
);
|
|
|
|
|
2022-04-13 21:07:33 -04:00
|
|
|
deviceWorkspace->addToMdiArea(m_deviceUIs.back()->m_deviceGUI);
|
|
|
|
spectrumWorkspace->addToMdiArea(m_deviceUIs.back()->m_mainSpectrumGUI);
|
2022-04-07 10:32:03 -04:00
|
|
|
emit m_mainCore->deviceSetAdded(deviceSetIndex, deviceAPI);
|
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
void MainWindow::sampleMIMOCreate(
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceSetIndex,
|
|
|
|
int deviceIndex,
|
2022-04-09 07:38:22 -04:00
|
|
|
DeviceUISet *deviceUISet
|
2022-04-07 10:32:03 -04:00
|
|
|
)
|
|
|
|
{
|
2022-04-14 14:41:32 -04:00
|
|
|
DeviceAPI *deviceAPI = deviceUISet->m_deviceAPI;
|
2022-04-07 10:32:03 -04:00
|
|
|
int selectedDeviceIndex = deviceIndex;
|
|
|
|
DeviceEnumerator::instance()->changeMIMOSelection(deviceSetIndex, deviceIndex);
|
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(deviceIndex);
|
2020-11-10 06:08:58 -05:00
|
|
|
deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(deviceIndex));
|
|
|
|
|
2022-05-14 05:18:09 -04:00
|
|
|
qDebug() << "MainWindow::sampleMIMOCreate:"
|
|
|
|
<< "deviceSetIndex" << deviceSetIndex
|
2022-04-07 10:32:03 -04:00
|
|
|
<< "newDeviceIndex:" << deviceIndex
|
|
|
|
<< "hardwareId:" << samplingDevice->hardwareId
|
|
|
|
<< "sequence:" << samplingDevice->sequence
|
|
|
|
<< "id:" << samplingDevice->id
|
|
|
|
<< "serial:" << samplingDevice->serial
|
|
|
|
<< "displayedName:" << samplingDevice->displayedName;
|
|
|
|
|
|
|
|
if (deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
|
|
|
|
{
|
2022-05-14 05:18:09 -04:00
|
|
|
qDebug("MainWindow::sampleMIMOCreate: non existent device replaced by Test MIMO");
|
2022-04-07 10:32:03 -04:00
|
|
|
int testMIMODeviceIndex = DeviceEnumerator::instance()->getTestMIMODeviceIndex();
|
|
|
|
selectedDeviceIndex = testMIMODeviceIndex;
|
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(testMIMODeviceIndex);
|
|
|
|
deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(testMIMODeviceIndex));
|
|
|
|
}
|
2020-11-10 06:08:58 -05:00
|
|
|
|
|
|
|
QString userArgs = m_mainCore->m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
|
|
|
|
|
|
|
if (userArgs.size() > 0) {
|
|
|
|
deviceAPI->setHardwareUserArguments(userArgs);
|
|
|
|
}
|
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
// DeviceGUI *oldDeviceGUI = deviceUISet->m_deviceGUI; // store old GUI pointer for later
|
2020-11-10 06:08:58 -05:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
// constructs new GUI and output object
|
2020-11-10 06:08:58 -05:00
|
|
|
DeviceSampleMIMO *mimo = deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance(
|
|
|
|
deviceAPI->getSamplingDeviceId(), deviceAPI);
|
|
|
|
deviceAPI->setSampleMIMO(mimo);
|
|
|
|
QWidget *gui;
|
2022-04-07 10:32:03 -04:00
|
|
|
DeviceGUI *deviceGUI = deviceAPI->getPluginInterface()->createSampleMIMOPluginInstanceGUI(
|
2020-11-10 06:08:58 -05:00
|
|
|
deviceAPI->getSamplingDeviceId(),
|
|
|
|
&gui,
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->deviceMove(deviceGUI, wsIndexDest); }
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::deviceChange,
|
|
|
|
this,
|
2022-04-15 04:04:24 -04:00
|
|
|
[=](int newDeviceIndex){ this->samplingDeviceChangeHandler(deviceGUI, newDeviceIndex); }
|
2022-04-07 10:32:03 -04:00
|
|
|
);
|
2022-04-12 10:20:45 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::showSpectrum,
|
|
|
|
this,
|
2022-04-27 18:01:08 -04:00
|
|
|
&MainWindow::mainSpectrumShow
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::showAllChannels,
|
|
|
|
this,
|
|
|
|
&MainWindow::showAllChannels
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::closing,
|
|
|
|
this,
|
|
|
|
[=](){ this->removeDeviceSet(deviceGUI->getIndex()); }
|
|
|
|
);
|
2022-04-13 12:43:37 -04:00
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::deviceSetPresetsDialogRequested,
|
|
|
|
this,
|
|
|
|
&MainWindow::openDeviceSetPresetsDialog
|
|
|
|
);
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceAPI->getSampleMIMO()->setMessageQueueToGUI(deviceGUI->getInputMessageQueue());
|
|
|
|
deviceUISet->m_deviceGUI = deviceGUI;
|
2022-04-09 07:38:22 -04:00
|
|
|
const PluginInterface::SamplingDevice *selectedDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
|
|
|
deviceUISet->m_selectedDeviceId = selectedDevice->id;
|
|
|
|
deviceUISet->m_selectedDeviceSerial = selectedDevice->serial;
|
|
|
|
deviceUISet->m_selectedDeviceSequence = selectedDevice->sequence;
|
|
|
|
deviceUISet->m_selectedDeviceItemImdex = selectedDevice->deviceItemIndex;
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->getSampleMIMO()->init();
|
|
|
|
// Finalize GUI setup and add it to workspace MDI
|
|
|
|
deviceGUI->setDeviceType(DeviceGUI::DeviceMIMO);
|
|
|
|
deviceGUI->setIndex(deviceSetIndex);
|
|
|
|
deviceGUI->setToolTip(samplingDevice->displayedName);
|
|
|
|
deviceGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
|
|
|
|
deviceGUI->setCurrentDeviceIndex(selectedDeviceIndex);
|
2022-04-17 19:42:03 -04:00
|
|
|
QStringList channelNames, tmpChannelNames;
|
2022-04-12 10:20:45 -04:00
|
|
|
m_pluginManager->listMIMOChannels(channelNames);
|
2022-04-17 19:42:03 -04:00
|
|
|
m_pluginManager->listRxChannels(tmpChannelNames);
|
|
|
|
channelNames.append(tmpChannelNames);
|
|
|
|
m_pluginManager->listTxChannels(tmpChannelNames);
|
|
|
|
channelNames.append(tmpChannelNames);
|
2022-04-12 10:20:45 -04:00
|
|
|
deviceGUI->setChannelNames(channelNames);
|
2022-04-09 07:38:22 -04:00
|
|
|
MainSpectrumGUI *spectrumGUI = deviceUISet->m_mainSpectrumGUI;
|
|
|
|
spectrumGUI->setDeviceType(MainSpectrumGUI::DeviceMIMO);
|
|
|
|
spectrumGUI->setIndex(deviceSetIndex);
|
|
|
|
spectrumGUI->setToolTip(samplingDevice->displayedName);
|
|
|
|
spectrumGUI->setTitle(samplingDevice->displayedName.split(" ")[0]);
|
2020-11-10 06:08:58 -05:00
|
|
|
}
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
void MainWindow::removeDeviceSet(int deviceSetIndex)
|
|
|
|
{
|
2022-04-14 14:41:32 -04:00
|
|
|
qDebug("MainWindow::removeDeviceSet: index: %d", deviceSetIndex);
|
2022-04-12 10:20:45 -04:00
|
|
|
if (deviceSetIndex >= (int) m_deviceUIs.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
|
|
|
|
if (deviceUISet->m_deviceSourceEngine) // source device
|
|
|
|
{
|
|
|
|
DSPDeviceSourceEngine *deviceEngine = deviceUISet->m_deviceSourceEngine;
|
|
|
|
deviceEngine->stopAcquistion();
|
|
|
|
deviceEngine->removeSink(deviceUISet->m_spectrumVis);
|
|
|
|
|
|
|
|
// deletes old UI and core object
|
|
|
|
deviceUISet->freeChannels(); // destroys the channel instances
|
|
|
|
deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
|
|
|
|
deviceUISet->m_deviceGUI->destroy();
|
|
|
|
deviceUISet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
|
|
|
|
deviceUISet->m_deviceAPI->getSampleSource());
|
|
|
|
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
|
|
|
|
|
|
|
DeviceAPI *sourceAPI = deviceUISet->m_deviceAPI;
|
|
|
|
delete deviceUISet;
|
|
|
|
|
|
|
|
deviceEngine->stop();
|
|
|
|
m_dspEngine->removeDeviceEngineAt(deviceSetIndex);
|
2022-05-14 05:18:09 -04:00
|
|
|
DeviceEnumerator::instance()->removeRxSelection(deviceSetIndex);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
delete sourceAPI;
|
|
|
|
}
|
|
|
|
else if (deviceUISet->m_deviceSinkEngine) // sink device
|
|
|
|
{
|
|
|
|
DSPDeviceSinkEngine *deviceEngine = deviceUISet->m_deviceSinkEngine;
|
|
|
|
deviceEngine->stopGeneration();
|
|
|
|
deviceEngine->removeSpectrumSink(deviceUISet->m_spectrumVis);
|
|
|
|
|
|
|
|
// deletes old UI and output object
|
|
|
|
deviceUISet->freeChannels();
|
|
|
|
deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
|
|
|
|
deviceUISet->m_deviceGUI->destroy();
|
|
|
|
deviceUISet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
|
|
|
|
deviceUISet->m_deviceAPI->getSampleSink());
|
|
|
|
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
|
|
|
|
|
|
|
DeviceAPI *sinkAPI = deviceUISet->m_deviceAPI;
|
|
|
|
delete deviceUISet;
|
|
|
|
|
|
|
|
deviceEngine->stop();
|
|
|
|
m_dspEngine->removeDeviceEngineAt(deviceSetIndex);
|
2022-05-14 05:18:09 -04:00
|
|
|
DeviceEnumerator::instance()->removeTxSelection(deviceSetIndex);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
delete sinkAPI;
|
|
|
|
}
|
|
|
|
else if (deviceUISet->m_deviceMIMOEngine) // MIMO device
|
|
|
|
{
|
|
|
|
DSPDeviceMIMOEngine *deviceEngine = deviceUISet->m_deviceMIMOEngine;
|
|
|
|
deviceEngine->stopProcess(1); // Tx side
|
|
|
|
deviceEngine->stopProcess(0); // Rx side
|
|
|
|
deviceEngine->removeSpectrumSink(deviceUISet->m_spectrumVis);
|
|
|
|
|
|
|
|
// deletes old UI and output object
|
|
|
|
deviceUISet->freeChannels();
|
|
|
|
deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
|
|
|
|
deviceUISet->m_deviceGUI->destroy();
|
|
|
|
deviceUISet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(
|
|
|
|
deviceUISet->m_deviceAPI->getSampleMIMO());
|
|
|
|
|
|
|
|
DeviceAPI *mimoAPI = deviceUISet->m_deviceAPI;
|
|
|
|
delete deviceUISet;
|
|
|
|
|
|
|
|
deviceEngine->stop();
|
|
|
|
m_dspEngine->removeDeviceEngineAt(deviceSetIndex);
|
2022-05-14 05:18:09 -04:00
|
|
|
DeviceEnumerator::instance()->removeMIMOSelection(deviceSetIndex);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
delete mimoAPI;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_deviceUIs.erase(m_deviceUIs.begin() + deviceSetIndex);
|
|
|
|
m_mainCore->removeDeviceSet(deviceSetIndex);
|
|
|
|
|
|
|
|
// Renumerate
|
|
|
|
for (int i = 0; i < (int) m_deviceUIs.size(); i++)
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[i];
|
|
|
|
deviceUISet->setIndex(i);
|
2022-04-27 18:01:08 -04:00
|
|
|
DeviceGUI *deviceGUI = m_deviceUIs[i]->m_deviceGUI;
|
|
|
|
Workspace *deviceWorkspace = m_workspaces[deviceGUI->getWorkspaceIndex()];
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(deviceWorkspace, i, channelPluginIndex); }
|
|
|
|
);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
emit m_mainCore->deviceSetRemoved(deviceSetIndex);
|
|
|
|
}
|
|
|
|
|
2022-04-15 04:04:24 -04:00
|
|
|
void MainWindow::removeLastDeviceSet()
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-09 07:38:22 -04:00
|
|
|
int removedDeviceSetIndex = m_deviceUIs.size() - 1;
|
2022-03-23 00:53:12 -04:00
|
|
|
|
|
|
|
if (m_deviceUIs.back()->m_deviceSourceEngine) // source tab
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
|
|
|
DSPDeviceSourceEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceSourceEngine;
|
|
|
|
lastDeviceEngine->stopAcquistion();
|
|
|
|
lastDeviceEngine->removeSink(m_deviceUIs.back()->m_spectrumVis);
|
|
|
|
|
|
|
|
// deletes old UI and input object
|
2019-09-07 18:44:56 -04:00
|
|
|
m_deviceUIs.back()->freeChannels(); // destroys the channel instances
|
2020-10-03 01:24:56 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
|
|
|
|
m_deviceUIs.back()->m_deviceGUI->destroy();
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
|
2022-06-24 20:53:11 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->getSampleSource());
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *sourceAPI = m_deviceUIs.back()->m_deviceAPI;
|
2017-10-22 13:12:43 -04:00
|
|
|
delete m_deviceUIs.back();
|
|
|
|
|
|
|
|
lastDeviceEngine->stop();
|
|
|
|
m_dspEngine->removeLastDeviceSourceEngine();
|
2018-02-14 18:25:50 -05:00
|
|
|
|
|
|
|
delete sourceAPI;
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
else if (m_deviceUIs.back()->m_deviceSinkEngine) // sink tab
|
|
|
|
{
|
|
|
|
DSPDeviceSinkEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceSinkEngine;
|
|
|
|
lastDeviceEngine->stopGeneration();
|
|
|
|
lastDeviceEngine->removeSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
|
|
|
|
|
|
|
|
// deletes old UI and output object
|
2019-09-07 18:44:56 -04:00
|
|
|
m_deviceUIs.back()->freeChannels();
|
2020-10-03 01:24:56 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
|
|
|
|
m_deviceUIs.back()->m_deviceGUI->destroy();
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
|
2022-06-24 20:53:11 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->getSampleSink());
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *sinkAPI = m_deviceUIs.back()->m_deviceAPI;
|
2017-10-22 13:12:43 -04:00
|
|
|
delete m_deviceUIs.back();
|
|
|
|
|
|
|
|
lastDeviceEngine->stop();
|
|
|
|
m_dspEngine->removeLastDeviceSinkEngine();
|
2018-02-14 18:25:50 -05:00
|
|
|
|
|
|
|
delete sinkAPI;
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
2019-05-18 05:59:56 -04:00
|
|
|
else if (m_deviceUIs.back()->m_deviceMIMOEngine) // MIMO tab
|
|
|
|
{
|
|
|
|
DSPDeviceMIMOEngine *lastDeviceEngine = m_deviceUIs.back()->m_deviceMIMOEngine;
|
2019-10-20 14:05:01 -04:00
|
|
|
lastDeviceEngine->stopProcess(1); // Tx side
|
|
|
|
lastDeviceEngine->stopProcess(0); // Rx side
|
2019-05-18 05:59:56 -04:00
|
|
|
lastDeviceEngine->removeSpectrumSink(m_deviceUIs.back()->m_spectrumVis);
|
|
|
|
|
|
|
|
// deletes old UI and output object
|
2019-09-07 18:44:56 -04:00
|
|
|
m_deviceUIs.back()->freeChannels();
|
2019-05-18 05:59:56 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
|
2020-10-03 01:24:56 -04:00
|
|
|
m_deviceUIs.back()->m_deviceGUI->destroy();
|
2019-05-18 05:59:56 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
m_deviceUIs.back()->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(
|
2022-06-24 20:53:11 -04:00
|
|
|
m_deviceUIs.back()->m_deviceAPI->getSampleMIMO());
|
2019-05-18 05:59:56 -04:00
|
|
|
|
|
|
|
DeviceAPI *mimoAPI = m_deviceUIs.back()->m_deviceAPI;
|
|
|
|
delete m_deviceUIs.back();
|
|
|
|
|
|
|
|
lastDeviceEngine->stop();
|
|
|
|
m_dspEngine->removeLastDeviceMIMOEngine();
|
|
|
|
|
|
|
|
delete mimoAPI;
|
|
|
|
}
|
2017-10-22 13:12:43 -04:00
|
|
|
|
|
|
|
m_deviceUIs.pop_back();
|
2020-10-11 02:27:58 -04:00
|
|
|
m_mainCore->removeLastDeviceSet();
|
2022-04-09 07:38:22 -04:00
|
|
|
emit m_mainCore->deviceSetRemoved(removedDeviceSetIndex);
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2020-09-19 19:06:34 -04:00
|
|
|
void MainWindow::addFeatureSet()
|
|
|
|
{
|
2022-05-16 14:51:15 -04:00
|
|
|
int newFeatureSetIndex = m_featureUIs.size();
|
|
|
|
|
|
|
|
if (newFeatureSetIndex != 0)
|
|
|
|
{
|
|
|
|
qWarning("MainWindow::addFeatureSet: attempt to add more than one feature set (%d)", newFeatureSetIndex);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-10-10 18:22:42 -04:00
|
|
|
m_mainCore->appendFeatureSet();
|
2022-05-16 14:51:15 -04:00
|
|
|
m_featureUIs.push_back(new FeatureUISet(newFeatureSetIndex, m_mainCore->m_featureSets[newFeatureSetIndex]));
|
|
|
|
emit m_mainCore->featureSetAdded(newFeatureSetIndex);
|
2020-09-19 19:06:34 -04:00
|
|
|
}
|
|
|
|
|
2020-11-14 16:08:06 -05:00
|
|
|
void MainWindow::removeFeatureSet(unsigned int tabIndex)
|
2020-09-19 19:06:34 -04:00
|
|
|
{
|
|
|
|
if (tabIndex < m_featureUIs.size())
|
|
|
|
{
|
|
|
|
delete m_featureUIs[tabIndex];
|
2021-12-04 04:54:19 -05:00
|
|
|
m_featureUIs.pop_back();
|
2020-10-10 18:22:42 -04:00
|
|
|
m_mainCore->removeFeatureSet(tabIndex);
|
2022-03-23 00:53:12 -04:00
|
|
|
emit m_mainCore->featureSetRemoved(tabIndex);
|
2020-09-19 19:06:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::removeAllFeatureSets()
|
|
|
|
{
|
|
|
|
while (m_featureUIs.size() > 0)
|
|
|
|
{
|
|
|
|
delete m_featureUIs.back();
|
2021-12-04 04:54:19 -05:00
|
|
|
m_featureUIs.pop_back();
|
|
|
|
m_mainCore->removeLastFeatureSet();
|
2020-09-19 19:06:34 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-23 17:41:37 -05:00
|
|
|
void MainWindow::deleteChannel(int deviceSetIndex, int channelIndex)
|
|
|
|
{
|
|
|
|
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_deviceUIs.size()))
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceSet = m_deviceUIs[deviceSetIndex];
|
2019-09-07 18:44:56 -04:00
|
|
|
deviceSet->deleteChannel(channelIndex);
|
2017-12-23 17:41:37 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::loadSettings()
|
|
|
|
{
|
|
|
|
qDebug() << "MainWindow::loadSettings";
|
|
|
|
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->m_settings.load();
|
|
|
|
m_mainCore->m_settings.sortPresets();
|
|
|
|
m_mainCore->m_settings.sortCommands();
|
|
|
|
m_mainCore->setLoggingOptions();
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
void MainWindow::loadDeviceSetPresetSettings(const Preset* preset, int deviceSetIndex)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-09 07:38:22 -04:00
|
|
|
qDebug("MainWindow::loadDeviceSetPresetSettings: preset [%s | %s]",
|
2017-10-22 13:12:43 -04:00
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
if (deviceSetIndex >= 0)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-09 07:38:22 -04:00
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
deviceUISet->loadDeviceSetSettings(preset, m_pluginManager->getPluginAPI(), &m_workspaces, nullptr);
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
// m_spectrumToggleViewAction->setChecked(preset->getShowSpectrum());
|
2022-02-15 18:49:22 -05:00
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
// // has to be last step
|
|
|
|
// if (!preset->getLayout().isEmpty()) {
|
|
|
|
// restoreState(preset->getLayout());
|
|
|
|
// }
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
void MainWindow::saveDeviceSetPresetSettings(Preset* preset, int deviceSetIndex)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-09 07:38:22 -04:00
|
|
|
qDebug("MainWindow::saveDeviceSetPresetSettings: preset [%s | %s]",
|
2017-10-22 13:12:43 -04:00
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
// Save from currently selected source tab
|
|
|
|
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
|
2022-04-09 07:38:22 -04:00
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
deviceUISet->saveDeviceSetSettings(preset);
|
|
|
|
// preset->setShowSpectrum(m_spectrumToggleViewAction->isChecked());
|
|
|
|
// preset->setLayout(saveState());
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::loadFeatureSetPresetSettings(const FeatureSetPreset* preset, int featureSetIndex, Workspace *workspace)
|
2020-09-23 23:38:05 -04:00
|
|
|
{
|
|
|
|
qDebug("MainWindow::loadFeatureSetPresetSettings: preset [%s | %s]",
|
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
if (featureSetIndex >= 0)
|
|
|
|
{
|
|
|
|
FeatureUISet *featureSetUI = m_featureUIs[featureSetIndex];
|
2020-09-27 18:20:37 -04:00
|
|
|
qDebug("MainWindow::loadFeatureSetPresetSettings: m_apiAdapter: %p", m_apiAdapter);
|
2022-04-09 07:38:22 -04:00
|
|
|
featureSetUI->loadFeatureSetSettings(preset, m_pluginManager->getPluginAPI(), m_apiAdapter, &m_workspaces, workspace);
|
2020-09-23 23:38:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::saveFeatureSetPresetSettings(FeatureSetPreset* preset, int featureSetIndex)
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::saveFeatureSetPresetSettings: preset [%s | %s]",
|
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
// Save from currently selected source tab
|
|
|
|
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
|
|
|
|
FeatureUISet *featureUI = m_featureUIs[featureSetIndex];
|
|
|
|
|
|
|
|
preset->clearFeatures();
|
|
|
|
featureUI->saveFeatureSetSettings(preset);
|
|
|
|
}
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
void MainWindow::loadConfiguration(const Configuration *configuration, bool fromDialog)
|
2018-01-05 05:54:05 -05:00
|
|
|
{
|
2022-04-09 07:38:22 -04:00
|
|
|
qDebug("MainWindow::loadConfiguration: configuration [%s | %s] %d workspace(s) - %d device set(s) - %d feature(s)",
|
2022-04-05 10:26:57 -04:00
|
|
|
qPrintable(configuration->getGroup()),
|
|
|
|
qPrintable(configuration->getDescription()),
|
2022-04-26 13:44:18 -04:00
|
|
|
configuration->getNumberOfWorkspaceGeometries(),
|
2022-04-09 07:38:22 -04:00
|
|
|
configuration->getDeviceSetPresets().size(),
|
|
|
|
configuration->getFeatureSetPreset().getFeatureCount()
|
2022-04-05 10:26:57 -04:00
|
|
|
);
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
QMessageBox *waitBox = nullptr;
|
|
|
|
|
|
|
|
if (fromDialog)
|
|
|
|
{
|
|
|
|
waitBox = new QMessageBox(this);
|
|
|
|
waitBox->setStandardButtons(QMessageBox::NoButton);
|
|
|
|
waitBox->setWindowModality(Qt::NonModal);
|
|
|
|
waitBox->setIcon(QMessageBox::Information);
|
|
|
|
waitBox->setText("Loading configuration ");
|
|
|
|
waitBox->setInformativeText("Deleting existing...");
|
|
|
|
waitBox->setWindowTitle("Please wait");
|
|
|
|
waitBox->show();
|
|
|
|
waitBox->raise();
|
|
|
|
}
|
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
// Wipe out everything first
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
// Device sets
|
|
|
|
while (m_deviceUIs.size() > 0) {
|
2022-04-15 04:04:24 -04:00
|
|
|
removeLastDeviceSet();
|
2022-04-09 07:38:22 -04:00
|
|
|
}
|
2022-04-05 10:26:57 -04:00
|
|
|
// Features
|
|
|
|
m_featureUIs[0]->freeFeatures();
|
|
|
|
// Workspaces
|
|
|
|
for (const auto& workspace : m_workspaces) {
|
|
|
|
delete workspace;
|
|
|
|
}
|
|
|
|
m_workspaces.clear();
|
|
|
|
|
|
|
|
// Reconstruct
|
|
|
|
|
|
|
|
// Workspaces
|
2022-05-19 09:48:14 -04:00
|
|
|
for (int i = 0; i < configuration->getNumberOfWorkspaceGeometries(); i++)
|
|
|
|
{
|
2022-04-05 10:26:57 -04:00
|
|
|
addWorkspace();
|
2022-05-19 09:48:14 -04:00
|
|
|
m_workspaces[i]->setAutoStackOption(configuration->getWorkspaceAutoStackOptions()[i]);
|
2022-04-05 10:26:57 -04:00
|
|
|
}
|
2022-04-09 07:38:22 -04:00
|
|
|
|
|
|
|
if (m_workspaces.size() <= 0) { // cannot go further if there are no workspaces
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Device sets
|
2022-04-12 10:20:45 -04:00
|
|
|
if (waitBox) {
|
|
|
|
waitBox->setInformativeText("Loading device sets...");
|
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
const QList<Preset>& deviceSetPresets = configuration->getDeviceSetPresets();
|
|
|
|
|
|
|
|
for (const auto& deviceSetPreset : deviceSetPresets)
|
|
|
|
{
|
|
|
|
if (deviceSetPreset.isSourcePreset())
|
|
|
|
{
|
|
|
|
int bestDeviceIndex = DeviceEnumerator::instance()->getBestRxSamplingDeviceIndex(
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceId,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceSerial,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceSequence,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceItemIndex
|
|
|
|
);
|
2022-04-13 21:07:33 -04:00
|
|
|
qDebug("MainWindow::loadConfiguration: add source %s in workspace %d spectrum in %d",
|
|
|
|
qPrintable(deviceSetPreset.getSelectedDevice().m_deviceId),
|
|
|
|
deviceSetPreset.getDeviceWorkspaceIndex(),
|
|
|
|
deviceSetPreset.getSpectrumWorkspaceIndex());
|
|
|
|
int deviceWorkspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ?
|
2022-04-09 07:38:22 -04:00
|
|
|
deviceSetPreset.getDeviceWorkspaceIndex() :
|
|
|
|
0;
|
2022-04-13 21:07:33 -04:00
|
|
|
int spectrumWorkspaceIndex = deviceSetPreset.getSpectrumWorkspaceIndex() < m_workspaces.size() ?
|
|
|
|
deviceSetPreset.getSpectrumWorkspaceIndex() :
|
|
|
|
deviceWorkspaceIndex;
|
|
|
|
sampleSourceAdd(m_workspaces[deviceWorkspaceIndex], m_workspaces[spectrumWorkspaceIndex], bestDeviceIndex);
|
2022-04-09 07:38:22 -04:00
|
|
|
}
|
|
|
|
else if (deviceSetPreset.isSinkPreset())
|
|
|
|
{
|
|
|
|
int bestDeviceIndex = DeviceEnumerator::instance()->getBestTxSamplingDeviceIndex(
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceId,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceSerial,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceSequence,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceItemIndex
|
|
|
|
);
|
2022-04-13 21:07:33 -04:00
|
|
|
qDebug("MainWindow::loadConfiguration: add sink %s in workspace %d spectrum in %d",
|
|
|
|
qPrintable(deviceSetPreset.getSelectedDevice().m_deviceId),
|
|
|
|
deviceSetPreset.getDeviceWorkspaceIndex(),
|
|
|
|
deviceSetPreset.getSpectrumWorkspaceIndex());
|
|
|
|
int deviceWorkspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ?
|
2022-04-09 07:38:22 -04:00
|
|
|
deviceSetPreset.getDeviceWorkspaceIndex() :
|
|
|
|
0;
|
2022-04-13 21:07:33 -04:00
|
|
|
int spectrumWorkspaceIndex = deviceSetPreset.getSpectrumWorkspaceIndex() < m_workspaces.size() ?
|
|
|
|
deviceSetPreset.getSpectrumWorkspaceIndex() :
|
|
|
|
deviceWorkspaceIndex;
|
|
|
|
sampleSinkAdd(m_workspaces[deviceWorkspaceIndex], m_workspaces[spectrumWorkspaceIndex], bestDeviceIndex);
|
2022-04-20 14:08:41 -04:00
|
|
|
}
|
|
|
|
else if (deviceSetPreset.isMIMOPreset())
|
2022-04-09 07:38:22 -04:00
|
|
|
{
|
|
|
|
int bestDeviceIndex = DeviceEnumerator::instance()->getBestMIMOSamplingDeviceIndex(
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceId,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceSerial,
|
|
|
|
deviceSetPreset.getSelectedDevice().m_deviceSequence
|
|
|
|
);
|
2022-04-13 21:07:33 -04:00
|
|
|
qDebug("MainWindow::loadConfiguration: add MIMO %s in workspace %d spectrum in %d",
|
|
|
|
qPrintable(deviceSetPreset.getSelectedDevice().m_deviceId),
|
|
|
|
deviceSetPreset.getDeviceWorkspaceIndex(),
|
|
|
|
deviceSetPreset.getSpectrumWorkspaceIndex());
|
|
|
|
int deviceWorkspaceIndex = deviceSetPreset.getDeviceWorkspaceIndex() < m_workspaces.size() ?
|
2022-04-09 07:38:22 -04:00
|
|
|
deviceSetPreset.getDeviceWorkspaceIndex() :
|
|
|
|
0;
|
2022-04-13 21:07:33 -04:00
|
|
|
int spectrumWorkspaceIndex = deviceSetPreset.getSpectrumWorkspaceIndex() < m_workspaces.size() ?
|
|
|
|
deviceSetPreset.getSpectrumWorkspaceIndex() :
|
|
|
|
deviceWorkspaceIndex;
|
|
|
|
sampleMIMOAdd(m_workspaces[deviceWorkspaceIndex], m_workspaces[spectrumWorkspaceIndex], bestDeviceIndex);
|
2022-04-09 07:38:22 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
m_deviceUIs.back()->m_deviceGUI->restoreGeometry(deviceSetPreset.getDeviceGeometry());
|
|
|
|
m_deviceUIs.back()->m_mainSpectrumGUI->restoreGeometry(deviceSetPreset.getSpectrumGeometry());
|
|
|
|
m_deviceUIs.back()->loadDeviceSetSettings(&deviceSetPreset, m_pluginManager->getPluginAPI(), &m_workspaces, nullptr);
|
|
|
|
}
|
2022-04-12 10:20:45 -04:00
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
// Features
|
2022-04-12 10:20:45 -04:00
|
|
|
if (waitBox) {
|
|
|
|
waitBox->setInformativeText("Loading device sets...");
|
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
m_featureUIs[0]->loadFeatureSetSettings(
|
|
|
|
&configuration->getFeatureSetPreset(),
|
|
|
|
m_pluginManager->getPluginAPI(),
|
|
|
|
m_apiAdapter,
|
|
|
|
&m_workspaces,
|
|
|
|
nullptr
|
|
|
|
);
|
2022-04-05 10:26:57 -04:00
|
|
|
|
|
|
|
for (int i = 0; i < m_featureUIs[0]->getNumberOfFeatures(); i++)
|
|
|
|
{
|
|
|
|
FeatureGUI *gui = m_featureUIs[0]->getFeatureGuiAt(i);
|
|
|
|
QObject::connect(
|
|
|
|
gui,
|
|
|
|
&FeatureGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->featureMove(gui, wsIndexDest); }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lastly restore workspaces geometry
|
2022-04-12 10:20:45 -04:00
|
|
|
if (waitBox) {
|
|
|
|
waitBox->setInformativeText("Finalizing...");
|
|
|
|
}
|
|
|
|
|
2022-04-26 13:44:18 -04:00
|
|
|
for (int i = 0; i < configuration->getNumberOfWorkspaceGeometries(); i++)
|
|
|
|
{
|
2022-09-24 17:05:29 -04:00
|
|
|
m_workspaces[i]->restoreGeometry(configuration->getWorkspaceGeometries()[i]);
|
2022-04-05 10:26:57 -04:00
|
|
|
m_workspaces[i]->restoreGeometry(configuration->getWorkspaceGeometries()[i]);
|
2022-04-26 13:44:18 -04:00
|
|
|
m_workspaces[i]->adjustSubWindowsAfterRestore();
|
2022-04-05 10:26:57 -04:00
|
|
|
}
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
if (waitBox)
|
|
|
|
{
|
|
|
|
waitBox->close();
|
|
|
|
delete waitBox;
|
|
|
|
}
|
2022-04-05 10:26:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::saveConfiguration(Configuration *configuration)
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::saveConfiguration: configuration [%s | %s] %d workspaces",
|
|
|
|
qPrintable(configuration->getGroup()),
|
|
|
|
qPrintable(configuration->getDescription()),
|
|
|
|
m_workspaces.size()
|
|
|
|
);
|
|
|
|
|
|
|
|
configuration->clearData();
|
2022-04-09 07:38:22 -04:00
|
|
|
QList<Preset>& deviceSetPresets = configuration->getDeviceSetPresets();
|
|
|
|
|
|
|
|
for (const auto& deviceUISet : m_deviceUIs)
|
|
|
|
{
|
|
|
|
deviceSetPresets.push_back(Preset());
|
|
|
|
deviceUISet->saveDeviceSetSettings(&deviceSetPresets.back());
|
|
|
|
deviceSetPresets.back().setSpectrumGeometry(deviceUISet->m_mainSpectrumGUI->saveGeometry());
|
|
|
|
deviceSetPresets.back().setSpectrumWorkspaceIndex(deviceUISet->m_mainSpectrumGUI->getWorkspaceIndex());
|
|
|
|
deviceSetPresets.back().setDeviceGeometry(deviceUISet->m_deviceGUI->saveGeometry());
|
|
|
|
deviceSetPresets.back().setDeviceWorkspaceIndex(deviceUISet->m_deviceGUI->getWorkspaceIndex());
|
2022-04-20 14:08:41 -04:00
|
|
|
qDebug("MainWindow::saveConfiguration: %s device in workspace %d spectrum in %d",
|
2022-04-13 21:07:33 -04:00
|
|
|
qPrintable(deviceUISet->m_deviceAPI->getSamplingDeviceId()),
|
|
|
|
deviceUISet->m_deviceGUI->getWorkspaceIndex(),
|
|
|
|
deviceUISet->m_mainSpectrumGUI->getWorkspaceIndex());
|
2022-04-09 07:38:22 -04:00
|
|
|
}
|
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
m_featureUIs[0]->saveFeatureSetSettings(&configuration->getFeatureSetPreset());
|
|
|
|
|
2022-05-19 09:48:14 -04:00
|
|
|
for (const auto& workspace : m_workspaces)
|
|
|
|
{
|
2022-04-05 10:26:57 -04:00
|
|
|
configuration->getWorkspaceGeometries().push_back(workspace->saveGeometry());
|
2022-05-19 09:48:14 -04:00
|
|
|
configuration->getWorkspaceAutoStackOptions().push_back(workspace->getAutoStackOption());
|
2022-04-05 10:26:57 -04:00
|
|
|
}
|
2018-01-05 05:54:05 -05:00
|
|
|
}
|
|
|
|
|
2021-12-13 05:23:05 -05:00
|
|
|
QString MainWindow::openGLVersion()
|
|
|
|
{
|
|
|
|
QOpenGLContext *glCurrentContext = QOpenGLContext::globalShareContext();
|
|
|
|
if (glCurrentContext)
|
|
|
|
{
|
|
|
|
if (glCurrentContext->isValid())
|
|
|
|
{
|
|
|
|
int major = glCurrentContext->format().majorVersion();
|
|
|
|
int minor = glCurrentContext->format().minorVersion();
|
|
|
|
bool es = glCurrentContext->isOpenGLES();
|
|
|
|
QString version = QString("%1.%2%3").arg(major).arg(minor).arg(es ? " ES" : "");
|
2022-05-16 07:43:07 -04:00
|
|
|
// Waterfall doesn't work if version is less than 2.1, so display in red
|
|
|
|
if ((major < 2) || ((major == 2) && (minor == 0))) {
|
2021-12-13 05:23:05 -05:00
|
|
|
version = "<span style=\"color:red\">" + version + "</span>";
|
|
|
|
}
|
|
|
|
return version;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "N/A";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::createMenuBar()
|
|
|
|
{
|
|
|
|
QMenuBar *menuBar = this->menuBar();
|
|
|
|
|
2022-04-20 15:33:18 -04:00
|
|
|
QMenu *fileMenu = menuBar->addMenu("&File");
|
|
|
|
QAction *exitAction = fileMenu->addAction("E&xit");
|
2022-04-04 04:23:52 -04:00
|
|
|
exitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
|
|
|
|
exitAction->setToolTip("Exit");
|
|
|
|
QObject::connect(exitAction, &QAction::triggered, this, &QMainWindow::close);
|
|
|
|
|
2022-04-20 15:33:18 -04:00
|
|
|
QMenu *viewMenu = menuBar->addMenu("&View");
|
|
|
|
QAction *fullscreenAction = viewMenu->addAction("&Fullscreen");
|
2022-04-04 04:23:52 -04:00
|
|
|
fullscreenAction->setShortcut(QKeySequence(Qt::Key_F11));
|
|
|
|
fullscreenAction->setToolTip("Toggle fullscreen view");
|
|
|
|
fullscreenAction->setCheckable(true);
|
|
|
|
QObject::connect(fullscreenAction, &QAction::triggered, this, &MainWindow::on_action_View_Fullscreen_toggled);
|
|
|
|
|
2022-04-20 15:33:18 -04:00
|
|
|
QMenu *workspacesMenu = menuBar->addMenu("&Workspaces");
|
|
|
|
QAction *newWorkspaceAction = workspacesMenu->addAction("&New");
|
2022-04-04 04:23:52 -04:00
|
|
|
newWorkspaceAction->setToolTip("Add a new workspace");
|
|
|
|
QObject::connect(newWorkspaceAction, &QAction::triggered, this, &MainWindow::addWorkspace);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *viewAllWorkspacesAction = workspacesMenu->addAction("&View all");
|
2022-04-04 04:23:52 -04:00
|
|
|
viewAllWorkspacesAction->setToolTip("View all workspaces");
|
|
|
|
QObject::connect(viewAllWorkspacesAction, &QAction::triggered, this, &MainWindow::viewAllWorkspaces);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *removeEmptyWorkspacesAction = workspacesMenu->addAction("&Remove empty");
|
2022-04-05 10:26:57 -04:00
|
|
|
removeEmptyWorkspacesAction->setToolTip("Remove empty workspaces");
|
|
|
|
QObject::connect(removeEmptyWorkspacesAction, &QAction::triggered, this, &MainWindow::removeEmptyWorkspaces);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-20 15:33:18 -04:00
|
|
|
QMenu *preferencesMenu = menuBar->addMenu("&Preferences");
|
|
|
|
QAction *configurationsAction = preferencesMenu->addAction("&Configurations...");
|
2022-04-05 10:26:57 -04:00
|
|
|
configurationsAction->setToolTip("Manage configurations");
|
|
|
|
QObject::connect(configurationsAction, &QAction::triggered, this, &MainWindow::on_action_Configurations_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *audioAction = preferencesMenu->addAction("&Audio...");
|
2022-04-04 04:23:52 -04:00
|
|
|
audioAction->setToolTip("Audio preferences");
|
|
|
|
QObject::connect(audioAction, &QAction::triggered, this, &MainWindow::on_action_Audio_triggered);
|
2022-06-18 07:35:44 -04:00
|
|
|
QAction *graphicsAction = preferencesMenu->addAction("&Graphics...");
|
|
|
|
graphicsAction->setToolTip("Graphics preferences");
|
|
|
|
QObject::connect(graphicsAction, &QAction::triggered, this, &MainWindow::on_action_Graphics_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *loggingAction = preferencesMenu->addAction("&Logging...");
|
2022-04-04 04:23:52 -04:00
|
|
|
loggingAction->setToolTip("Logging preferences");
|
|
|
|
QObject::connect(loggingAction, &QAction::triggered, this, &MainWindow::on_action_Logging_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *myPositionAction = preferencesMenu->addAction("My &Position...");
|
2022-04-04 04:23:52 -04:00
|
|
|
myPositionAction->setToolTip("Set station position");
|
|
|
|
QObject::connect(myPositionAction, &QAction::triggered, this, &MainWindow::on_action_My_Position_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *fftAction = preferencesMenu->addAction("&FFT...");
|
2022-04-04 04:23:52 -04:00
|
|
|
fftAction->setToolTip("Set FFT cache");
|
|
|
|
QObject::connect(fftAction, &QAction::triggered, this, &MainWindow::on_action_FFT_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QMenu *devicesMenu = preferencesMenu->addMenu("&Devices");
|
|
|
|
QAction *userArgumentsAction = devicesMenu->addAction("&User arguments...");
|
2022-04-04 04:23:52 -04:00
|
|
|
userArgumentsAction->setToolTip("Device custom user arguments");
|
|
|
|
QObject::connect(userArgumentsAction, &QAction::triggered, this, &MainWindow::on_action_DeviceUserArguments_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *commandsAction = preferencesMenu->addAction("C&ommands...");
|
2022-04-04 10:13:42 -04:00
|
|
|
commandsAction->setToolTip("External commands dialog");
|
|
|
|
QObject::connect(commandsAction, &QAction::triggered, this, &MainWindow::on_action_commands_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *saveAllAction = preferencesMenu->addAction("&Save all");
|
2022-04-05 10:26:57 -04:00
|
|
|
saveAllAction->setToolTip("Save all current settings");
|
|
|
|
QObject::connect(saveAllAction, &QAction::triggered, this, &MainWindow::on_action_saveAll_triggered);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-20 15:33:18 -04:00
|
|
|
QMenu *helpMenu = menuBar->addMenu("&Help");
|
|
|
|
QAction *quickStartAction = helpMenu->addAction("&Quick start...");
|
2022-04-04 04:23:52 -04:00
|
|
|
quickStartAction->setToolTip("Instructions for quick start");
|
|
|
|
QObject::connect(quickStartAction, &QAction::triggered, this, &MainWindow::on_action_Quick_Start_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *mainWindowAction = helpMenu->addAction("&Main Window...");
|
2022-04-04 04:23:52 -04:00
|
|
|
mainWindowAction->setToolTip("Help on main window details");
|
|
|
|
QObject::connect(mainWindowAction, &QAction::triggered, this, &MainWindow::on_action_Main_Window_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *loadedPluginsAction = helpMenu->addAction("Loaded &Plugins...");
|
2022-04-04 04:23:52 -04:00
|
|
|
loadedPluginsAction->setToolTip("List available plugins");
|
|
|
|
QObject::connect(loadedPluginsAction, &QAction::triggered, this, &MainWindow::on_action_Loaded_Plugins_triggered);
|
2022-04-20 15:33:18 -04:00
|
|
|
QAction *aboutAction = helpMenu->addAction("&About SDRangel...");
|
2022-04-04 04:23:52 -04:00
|
|
|
aboutAction->setToolTip("SDRangel application details");
|
|
|
|
QObject::connect(aboutAction, &QAction::triggered, this, &MainWindow::on_action_About_triggered);
|
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::createStatusBar()
|
|
|
|
{
|
|
|
|
QString qtVersionStr = QString("Qt %1 ").arg(QT_VERSION_STR);
|
2021-12-13 05:23:05 -05:00
|
|
|
QString openGLVersionStr = QString("OpenGL %1 ").arg(openGLVersion());
|
2020-11-04 16:52:15 -05:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
|
2021-12-13 05:23:05 -05:00
|
|
|
m_showSystemWidget = new QLabel("SDRangel " + qApp->applicationVersion() + " " + qtVersionStr + openGLVersionStr
|
2018-01-06 19:33:57 -05:00
|
|
|
+ QSysInfo::currentCpuArchitecture() + " " + QSysInfo::prettyProductName(), this);
|
2017-10-22 13:12:43 -04:00
|
|
|
#else
|
2021-12-13 05:23:05 -05:00
|
|
|
m_showSystemWidget = new QLabel("SDRangel " + qApp->applicationVersion() + " " + qtVersionStr + openGLVersionStr, this);
|
2017-10-22 13:12:43 -04:00
|
|
|
#endif
|
|
|
|
statusBar()->addPermanentWidget(m_showSystemWidget);
|
|
|
|
|
|
|
|
m_dateTimeWidget = new QLabel(tr("Date"), this);
|
|
|
|
m_dateTimeWidget->setToolTip(tr("Current date/time"));
|
|
|
|
statusBar()->addPermanentWidget(m_dateTimeWidget);
|
|
|
|
}
|
|
|
|
|
2019-07-22 12:49:24 -04:00
|
|
|
void MainWindow::closeEvent(QCloseEvent *closeEvent)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2019-07-22 12:49:24 -04:00
|
|
|
qDebug("MainWindow::closeEvent");
|
|
|
|
|
2021-07-01 10:28:43 -04:00
|
|
|
// Save window size and position
|
|
|
|
QSettings s;
|
2021-07-01 11:07:25 -04:00
|
|
|
s.setValue("mainWindowGeometry", qCompress(saveGeometry()).toBase64());
|
|
|
|
s.setValue("mainWindowState", qCompress(saveState()).toBase64());
|
2021-07-01 10:28:43 -04:00
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
saveConfiguration(m_mainCore->m_settings.getWorkingConfiguration());
|
|
|
|
m_mainCore->m_settings.save();
|
2019-07-22 12:49:24 -04:00
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
while (m_deviceUIs.size() > 0) {
|
2022-04-15 04:04:24 -04:00
|
|
|
removeLastDeviceSet();
|
2022-04-09 07:38:22 -04:00
|
|
|
}
|
2019-07-22 12:49:24 -04:00
|
|
|
|
|
|
|
closeEvent->accept();
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::applySettings()
|
|
|
|
{
|
2022-04-05 10:26:57 -04:00
|
|
|
loadConfiguration(m_mainCore->m_settings.getWorkingConfiguration());
|
2019-08-11 19:46:27 -04:00
|
|
|
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->m_settings.sortPresets();
|
2022-04-09 07:38:22 -04:00
|
|
|
// int middleIndex = m_mainCore->m_settings.getPresetCount() / 2;
|
|
|
|
// QTreeWidgetItem *treeItem;
|
2022-04-04 04:23:52 -04:00
|
|
|
// ui->presetTree->clear();
|
2019-08-11 19:46:27 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
// for (int i = 0; i < m_mainCore->m_settings.getPresetCount(); ++i)
|
|
|
|
// {
|
|
|
|
// treeItem = addPresetToTree(m_mainCore->m_settings.getPreset(i));
|
2019-08-11 19:46:27 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
// if (i == middleIndex) {
|
|
|
|
// ui->presetTree->setCurrentItem(treeItem);
|
|
|
|
// }
|
|
|
|
// }
|
2019-08-11 19:46:27 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
// m_mainCore->m_settings.sortCommands();
|
|
|
|
// ui->commandTree->clear();
|
2019-08-11 19:46:27 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
// for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i) {
|
|
|
|
// treeItem = addCommandToTree(m_mainCore->m_settings.getCommand(i));
|
|
|
|
// }
|
2019-08-11 19:46:27 -04:00
|
|
|
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->setLoggingOptions();
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2017-11-25 10:08:18 -05:00
|
|
|
bool MainWindow::handleMessage(const Message& cmd)
|
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
if (MainCore::MsgLoadPreset::match(cmd))
|
2017-11-25 10:08:18 -05:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgLoadPreset& notif = (MainCore::MsgLoadPreset&) cmd;
|
2022-04-13 12:43:37 -04:00
|
|
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
|
|
|
const Preset *preset = notif.getPreset();
|
|
|
|
|
|
|
|
if (deviceSetIndex < (int) m_deviceUIs.size())
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
deviceUISet->loadDeviceSetSettings(preset, m_pluginManager->getPluginAPI(), &m_workspaces, nullptr);
|
|
|
|
}
|
|
|
|
|
2017-11-25 10:08:18 -05:00
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgSavePreset::match(cmd))
|
2017-11-25 10:47:13 -05:00
|
|
|
{
|
2022-05-16 14:51:15 -04:00
|
|
|
MainCore::MsgSavePreset& notif = (MainCore::MsgSavePreset&) cmd;
|
|
|
|
saveDeviceSetPresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
|
|
|
|
m_mainCore->m_settings.sortPresets();
|
|
|
|
m_mainCore->m_settings.save();
|
2020-09-23 23:38:05 -04:00
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgLoadFeatureSetPreset::match(cmd))
|
2020-09-23 23:38:05 -04:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
if (m_workspaces.size() > 0)
|
|
|
|
{
|
|
|
|
MainCore::MsgLoadFeatureSetPreset& notif = (MainCore::MsgLoadFeatureSetPreset&) cmd;
|
|
|
|
loadFeatureSetPresetSettings(notif.getPreset(), notif.getFeatureSetIndex(), m_workspaces[0]);
|
|
|
|
}
|
|
|
|
|
2020-09-23 23:38:05 -04:00
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgSaveFeatureSetPreset::match(cmd))
|
2020-09-23 23:38:05 -04:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgSaveFeatureSetPreset& notif = (MainCore::MsgSaveFeatureSetPreset&) cmd;
|
2020-09-23 23:38:05 -04:00
|
|
|
saveFeatureSetPresetSettings(notif.getPreset(), notif.getFeatureSetIndex());
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->m_settings.sortFeatureSetPresets();
|
|
|
|
m_mainCore->m_settings.save();
|
2017-11-25 10:47:13 -05:00
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgDeletePreset::match(cmd))
|
2017-11-25 13:42:56 -05:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgDeletePreset& notif = (MainCore::MsgDeletePreset&) cmd;
|
2017-11-25 13:42:56 -05:00
|
|
|
const Preset *presetToDelete = notif.getPreset();
|
|
|
|
// remove preset from settings
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->m_settings.deletePreset(presetToDelete);
|
2017-11-25 13:42:56 -05:00
|
|
|
return true;
|
|
|
|
}
|
2022-05-08 13:33:10 -04:00
|
|
|
else if (MainCore::MsgLoadConfiguration::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgLoadConfiguration& notif = (MainCore::MsgLoadConfiguration&) cmd;
|
|
|
|
const Configuration *configuration = notif.getConfiguration();
|
|
|
|
loadConfiguration(configuration, false);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MainCore::MsgSaveConfiguration::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgSaveConfiguration& notif = (MainCore::MsgSaveConfiguration&) cmd;
|
|
|
|
Configuration *configuration = notif.getConfiguration();
|
|
|
|
saveConfiguration(configuration);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MainCore::MsgDeleteConfiguration::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgDeleteConfiguration& notif = (MainCore::MsgDeleteConfiguration&) cmd;
|
|
|
|
const Configuration *configurationToDelete = notif.getConfiguration();
|
|
|
|
// remove configuration from settings
|
|
|
|
m_mainCore->m_settings.deleteConfiguration(configurationToDelete);
|
|
|
|
return true;
|
|
|
|
}
|
2022-05-09 15:31:14 -04:00
|
|
|
else if (MainCore::MsgDeleteEmptyWorkspaces::match(cmd))
|
|
|
|
{
|
|
|
|
removeEmptyWorkspaces();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MainCore::MsgAddWorkspace::match(cmd))
|
|
|
|
{
|
|
|
|
addWorkspace();
|
|
|
|
return true;
|
|
|
|
}
|
2021-09-03 23:58:06 -04:00
|
|
|
else if (MainCore::MsgDeleteFeatureSetPreset::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgDeleteFeatureSetPreset& notif = (MainCore::MsgDeleteFeatureSetPreset&) cmd;
|
|
|
|
const FeatureSetPreset *presetToDelete = notif.getPreset();
|
|
|
|
// remove preset from settings
|
|
|
|
m_mainCore->m_settings.deleteFeatureSetPreset(presetToDelete);
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgAddDeviceSet::match(cmd))
|
2017-11-25 16:52:24 -05:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgAddDeviceSet& notif = (MainCore::MsgAddDeviceSet&) cmd;
|
2019-05-08 19:12:40 -04:00
|
|
|
int direction = notif.getDirection();
|
2017-11-25 16:52:24 -05:00
|
|
|
|
2022-05-16 14:51:15 -04:00
|
|
|
if (m_workspaces.size() > 0)
|
|
|
|
{
|
|
|
|
if (direction == 1) { // Single stream Tx
|
|
|
|
sampleSinkAdd(m_workspaces[0], m_workspaces[0], -1); // create with file output device by default
|
|
|
|
} else if (direction == 0) { // Single stream Rx
|
|
|
|
sampleSourceAdd(m_workspaces[0], m_workspaces[0], -1); // create with file input device by default
|
|
|
|
} else if (direction == 2) { // MIMO
|
|
|
|
sampleMIMOAdd(m_workspaces[0], m_workspaces[0], -1); // create with testMI MIMO device by default
|
|
|
|
}
|
2019-05-18 05:59:56 -04:00
|
|
|
}
|
2017-11-25 16:52:24 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgRemoveLastDeviceSet::match(cmd))
|
2017-11-25 16:52:24 -05:00
|
|
|
{
|
2022-05-16 14:51:15 -04:00
|
|
|
if (m_deviceUIs.size() > 0) {
|
2022-04-15 04:04:24 -04:00
|
|
|
removeLastDeviceSet();
|
2017-11-25 16:52:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgSetDevice::match(cmd))
|
2017-11-27 02:14:07 -05:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgSetDevice& notif = (MainCore::MsgSetDevice&) cmd;
|
2022-05-16 14:51:15 -04:00
|
|
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
2022-04-07 10:32:03 -04:00
|
|
|
|
2022-05-16 14:51:15 -04:00
|
|
|
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_deviceUIs.size()))
|
|
|
|
{
|
|
|
|
Workspace *workspace = m_workspaces[m_deviceUIs[deviceSetIndex]->m_deviceGUI->getWorkspaceIndex()];
|
|
|
|
sampleDeviceChange(notif.getDeviceType(), notif.getDeviceSetIndex(), notif.getDeviceIndex(), workspace);
|
2021-08-21 14:09:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgAddChannel::match(cmd))
|
2017-12-10 19:18:10 -05:00
|
|
|
{
|
2022-05-16 14:51:15 -04:00
|
|
|
MainCore::MsgAddChannel& notif = (MainCore::MsgAddChannel&) cmd;
|
|
|
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
|
|
|
|
|
|
|
if ((deviceSetIndex >= 0) && (deviceSetIndex < (int) m_deviceUIs.size()))
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
int deviceWorkspaceIndex = deviceUISet->m_deviceGUI->getWorkspaceIndex();
|
|
|
|
deviceWorkspaceIndex = deviceWorkspaceIndex < m_workspaces.size() ? deviceWorkspaceIndex : 0;
|
|
|
|
int channelRegistrationIndex;
|
|
|
|
|
|
|
|
if (deviceUISet->m_deviceMIMOEngine)
|
|
|
|
{
|
|
|
|
int nbMIMOChannels = deviceUISet->getNumberOfAvailableMIMOChannels();
|
|
|
|
int nbRxChannels = deviceUISet->getNumberOfAvailableRxChannels();
|
|
|
|
int direction = notif.getDirection();
|
|
|
|
|
|
|
|
if (direction == 2) {
|
|
|
|
channelRegistrationIndex = notif.getChannelRegistrationIndex();
|
|
|
|
} else if (direction == 0) {
|
|
|
|
channelRegistrationIndex = nbMIMOChannels + notif.getChannelRegistrationIndex();
|
|
|
|
} else {
|
|
|
|
channelRegistrationIndex = nbMIMOChannels + nbRxChannels + notif.getChannelRegistrationIndex();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
channelRegistrationIndex = notif.getChannelRegistrationIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
channelAddClicked(m_workspaces[deviceWorkspaceIndex], deviceSetIndex, channelRegistrationIndex);
|
|
|
|
}
|
2017-12-10 19:18:10 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgDeleteChannel::match(cmd))
|
2017-12-23 17:41:37 -05:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgDeleteChannel& notif = (MainCore::MsgDeleteChannel&) cmd;
|
2017-12-23 17:41:37 -05:00
|
|
|
deleteChannel(notif.getDeviceSetIndex(), notif.getChannelIndex());
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgAddFeature::match(cmd))
|
2020-09-20 21:13:36 -04:00
|
|
|
{
|
2022-05-16 14:51:15 -04:00
|
|
|
MainCore::MsgAddFeature& notif = (MainCore::MsgAddFeature&) cmd;
|
|
|
|
|
|
|
|
if (m_workspaces.size() > 0) {
|
|
|
|
featureAddClicked(m_workspaces[0], notif.getFeatureRegistrationIndex());
|
|
|
|
}
|
2020-09-20 21:13:36 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgDeleteFeature::match(cmd))
|
2020-09-20 21:13:36 -04:00
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MainCore::MsgDeleteFeature& notif = (MainCore::MsgDeleteFeature&) cmd;
|
2022-05-16 14:51:15 -04:00
|
|
|
deleteFeature(0, notif.getFeatureIndex());
|
2020-09-20 21:13:36 -04:00
|
|
|
return true;
|
|
|
|
}
|
2022-05-13 16:24:48 -04:00
|
|
|
else if (MainCore::MsgMoveDeviceUIToWorkspace::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgMoveDeviceUIToWorkspace& notif = (MainCore::MsgMoveDeviceUIToWorkspace&) cmd;
|
|
|
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
|
|
|
|
|
|
|
if (deviceSetIndex < (int) m_deviceUIs.size())
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
DeviceGUI *gui = deviceUISet->m_deviceGUI;
|
|
|
|
deviceMove(gui, notif.getWorkspaceIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MainCore::MsgMoveMainSpectrumUIToWorkspace::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgMoveMainSpectrumUIToWorkspace& notif = (MainCore::MsgMoveMainSpectrumUIToWorkspace&) cmd;
|
|
|
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
|
|
|
|
|
|
|
if (deviceSetIndex < (int) m_deviceUIs.size())
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
MainSpectrumGUI *gui = deviceUISet->m_mainSpectrumGUI;
|
|
|
|
mainSpectrumMove(gui, notif.getWorkspaceIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MainCore::MsgMoveFeatureUIToWorkspace::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgMoveFeatureUIToWorkspace& notif = (MainCore::MsgMoveFeatureUIToWorkspace&) cmd;
|
|
|
|
int featureIndex = notif.getFeatureIndex();
|
|
|
|
|
|
|
|
if (featureIndex < (int) m_featureUIs[0]->getNumberOfFeatures())
|
|
|
|
{
|
|
|
|
FeatureGUI *gui = m_featureUIs[0]->getFeatureGuiAt(featureIndex);
|
|
|
|
featureMove(gui, notif.getWorkspaceIndex());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MainCore::MsgMoveChannelUIToWorkspace::match(cmd))
|
|
|
|
{
|
|
|
|
MainCore::MsgMoveChannelUIToWorkspace& notif = (MainCore::MsgMoveChannelUIToWorkspace&) cmd;
|
|
|
|
int deviceSetIndex = notif.getDeviceSetIndex();
|
|
|
|
|
|
|
|
if (deviceSetIndex < (int) m_deviceUIs.size())
|
|
|
|
{
|
|
|
|
int channelIndex = notif.getChannelIndex();
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
|
|
|
|
if (channelIndex < deviceUISet->getNumberOfChannels())
|
|
|
|
{
|
|
|
|
ChannelGUI *gui = deviceUISet->getChannelGUIAt(channelIndex);
|
|
|
|
channelMove(gui, notif.getWorkspaceIndex());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgApplySettings::match(cmd))
|
2019-08-10 19:27:19 -04:00
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
return true;
|
|
|
|
}
|
2020-10-10 14:08:11 -04:00
|
|
|
else if (MainCore::MsgDVSerial::match(cmd))
|
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
// MainCore::MsgDVSerial& notif = (MainCore::MsgDVSerial&) cmd;
|
|
|
|
// ui->action_DV_Serial->setChecked(notif.getActive());
|
2020-10-10 14:08:11 -04:00
|
|
|
return true;
|
|
|
|
}
|
2017-11-25 10:08:18 -05:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::handleMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::handleMessages: message: %s", message->getIdentifier());
|
2017-11-25 10:08:18 -05:00
|
|
|
handleMessage(*message);
|
2017-10-22 13:12:43 -04:00
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::handleWorkspaceVisibility(Workspace *workspace, bool visibility)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
qDebug("MainWindow::handleWorkspaceHasFocus: index: %d %s",
|
|
|
|
workspace->getIndex(), visibility ? "visible" : "non visible");
|
|
|
|
m_currentWorkspace = workspace;
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::addWorkspace()
|
2018-01-04 05:11:53 -05:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
int workspaceIndex = m_workspaces.size();
|
|
|
|
m_workspaces.push_back(new Workspace(workspaceIndex));
|
|
|
|
QStringList featureNames;
|
|
|
|
m_pluginManager->listFeatures(featureNames);
|
|
|
|
m_workspaces.back()->addAvailableFeatures(featureNames);
|
|
|
|
this->addDockWidget(Qt::LeftDockWidgetArea, m_workspaces.back());
|
2018-01-04 05:11:53 -05:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::addRxDevice,
|
|
|
|
this,
|
2022-04-13 21:07:33 -04:00
|
|
|
[=](Workspace *inWorkspace, int deviceIndex) { this->sampleSourceAdd(inWorkspace, inWorkspace, deviceIndex); }
|
2022-04-07 10:32:03 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::addTxDevice,
|
|
|
|
this,
|
2022-04-16 10:45:53 -04:00
|
|
|
[=](Workspace *inWorkspace, int deviceIndex) { this->sampleSinkAdd(inWorkspace, inWorkspace, deviceIndex); }
|
2022-04-07 10:32:03 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::addMIMODevice,
|
|
|
|
this,
|
2022-04-16 10:45:53 -04:00
|
|
|
[=](Workspace *inWorkspace, int deviceIndex) { this->sampleMIMOAdd(inWorkspace, inWorkspace, deviceIndex); }
|
2022-04-07 10:32:03 -04:00
|
|
|
);
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::addFeature,
|
|
|
|
this,
|
|
|
|
&MainWindow::featureAddClicked
|
|
|
|
);
|
2018-01-04 05:11:53 -05:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::featurePresetsDialogRequested,
|
|
|
|
this,
|
|
|
|
&MainWindow::openFeaturePresetsDialog
|
|
|
|
);
|
2018-01-04 05:11:53 -05:00
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::startAllDevices,
|
|
|
|
this,
|
|
|
|
&MainWindow::startAllDevices
|
|
|
|
);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
m_workspaces.back(),
|
|
|
|
&Workspace::stopAllDevices,
|
|
|
|
this,
|
|
|
|
&MainWindow::stopAllDevices
|
|
|
|
);
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
if (m_workspaces.size() > 1)
|
2018-01-04 05:11:53 -05:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
for (int i = 1; i < m_workspaces.size(); i++) {
|
|
|
|
tabifyDockWidget(m_workspaces[0], m_workspaces[i]);
|
2018-01-04 05:11:53 -05:00
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
m_workspaces.back()->show();
|
|
|
|
m_workspaces.back()->raise();
|
|
|
|
// QList<QTabBar *> tabBars = findChildren<QTabBar *>();
|
2018-01-04 05:11:53 -05:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
// if (tabBars.size() > 0) {
|
|
|
|
// tabBars.back()->setStyleSheet("QTabBar::tab:selected { background: rgb(128,70,0); }"); // change text color so it is visible
|
|
|
|
// }
|
2018-01-04 05:11:53 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::viewAllWorkspaces()
|
2018-01-04 05:11:53 -05:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
for (const auto& workspace : m_workspaces)
|
2018-01-04 05:11:53 -05:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
if (workspace->isHidden()) {
|
|
|
|
workspace->show();
|
2018-01-05 05:45:20 -05:00
|
|
|
}
|
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
2018-01-04 05:11:53 -05:00
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
void MainWindow::removeEmptyWorkspaces()
|
|
|
|
{
|
|
|
|
QList<Workspace *>::iterator it = m_workspaces.begin();
|
|
|
|
|
|
|
|
while (it != m_workspaces.end())
|
|
|
|
{
|
|
|
|
if ((*it)->getNumberOfSubWindows() == 0)
|
|
|
|
{
|
|
|
|
removeDockWidget(*it);
|
|
|
|
it = m_workspaces.erase(it);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
}
|
2022-04-25 17:48:14 -04:00
|
|
|
|
|
|
|
// Renumerate
|
|
|
|
for (int i = 0; i < m_workspaces.size(); i++)
|
|
|
|
{
|
|
|
|
Workspace *workspace = m_workspaces[i];
|
|
|
|
workspace->setIndex(i);
|
|
|
|
QList<QMdiSubWindow *> subWindows = workspace->getSubWindowList();
|
|
|
|
|
|
|
|
for (auto& subWindow : subWindows)
|
|
|
|
{
|
|
|
|
if (qobject_cast<DeviceGUI*>(subWindow)) {
|
|
|
|
qobject_cast<DeviceGUI*>(subWindow)->setWorkspaceIndex(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qobject_cast<MainSpectrumGUI*>(subWindow)) {
|
|
|
|
qobject_cast<MainSpectrumGUI*>(subWindow)->setWorkspaceIndex(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qobject_cast<ChannelGUI*>(subWindow)) {
|
|
|
|
qobject_cast<ChannelGUI*>(subWindow)->setWorkspaceIndex(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qobject_cast<FeatureGUI*>(subWindow)) {
|
|
|
|
qobject_cast<FeatureGUI*>(subWindow)->setWorkspaceIndex(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-05 10:26:57 -04:00
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::on_action_View_Fullscreen_toggled(bool checked)
|
|
|
|
{
|
|
|
|
if(checked) {
|
|
|
|
showFullScreen();
|
|
|
|
} else {
|
|
|
|
showNormal();
|
|
|
|
}
|
|
|
|
}
|
2018-01-04 05:11:53 -05:00
|
|
|
|
2019-07-29 12:54:50 -04:00
|
|
|
void MainWindow::commandKeysConnect(QObject *object, const char *slot)
|
|
|
|
{
|
|
|
|
setFocus();
|
2022-04-04 10:13:42 -04:00
|
|
|
connect(
|
|
|
|
m_commandKeyReceiver,
|
|
|
|
SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
|
|
|
|
object,
|
|
|
|
slot
|
|
|
|
);
|
2019-07-29 12:54:50 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::commandKeysDisconnect(QObject *object, const char *slot)
|
|
|
|
{
|
2022-04-04 10:13:42 -04:00
|
|
|
disconnect(
|
|
|
|
m_commandKeyReceiver,
|
|
|
|
SIGNAL(capturedKey(Qt::Key, Qt::KeyboardModifiers, bool)),
|
|
|
|
object,
|
|
|
|
slot
|
|
|
|
);
|
2018-01-04 23:05:12 -05:00
|
|
|
}
|
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
void MainWindow::on_action_saveAll_triggered()
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-05 10:26:57 -04:00
|
|
|
saveConfiguration(m_mainCore->m_settings.getWorkingConfiguration());
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->m_settings.save();
|
2022-04-05 10:26:57 -04:00
|
|
|
QMessageBox::information(this, tr("Done"), tr("All curent settings saved"));
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2021-11-24 06:31:51 -05:00
|
|
|
void MainWindow::on_action_Quick_Start_triggered()
|
|
|
|
{
|
2022-05-15 05:11:56 -04:00
|
|
|
QDesktopServices::openUrl(QUrl("https://github.com/f4exb/sdrangel/wiki/Quick-start"));
|
2021-11-24 06:31:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_action_Main_Window_triggered()
|
|
|
|
{
|
2022-05-15 05:11:56 -04:00
|
|
|
QDesktopServices::openUrl(QUrl("https://github.com/f4exb/sdrangel/blob/master/sdrgui/readme.md"));
|
2021-11-24 06:31:51 -05:00
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::on_action_Loaded_Plugins_triggered()
|
|
|
|
{
|
|
|
|
PluginsDialog pluginsDialog(m_pluginManager, this);
|
|
|
|
pluginsDialog.exec();
|
|
|
|
}
|
|
|
|
|
2022-04-05 10:26:57 -04:00
|
|
|
void MainWindow::on_action_Configurations_triggered()
|
|
|
|
{
|
|
|
|
ConfigurationsDialog dialog(this);
|
|
|
|
dialog.setConfigurations(m_mainCore->m_settings.getConfigurations());
|
|
|
|
dialog.populateTree();
|
|
|
|
QObject::connect(
|
|
|
|
&dialog,
|
|
|
|
&ConfigurationsDialog::saveConfiguration,
|
|
|
|
this,
|
|
|
|
&MainWindow::saveConfiguration
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
&dialog,
|
|
|
|
&ConfigurationsDialog::loadConfiguration,
|
|
|
|
this,
|
2022-04-12 10:20:45 -04:00
|
|
|
[=](const Configuration* configuration) { this->loadConfiguration(configuration, true); }
|
2022-04-05 10:26:57 -04:00
|
|
|
);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::on_action_Audio_triggered()
|
|
|
|
{
|
2018-03-25 07:36:09 -04:00
|
|
|
AudioDialogX audioDialog(m_dspEngine->getAudioDeviceManager(), this);
|
2017-10-22 13:12:43 -04:00
|
|
|
audioDialog.exec();
|
|
|
|
}
|
|
|
|
|
2022-06-18 07:35:44 -04:00
|
|
|
void MainWindow::on_action_Graphics_triggered()
|
|
|
|
{
|
|
|
|
GraphicsDialog graphicsDialog(m_mainCore->m_settings, this);
|
|
|
|
graphicsDialog.exec();
|
|
|
|
}
|
|
|
|
|
2017-11-11 13:26:23 -05:00
|
|
|
void MainWindow::on_action_Logging_triggered()
|
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
LoggingDialog loggingDialog(m_mainCore->m_settings, this);
|
2017-11-11 13:26:23 -05:00
|
|
|
loggingDialog.exec();
|
2020-10-10 14:08:11 -04:00
|
|
|
m_mainCore->setLoggingOptions();
|
2017-11-11 13:26:23 -05:00
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::on_action_My_Position_triggered()
|
|
|
|
{
|
2020-10-10 14:08:11 -04:00
|
|
|
MyPositionDialog myPositionDialog(m_mainCore->m_settings, this);
|
2017-10-22 13:12:43 -04:00
|
|
|
myPositionDialog.exec();
|
|
|
|
}
|
|
|
|
|
2019-06-12 12:50:53 -04:00
|
|
|
void MainWindow::on_action_DeviceUserArguments_triggered()
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::on_action_DeviceUserArguments_triggered");
|
2020-10-10 14:08:11 -04:00
|
|
|
DeviceUserArgsDialog deviceUserArgsDialog(DeviceEnumerator::instance(), m_mainCore->m_settings.getDeviceUserArgs(), this);
|
2019-06-12 12:50:53 -04:00
|
|
|
deviceUserArgsDialog.exec();
|
|
|
|
}
|
|
|
|
|
2022-04-04 10:13:42 -04:00
|
|
|
void MainWindow::on_action_commands_triggered()
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::on_action_commands_triggered");
|
|
|
|
CommandsDialog commandsDialog(this);
|
|
|
|
commandsDialog.setApiHost(m_apiServer->getHost());
|
|
|
|
commandsDialog.setApiPort(m_apiServer->getPort());
|
|
|
|
commandsDialog.setCommandKeyReceiver(m_commandKeyReceiver);
|
|
|
|
commandsDialog.populateTree();
|
|
|
|
commandsDialog.exec();
|
|
|
|
}
|
|
|
|
|
2021-11-01 20:04:43 -04:00
|
|
|
void MainWindow::on_action_FFT_triggered()
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::on_action_FFT_triggered");
|
2021-11-02 02:57:10 -04:00
|
|
|
|
|
|
|
if (m_fftWisdomProcess)
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, "FFTW Wisdom", QString("Process %1 is already running").arg(m_fftWisdomProcess->processId()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-01 20:04:43 -04:00
|
|
|
m_fftWisdomProcess = new QProcess(this);
|
|
|
|
connect(m_fftWisdomProcess,
|
|
|
|
SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
|
|
this,
|
|
|
|
SLOT(fftWisdomProcessFinished(int, QProcess::ExitStatus)));
|
|
|
|
FFTWisdomDialog fftWisdomDialog(m_fftWisdomProcess, this);
|
|
|
|
|
|
|
|
if (fftWisdomDialog.exec() == QDialog::Rejected)
|
|
|
|
{
|
|
|
|
disconnect(m_fftWisdomProcess,
|
|
|
|
SIGNAL(finished(int, QProcess::ExitStatus)),
|
|
|
|
this,
|
|
|
|
SLOT(fftWisdomProcessFinished(int, QProcess::ExitStatus)));
|
|
|
|
delete m_fftWisdomProcess;
|
2021-11-02 02:57:10 -04:00
|
|
|
m_fftWisdomProcess = nullptr;
|
2021-11-01 20:04:43 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, "FFTW Wisdom", QString("Process %1 started").arg(m_fftWisdomProcess->processId()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::fftWisdomProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::fftWisdomProcessFinished: process finished rc=%d (%d)", exitCode, (int) exitStatus);
|
|
|
|
|
|
|
|
if ((exitCode != 0) || (exitStatus != QProcess::NormalExit))
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, "FFTW Wisdom", "fftwf-widdsom program failed");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QString log = m_fftWisdomProcess->readAllStandardOutput();
|
|
|
|
QMessageBox::information(this, "FFTW Wisdom", QString("Success\n%1").arg(log));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
delete m_fftWisdomProcess;
|
2021-11-04 14:19:17 -04:00
|
|
|
m_fftWisdomProcess = nullptr;
|
2021-11-01 20:04:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-15 04:04:24 -04:00
|
|
|
void MainWindow::samplingDeviceChangeHandler(DeviceGUI *deviceGUI, int newDeviceIndex)
|
2020-09-13 11:50:24 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
int deviceType = (int) deviceGUI->getDeviceType();
|
|
|
|
int deviceSetIndex = deviceGUI->getIndex();
|
|
|
|
Workspace *workspace = m_workspaces[deviceGUI->getWorkspaceIndex()];
|
|
|
|
sampleDeviceChange(deviceType, deviceSetIndex, newDeviceIndex, workspace);
|
|
|
|
}
|
2020-09-13 11:50:24 -04:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void MainWindow::sampleDeviceChange(int deviceType, int deviceSetIndex, int newDeviceIndex, Workspace *workspace)
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::sampleDeviceChange: deviceType: %d deviceSetIndex: %d newDeviceIndex: %d",
|
|
|
|
deviceType, deviceSetIndex, newDeviceIndex);
|
2020-09-13 11:50:24 -04:00
|
|
|
if (deviceType == 0) {
|
2022-04-07 10:32:03 -04:00
|
|
|
sampleSourceChange(deviceSetIndex, newDeviceIndex, workspace);
|
2020-09-13 11:50:24 -04:00
|
|
|
} else if (deviceType == 1) {
|
2022-04-07 10:32:03 -04:00
|
|
|
sampleSinkChange(deviceSetIndex, newDeviceIndex, workspace);
|
2020-11-10 06:08:58 -05:00
|
|
|
} else if (deviceType == 2) {
|
2022-04-07 10:32:03 -04:00
|
|
|
sampleMIMOChange(deviceSetIndex, newDeviceIndex, workspace);
|
2020-09-13 11:50:24 -04:00
|
|
|
}
|
2022-03-11 23:45:24 -05:00
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
emit MainCore::instance()->deviceChanged(deviceSetIndex);
|
2020-09-13 11:50:24 -04:00
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void MainWindow::sampleSourceChange(int deviceSetIndex, int newDeviceIndex, Workspace *workspace)
|
2020-09-13 11:50:24 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
if (deviceSetIndex >= 0)
|
2020-09-13 11:50:24 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug("MainWindow::sampleSourceChange: deviceSet %d workspace: %d", deviceSetIndex, workspace->getIndex());
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
2022-04-30 05:47:05 -04:00
|
|
|
QPoint p = deviceUISet->m_deviceGUI->pos();
|
2022-04-14 14:41:32 -04:00
|
|
|
workspace->removeFromMdiArea(deviceUISet->m_deviceGUI);
|
2022-04-07 10:32:03 -04:00
|
|
|
// deviceUI->m_deviceAPI->saveSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // save old API settings
|
|
|
|
deviceUISet->m_deviceAPI->stopDeviceEngine();
|
2020-09-13 11:50:24 -04:00
|
|
|
|
|
|
|
// deletes old UI and input object
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->getSampleSource()->setMessageQueueToGUI(nullptr); // have source stop sending messages to the GUI
|
2022-04-14 14:41:32 -04:00
|
|
|
|
2022-04-30 05:47:05 -04:00
|
|
|
deviceUISet->m_deviceGUI->destroy();
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(deviceUISet->m_deviceAPI->getSampleSource());
|
|
|
|
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2020-09-13 11:50:24 -04:00
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
sampleSourceCreate(deviceSetIndex, newDeviceIndex, deviceUISet);
|
2022-04-09 07:38:22 -04:00
|
|
|
deviceUISet->m_deviceGUI->setWorkspaceIndex(workspace->getIndex());
|
|
|
|
workspace->addToMdiArea(deviceUISet->m_deviceGUI);
|
2022-04-30 05:47:05 -04:00
|
|
|
deviceUISet->m_deviceGUI->move(p);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
deviceUISet->m_deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
2022-04-15 12:59:29 -04:00
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(workspace, deviceSetIndex, channelPluginIndex); }
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
2020-09-13 11:50:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void MainWindow::sampleSinkChange(int deviceSetIndex, int newDeviceIndex, Workspace *workspace)
|
2020-09-13 11:50:24 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
if (deviceSetIndex >= 0)
|
2020-09-13 11:50:24 -04:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug("MainWindow::sampleSinkChange: deviceSet %d workspace: %d", deviceSetIndex, workspace->getIndex());
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
2022-04-30 05:47:05 -04:00
|
|
|
QPoint p = deviceUISet->m_deviceGUI->pos();
|
|
|
|
workspace->removeFromMdiArea(deviceUISet->m_deviceGUI);
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->saveSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // save old API settings
|
|
|
|
deviceUISet->m_deviceAPI->stopDeviceEngine();
|
2020-09-13 11:50:24 -04:00
|
|
|
|
|
|
|
// deletes old UI and output object
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->getSampleSink()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
|
2022-04-30 05:47:05 -04:00
|
|
|
m_deviceUIs[deviceSetIndex]->m_deviceGUI->destroy();
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(deviceUISet->m_deviceAPI->getSampleSink());
|
|
|
|
deviceUISet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2020-09-13 11:50:24 -04:00
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
sampleSinkCreate(deviceSetIndex, newDeviceIndex, deviceUISet);
|
2022-04-09 07:38:22 -04:00
|
|
|
deviceUISet->m_deviceGUI->setWorkspaceIndex(workspace->getIndex());
|
|
|
|
workspace->addToMdiArea(deviceUISet->m_deviceGUI);
|
2022-04-30 05:47:05 -04:00
|
|
|
deviceUISet->m_deviceGUI->move(p);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
deviceUISet->m_deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
2022-04-15 12:59:29 -04:00
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(workspace, deviceSetIndex, channelPluginIndex); }
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
2020-09-13 11:50:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void MainWindow::sampleMIMOChange(int deviceSetIndex, int newDeviceIndex, Workspace *workspace)
|
2020-11-10 06:08:58 -05:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
if (deviceSetIndex >= 0)
|
2020-11-10 06:08:58 -05:00
|
|
|
{
|
2022-04-07 10:32:03 -04:00
|
|
|
qDebug("MainWindow::sampleSinkChange: deviceSet %d workspace: %d", deviceSetIndex, workspace->getIndex());
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
2022-04-30 05:47:05 -04:00
|
|
|
QPoint p = deviceUISet->m_deviceGUI->pos();
|
|
|
|
workspace->removeFromMdiArea(deviceUISet->m_deviceGUI);
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->saveSamplingDeviceSettings(m_mainCore->m_settings.getWorkingPreset()); // save old API settings
|
|
|
|
deviceUISet->m_deviceAPI->stopDeviceEngine();
|
2020-11-10 06:08:58 -05:00
|
|
|
|
|
|
|
// deletes old UI and output object
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->getSampleMIMO()->setMessageQueueToGUI(nullptr); // have sink stop sending messages to the GUI
|
2022-04-30 05:47:05 -04:00
|
|
|
deviceUISet->m_deviceGUI->destroy();
|
2022-04-07 10:32:03 -04:00
|
|
|
deviceUISet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceUISet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(deviceUISet->m_deviceAPI->getSampleMIMO());
|
2020-11-10 06:08:58 -05:00
|
|
|
|
2022-04-14 14:41:32 -04:00
|
|
|
sampleMIMOCreate(deviceSetIndex, newDeviceIndex, deviceUISet);
|
2022-04-09 07:38:22 -04:00
|
|
|
deviceUISet->m_deviceGUI->setWorkspaceIndex(workspace->getIndex());
|
|
|
|
workspace->addToMdiArea(deviceUISet->m_deviceGUI);
|
2022-04-30 05:47:05 -04:00
|
|
|
deviceUISet->m_deviceGUI->move(p);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
deviceUISet->m_deviceGUI,
|
|
|
|
&DeviceGUI::addChannelEmitted,
|
|
|
|
this,
|
2022-04-15 12:59:29 -04:00
|
|
|
[=](int channelPluginIndex){ this->channelAddClicked(workspace, deviceSetIndex, channelPluginIndex); }
|
2022-04-12 10:20:45 -04:00
|
|
|
);
|
2020-11-10 06:08:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
void MainWindow::channelMoveToDeviceSet(ChannelGUI *gui, int dsIndexDestination)
|
|
|
|
{
|
|
|
|
int deviceSetIndex = gui->getDeviceSetIndex();
|
|
|
|
int channelIndex = gui->getIndex();
|
|
|
|
qDebug("MainWindow::channelMoveToDeviceSet: %s at %d:%d to %d",
|
|
|
|
qPrintable(gui->getTitle()), deviceSetIndex, channelIndex, dsIndexDestination);
|
|
|
|
|
|
|
|
if ((deviceSetIndex < (int) m_deviceUIs.size()) && (dsIndexDestination < (int) m_deviceUIs.size()))
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUI = m_deviceUIs[deviceSetIndex];
|
|
|
|
DeviceUISet *destDeviceUI = m_deviceUIs[dsIndexDestination];
|
|
|
|
ChannelAPI *channelAPI = deviceUI->getChannelAt(channelIndex);
|
|
|
|
deviceUI->unregisterChannelInstanceAt(channelIndex);
|
|
|
|
|
|
|
|
if (deviceUI->m_deviceSourceEngine) // source devices
|
|
|
|
{
|
|
|
|
destDeviceUI->registerRxChannelInstance(channelAPI, gui);
|
|
|
|
}
|
|
|
|
else if (deviceUI->m_deviceSinkEngine) // sink devices
|
|
|
|
{
|
|
|
|
destDeviceUI->registerTxChannelInstance(channelAPI, gui);
|
|
|
|
}
|
|
|
|
else if (deviceUI->m_deviceMIMOEngine) // MIMO devices
|
|
|
|
{
|
|
|
|
destDeviceUI->registerChannelInstance(channelAPI, gui);
|
|
|
|
}
|
|
|
|
|
|
|
|
gui->setIndex(channelAPI->getIndexInDeviceSet());
|
|
|
|
gui->setDeviceSetIndex(dsIndexDestination);
|
|
|
|
DeviceAPI *destDeviceAPI = destDeviceUI->m_deviceAPI;
|
2022-04-18 06:08:33 -04:00
|
|
|
gui->setIndexToolTip(destDeviceAPI->getSamplingDeviceDisplayName());
|
2022-04-16 10:45:53 -04:00
|
|
|
channelAPI->setDeviceAPI(destDeviceAPI);
|
|
|
|
deviceUI->removeChannelMarker(&gui->getChannelMarker());
|
|
|
|
destDeviceUI->addChannelMarker(&gui->getChannelMarker());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 12:59:29 -04:00
|
|
|
void MainWindow::channelDuplicate(ChannelGUI *sourceChannelGUI)
|
2017-10-22 13:12:43 -04:00
|
|
|
{
|
2022-04-16 10:45:53 -04:00
|
|
|
channelDuplicateToDeviceSet(sourceChannelGUI, sourceChannelGUI->getDeviceSetIndex()); // Duplicate in same device set
|
|
|
|
}
|
2022-04-15 12:59:29 -04:00
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
void MainWindow::channelDuplicateToDeviceSet(ChannelGUI *sourceChannelGUI, int dsIndexDestination)
|
|
|
|
{
|
|
|
|
int dsIndexSource = sourceChannelGUI->getDeviceSetIndex();
|
|
|
|
int sourceChannelIndex = sourceChannelGUI->getIndex();
|
2022-04-15 12:59:29 -04:00
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
qDebug("MainWindow::channelDuplicateToDeviceSet: %s at %d:%d to %d in workspace %d",
|
|
|
|
qPrintable(sourceChannelGUI->getTitle()), dsIndexSource, sourceChannelIndex, dsIndexDestination, sourceChannelGUI->getWorkspaceIndex());
|
|
|
|
|
|
|
|
if ((dsIndexSource < (int) m_deviceUIs.size()) && (dsIndexDestination < (int) m_deviceUIs.size()))
|
2022-04-15 12:59:29 -04:00
|
|
|
{
|
2022-04-16 10:45:53 -04:00
|
|
|
DeviceUISet *sourceDeviceUI = m_deviceUIs[dsIndexSource];
|
|
|
|
ChannelAPI *sourceChannelAPI = sourceDeviceUI->getChannelAt(sourceChannelIndex);
|
|
|
|
ChannelGUI *destChannelGUI = nullptr;
|
|
|
|
DeviceUISet *destDeviceUI = m_deviceUIs[dsIndexDestination];
|
2022-04-15 12:59:29 -04:00
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
if (destDeviceUI->m_deviceSourceEngine) // source device => Rx channels
|
2022-04-15 12:59:29 -04:00
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations();
|
|
|
|
PluginInterface *pluginInterface = nullptr;
|
|
|
|
|
|
|
|
for (const auto& channelRegistration : *channelRegistrations)
|
|
|
|
{
|
|
|
|
if (channelRegistration.m_channelIdURI == sourceChannelAPI->getURI())
|
|
|
|
{
|
|
|
|
pluginInterface = channelRegistration.m_plugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginInterface)
|
|
|
|
{
|
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSink *rxChannel;
|
2022-04-16 10:45:53 -04:00
|
|
|
pluginInterface->createRxChannel(destDeviceUI->m_deviceAPI, &rxChannel, &channelAPI);
|
|
|
|
destChannelGUI = pluginInterface->createRxChannelGUI(destDeviceUI, rxChannel);
|
|
|
|
destDeviceUI->registerRxChannelInstance(channelAPI, destChannelGUI);
|
|
|
|
destChannelGUI->setDeviceType(ChannelGUI::DeviceRx);
|
|
|
|
destChannelGUI->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-15 12:59:29 -04:00
|
|
|
QByteArray b = sourceChannelGUI->serialize();
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->deserialize(b);
|
2022-04-15 12:59:29 -04:00
|
|
|
}
|
|
|
|
}
|
2022-04-16 10:45:53 -04:00
|
|
|
else if (destDeviceUI->m_deviceSinkEngine) // sink device => Tx channels
|
2022-04-15 12:59:29 -04:00
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
|
|
|
|
PluginInterface *pluginInterface = nullptr;
|
|
|
|
|
|
|
|
for (const auto& channelRegistration : *channelRegistrations)
|
|
|
|
{
|
|
|
|
if (channelRegistration.m_channelIdURI == sourceChannelAPI->getURI())
|
|
|
|
{
|
|
|
|
pluginInterface = channelRegistration.m_plugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginInterface)
|
|
|
|
{
|
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSource *txChannel;
|
2022-04-16 10:45:53 -04:00
|
|
|
pluginInterface->createTxChannel(destDeviceUI->m_deviceAPI, &txChannel, &channelAPI);
|
|
|
|
destChannelGUI = pluginInterface->createTxChannelGUI(destDeviceUI, txChannel);
|
|
|
|
destDeviceUI->registerTxChannelInstance(channelAPI, destChannelGUI);
|
|
|
|
destChannelGUI->setDeviceType(ChannelGUI::DeviceTx);
|
|
|
|
destChannelGUI->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-15 12:59:29 -04:00
|
|
|
QByteArray b = sourceChannelGUI->serialize();
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->deserialize(b);
|
2022-04-15 12:59:29 -04:00
|
|
|
}
|
|
|
|
}
|
2022-04-16 10:45:53 -04:00
|
|
|
else if (destDeviceUI->m_deviceMIMOEngine) // MIMO device => Any type of channel is possible
|
2022-04-15 12:59:29 -04:00
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *rxChannelRegistrations = m_pluginManager->getRxChannelRegistrations();
|
|
|
|
PluginAPI::ChannelRegistrations *txChannelRegistrations = m_pluginManager->getTxChannelRegistrations();
|
|
|
|
PluginAPI::ChannelRegistrations *mimoChannelRegistrations = m_pluginManager->getMIMOChannelRegistrations();
|
|
|
|
PluginInterface *pluginInterface = nullptr;
|
|
|
|
|
|
|
|
for (const auto& channelRegistration : *rxChannelRegistrations)
|
|
|
|
{
|
|
|
|
if (channelRegistration.m_channelIdURI == sourceChannelAPI->getURI())
|
|
|
|
{
|
|
|
|
pluginInterface = channelRegistration.m_plugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginInterface) // Rx channel
|
|
|
|
{
|
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSink *rxChannel;
|
2022-04-16 10:45:53 -04:00
|
|
|
pluginInterface->createRxChannel(destDeviceUI->m_deviceAPI, &rxChannel, &channelAPI);
|
|
|
|
destChannelGUI = pluginInterface->createRxChannelGUI(destDeviceUI, rxChannel);
|
|
|
|
destDeviceUI->registerRxChannelInstance(channelAPI, destChannelGUI);
|
|
|
|
destChannelGUI->setDeviceType(ChannelGUI::DeviceMIMO);
|
|
|
|
destChannelGUI->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-15 12:59:29 -04:00
|
|
|
QByteArray b = sourceChannelGUI->serialize();
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->deserialize(b);
|
2022-04-15 12:59:29 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (const auto& channelRegistration : *txChannelRegistrations)
|
|
|
|
{
|
|
|
|
if (channelRegistration.m_channelIdURI == sourceChannelAPI->getURI())
|
|
|
|
{
|
|
|
|
pluginInterface = channelRegistration.m_plugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginInterface) // Tx channel
|
|
|
|
{
|
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSource *txChannel;
|
2022-04-16 10:45:53 -04:00
|
|
|
pluginInterface->createTxChannel(destDeviceUI->m_deviceAPI, &txChannel, &channelAPI);
|
|
|
|
destChannelGUI = pluginInterface->createTxChannelGUI(destDeviceUI, txChannel);
|
|
|
|
destDeviceUI->registerTxChannelInstance(channelAPI, destChannelGUI);
|
|
|
|
destChannelGUI->setDeviceType(ChannelGUI::DeviceMIMO);
|
|
|
|
destChannelGUI->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-15 12:59:29 -04:00
|
|
|
QByteArray b = sourceChannelGUI->serialize();
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->deserialize(b);
|
2022-04-15 12:59:29 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (const auto& channelRegistration : *mimoChannelRegistrations)
|
|
|
|
{
|
|
|
|
if (channelRegistration.m_channelIdURI == sourceChannelAPI->getURI())
|
|
|
|
{
|
|
|
|
pluginInterface = channelRegistration.m_plugin;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginInterface)
|
|
|
|
{
|
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
MIMOChannel *mimoChannel;
|
2022-04-16 10:45:53 -04:00
|
|
|
pluginInterface->createMIMOChannel(destDeviceUI->m_deviceAPI, &mimoChannel, &channelAPI);
|
|
|
|
destChannelGUI = pluginInterface->createMIMOChannelGUI(destDeviceUI, mimoChannel);
|
|
|
|
destDeviceUI->registerChannelInstance(channelAPI, destChannelGUI);
|
|
|
|
destChannelGUI->setDeviceType(ChannelGUI::DeviceMIMO);
|
|
|
|
destChannelGUI->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-15 12:59:29 -04:00
|
|
|
QByteArray b = sourceChannelGUI->serialize();
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->deserialize(b);
|
2022-04-15 12:59:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
DeviceAPI *destDeviceAPI = destDeviceUI->m_deviceAPI;
|
2022-04-15 12:59:29 -04:00
|
|
|
int workspaceIndex = sourceChannelGUI->getWorkspaceIndex();
|
|
|
|
Workspace *workspace = workspaceIndex < m_workspaces.size() ? m_workspaces[sourceChannelGUI->getWorkspaceIndex()] : nullptr;
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
if (destChannelGUI && workspace)
|
2022-04-15 12:59:29 -04:00
|
|
|
{
|
|
|
|
QObject::connect(
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI,
|
2022-04-15 12:59:29 -04:00
|
|
|
&ChannelGUI::moveToWorkspace,
|
|
|
|
this,
|
2022-04-16 10:45:53 -04:00
|
|
|
[=](int wsIndexDest){ this->channelMove(destChannelGUI, wsIndexDest); }
|
2022-04-15 12:59:29 -04:00
|
|
|
);
|
|
|
|
QObject::connect(
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI,
|
2022-04-15 12:59:29 -04:00
|
|
|
&ChannelGUI::duplicateChannelEmitted,
|
|
|
|
this,
|
2022-04-16 10:45:53 -04:00
|
|
|
[=](){ this->channelDuplicate(destChannelGUI); }
|
|
|
|
);
|
|
|
|
QObject::connect(
|
|
|
|
destChannelGUI,
|
|
|
|
&ChannelGUI::moveToDeviceSet,
|
|
|
|
this,
|
|
|
|
[=](int dsIndexDest){ this->channelMoveToDeviceSet(destChannelGUI, dsIndexDest); }
|
2022-04-15 12:59:29 -04:00
|
|
|
);
|
|
|
|
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->setDeviceSetIndex(dsIndexDestination);
|
2022-04-18 06:08:33 -04:00
|
|
|
destChannelGUI->setIndexToolTip(destDeviceAPI->getSamplingDeviceDisplayName());
|
2022-04-16 10:45:53 -04:00
|
|
|
destChannelGUI->setWorkspaceIndex(workspace->getIndex());
|
2022-04-15 12:59:29 -04:00
|
|
|
qDebug("MainWindow::channelDuplicate: adding %s to workspace #%d",
|
2022-04-16 10:45:53 -04:00
|
|
|
qPrintable(destChannelGUI->getTitle()), workspace->getIndex());
|
|
|
|
workspace->addToMdiArea((QMdiSubWindow*) destChannelGUI);
|
2022-04-15 12:59:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::channelAddClicked(Workspace *workspace, int deviceSetIndex, int channelPluginIndex)
|
|
|
|
{
|
|
|
|
if (deviceSetIndex < (int) m_deviceUIs.size())
|
2022-04-12 10:20:45 -04:00
|
|
|
{
|
|
|
|
DeviceUISet *deviceUI = m_deviceUIs[deviceSetIndex];
|
|
|
|
ChannelGUI *gui = nullptr;
|
|
|
|
DeviceAPI *deviceAPI = deviceUI->m_deviceAPI;
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
if (deviceUI->m_deviceSourceEngine) // source device => Rx channels
|
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations(); // Available channel plugins
|
2022-04-15 12:59:29 -04:00
|
|
|
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex].m_plugin;
|
2022-04-12 10:20:45 -04:00
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSink *rxChannel;
|
|
|
|
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
|
|
|
|
gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
|
|
|
|
deviceUI->registerRxChannelInstance(channelAPI, gui);
|
|
|
|
gui->setDeviceType(ChannelGUI::DeviceRx);
|
|
|
|
gui->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-17 04:20:07 -04:00
|
|
|
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
|
|
|
else if (deviceUI->m_deviceSinkEngine) // sink device => Tx channels
|
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
|
2022-04-15 12:59:29 -04:00
|
|
|
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex].m_plugin;
|
2022-04-12 10:20:45 -04:00
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSource *txChannel;
|
|
|
|
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
|
|
|
|
gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
|
|
|
|
deviceUI->registerTxChannelInstance(channelAPI, gui);
|
|
|
|
gui->setDeviceType(ChannelGUI::DeviceTx);
|
|
|
|
gui->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-17 04:20:07 -04:00
|
|
|
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
|
|
|
else if (deviceUI->m_deviceMIMOEngine) // MIMO device => all possible channels. Depends on index range
|
|
|
|
{
|
|
|
|
int nbMIMOChannels = deviceUI->getNumberOfAvailableMIMOChannels();
|
|
|
|
int nbRxChannels = deviceUI->getNumberOfAvailableRxChannels();
|
|
|
|
int nbTxChannels = deviceUI->getNumberOfAvailableTxChannels();
|
|
|
|
qDebug("MainWindow::channelAddClicked: MIMO: dev %d : nbMIMO: %d nbRx: %d nbTx: %d selected: %d",
|
2022-04-15 12:59:29 -04:00
|
|
|
deviceSetIndex, nbMIMOChannels, nbRxChannels, nbTxChannels, channelPluginIndex);
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-15 12:59:29 -04:00
|
|
|
if (channelPluginIndex < nbMIMOChannels)
|
2022-04-12 10:20:45 -04:00
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getMIMOChannelRegistrations(); // Available channel plugins
|
2022-04-15 12:59:29 -04:00
|
|
|
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex].m_plugin;
|
2022-04-12 10:20:45 -04:00
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
MIMOChannel *mimoChannel;
|
|
|
|
pluginInterface->createMIMOChannel(deviceUI->m_deviceAPI, &mimoChannel, &channelAPI);
|
|
|
|
gui = pluginInterface->createMIMOChannelGUI(deviceUI, mimoChannel);
|
|
|
|
deviceUI->registerChannelInstance(channelAPI, gui);
|
|
|
|
gui->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-17 04:20:07 -04:00
|
|
|
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
2022-04-15 12:59:29 -04:00
|
|
|
else if (channelPluginIndex < nbMIMOChannels + nbRxChannels) // Rx
|
2022-04-12 10:20:45 -04:00
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getRxChannelRegistrations(); // Available channel plugins
|
2022-04-15 12:59:29 -04:00
|
|
|
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex - nbMIMOChannels].m_plugin;
|
2022-04-12 10:20:45 -04:00
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSink *rxChannel;
|
|
|
|
pluginInterface->createRxChannel(deviceUI->m_deviceAPI, &rxChannel, &channelAPI);
|
|
|
|
gui = pluginInterface->createRxChannelGUI(deviceUI, rxChannel);
|
|
|
|
deviceUI->registerRxChannelInstance(channelAPI, gui);
|
|
|
|
gui->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-17 04:20:07 -04:00
|
|
|
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
2022-04-15 12:59:29 -04:00
|
|
|
else if (channelPluginIndex < nbMIMOChannels + nbRxChannels + nbTxChannels)
|
2022-04-12 10:20:45 -04:00
|
|
|
{
|
|
|
|
PluginAPI::ChannelRegistrations *channelRegistrations = m_pluginManager->getTxChannelRegistrations(); // Available channel plugins
|
2022-04-15 12:59:29 -04:00
|
|
|
PluginInterface *pluginInterface = (*channelRegistrations)[channelPluginIndex - nbMIMOChannels - nbRxChannels].m_plugin;
|
2022-04-12 10:20:45 -04:00
|
|
|
ChannelAPI *channelAPI;
|
|
|
|
BasebandSampleSource *txChannel;
|
|
|
|
pluginInterface->createTxChannel(deviceUI->m_deviceAPI, &txChannel, &channelAPI);
|
|
|
|
gui = pluginInterface->createTxChannelGUI(deviceUI, txChannel);
|
|
|
|
deviceUI->registerTxChannelInstance(channelAPI, gui);
|
|
|
|
gui->setIndex(channelAPI->getIndexInDeviceSet());
|
2022-04-17 04:20:07 -04:00
|
|
|
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
gui->setDeviceType(ChannelGUI::DeviceMIMO);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gui)
|
|
|
|
{
|
|
|
|
QObject::connect(
|
|
|
|
gui,
|
|
|
|
&ChannelGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->channelMove(gui, wsIndexDest); }
|
|
|
|
);
|
2022-04-15 12:59:29 -04:00
|
|
|
QObject::connect(
|
|
|
|
gui,
|
|
|
|
&ChannelGUI::duplicateChannelEmitted,
|
|
|
|
this,
|
|
|
|
[=](){ this->channelDuplicate(gui); }
|
|
|
|
);
|
2022-04-16 10:45:53 -04:00
|
|
|
QObject::connect(
|
|
|
|
gui,
|
|
|
|
&ChannelGUI::moveToDeviceSet,
|
|
|
|
this,
|
|
|
|
[=](int dsIndexDest){ this->channelMoveToDeviceSet(gui, dsIndexDest); }
|
|
|
|
);
|
2022-04-12 10:20:45 -04:00
|
|
|
|
|
|
|
gui->setDeviceSetIndex(deviceSetIndex);
|
2022-04-18 06:08:33 -04:00
|
|
|
gui->setIndexToolTip(deviceAPI->getSamplingDeviceDisplayName());
|
2022-04-12 10:20:45 -04:00
|
|
|
gui->setWorkspaceIndex(workspace->getIndex());
|
|
|
|
qDebug("MainWindow::channelAddClicked: adding %s to workspace #%d",
|
|
|
|
qPrintable(gui->getTitle()), workspace->getIndex());
|
|
|
|
workspace->addToMdiArea((QMdiSubWindow*) gui);
|
|
|
|
//gui->restoreGeometry(gui->getGeometryBytes());
|
|
|
|
}
|
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::featureAddClicked(Workspace *workspace, int featureIndex)
|
|
|
|
{
|
|
|
|
qDebug("MainWindow::featureAddClicked: W%d feature at %d", workspace->getIndex(), featureIndex);
|
|
|
|
|
2022-04-15 04:04:24 -04:00
|
|
|
int currentFeatureSetIndex = 0; // Do it in the unique set
|
|
|
|
FeatureUISet *featureUISet = m_featureUIs[currentFeatureSetIndex];
|
2022-04-04 04:23:52 -04:00
|
|
|
qDebug("MainWindow::featureAddClicked: m_apiAdapter: %p", m_apiAdapter);
|
|
|
|
PluginAPI::FeatureRegistrations *featureRegistrations = m_pluginManager->getFeatureRegistrations(); // Available feature plugins
|
|
|
|
PluginInterface *pluginInterface = (*featureRegistrations)[featureIndex].m_plugin;
|
|
|
|
Feature *feature = pluginInterface->createFeature(m_apiAdapter);
|
|
|
|
FeatureGUI *gui = pluginInterface->createFeatureGUI(featureUISet, feature);
|
|
|
|
featureUISet->registerFeatureInstance(gui, feature);
|
|
|
|
gui->setIndex(feature->getIndexInFeatureSet());
|
|
|
|
gui->setWorkspaceIndex(workspace->getIndex());
|
2022-04-18 06:08:33 -04:00
|
|
|
gui->setDisplayedame(pluginInterface->getPluginDescriptor().displayedName);
|
2022-04-04 04:23:52 -04:00
|
|
|
workspace->addToMdiArea((QMdiSubWindow*) gui);
|
|
|
|
|
|
|
|
QObject::connect(
|
|
|
|
gui,
|
|
|
|
&FeatureGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->featureMove(gui, wsIndexDest); }
|
|
|
|
);
|
|
|
|
}
|
2017-10-22 13:12:43 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::featureMove(FeatureGUI *gui, int wsIndexDestnation)
|
|
|
|
{
|
|
|
|
int wsIndexOrigin = gui->getWorkspaceIndex();
|
2019-05-18 09:40:00 -04:00
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
if (wsIndexOrigin == wsIndexDestnation) {
|
|
|
|
return;
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
2022-04-04 04:23:52 -04:00
|
|
|
|
|
|
|
m_workspaces[wsIndexOrigin]->removeFromMdiArea(gui);
|
|
|
|
gui->setWorkspaceIndex(wsIndexDestnation);
|
|
|
|
m_workspaces[wsIndexDestnation]->addToMdiArea(gui);
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
|
|
|
|
2022-04-07 10:32:03 -04:00
|
|
|
void MainWindow::deviceMove(DeviceGUI *gui, int wsIndexDestnation)
|
|
|
|
{
|
|
|
|
int wsIndexOrigin = gui->getWorkspaceIndex();
|
2022-04-13 21:07:33 -04:00
|
|
|
qDebug("MainWindow::deviceMove: %s from %d to %d",
|
|
|
|
qPrintable(gui->getTitle()), wsIndexOrigin, wsIndexDestnation);
|
2022-04-07 10:32:03 -04:00
|
|
|
|
|
|
|
if (wsIndexOrigin == wsIndexDestnation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_workspaces[wsIndexOrigin]->removeFromMdiArea(gui);
|
|
|
|
gui->setWorkspaceIndex(wsIndexDestnation);
|
|
|
|
m_workspaces[wsIndexDestnation]->addToMdiArea(gui);
|
|
|
|
}
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
void MainWindow::channelMove(ChannelGUI *gui, int wsIndexDestnation)
|
|
|
|
{
|
|
|
|
int wsIndexOrigin = gui->getWorkspaceIndex();
|
|
|
|
|
|
|
|
if (wsIndexOrigin == wsIndexDestnation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_workspaces[wsIndexOrigin]->removeFromMdiArea(gui);
|
|
|
|
gui->setWorkspaceIndex(wsIndexDestnation);
|
|
|
|
m_workspaces[wsIndexDestnation]->addToMdiArea(gui);
|
|
|
|
}
|
|
|
|
|
2022-04-09 07:38:22 -04:00
|
|
|
void MainWindow::mainSpectrumMove(MainSpectrumGUI *gui, int wsIndexDestnation)
|
|
|
|
{
|
|
|
|
int wsIndexOrigin = gui->getWorkspaceIndex();
|
2022-04-13 21:07:33 -04:00
|
|
|
qDebug("MainWindow::mainSpectrumMove: %s from %d to %d",
|
|
|
|
qPrintable(gui->getTitle()), wsIndexOrigin, wsIndexDestnation);
|
2022-04-09 07:38:22 -04:00
|
|
|
|
|
|
|
if (wsIndexOrigin == wsIndexDestnation) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_workspaces[wsIndexOrigin]->removeFromMdiArea(gui);
|
|
|
|
gui->setWorkspaceIndex(wsIndexDestnation);
|
|
|
|
m_workspaces[wsIndexDestnation]->addToMdiArea(gui);
|
|
|
|
}
|
|
|
|
|
2022-04-27 18:01:08 -04:00
|
|
|
void MainWindow::mainSpectrumShow(int deviceSetIndex)
|
2022-04-09 18:11:23 -04:00
|
|
|
{
|
2022-04-27 18:01:08 -04:00
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
deviceUISet->m_mainSpectrumGUI->show();
|
|
|
|
deviceUISet->m_mainSpectrumGUI->raise();
|
2022-04-09 18:11:23 -04:00
|
|
|
}
|
|
|
|
|
2022-06-24 16:52:17 -04:00
|
|
|
void MainWindow::mainSpectrumRequestDeviceCenterFrequency(int deviceSetIndex, qint64 deviceCenterFrequency)
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
DeviceAPI *deviceAPI = deviceUISet->m_deviceAPI;
|
|
|
|
|
|
|
|
if (deviceAPI->getSampleSource()) {
|
|
|
|
deviceAPI->getSampleSource()->setCenterFrequency(deviceCenterFrequency);
|
|
|
|
} else if (deviceAPI->getSampleSink()) {
|
|
|
|
deviceAPI->getSampleSink()->setCenterFrequency(deviceCenterFrequency);
|
|
|
|
}
|
|
|
|
// Not implemented for MIMO
|
|
|
|
}
|
|
|
|
|
2022-04-12 10:20:45 -04:00
|
|
|
void MainWindow::showAllChannels(int deviceSetIndex)
|
|
|
|
{
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceSetIndex];
|
|
|
|
|
2022-04-18 04:21:47 -04:00
|
|
|
for (int i = 0; i < deviceUISet->getNumberOfChannels(); i++)
|
|
|
|
{
|
2022-04-12 10:20:45 -04:00
|
|
|
deviceUISet->getChannelGUIAt(i)->show();
|
2022-04-18 04:21:47 -04:00
|
|
|
deviceUISet->getChannelGUIAt(i)->raise();
|
2022-04-12 10:20:45 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-27 05:18:17 -04:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2022-04-04 04:23:52 -04:00
|
|
|
void MainWindow::openFeaturePresetsDialog(QPoint p, Workspace *workspace)
|
2020-09-19 19:06:34 -04:00
|
|
|
{
|
2022-04-04 04:23:52 -04:00
|
|
|
FeaturePresetsDialog dialog;
|
|
|
|
dialog.setFeatureUISet(m_featureUIs[0]);
|
|
|
|
dialog.setPresets(m_mainCore->m_settings.getFeatureSetPresets());
|
|
|
|
dialog.setPluginAPI(m_pluginManager->getPluginAPI());
|
|
|
|
dialog.setWebAPIAdapter(m_apiAdapter);
|
2022-04-09 07:38:22 -04:00
|
|
|
dialog.setCurrentWorkspace(workspace);
|
|
|
|
dialog.setWorkspaces(&m_workspaces);
|
2022-04-04 04:23:52 -04:00
|
|
|
dialog.populateTree();
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
2022-04-05 10:26:57 -04:00
|
|
|
|
|
|
|
if (dialog.wasPresetLoaded())
|
|
|
|
{
|
|
|
|
for (int i = 0; i < m_featureUIs[0]->getNumberOfFeatures(); i++)
|
|
|
|
{
|
|
|
|
FeatureGUI *gui = m_featureUIs[0]->getFeatureGuiAt(i);
|
|
|
|
QObject::connect(
|
|
|
|
gui,
|
|
|
|
&FeatureGUI::moveToWorkspace,
|
|
|
|
this,
|
|
|
|
[=](int wsIndexDest){ this->featureMove(gui, wsIndexDest); }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-09-19 19:06:34 -04:00
|
|
|
}
|
|
|
|
|
2022-04-13 12:43:37 -04:00
|
|
|
void MainWindow::openDeviceSetPresetsDialog(QPoint p, DeviceGUI *deviceGUI)
|
|
|
|
{
|
|
|
|
Workspace *workspace = m_workspaces[deviceGUI->getWorkspaceIndex()];
|
|
|
|
DeviceUISet *deviceUISet = m_deviceUIs[deviceGUI->getIndex()];
|
|
|
|
|
|
|
|
DeviceSetPresetsDialog dialog;
|
|
|
|
dialog.setDeviceUISet(deviceUISet);
|
|
|
|
dialog.setPresets(m_mainCore->m_settings.getPresets());
|
|
|
|
dialog.setPluginAPI(m_pluginManager->getPluginAPI());
|
|
|
|
dialog.setCurrentWorkspace(workspace);
|
|
|
|
dialog.setWorkspaces(&m_workspaces);
|
|
|
|
dialog.populateTree((int) deviceGUI->getDeviceType());
|
|
|
|
dialog.move(p);
|
|
|
|
dialog.exec();
|
|
|
|
}
|
|
|
|
|
2020-09-20 21:13:36 -04:00
|
|
|
void MainWindow::deleteFeature(int featureSetIndex, int featureIndex)
|
|
|
|
{
|
|
|
|
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_featureUIs.size()))
|
|
|
|
{
|
2021-11-26 02:41:42 -05:00
|
|
|
FeatureUISet *featureUISet = m_featureUIs[featureSetIndex];
|
|
|
|
featureUISet->deleteFeature(featureIndex);
|
2020-09-20 21:13:36 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-22 13:12:43 -04:00
|
|
|
void MainWindow::on_action_About_triggered()
|
|
|
|
{
|
2021-11-01 05:51:50 -04:00
|
|
|
AboutDialog dlg(m_apiHost.isEmpty() ? "127.0.0.1" : m_apiHost, m_apiPort, m_mainCore->m_settings, this);
|
2017-10-22 13:12:43 -04:00
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::updateStatus()
|
|
|
|
{
|
2018-05-11 05:00:08 -04:00
|
|
|
m_dateTimeWidget->setText(QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss t"));
|
2017-10-22 13:12:43 -04:00
|
|
|
}
|
2017-11-11 13:26:23 -05:00
|
|
|
|
2018-01-04 23:05:12 -05:00
|
|
|
void MainWindow::commandKeyPressed(Qt::Key key, Qt::KeyboardModifiers keyModifiers, bool release)
|
|
|
|
{
|
2022-04-04 10:13:42 -04:00
|
|
|
qDebug("MainWindow::commandKeyPressed: key: %x mod: %x %s", (int) key, (int) keyModifiers, release ? "release" : "press");
|
|
|
|
int currentDeviceSetIndex = 0;
|
2018-01-05 04:28:32 -05:00
|
|
|
|
2022-04-04 10:13:42 -04:00
|
|
|
for (int i = 0; i < m_mainCore->m_settings.getCommandCount(); ++i)
|
|
|
|
{
|
|
|
|
const Command* command = m_mainCore->m_settings.getCommand(i);
|
2018-01-05 04:28:32 -05:00
|
|
|
|
2022-04-04 10:13:42 -04:00
|
|
|
if (command->getAssociateKey()
|
|
|
|
&& (command->getRelease() == release)
|
|
|
|
&& (command->getKey() == key)
|
|
|
|
&& (command->getKeyModifiers() == keyModifiers))
|
|
|
|
{
|
|
|
|
Command* command_mod = const_cast<Command*>(command);
|
|
|
|
command_mod->run(m_apiServer->getHost(), m_apiServer->getPort(), currentDeviceSetIndex);
|
|
|
|
}
|
|
|
|
}
|
2018-01-04 23:05:12 -05:00
|
|
|
}
|