2017-12-17 05:09:51 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// Swagger server adapter interface //
|
|
|
|
// //
|
|
|
|
// 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:44:23 -04:00
|
|
|
// (at your option) any later version. //
|
2017-12-17 05:09:51 -05: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 <QDebug>
|
2018-01-06 20:52:35 -05:00
|
|
|
#include <QSysInfo>
|
2018-02-18 17:01:02 -05:00
|
|
|
#include <QResource>
|
2017-12-17 05:09:51 -05:00
|
|
|
|
|
|
|
#include "dsp/dspengine.h"
|
|
|
|
#include "dsp/dspdevicesourceengine.h"
|
2017-12-19 19:01:53 -05:00
|
|
|
#include "dsp/dspdevicesinkengine.h"
|
2019-12-14 12:45:25 -05:00
|
|
|
#include "dsp/dspdevicemimoengine.h"
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2017-12-19 19:01:53 -05:00
|
|
|
#include "device/deviceset.h"
|
|
|
|
#include "device/deviceenumerator.h"
|
2020-09-20 21:13:36 -04:00
|
|
|
#include "feature/featureset.h"
|
2017-12-17 05:09:51 -05:00
|
|
|
#include "plugin/pluginmanager.h"
|
|
|
|
#include "loggerwithfile.h"
|
|
|
|
#include "webapi/webapirequestmapper.h"
|
|
|
|
#include "webapi/webapiserver.h"
|
|
|
|
#include "webapi/webapiadaptersrv.h"
|
|
|
|
|
|
|
|
#include "maincore.h"
|
|
|
|
|
2017-12-17 17:15:42 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteInstance, Message)
|
2017-12-20 08:31:17 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadPreset, Message)
|
2017-12-20 17:57:06 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgSavePreset, Message)
|
2017-12-20 18:31:38 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeletePreset, Message)
|
2020-09-23 23:38:05 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadFeatureSetPreset, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgSaveFeatureSetPreset, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteFeatureSetPreset, Message)
|
2017-12-19 19:01:53 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddDeviceSet, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgRemoveLastDeviceSet, Message)
|
2017-12-21 18:07:59 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgSetDevice, Message)
|
2017-12-22 12:19:49 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddChannel, Message)
|
2017-12-23 16:33:30 -05:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteChannel, Message)
|
2019-08-13 06:18:47 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgApplySettings, Message)
|
2020-09-20 21:13:36 -04:00
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgAddFeature, Message)
|
|
|
|
MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteFeature, Message)
|
2017-12-17 17:15:42 -05:00
|
|
|
|
2017-12-17 05:09:51 -05:00
|
|
|
MainCore *MainCore::m_instance = 0;
|
|
|
|
|
2017-12-17 06:08:18 -05:00
|
|
|
MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent) :
|
|
|
|
QObject(parent),
|
2017-12-17 05:09:51 -05:00
|
|
|
m_settings(),
|
|
|
|
m_masterTabIndex(-1),
|
|
|
|
m_dspEngine(DSPEngine::instance()),
|
2018-06-21 13:28:11 -04:00
|
|
|
m_lastEngineState(DSPDeviceSourceEngine::StNotStarted),
|
2017-12-17 18:00:21 -05:00
|
|
|
m_logger(logger)
|
2017-12-17 05:09:51 -05:00
|
|
|
{
|
|
|
|
qDebug() << "MainCore::MainCore: start";
|
|
|
|
|
|
|
|
m_instance = this;
|
2018-03-23 13:08:38 -04:00
|
|
|
m_settings.setAudioDeviceManager(m_dspEngine->getAudioDeviceManager());
|
2019-07-20 17:25:00 -04:00
|
|
|
m_settings.setAMBEEngine(m_dspEngine->getAMBEEngine());
|
2017-12-17 05:09:51 -05:00
|
|
|
|
2020-03-12 01:27:38 -04:00
|
|
|
qDebug() << "MainCore::MainCore: create FFT factory...";
|
|
|
|
m_dspEngine->createFFTFactory(parser.getFFTWFWisdomFileName());
|
|
|
|
|
|
|
|
qDebug() << "MainCore::MainCore: load plugins...";
|
2017-12-17 05:09:51 -05:00
|
|
|
m_pluginManager = new PluginManager(this);
|
|
|
|
m_pluginManager->loadPlugins(QString("pluginssrv"));
|
|
|
|
|
|
|
|
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
|
|
|
|
m_masterTimer.start(50);
|
|
|
|
|
2020-03-12 01:27:38 -04:00
|
|
|
qDebug() << "MainCore::MainCore: load setings...";
|
2017-12-18 07:56:10 -05:00
|
|
|
loadSettings();
|
|
|
|
|
2020-03-12 01:27:38 -04:00
|
|
|
qDebug() << "MainCore::MainCore: finishing...";
|
2018-02-18 17:01:02 -05:00
|
|
|
QString applicationDirPath = QCoreApplication::instance()->applicationDirPath();
|
|
|
|
|
2017-12-17 05:09:51 -05:00
|
|
|
m_apiAdapter = new WebAPIAdapterSrv(*this);
|
2017-12-17 18:00:21 -05:00
|
|
|
m_requestMapper = new WebAPIRequestMapper(this);
|
2017-12-17 05:09:51 -05:00
|
|
|
m_requestMapper->setAdapter(m_apiAdapter);
|
2020-09-09 20:43:28 -04:00
|
|
|
m_apiHost = parser.getServerAddress();
|
|
|
|
m_apiPort = parser.getServerPort();
|
2017-12-17 05:09:51 -05:00
|
|
|
m_apiServer = new WebAPIServer(parser.getServerAddress(), parser.getServerPort(), m_requestMapper);
|
|
|
|
m_apiServer->start();
|
|
|
|
|
2019-05-12 04:25:55 -04:00
|
|
|
m_dspEngine->setMIMOSupport(parser.getMIMOSupport());
|
|
|
|
|
2017-12-17 05:09:51 -05:00
|
|
|
qDebug() << "MainCore::MainCore: end";
|
|
|
|
}
|
|
|
|
|
|
|
|
MainCore::~MainCore()
|
|
|
|
{
|
2018-02-14 05:27:57 -05:00
|
|
|
while (m_deviceSets.size() > 0) {
|
|
|
|
removeLastDevice();
|
|
|
|
}
|
|
|
|
|
2017-12-18 07:56:10 -05:00
|
|
|
m_apiServer->stop();
|
2020-09-23 23:38:05 -04:00
|
|
|
m_settings.save();
|
2017-12-17 05:09:51 -05:00
|
|
|
delete m_apiServer;
|
|
|
|
delete m_requestMapper;
|
|
|
|
delete m_apiAdapter;
|
|
|
|
|
|
|
|
delete m_pluginManager;
|
|
|
|
|
|
|
|
qDebug() << "MainCore::~MainCore: end";
|
|
|
|
delete m_logger;
|
|
|
|
}
|
2017-12-17 06:08:18 -05:00
|
|
|
|
2017-12-17 17:15:42 -05:00
|
|
|
bool MainCore::handleMessage(const Message& cmd)
|
|
|
|
{
|
|
|
|
if (MsgDeleteInstance::match(cmd))
|
|
|
|
{
|
2017-12-19 19:01:53 -05:00
|
|
|
while (m_deviceSets.size() > 0)
|
|
|
|
{
|
|
|
|
removeLastDevice();
|
|
|
|
}
|
|
|
|
|
2017-12-17 18:00:21 -05:00
|
|
|
emit finished();
|
2017-12-17 17:15:42 -05:00
|
|
|
return true;
|
|
|
|
}
|
2017-12-20 08:31:17 -05:00
|
|
|
else if (MsgLoadPreset::match(cmd))
|
|
|
|
{
|
|
|
|
MsgLoadPreset& notif = (MsgLoadPreset&) cmd;
|
|
|
|
loadPresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-20 17:57:06 -05:00
|
|
|
else if (MsgSavePreset::match(cmd))
|
|
|
|
{
|
|
|
|
MsgSavePreset& notif = (MsgSavePreset&) cmd;
|
|
|
|
savePresetSettings(notif.getPreset(), notif.getDeviceSetIndex());
|
|
|
|
m_settings.sortPresets();
|
2020-09-23 23:38:05 -04:00
|
|
|
m_settings.save();
|
2017-12-20 17:57:06 -05:00
|
|
|
return true;
|
|
|
|
}
|
2017-12-20 18:31:38 -05:00
|
|
|
else if (MsgDeletePreset::match(cmd))
|
|
|
|
{
|
|
|
|
MsgDeletePreset& notif = (MsgDeletePreset&) cmd;
|
|
|
|
const Preset *presetToDelete = notif.getPreset();
|
|
|
|
// remove preset from settings
|
|
|
|
m_settings.deletePreset(presetToDelete);
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-23 23:38:05 -04:00
|
|
|
else if (MsgLoadFeatureSetPreset::match(cmd))
|
|
|
|
{
|
|
|
|
MsgLoadFeatureSetPreset& notif = (MsgLoadFeatureSetPreset&) cmd;
|
|
|
|
loadFeatureSetPresetSettings(notif.getPreset(), notif.getFeatureSetIndex());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgSaveFeatureSetPreset::match(cmd))
|
|
|
|
{
|
|
|
|
MsgSaveFeatureSetPreset& notif = (MsgSaveFeatureSetPreset&) cmd;
|
|
|
|
saveFeatureSetPresetSettings(notif.getPreset(), notif.getFeatureSetIndex());
|
|
|
|
m_settings.sortPresets();
|
|
|
|
m_settings.save();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgDeleteFeatureSetPreset::match(cmd))
|
|
|
|
{
|
|
|
|
MsgDeleteFeatureSetPreset& notif = (MsgDeleteFeatureSetPreset&) cmd;
|
|
|
|
const FeatureSetPreset *presetToDelete = notif.getPreset();
|
|
|
|
// remove preset from settings
|
|
|
|
m_settings.deleteFeatureSetPreset(presetToDelete);
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-19 19:01:53 -05:00
|
|
|
else if (MsgAddDeviceSet::match(cmd))
|
|
|
|
{
|
|
|
|
MsgAddDeviceSet& notif = (MsgAddDeviceSet&) cmd;
|
2019-05-08 19:12:40 -04:00
|
|
|
int direction = notif.getDirection();
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-05-08 19:12:40 -04:00
|
|
|
if (direction == 1) { // Single stream Tx
|
2017-12-19 19:01:53 -05:00
|
|
|
addSinkDevice();
|
2019-05-08 19:12:40 -04:00
|
|
|
} else if (direction == 0) { // Single stream Rx
|
2017-12-19 19:01:53 -05:00
|
|
|
addSourceDevice();
|
2019-12-14 12:45:25 -05:00
|
|
|
}
|
2017-12-19 19:01:53 -05:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgRemoveLastDeviceSet::match(cmd))
|
|
|
|
{
|
|
|
|
if (m_deviceSets.size() > 0) {
|
|
|
|
removeLastDevice();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-21 18:07:59 -05:00
|
|
|
else if (MsgSetDevice::match(cmd))
|
|
|
|
{
|
|
|
|
MsgSetDevice& notif = (MsgSetDevice&) cmd;
|
|
|
|
|
2019-05-18 00:30:37 -04:00
|
|
|
if (notif.getDeviceType() == 1) {
|
2017-12-21 18:07:59 -05:00
|
|
|
changeSampleSink(notif.getDeviceSetIndex(), notif.getDeviceIndex());
|
2019-05-18 00:30:37 -04:00
|
|
|
} else if (notif.getDeviceType() == 0) {
|
2017-12-21 18:07:59 -05:00
|
|
|
changeSampleSource(notif.getDeviceSetIndex(), notif.getDeviceIndex());
|
2019-12-29 00:01:14 -05:00
|
|
|
} else if (notif.getDeviceType() == 2) {
|
|
|
|
changeSampleMIMO(notif.getDeviceSetIndex(), notif.getDeviceIndex());
|
|
|
|
}
|
2017-12-21 18:07:59 -05:00
|
|
|
return true;
|
|
|
|
}
|
2017-12-22 12:19:49 -05:00
|
|
|
else if (MsgAddChannel::match(cmd))
|
|
|
|
{
|
|
|
|
MsgAddChannel& notif = (MsgAddChannel&) cmd;
|
|
|
|
addChannel(notif.getDeviceSetIndex(), notif.getChannelRegistrationIndex());
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-23 16:33:30 -05:00
|
|
|
else if (MsgDeleteChannel::match(cmd))
|
|
|
|
{
|
|
|
|
MsgDeleteChannel& notif = (MsgDeleteChannel&) cmd;
|
|
|
|
deleteChannel(notif.getDeviceSetIndex(), notif.getChannelIndex());
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-20 21:13:36 -04:00
|
|
|
else if (MsgAddFeature::match(cmd))
|
|
|
|
{
|
|
|
|
MsgAddFeature& notif = (MsgAddFeature&) cmd;
|
|
|
|
addFeature(notif.getFeatureSetIndex(), notif.getFeatureRegistrationIndex());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (MsgDeleteFeature::match(cmd))
|
|
|
|
{
|
|
|
|
MsgDeleteFeature& notif = (MsgDeleteFeature&) cmd;
|
|
|
|
deleteFeature(notif.getFeatureSetIndex(), notif.getFeatureIndex());
|
|
|
|
return true;
|
|
|
|
}
|
2019-08-13 06:18:47 -04:00
|
|
|
else if (MsgApplySettings::match(cmd))
|
|
|
|
{
|
|
|
|
applySettings();
|
|
|
|
return true;
|
|
|
|
}
|
2017-12-17 17:15:42 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainCore::handleMessages()
|
|
|
|
{
|
|
|
|
Message* message;
|
|
|
|
|
|
|
|
while ((message = m_inputMessageQueue.pop()) != 0)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::handleMessages: message: %s", message->getIdentifier());
|
|
|
|
handleMessage(*message);
|
|
|
|
delete message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-18 07:56:10 -05:00
|
|
|
void MainCore::loadSettings()
|
|
|
|
{
|
|
|
|
qDebug() << "MainCore::loadSettings";
|
|
|
|
|
2020-09-23 23:38:05 -04:00
|
|
|
m_settings.load();
|
2017-12-18 07:56:10 -05:00
|
|
|
m_settings.sortPresets();
|
|
|
|
setLoggingOptions();
|
|
|
|
}
|
|
|
|
|
2019-08-13 06:18:47 -04:00
|
|
|
void MainCore::applySettings()
|
|
|
|
{
|
|
|
|
m_settings.sortPresets();
|
|
|
|
setLoggingOptions();
|
|
|
|
}
|
|
|
|
|
2017-12-18 07:56:10 -05:00
|
|
|
void MainCore::setLoggingOptions()
|
|
|
|
{
|
|
|
|
m_logger->setConsoleMinMessageLevel(m_settings.getConsoleMinLogLevel());
|
|
|
|
|
|
|
|
if (m_settings.getUseLogFile())
|
|
|
|
{
|
|
|
|
qtwebapp::FileLoggerSettings fileLoggerSettings; // default values
|
|
|
|
|
|
|
|
if (m_logger->hasFileLogger()) {
|
|
|
|
fileLoggerSettings = m_logger->getFileLoggerSettings(); // values from file logger if it exists
|
|
|
|
}
|
|
|
|
|
|
|
|
fileLoggerSettings.fileName = m_settings.getLogFileName(); // put new values
|
|
|
|
m_logger->createOrSetFileLogger(fileLoggerSettings, 2000); // create file logger if it does not exist and apply settings in any case
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_logger->hasFileLogger()) {
|
|
|
|
m_logger->setFileMinMessageLevel(m_settings.getFileMinLogLevel());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_logger->setUseFileLogger(m_settings.getUseLogFile());
|
2018-01-06 20:52:35 -05:00
|
|
|
|
|
|
|
if (m_settings.getUseLogFile())
|
|
|
|
{
|
|
|
|
#if QT_VERSION >= 0x050400
|
2018-01-22 17:29:09 -05:00
|
|
|
QString appInfoStr(tr("%1 %2 Qt %3 %4b %5 %6 DSP Rx:%7b Tx:%8b PID %9")
|
|
|
|
.arg(QCoreApplication::applicationName())
|
|
|
|
.arg(QCoreApplication::applicationVersion())
|
2018-01-06 20:52:35 -05:00
|
|
|
.arg(QT_VERSION_STR)
|
2018-01-06 21:20:27 -05:00
|
|
|
.arg(QT_POINTER_SIZE*8)
|
2018-01-06 20:52:35 -05:00
|
|
|
.arg(QSysInfo::currentCpuArchitecture())
|
2018-01-22 17:29:09 -05:00
|
|
|
.arg(QSysInfo::prettyProductName())
|
|
|
|
.arg(SDR_RX_SAMP_SZ)
|
|
|
|
.arg(SDR_TX_SAMP_SZ)
|
|
|
|
.arg(QCoreApplication::applicationPid()));
|
2018-01-06 20:52:35 -05:00
|
|
|
#else
|
2018-01-22 17:29:09 -05:00
|
|
|
QString appInfoStr(tr("%1 %2 Qt %3 %4b DSP Rx:%5b Tx:%6b PID %7")
|
|
|
|
.arg(QCoreApplication::applicationName())
|
|
|
|
.arg(QCoreApplication::applicationVersion())
|
2018-01-06 21:20:27 -05:00
|
|
|
.arg(QT_VERSION_STR)
|
2018-01-22 17:29:09 -05:00
|
|
|
.arg(QT_POINTER_SIZE*8)
|
|
|
|
.arg(SDR_RX_SAMP_SZ)
|
|
|
|
.arg(SDR_RX_SAMP_SZ)
|
|
|
|
.arg(QCoreApplication::applicationPid());
|
2018-01-06 21:20:27 -05:00
|
|
|
#endif
|
2018-01-06 20:52:35 -05:00
|
|
|
m_logger->logToFile(QtInfoMsg, appInfoStr);
|
|
|
|
}
|
2017-12-18 07:56:10 -05:00
|
|
|
}
|
|
|
|
|
2017-12-19 19:01:53 -05:00
|
|
|
void MainCore::addSinkDevice()
|
|
|
|
{
|
|
|
|
DSPDeviceSinkEngine *dspDeviceSinkEngine = m_dspEngine->addDeviceSinkEngine();
|
|
|
|
dspDeviceSinkEngine->start();
|
|
|
|
|
|
|
|
uint dspDeviceSinkEngineUID = dspDeviceSinkEngine->getUID();
|
|
|
|
char uidCStr[16];
|
|
|
|
sprintf(uidCStr, "UID:%d", dspDeviceSinkEngineUID);
|
|
|
|
|
|
|
|
int deviceTabIndex = m_deviceSets.size();
|
|
|
|
m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
|
2019-12-14 12:45:25 -05:00
|
|
|
m_deviceSets.back()->m_deviceSourceEngine = nullptr;
|
|
|
|
m_deviceSets.back()->m_deviceSinkEngine = dspDeviceSinkEngine;
|
|
|
|
m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
|
2017-12-19 19:01:53 -05:00
|
|
|
|
|
|
|
char tabNameCStr[16];
|
|
|
|
sprintf(tabNameCStr, "T%d", deviceTabIndex);
|
|
|
|
|
2019-05-18 00:30:37 -04:00
|
|
|
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleTx, deviceTabIndex, nullptr, dspDeviceSinkEngine, nullptr);
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI = deviceAPI;
|
2017-12-19 19:01:53 -05:00
|
|
|
QList<QString> channelNames;
|
|
|
|
|
|
|
|
// create a file sink by default
|
2020-08-03 18:53:34 -04:00
|
|
|
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex();
|
2019-05-08 19:12:40 -04:00
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
2019-05-20 18:27:08 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
2019-05-08 19:12:40 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-06-13 19:14:27 -04:00
|
|
|
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
|
|
|
|
|
|
|
if (userArgs.size() > 0) {
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
|
|
|
|
}
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSink *sink = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSampleSink(sink);
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainCore::addSourceDevice()
|
|
|
|
{
|
|
|
|
DSPDeviceSourceEngine *dspDeviceSourceEngine = m_dspEngine->addDeviceSourceEngine();
|
|
|
|
dspDeviceSourceEngine->start();
|
|
|
|
|
|
|
|
uint dspDeviceSourceEngineUID = dspDeviceSourceEngine->getUID();
|
|
|
|
char uidCStr[16];
|
|
|
|
sprintf(uidCStr, "UID:%d", dspDeviceSourceEngineUID);
|
|
|
|
|
|
|
|
int deviceTabIndex = m_deviceSets.size();
|
|
|
|
m_deviceSets.push_back(new DeviceSet(deviceTabIndex));
|
|
|
|
m_deviceSets.back()->m_deviceSourceEngine = dspDeviceSourceEngine;
|
2019-12-14 12:45:25 -05:00
|
|
|
m_deviceSets.back()->m_deviceSinkEngine = nullptr;
|
|
|
|
m_deviceSets.back()->m_deviceMIMOEngine = nullptr;
|
2017-12-19 19:01:53 -05:00
|
|
|
|
|
|
|
char tabNameCStr[16];
|
|
|
|
sprintf(tabNameCStr, "R%d", deviceTabIndex);
|
|
|
|
|
2019-05-18 00:30:37 -04:00
|
|
|
DeviceAPI *deviceAPI = new DeviceAPI(DeviceAPI::StreamSingleRx, deviceTabIndex, dspDeviceSourceEngine, nullptr, nullptr);
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI = deviceAPI;
|
2017-12-19 19:01:53 -05:00
|
|
|
|
|
|
|
// Create a file source instance by default
|
2019-07-07 18:59:04 -04:00
|
|
|
int fileSourceDeviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
|
2019-05-08 19:12:40 -04:00
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(fileSourceDeviceIndex);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
2019-05-20 18:27:08 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
2019-05-08 19:12:40 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(fileSourceDeviceIndex));
|
|
|
|
|
2019-06-13 19:14:27 -04:00
|
|
|
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
|
|
|
|
|
|
|
if (userArgs.size() > 0) {
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setHardwareUserArguments(userArgs);
|
|
|
|
}
|
|
|
|
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSource *source = m_deviceSets.back()->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->getSamplingDeviceId(), m_deviceSets.back()->m_deviceAPI);
|
|
|
|
m_deviceSets.back()->m_deviceAPI->setSampleSource(source);
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainCore::removeLastDevice()
|
|
|
|
{
|
|
|
|
if (m_deviceSets.back()->m_deviceSourceEngine) // source set
|
|
|
|
{
|
|
|
|
DSPDeviceSourceEngine *lastDeviceEngine = m_deviceSets.back()->m_deviceSourceEngine;
|
|
|
|
lastDeviceEngine->stopAcquistion();
|
|
|
|
|
|
|
|
// deletes old UI and input object
|
2019-09-07 18:44:56 -04:00
|
|
|
m_deviceSets.back()->freeChannels(); // destroys the channel instances
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
|
|
|
|
m_deviceSets.back()->m_deviceAPI->getSampleSource());
|
|
|
|
m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *sourceAPI = m_deviceSets.back()->m_deviceAPI;
|
2017-12-19 19:01:53 -05:00
|
|
|
delete m_deviceSets.back();
|
|
|
|
|
|
|
|
lastDeviceEngine->stop();
|
|
|
|
m_dspEngine->removeLastDeviceSourceEngine();
|
2018-02-14 18:27:29 -05:00
|
|
|
|
|
|
|
delete sourceAPI;
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
|
|
|
else if (m_deviceSets.back()->m_deviceSinkEngine) // sink set
|
|
|
|
{
|
|
|
|
DSPDeviceSinkEngine *lastDeviceEngine = m_deviceSets.back()->m_deviceSinkEngine;
|
|
|
|
lastDeviceEngine->stopGeneration();
|
|
|
|
|
|
|
|
// deletes old UI and output object
|
2019-09-07 18:44:56 -04:00
|
|
|
m_deviceSets.back()->freeChannels();
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceSets.back()->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
m_deviceSets.back()->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
|
|
|
|
m_deviceSets.back()->m_deviceAPI->getSampleSink());
|
|
|
|
m_deviceSets.back()->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2017-12-19 19:01:53 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DeviceAPI *sinkAPI = m_deviceSets.back()->m_deviceAPI;
|
2017-12-19 19:01:53 -05:00
|
|
|
delete m_deviceSets.back();
|
|
|
|
|
|
|
|
lastDeviceEngine->stop();
|
|
|
|
m_dspEngine->removeLastDeviceSinkEngine();
|
2018-02-14 18:27:29 -05:00
|
|
|
|
|
|
|
delete sinkAPI;
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
m_deviceSets.pop_back();
|
|
|
|
}
|
|
|
|
|
2017-12-21 18:07:59 -05:00
|
|
|
void MainCore::changeSampleSource(int deviceSetIndex, int selectedDeviceIndex)
|
|
|
|
{
|
|
|
|
if (deviceSetIndex >= 0)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::changeSampleSource: deviceSet at %d", deviceSetIndex);
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
|
|
|
|
deviceSet->m_deviceAPI->stopDeviceEngine();
|
2017-12-21 18:07:59 -05:00
|
|
|
|
|
|
|
// deletes old UI and input object
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceSet->m_deviceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
|
|
|
|
deviceSet->m_deviceAPI->getSampleSource());
|
|
|
|
deviceSet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2017-12-21 18:07:59 -05:00
|
|
|
|
2019-05-08 19:12:40 -04:00
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(selectedDeviceIndex);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
2019-05-20 18:27:08 -04:00
|
|
|
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
2019-05-08 19:12:40 -04:00
|
|
|
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(selectedDeviceIndex));
|
2017-12-21 18:07:59 -05:00
|
|
|
|
2020-05-20 02:27:39 -04:00
|
|
|
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
|
|
|
|
{
|
|
|
|
qDebug("MainCore::changeSampleSource: non existent device replaced by File Input");
|
|
|
|
int deviceIndex = DeviceEnumerator::instance()->getFileInputDeviceIndex();
|
|
|
|
samplingDevice = DeviceEnumerator::instance()->getRxSamplingDevice(deviceIndex);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getRxPluginInterface(deviceIndex));
|
|
|
|
}
|
|
|
|
|
2017-12-21 18:07:59 -05:00
|
|
|
// add to buddies list
|
|
|
|
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
|
|
|
|
int nbOfBuddies = 0;
|
|
|
|
|
|
|
|
for (; it != m_deviceSets.end(); ++it)
|
|
|
|
{
|
|
|
|
if (*it != deviceSet) // do not add to itself
|
|
|
|
{
|
|
|
|
if ((*it)->m_deviceSourceEngine) // it is a source device
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
2017-12-21 18:07:59 -05:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
(*it)->m_deviceAPI->addSourceBuddy(deviceSet->m_deviceAPI);
|
2017-12-21 18:07:59 -05:00
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
2017-12-21 18:07:59 -05:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
(*it)->m_deviceAPI->addSourceBuddy(deviceSet->m_deviceAPI);
|
2017-12-21 18:07:59 -05:00
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbOfBuddies == 0) {
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->setBuddyLeader(true);
|
2017-12-21 18:07:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// constructs new GUI and input object
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSource *source = deviceSet->m_deviceAPI->getPluginInterface()->createSampleSourcePluginInstance(
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
|
|
|
|
deviceSet->m_deviceAPI->setSampleSource(source);
|
2017-12-28 11:22:18 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
|
2017-12-21 18:07:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainCore::changeSampleSink(int deviceSetIndex, int selectedDeviceIndex)
|
|
|
|
{
|
|
|
|
if (deviceSetIndex >= 0)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::changeSampleSink: device set at %d", deviceSetIndex);
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
|
|
|
|
deviceSet->m_deviceAPI->stopDeviceEngine();
|
2017-12-21 18:07:59 -05:00
|
|
|
|
|
|
|
// deletes old UI and output object
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceSet->m_deviceAPI->getPluginInterface()->deleteSampleSinkPluginInstanceOutput(
|
|
|
|
deviceSet->m_deviceAPI->getSampleSink());
|
|
|
|
deviceSet->m_deviceAPI->clearBuddiesLists(); // clear old API buddies lists
|
2017-12-21 18:07:59 -05:00
|
|
|
|
2019-05-08 19:12:40 -04:00
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(selectedDeviceIndex);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
2019-05-20 18:27:08 -04:00
|
|
|
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
2019-05-08 19:12:40 -04:00
|
|
|
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(selectedDeviceIndex));
|
2017-12-21 18:07:59 -05:00
|
|
|
|
2020-05-20 02:27:39 -04:00
|
|
|
if (deviceSet->m_deviceAPI->getSamplingDeviceId().size() == 0) // non existent device => replace by default
|
|
|
|
{
|
|
|
|
qDebug("MainCore::changeSampleSink: non existent device replaced by File Sink");
|
2020-08-03 18:53:34 -04:00
|
|
|
int fileSinkDeviceIndex = DeviceEnumerator::instance()->getFileOutputDeviceIndex();
|
2020-05-20 02:27:39 -04:00
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getTxSamplingDevice(fileSinkDeviceIndex);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getTxPluginInterface(fileSinkDeviceIndex));
|
|
|
|
}
|
|
|
|
|
2017-12-21 18:07:59 -05:00
|
|
|
// add to buddies list
|
|
|
|
std::vector<DeviceSet*>::iterator it = m_deviceSets.begin();
|
|
|
|
int nbOfBuddies = 0;
|
|
|
|
|
|
|
|
for (; it != m_deviceSets.end(); ++it)
|
|
|
|
{
|
|
|
|
if (*it != deviceSet) // do not add to itself
|
|
|
|
{
|
|
|
|
if ((*it)->m_deviceSourceEngine) // it is a source device
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
2017-12-21 18:07:59 -05:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
(*it)->m_deviceAPI->addSinkBuddy(deviceSet->m_deviceAPI);
|
2017-12-21 18:07:59 -05:00
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((*it)->m_deviceSinkEngine) // it is a sink device
|
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
if ((deviceSet->m_deviceAPI->getHardwareId() == (*it)->m_deviceAPI->getHardwareId()) &&
|
|
|
|
(deviceSet->m_deviceAPI->getSamplingDeviceSerial() == (*it)->m_deviceAPI->getSamplingDeviceSerial()))
|
2017-12-21 18:07:59 -05:00
|
|
|
{
|
2019-05-08 16:11:53 -04:00
|
|
|
(*it)->m_deviceAPI->addSinkBuddy(deviceSet->m_deviceAPI);
|
2017-12-21 18:07:59 -05:00
|
|
|
nbOfBuddies++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nbOfBuddies == 0) {
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->setBuddyLeader(true);
|
2017-12-21 18:07:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// constructs new GUI and output object
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSink *sink = deviceSet->m_deviceAPI->getPluginInterface()->createSampleSinkPluginInstance(
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
|
|
|
|
deviceSet->m_deviceAPI->setSampleSink(sink);
|
2017-12-28 11:22:18 -05:00
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
|
2017-12-21 18:07:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-29 00:01:14 -05:00
|
|
|
void MainCore::changeSampleMIMO(int deviceSetIndex, int selectedDeviceIndex)
|
|
|
|
{
|
|
|
|
if (deviceSetIndex >= 0)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::changeSampleMIMO: device set at %d", deviceSetIndex);
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
|
|
|
|
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(m_settings.getWorkingPreset()); // save old API settings
|
|
|
|
deviceSet->m_deviceAPI->stopDeviceEngine();
|
|
|
|
|
|
|
|
// deletes old UI and output object
|
|
|
|
deviceSet->m_deviceAPI->resetSamplingDeviceId();
|
|
|
|
deviceSet->m_deviceAPI->getPluginInterface()->deleteSampleMIMOPluginInstanceMIMO(
|
|
|
|
deviceSet->m_deviceAPI->getSampleMIMO());
|
|
|
|
|
|
|
|
const PluginInterface::SamplingDevice *samplingDevice = DeviceEnumerator::instance()->getMIMOSamplingDevice(selectedDeviceIndex);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSequence(samplingDevice->sequence);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceNbItems(samplingDevice->deviceNbItems);
|
|
|
|
deviceSet->m_deviceAPI->setDeviceItemIndex(samplingDevice->deviceItemIndex);
|
|
|
|
deviceSet->m_deviceAPI->setHardwareId(samplingDevice->hardwareId);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceId(samplingDevice->id);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceSerial(samplingDevice->serial);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDeviceDisplayName(samplingDevice->displayedName);
|
|
|
|
deviceSet->m_deviceAPI->setSamplingDevicePluginInterface(DeviceEnumerator::instance()->getMIMOPluginInterface(selectedDeviceIndex));
|
|
|
|
|
|
|
|
QString userArgs = m_settings.getDeviceUserArgs().findUserArgs(samplingDevice->hardwareId, samplingDevice->sequence);
|
|
|
|
|
|
|
|
if (userArgs.size() > 0) {
|
|
|
|
deviceSet->m_deviceAPI->setHardwareUserArguments(userArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
// constructs new GUI and MIMO object
|
|
|
|
DeviceSampleMIMO *mimo = deviceSet->m_deviceAPI->getPluginInterface()->createSampleMIMOPluginInstance(
|
|
|
|
deviceSet->m_deviceAPI->getSamplingDeviceId(), deviceSet->m_deviceAPI);
|
|
|
|
deviceSet->m_deviceAPI->setSampleMIMO(mimo);
|
|
|
|
|
|
|
|
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(m_settings.getWorkingPreset()); // load new API settings
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-22 12:19:49 -05:00
|
|
|
void MainCore::addChannel(int deviceSetIndex, int selectedChannelIndex)
|
|
|
|
{
|
|
|
|
if (deviceSetIndex >= 0)
|
|
|
|
{
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
|
|
|
|
|
|
|
|
if (deviceSet->m_deviceSourceEngine) // source device => Rx channels
|
|
|
|
{
|
2017-12-22 23:56:40 -05:00
|
|
|
deviceSet->addRxChannel(selectedChannelIndex, m_pluginManager->getPluginAPI());
|
2017-12-22 12:19:49 -05:00
|
|
|
}
|
|
|
|
else if (deviceSet->m_deviceSinkEngine) // sink device => Tx channels
|
|
|
|
{
|
2017-12-22 23:56:40 -05:00
|
|
|
deviceSet->addTxChannel(selectedChannelIndex, m_pluginManager->getPluginAPI());
|
2017-12-22 12:19:49 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-23 16:33:30 -05:00
|
|
|
void MainCore::deleteChannel(int deviceSetIndex, int channelIndex)
|
|
|
|
{
|
|
|
|
if (deviceSetIndex >= 0)
|
|
|
|
{
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[deviceSetIndex];
|
2019-09-07 18:44:56 -04:00
|
|
|
deviceSet->deleteChannel(channelIndex);
|
2017-12-23 16:33:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-20 21:13:36 -04:00
|
|
|
void MainCore::addFeature(int featureSetIndex, int featureIndex)
|
|
|
|
{
|
|
|
|
if (featureSetIndex >= 0)
|
|
|
|
{
|
|
|
|
FeatureSet *featureSet = m_featureSets[featureSetIndex];
|
|
|
|
featureSet->addFeature(featureSetIndex, m_pluginManager->getPluginAPI(), m_apiAdapter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainCore::deleteFeature(int featureSetIndex, int featureIndex)
|
|
|
|
{
|
|
|
|
if ((featureSetIndex >= 0) && (featureSetIndex < (int) m_featureSets.size()))
|
|
|
|
{
|
|
|
|
FeatureSet *featureSet = m_featureSets[featureSetIndex];
|
|
|
|
featureSet->deleteFeature(featureIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-20 08:31:17 -05:00
|
|
|
void MainCore::loadPresetSettings(const Preset* preset, int tabIndex)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::loadPresetSettings: preset [%s | %s]",
|
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
if (tabIndex >= 0)
|
|
|
|
{
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[tabIndex];
|
2019-09-13 07:40:31 -04:00
|
|
|
deviceSet->m_deviceAPI->loadSamplingDeviceSettings(preset);
|
2017-12-20 08:31:17 -05:00
|
|
|
|
2019-09-13 07:40:31 -04:00
|
|
|
if (deviceSet->m_deviceSourceEngine) { // source device
|
2017-12-20 08:31:17 -05:00
|
|
|
deviceSet->loadRxChannelSettings(preset, m_pluginManager->getPluginAPI());
|
2019-09-13 07:40:31 -04:00
|
|
|
} else if (deviceSet->m_deviceSinkEngine) { // sink device
|
2017-12-20 08:31:17 -05:00
|
|
|
deviceSet->loadTxChannelSettings(preset, m_pluginManager->getPluginAPI());
|
2019-09-13 07:40:31 -04:00
|
|
|
} else if (deviceSet->m_deviceMIMOEngine) { // MIMO device
|
|
|
|
deviceSet->loadMIMOChannelSettings(preset, m_pluginManager->getPluginAPI());
|
2017-12-20 08:31:17 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-19 19:01:53 -05:00
|
|
|
void MainCore::savePresetSettings(Preset* preset, int tabIndex)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::savePresetSettings: preset [%s | %s]",
|
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
// Save from currently selected source tab
|
|
|
|
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
|
|
|
|
DeviceSet *deviceSet = m_deviceSets[tabIndex];
|
|
|
|
|
|
|
|
if (deviceSet->m_deviceSourceEngine) // source device
|
|
|
|
{
|
|
|
|
preset->clearChannels();
|
2019-09-13 07:40:31 -04:00
|
|
|
preset->setSourcePreset();
|
2017-12-19 19:01:53 -05:00
|
|
|
deviceSet->saveRxChannelSettings(preset);
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(preset);
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
|
|
|
else if (deviceSet->m_deviceSinkEngine) // sink device
|
|
|
|
{
|
|
|
|
preset->clearChannels();
|
2019-09-13 07:40:31 -04:00
|
|
|
preset->setSinkPreset();
|
2017-12-19 19:01:53 -05:00
|
|
|
deviceSet->saveTxChannelSettings(preset);
|
2019-05-08 16:11:53 -04:00
|
|
|
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(preset);
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
2019-09-13 07:40:31 -04:00
|
|
|
else if (deviceSet->m_deviceMIMOEngine) // MIMO device
|
|
|
|
{
|
|
|
|
preset->clearChannels();
|
|
|
|
preset->setMIMOPreset();
|
|
|
|
deviceSet->saveMIMOChannelSettings(preset);
|
|
|
|
deviceSet->m_deviceAPI->saveSamplingDeviceSettings(preset);
|
|
|
|
}
|
2017-12-19 19:01:53 -05:00
|
|
|
}
|
|
|
|
|
2020-09-23 23:38:05 -04:00
|
|
|
void MainCore::loadFeatureSetPresetSettings(const FeatureSetPreset* preset, int featureSetIndex)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::loadFeatureSetPresetSettings: preset [%s | %s]",
|
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
if (featureSetIndex >= 0)
|
|
|
|
{
|
|
|
|
FeatureSet *featureSet = m_featureSets[featureSetIndex];
|
|
|
|
featureSet->loadFeatureSetSettings(preset, m_pluginManager->getPluginAPI(), m_apiAdapter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainCore::saveFeatureSetPresetSettings(FeatureSetPreset* preset, int featureSetIndex)
|
|
|
|
{
|
|
|
|
qDebug("MainCore::saveFeatureSetPresetSettings: preset [%s | %s]",
|
|
|
|
qPrintable(preset->getGroup()),
|
|
|
|
qPrintable(preset->getDescription()));
|
|
|
|
|
|
|
|
// Save from currently selected source tab
|
|
|
|
//int currentSourceTabIndex = ui->tabInputsView->currentIndex();
|
|
|
|
FeatureSet *featureSet = m_featureSets[featureSetIndex];
|
|
|
|
|
|
|
|
preset->clearFeatures();
|
|
|
|
featureSet->saveFeatureSetSettings(preset);
|
|
|
|
}
|