| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-19 06:43:20 +01:00
										 |  |  | // Copyright (C) 2020-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>          //
 | 
					
						
							|  |  |  | // Copyright (C) 2021-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							|  |  |  | // Copyright (C) 2023 Mohamed <mohamedadlyi@github.com>                          //
 | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | // (at your option) any later version.                                           //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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 <QGlobalStatic>
 | 
					
						
							|  |  |  | #include <QCoreApplication>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							| 
									
										
										
										
											2022-12-20 21:06:39 +00:00
										 |  |  | #include <QDebug>
 | 
					
						
							|  |  |  | #include <QGeoPositionInfoSource>
 | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "loggerwithfile.h"
 | 
					
						
							|  |  |  | #include "dsp/dsptypes.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  | #include "feature/featureset.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  | #include "feature/feature.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-11 08:27:58 +02:00
										 |  |  | #include "device/deviceset.h"
 | 
					
						
							| 
									
										
										
										
											2022-04-12 16:20:45 +02:00
										 |  |  | #include "device/deviceapi.h"
 | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  | #include "channel/channelapi.h"
 | 
					
						
							| 
									
										
										
										
											2023-02-17 21:57:09 +00:00
										 |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  | #include "util/android.h"
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "maincore.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-10 20:08:11 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDVSerial, Message) | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteInstance, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadPreset, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgSavePreset, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeletePreset, Message) | 
					
						
							| 
									
										
										
										
											2022-05-08 19:33:10 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadConfiguration, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgSaveConfiguration, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteConfiguration, Message) | 
					
						
							| 
									
										
										
										
											2022-05-09 21:31:14 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgAddWorkspace, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteEmptyWorkspaces, Message) | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgLoadFeatureSetPreset, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgSaveFeatureSetPreset, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteFeatureSetPreset, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgAddDeviceSet, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgRemoveLastDeviceSet, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgSetDevice, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgAddChannel, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteChannel, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgApplySettings, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgAddFeature, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgDeleteFeature, Message) | 
					
						
							| 
									
										
										
										
											2020-11-29 09:26:32 +01:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelReport, Message) | 
					
						
							| 
									
										
										
										
											2020-12-13 13:04:36 +01:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelSettings, Message) | 
					
						
							| 
									
										
										
										
											2020-12-20 01:53:03 +01:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelDemodReport, Message) | 
					
						
							| 
									
										
										
										
											2021-06-29 21:47:27 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgChannelDemodQuery, Message) | 
					
						
							| 
									
										
										
										
											2022-05-13 22:24:48 +02:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveDeviceUIToWorkspace, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveMainSpectrumUIToWorkspace, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveFeatureUIToWorkspace, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgMoveChannelUIToWorkspace, Message) | 
					
						
							| 
									
										
										
										
											2021-01-13 17:07:38 +00:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgMapItem, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgPacket, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgTargetAzimuthElevation, Message) | 
					
						
							| 
									
										
										
										
											2021-10-12 11:07:56 +01:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgStarTrackerTarget, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgStarTrackerDisplaySettings, Message) | 
					
						
							|  |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgStarTrackerDisplayLoSSettings, Message) | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | MESSAGE_CLASS_DEFINITION(MainCore::MsgSkyMapTarget, Message) | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | MainCore::MainCore() | 
					
						
							| 
									
										
										
										
											2020-10-11 19:58:45 +02:00
										 |  |  | { | 
					
						
							|  |  |  | 	m_masterTimer.setTimerType(Qt::PreciseTimer); | 
					
						
							|  |  |  | 	m_masterTimer.start(50); | 
					
						
							| 
									
										
										
										
											2022-03-15 22:21:06 +01:00
										 |  |  |     m_startMsecsSinceEpoch = QDateTime::currentMSecsSinceEpoch(); | 
					
						
							|  |  |  |     m_masterElapsedTimer.start(); | 
					
						
							| 
									
										
										
										
											2022-12-20 21:06:39 +00:00
										 |  |  |     // Position can take a while to determine, so we start updates at program startup
 | 
					
						
							|  |  |  |     initPosition(); | 
					
						
							| 
									
										
										
										
											2023-02-17 21:57:09 +00:00
										 |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  |     QObject::connect(this, &MainCore::deviceStateChanged, this, &MainCore::updateWakeLock); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2020-10-11 19:58:45 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | MainCore::~MainCore() | 
					
						
							|  |  |  | {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Q_GLOBAL_STATIC(MainCore, mainCore) | 
					
						
							|  |  |  | MainCore *MainCore::instance() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return mainCore; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::setLoggingOptions() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-01-02 15:30:34 +00:00
										 |  |  |     if (!m_logger) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qDebug() << "MainCore::setLoggingOptions: No logger."; | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  |     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()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (m_settings.getUseLogFile()) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-11-04 22:52:15 +01:00
										 |  |  | #if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
 | 
					
						
							| 
									
										
										
										
											2020-10-09 08:52:30 +02:00
										 |  |  |         QString appInfoStr(QString("%1 %2 Qt %3 %4b %5 %6 DSP Rx:%7b Tx:%8b PID %9") | 
					
						
							|  |  |  |                 .arg(QCoreApplication::applicationName()) | 
					
						
							|  |  |  |                 .arg(QCoreApplication::applicationVersion()) | 
					
						
							|  |  |  |                 .arg(QT_VERSION_STR) | 
					
						
							|  |  |  |                 .arg(QT_POINTER_SIZE*8) | 
					
						
							|  |  |  |                 .arg(QSysInfo::currentCpuArchitecture()) | 
					
						
							|  |  |  |                 .arg(QSysInfo::prettyProductName()) | 
					
						
							|  |  |  |                 .arg(SDR_RX_SAMP_SZ) | 
					
						
							|  |  |  |                 .arg(SDR_TX_SAMP_SZ) | 
					
						
							|  |  |  |                 .arg(QCoreApplication::applicationPid())); | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  |         QString appInfoStr(QString("%1 %2 Qt %3 %4b DSP Rx:%5b Tx:%6b PID %7") | 
					
						
							|  |  |  |                 .arg(QCoreApplication::applicationName()) | 
					
						
							|  |  |  |                 .arg(QCoreApplication::applicationVersion()) | 
					
						
							|  |  |  |                 .arg(QT_VERSION_STR) | 
					
						
							|  |  |  |                 .arg(QT_POINTER_SIZE*8) | 
					
						
							|  |  |  |                 .arg(SDR_RX_SAMP_SZ) | 
					
						
							|  |  |  |                 .arg(SDR_RX_SAMP_SZ) | 
					
						
							|  |  |  |                 .arg(QCoreApplication::applicationPid()); | 
					
						
							|  |  |  |  #endif
 | 
					
						
							|  |  |  |         m_logger->logToFile(QtInfoMsg, appInfoStr); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  | DeviceAPI *MainCore::getDevice(unsigned int deviceSetIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (deviceSetIndex < m_deviceSets.size()) { | 
					
						
							|  |  |  |         return m_deviceSets[deviceSetIndex]->m_deviceAPI; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-14 22:08:06 +01:00
										 |  |  | ChannelAPI *MainCore::getChannel(unsigned int deviceSetIndex, int channelIndex) | 
					
						
							| 
									
										
										
										
											2020-10-13 08:15:21 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-14 22:08:06 +01:00
										 |  |  |     if (deviceSetIndex < m_deviceSets.size()) { | 
					
						
							| 
									
										
										
										
											2020-10-13 08:15:21 +02:00
										 |  |  |         return m_deviceSets[deviceSetIndex]->getChannelAt(channelIndex); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-14 22:08:06 +01:00
										 |  |  | Feature *MainCore::getFeature(unsigned int featureSetIndex, int featureIndex) | 
					
						
							| 
									
										
										
										
											2020-10-13 08:15:21 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-11-14 22:08:06 +01:00
										 |  |  |     if (featureSetIndex < m_featureSets.size()) { | 
					
						
							| 
									
										
										
										
											2020-10-13 08:15:21 +02:00
										 |  |  |         return m_featureSets[featureSetIndex]->getFeatureAt(featureIndex); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return nullptr; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  | void MainCore::appendFeatureSet() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int newIndex = m_featureSets.size(); | 
					
						
							| 
									
										
										
										
											2022-05-16 20:51:15 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (newIndex != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         qWarning("MainCore::appendFeatureSet: attempt to add more than one feature set (%d)", newIndex); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     FeatureSet *featureSet = new FeatureSet(newIndex); | 
					
						
							|  |  |  |     m_featureSets.push_back(featureSet); | 
					
						
							|  |  |  |     m_featureSetsMap.insert(featureSet, newIndex); | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-14 22:08:06 +01:00
										 |  |  | void MainCore::removeFeatureSet(unsigned int index) | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     if (index < m_featureSets.size()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         FeatureSet *featureSet = m_featureSets[index]; | 
					
						
							|  |  |  |         m_featureSetsMap.remove(featureSet); | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  |         m_featureSets.erase(m_featureSets.begin() + index); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::removeLastFeatureSet() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     if (m_featureSets.size() != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         FeatureSet *featureSet = m_featureSets.back(); | 
					
						
							|  |  |  |         m_featureSetsMap.remove(featureSet); | 
					
						
							| 
									
										
										
										
											2020-10-11 00:22:42 +02:00
										 |  |  |         m_featureSets.pop_back(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-11 08:27:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void MainCore::appendDeviceSet(int deviceType) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int newIndex = m_deviceSets.size(); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     DeviceSet *deviceSet = new DeviceSet(newIndex, deviceType); | 
					
						
							|  |  |  |     m_deviceSets.push_back(deviceSet); | 
					
						
							|  |  |  |     m_deviceSetsMap.insert(deviceSet, newIndex); | 
					
						
							| 
									
										
										
										
											2020-10-11 08:27:58 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::removeLastDeviceSet() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     if (m_deviceSets.size() != 0) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_deviceSets.back(); | 
					
						
							|  |  |  |         m_deviceSetsMap.remove(deviceSet); | 
					
						
							| 
									
										
										
										
											2020-10-11 08:27:58 +02:00
										 |  |  |         m_deviceSets.pop_back(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 16:20:45 +02:00
										 |  |  | void MainCore::removeDeviceSet(int deviceSetIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (deviceSetIndex < (int) m_deviceSets.size()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DeviceSet *deviceSet = m_deviceSets[deviceSetIndex]; | 
					
						
							|  |  |  |         m_deviceSetsMap.remove(deviceSet); | 
					
						
							|  |  |  |         m_deviceSets.erase(m_deviceSets.begin() + deviceSetIndex); | 
					
						
							|  |  |  |         delete deviceSet; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Renumerate
 | 
					
						
							|  |  |  |     for (int i = 0; i < (int) m_deviceSets.size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_deviceSets[i]->m_deviceAPI->setDeviceSetIndex(i); | 
					
						
							|  |  |  |         m_deviceSets[i]->setIndex(i); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  | void MainCore::addChannelInstance(DeviceSet *deviceSet, ChannelAPI *channelAPI) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_channelsMap.insert(channelAPI, deviceSet); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |     emit channelAdded(m_deviceSetsMap[deviceSet], channelAPI); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     // debugMaps();
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::removeChannelInstanceAt(DeviceSet *deviceSet, int channelIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int deviceSetIndex = m_deviceSetsMap[deviceSet]; | 
					
						
							|  |  |  |     ChannelAPI *channelAPI = m_deviceSets[deviceSetIndex]->getChannelAt(channelIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |     if (channelAPI) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |         m_channelsMap.remove(channelAPI); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |         emit channelRemoved(deviceSetIndex, channelAPI); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::removeChannelInstance(ChannelAPI *channelAPI) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |     if (channelAPI) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int deviceSetIndex = m_deviceSetsMap[m_channelsMap[channelAPI]]; | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |         m_channelsMap.remove(channelAPI); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |         emit channelRemoved(deviceSetIndex, channelAPI); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::clearChannels(DeviceSet *deviceSet) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (int i = 0; i < deviceSet->getNumberOfChannels(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         ChannelAPI *channelAPI = deviceSet->getChannelAt(i); | 
					
						
							|  |  |  |         m_channelsMap.remove(channelAPI); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |         emit channelRemoved(m_deviceSetsMap[deviceSet], channelAPI); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::addFeatureInstance(FeatureSet *featureSet, Feature *feature) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_featuresMap.insert(feature, featureSet); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |     emit featureAdded(m_featureSetsMap[featureSet], feature); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     // debugMaps();
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::removeFeatureInstanceAt(FeatureSet *featureSet, int featureIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     int featureSetIndex = m_featureSetsMap[featureSet]; | 
					
						
							|  |  |  |     Feature *feature = m_featureSets[featureSetIndex]->getFeatureAt(featureIndex); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |     if (feature) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |         m_featuresMap.remove(feature); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |         emit featureRemoved(featureSetIndex, feature); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::removeFeatureInstance(Feature *feature) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |     if (feature) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         int featureSetIndex = m_featureSetsMap[m_featuresMap[feature]]; | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |         m_featuresMap.remove(feature); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |         emit featureRemoved(featureSetIndex, feature); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::clearFeatures(FeatureSet *featureSet) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (int i = 0; i < featureSet->getNumberOfFeatures(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         Feature *feature = featureSet->getFeatureAt(i); | 
					
						
							|  |  |  |         m_featuresMap.remove(feature); | 
					
						
							| 
									
										
										
										
											2022-03-12 05:45:24 +01:00
										 |  |  |         emit featureRemoved(m_featureSetsMap[featureSet], feature); | 
					
						
							| 
									
										
										
										
											2020-10-16 08:35:06 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::debugMaps() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QMap<DeviceSet*, int>::const_iterator dsIt = m_deviceSetsMap.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (; dsIt != m_deviceSetsMap.end(); ++dsIt) { | 
					
						
							|  |  |  |         qDebug("MainCore::debugMaps: device set %d #%d", dsIt.key()->getIndex(), dsIt.value()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMap<FeatureSet*, int>::const_iterator fsIt = m_featureSetsMap.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (; fsIt != m_featureSetsMap.end(); ++fsIt) { | 
					
						
							|  |  |  |         qDebug("MainCore::debugMaps: feature set %d #%d", fsIt.key()->getIndex(), fsIt.value()); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMap<ChannelAPI*, DeviceSet*>::const_iterator chIt = m_channelsMap.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (; chIt != m_channelsMap.end(); ++chIt) { | 
					
						
							|  |  |  |         qDebug("MainCore::debugMaps: channel ds: %d - %d: %s %s", | 
					
						
							|  |  |  |             chIt.value()->getIndex(), chIt.key()->getIndexInDeviceSet(), qPrintable(chIt.key()->getURI()), qPrintable(chIt.key()->getName())); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QMap<Feature*, FeatureSet*>::const_iterator feIt = m_featuresMap.begin(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (; feIt != m_featuresMap.end(); ++feIt) { | 
					
						
							|  |  |  |         qDebug("MainCore::debugMaps: feature fs: %d - %d: %s %s", | 
					
						
							|  |  |  |             feIt.value()->getIndex(), feIt.key()->getIndexInFeatureSet(), qPrintable(feIt.key()->getURI()), qPrintable(feIt.key()->getName())); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-12-20 21:06:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void MainCore::initPosition() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_positionSource = QGeoPositionInfoSource::createDefaultSource(this); | 
					
						
							|  |  |  |     if (m_positionSource) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         connect(m_positionSource, &QGeoPositionInfoSource::positionUpdated, this, &MainCore::positionUpdated); | 
					
						
							| 
									
										
										
										
											2023-04-10 15:57:16 +01:00
										 |  |  | #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
 | 
					
						
							| 
									
										
										
										
											2023-01-02 15:30:34 +00:00
										 |  |  |         connect(m_positionSource, &QGeoPositionInfoSource::updateTimeout, this, &MainCore::positionUpdateTimeout); | 
					
						
							|  |  |  |         connect(m_positionSource, qOverload<QGeoPositionInfoSource::Error>(&QGeoPositionInfoSource::error), this, &MainCore::positionError); | 
					
						
							| 
									
										
										
										
											2023-04-10 15:57:16 +01:00
										 |  |  | #else
 | 
					
						
							|  |  |  |         connect(m_positionSource, &QGeoPositionInfoSource::errorOccurred, this, &MainCore::positionError); | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											2023-01-02 15:30:34 +00:00
										 |  |  |         m_position = m_positionSource->lastKnownPosition(); | 
					
						
							|  |  |  |         m_positionSource->setUpdateInterval(1000); | 
					
						
							| 
									
										
										
										
											2022-12-20 21:06:39 +00:00
										 |  |  |         m_positionSource->startUpdates(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2023-01-02 15:30:34 +00:00
										 |  |  |         qWarning() << "MainCore::initPosition: No position source."; | 
					
						
							| 
									
										
										
										
											2022-12-20 21:06:39 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | const QGeoPositionInfo& MainCore::getPosition() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_position; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::positionUpdated(const QGeoPositionInfo &info) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (info.isValid()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         m_position = info; | 
					
						
							|  |  |  |         if (m_settings.getAutoUpdatePosition()) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             m_settings.setLatitude(m_position.coordinate().latitude()); | 
					
						
							|  |  |  |             m_settings.setLongitude(m_position.coordinate().longitude()); | 
					
						
							| 
									
										
										
										
											2023-02-16 14:47:40 +00:00
										 |  |  |             if (!std::isnan(m_position.coordinate().altitude())) { | 
					
						
							|  |  |  |                 m_settings.setAltitude(m_position.coordinate().altitude()); | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2022-12-20 21:06:39 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-01-02 15:30:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void MainCore::positionUpdateTimeout() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     qWarning() << "MainCore::positionUpdateTimeout: GPS signal lost"; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void MainCore::positionError(QGeoPositionInfoSource::Error positioningError) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2023-03-13 03:11:22 +02:00
										 |  |  |     #if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
 | 
					
						
							|  |  |  |     if (positioningError == 4){ | 
					
						
							|  |  |  |         positionUpdateTimeout(); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     #endif
 | 
					
						
							| 
									
										
										
										
											2023-01-02 15:30:34 +00:00
										 |  |  |     qWarning() << "MainCore::positionError: " << positioningError; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-02-17 21:57:09 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef ANDROID
 | 
					
						
							|  |  |  | // On Android, we want to prevent the app from being put to sleep, when any
 | 
					
						
							|  |  |  | // device is running
 | 
					
						
							|  |  |  | void MainCore::updateWakeLock() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool running = false; | 
					
						
							|  |  |  |     for (int i = 0; i < m_deviceSets.size(); i++) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if (m_deviceSets[i]->m_deviceAPI->state() == DeviceAPI::StRunning) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             running = true; | 
					
						
							|  |  |  |             break; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     if (running) { | 
					
						
							|  |  |  |         Android::acquireWakeLock(); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         Android::releaseWakeLock(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | AvailableChannelOrFeatureList MainCore::getAvailableChannels(const QStringList& uris) | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     AvailableChannelOrFeatureList list; | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     for (const auto deviceSet : m_deviceSets) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (int chi = 0; chi < deviceSet->getNumberOfChannels(); chi++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ChannelAPI* channel = deviceSet->getChannelAt(chi); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ((uris.size() == 0) || uris.contains(channel->getURI())) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 QChar type = getDeviceSetTypeId(deviceSet); | 
					
						
							|  |  |  |                 int streamIdx = type == 'M' ? channel->getStreamIndex() : -1; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 AvailableChannelOrFeature item { | 
					
						
							|  |  |  |                     type, | 
					
						
							|  |  |  |                     deviceSet->getIndex(), | 
					
						
							|  |  |  |                     chi, | 
					
						
							|  |  |  |                     streamIdx, | 
					
						
							|  |  |  |                     channel->getIdentifier(), | 
					
						
							|  |  |  |                     channel | 
					
						
							|  |  |  |                 }; | 
					
						
							|  |  |  |                 list.append(item); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return list; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | AvailableChannelOrFeatureList MainCore::getAvailableFeatures(const QStringList& uris) | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     AvailableChannelOrFeatureList list; | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  |     std::vector<FeatureSet*>& featureSets = MainCore::instance()->getFeatureeSets(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (const auto& featureSet : featureSets) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (int fei = 0; fei < featureSet->getNumberOfFeatures(); fei++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             Feature *feature = featureSet->getFeatureAt(fei); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             if ((uris.size() == 0) || uris.contains(feature->getURI())) | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |                 AvailableChannelOrFeature item { | 
					
						
							|  |  |  |                     'F', | 
					
						
							|  |  |  |                     featureSet->getIndex(), | 
					
						
							|  |  |  |                     fei, | 
					
						
							|  |  |  |                     -1, | 
					
						
							|  |  |  |                     feature->getIdentifier(), | 
					
						
							|  |  |  |                     feature | 
					
						
							|  |  |  |                 }; | 
					
						
							|  |  |  |                 list.append(item); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return list; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | AvailableChannelOrFeatureList MainCore::getAvailableChannelsAndFeatures(const QStringList& uris, const QString& kinds) | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     AvailableChannelOrFeatureList list; | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     if (kinds != "F") { | 
					
						
							|  |  |  |         list.append(getAvailableChannels(uris)); | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  |     if (kinds.contains("F")) { | 
					
						
							|  |  |  |         list.append(getAvailableFeatures(uris)); | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-16 16:31:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return list; | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-05 12:32:53 +00:00
										 |  |  | QChar MainCore::getDeviceSetTypeId(const DeviceSet* deviceSet) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (deviceSet->m_deviceMIMOEngine) { | 
					
						
							|  |  |  |         return 'M'; | 
					
						
							|  |  |  |     } else if (deviceSet->m_deviceSinkEngine) { | 
					
						
							|  |  |  |         return 'T'; | 
					
						
							|  |  |  |     } else if (deviceSet->m_deviceSourceEngine) { | 
					
						
							|  |  |  |         return 'R'; | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return 'X'; // Unknown
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString MainCore::getDeviceSetId(const DeviceSet* deviceSet) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QChar type = getDeviceSetTypeId(deviceSet); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return QString("%1%2").arg(type).arg(deviceSet->getIndex()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString MainCore::getChannelId(const ChannelAPI* channel) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<DeviceSet*> deviceSets = getDeviceSets(); | 
					
						
							|  |  |  |     DeviceSet* deviceSet = deviceSets[channel->getDeviceSetIndex()]; | 
					
						
							|  |  |  |     QString deviceSetId = getDeviceSetId(deviceSet); | 
					
						
							|  |  |  |     int index = channel->getIndexInDeviceSet(); | 
					
						
							| 
									
										
										
										
											2024-02-14 13:20:33 +00:00
										 |  |  |     if (deviceSet->m_deviceMIMOEngine) { | 
					
						
							|  |  |  |         return QString("%1:%2.%3").arg(deviceSetId).arg(index).arg(channel->getStreamIndex()); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         return QString("%1:%2").arg(deviceSetId).arg(index); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-12-05 12:32:53 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QStringList MainCore::getDeviceSetIds(bool rx, bool tx, bool mimo) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList list; | 
					
						
							|  |  |  |     std::vector<DeviceSet*> deviceSets = getDeviceSets(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (const auto deviceSet : deviceSets) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         DSPDeviceSourceEngine *deviceSourceEngine = deviceSet->m_deviceSourceEngine; | 
					
						
							|  |  |  |         DSPDeviceSinkEngine *deviceSinkEngine = deviceSet->m_deviceSinkEngine; | 
					
						
							|  |  |  |         DSPDeviceMIMOEngine *deviceMIMOEngine = deviceSet->m_deviceMIMOEngine; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (((deviceSourceEngine != nullptr) && rx) | 
					
						
							|  |  |  |             || ((deviceSinkEngine != nullptr) && tx) | 
					
						
							|  |  |  |             || ((deviceMIMOEngine != nullptr) && mimo)) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             list.append(getDeviceSetId(deviceSet)); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return list; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool MainCore::getDeviceSetTypeFromId(const QString& deviceSetId, QChar &type) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!deviceSetId.isEmpty()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         type = deviceSetId[0]; | 
					
						
							|  |  |  |         return (type == 'R') || (type == 'T') || (type == 'M'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool MainCore::getDeviceSetIndexFromId(const QString& deviceSetId, unsigned int &deviceSetIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const QRegularExpression re("[RTM]([0-9]+)"); | 
					
						
							|  |  |  |     QRegularExpressionMatch match = re.match(deviceSetId); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (match.hasMatch()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         deviceSetIndex = match.capturedTexts()[1].toInt(); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool MainCore::getDeviceAndChannelIndexFromId(const QString& channelId, unsigned int &deviceSetIndex, unsigned int &channelIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const QRegularExpression re("[RTM]([0-9]+):([0-9]+)"); | 
					
						
							|  |  |  |     QRegularExpressionMatch match = re.match(channelId); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (match.hasMatch()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         deviceSetIndex = match.capturedTexts()[1].toInt(); | 
					
						
							|  |  |  |         channelIndex = match.capturedTexts()[2].toInt(); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool MainCore::getFeatureIndexFromId(const QString& featureId, unsigned int &featureSetIndex, unsigned int &featureIndex) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     const QRegularExpression re("[F]([0-9]+):([0-9]+)"); | 
					
						
							|  |  |  |     QRegularExpressionMatch match = re.match(featureId); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (match.hasMatch()) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         featureSetIndex = match.capturedTexts()[1].toInt(); | 
					
						
							|  |  |  |         featureIndex = match.capturedTexts()[2].toInt(); | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-26 16:31:37 +01:00
										 |  |  | std::vector<ChannelAPI*> MainCore::getChannels(const QString& uri) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     std::vector<ChannelAPI*> channels; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (const auto deviceSet : m_deviceSets) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         for (int chi = 0; chi < deviceSet->getNumberOfChannels(); chi++) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             ChannelAPI* channel = deviceSet->getChannelAt(chi); | 
					
						
							|  |  |  |             if (channel->getURI() == uri) { | 
					
						
							|  |  |  |                 channels.push_back(channel); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return channels; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-12-05 12:32:53 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | QStringList MainCore::getChannelIds(const QString& uri) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QStringList list; | 
					
						
							|  |  |  |     std::vector<ChannelAPI*> channels = getChannels(uri); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     for (const auto channel : channels) { | 
					
						
							|  |  |  |         list.append(getChannelId(channel)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return list; | 
					
						
							|  |  |  | } |