| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-19 13:31:45 +01:00
										 |  |  | // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
					
						
							|  |  |  | // written by Christian Daniel                                                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2015-2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>          //
 | 
					
						
							|  |  |  | // Copyright (C) 2015 John Greb <hexameron@spam.no>                              //
 | 
					
						
							|  |  |  | // Copyright (C) 2022-2023 Jon Beniston, M7RCE <jon@beniston.com>                //
 | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +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                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 14:43:33 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02: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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef SDRGUI_DEVICE_DEVICEUISET_H_
 | 
					
						
							|  |  |  | #define SDRGUI_DEVICE_DEVICEUISET_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-04 19:07:42 +02:00
										 |  |  | #include <QObject>
 | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <QByteArray>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-24 15:51:50 +01:00
										 |  |  | #include "settings/serializableinterface.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-03 20:23:38 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | class SpectrumVis; | 
					
						
							|  |  |  | class GLSpectrum; | 
					
						
							|  |  |  | class GLSpectrumGUI; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  | class MainSpectrumGUI; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  | class DeviceAPI; | 
					
						
							| 
									
										
										
										
											2020-10-11 08:27:58 +02:00
										 |  |  | class DeviceSet; | 
					
						
							| 
									
										
										
										
											2019-05-16 18:39:13 +02:00
										 |  |  | class DSPDeviceSourceEngine; | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | class DSPDeviceSinkEngine; | 
					
						
							| 
									
										
										
										
											2019-05-16 18:39:13 +02:00
										 |  |  | class DSPDeviceMIMOEngine; | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  | class ChannelMarker; | 
					
						
							| 
									
										
										
										
											2017-11-01 00:18:10 +01:00
										 |  |  | class PluginAPI; | 
					
						
							| 
									
										
										
										
											2020-10-05 19:23:13 +02:00
										 |  |  | class DeviceGUI; | 
					
						
							| 
									
										
										
										
											2020-10-03 03:09:36 +02:00
										 |  |  | class ChannelAPI; | 
					
						
							| 
									
										
										
										
											2020-10-04 06:16:15 +02:00
										 |  |  | class ChannelGUI; | 
					
						
							| 
									
										
										
										
											2019-05-09 12:10:27 +02:00
										 |  |  | class Preset; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  | class Workspace; | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 18:58:18 +02:00
										 |  |  | namespace SWGSDRangel { | 
					
						
							|  |  |  |     class SWGGLSpectrum; | 
					
						
							|  |  |  |     class SWGSpectrumServer; | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     class SWGSuccessResponse; | 
					
						
							| 
									
										
										
										
											2020-05-05 18:58:18 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-24 15:51:50 +01:00
										 |  |  | class SDRGUI_API DeviceUISet : public QObject, public SerializableInterface | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-10-04 19:07:42 +02:00
										 |  |  |     Q_OBJECT | 
					
						
							| 
									
										
										
										
											2018-02-27 19:26:52 +01:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  |     SpectrumVis *m_spectrumVis; | 
					
						
							|  |  |  |     GLSpectrum *m_spectrum; | 
					
						
							|  |  |  |     GLSpectrumGUI *m_spectrumGUI; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     MainSpectrumGUI *m_mainSpectrumGUI; | 
					
						
							| 
									
										
										
										
											2019-05-08 22:11:53 +02:00
										 |  |  |     DeviceAPI *m_deviceAPI; | 
					
						
							| 
									
										
										
										
											2020-10-05 19:23:13 +02:00
										 |  |  |     DeviceGUI *m_deviceGUI; | 
					
						
							| 
									
										
										
										
											2019-05-16 18:39:13 +02:00
										 |  |  |     DSPDeviceSourceEngine *m_deviceSourceEngine; | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  |     DSPDeviceSinkEngine *m_deviceSinkEngine; | 
					
						
							| 
									
										
										
										
											2019-05-16 18:39:13 +02:00
										 |  |  |     DSPDeviceMIMOEngine *m_deviceMIMOEngine; | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  |     QByteArray m_mainWindowState; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     QString m_selectedDeviceId; | 
					
						
							|  |  |  |     QString m_selectedDeviceSerial; | 
					
						
							|  |  |  |     int m_selectedDeviceSequence; | 
					
						
							|  |  |  |     int m_selectedDeviceItemImdex; | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     DeviceUISet(int deviceSetIndex, DeviceSet *deviceSet); | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     ~DeviceUISet() final; | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 16:20:45 +02:00
										 |  |  |     void setIndex(int deviceSetIndex); | 
					
						
							| 
									
										
										
										
											2022-04-13 18:43:37 +02:00
										 |  |  |     int getIndex() const { return m_deviceSetIndex; } | 
					
						
							| 
									
										
										
										
											2022-04-16 16:45:53 +02:00
										 |  |  |     GLSpectrum *getSpectrum() { return m_spectrum; }        //!< Direct spectrum getter
 | 
					
						
							| 
									
										
										
										
											2019-10-26 22:30:53 +02:00
										 |  |  |     void setSpectrumScalingFactor(float scalef); | 
					
						
							| 
									
										
										
										
											2022-04-16 16:45:53 +02:00
										 |  |  |     void addChannelMarker(ChannelMarker* channelMarker);    //!< Add channel marker to spectrum
 | 
					
						
							|  |  |  |     void removeChannelMarker(ChannelMarker* channelMarker); //!< Remove channel marker from spectrum
 | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |     int getNumberOfChannels() const { return m_channelInstanceRegistrations.size(); } | 
					
						
							|  |  |  |     void freeChannels(); | 
					
						
							|  |  |  |     void deleteChannel(int channelIndex); | 
					
						
							| 
									
										
										
										
											2022-03-23 05:53:12 +01:00
										 |  |  |     ChannelAPI *getChannelAt(int channelIndex); | 
					
						
							| 
									
										
										
										
											2022-04-12 16:20:45 +02:00
										 |  |  |     ChannelGUI *getChannelGUIAt(int channelIndex); | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-24 15:51:50 +01:00
										 |  |  |     QByteArray serialize() const override; | 
					
						
							|  |  |  |     bool deserialize(const QByteArray& data) override; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     void loadDeviceSetSettings( | 
					
						
							|  |  |  |         const Preset* preset, | 
					
						
							|  |  |  |         PluginAPI *pluginAPI, | 
					
						
							|  |  |  |         QList<Workspace*> *workspaces, | 
					
						
							|  |  |  |         Workspace *currentWorkspace | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     void saveDeviceSetSettings(Preset* preset) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-15 08:52:30 +02:00
										 |  |  |     void registerRxChannelInstance(ChannelAPI *channelAPI, ChannelGUI* channelGUI); | 
					
						
							|  |  |  |     void registerTxChannelInstance(ChannelAPI *channelAPI, ChannelGUI* channelGUI); | 
					
						
							|  |  |  |     void registerChannelInstance(ChannelAPI *channelAPI, ChannelGUI* channelGUI); | 
					
						
							| 
									
										
										
										
											2022-04-16 16:45:53 +02:00
										 |  |  |     void unregisterChannelInstanceAt(int channelIndex); | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 15:40:00 +02:00
										 |  |  |     // These are the number of channel types available for selection
 | 
					
						
							|  |  |  |     void setNumberOfAvailableRxChannels(int number) { m_nbAvailableRxChannels = number; } | 
					
						
							|  |  |  |     void setNumberOfAvailableTxChannels(int number) { m_nbAvailableTxChannels = number; } | 
					
						
							|  |  |  |     void setNumberOfAvailableMIMOChannels(int number) { m_nbAvailableMIMOChannels = number; } | 
					
						
							|  |  |  |     int getNumberOfAvailableRxChannels() const { return m_nbAvailableRxChannels; } | 
					
						
							|  |  |  |     int getNumberOfAvailableTxChannels() const { return m_nbAvailableTxChannels; } | 
					
						
							|  |  |  |     int getNumberOfAvailableMIMOChannels() const { return m_nbAvailableMIMOChannels; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-05-05 18:58:18 +02:00
										 |  |  |     // REST API
 | 
					
						
							|  |  |  |     int webapiSpectrumSettingsGet(SWGSDRangel::SWGGLSpectrum& response, QString& errorMessage) const; | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     int webapiSpectrumSettingsPutPatch( | 
					
						
							|  |  |  |             bool force, | 
					
						
							|  |  |  |             const QStringList& spectrumSettingsKeys, | 
					
						
							|  |  |  |             SWGSDRangel::SWGGLSpectrum& response, // query + response
 | 
					
						
							|  |  |  |             QString& errorMessage); | 
					
						
							| 
									
										
										
										
											2020-05-05 18:58:18 +02:00
										 |  |  |     int webapiSpectrumServerGet(SWGSDRangel::SWGSpectrumServer& response, QString& errorMessage) const; | 
					
						
							| 
									
										
										
										
											2020-05-06 01:38:23 +02:00
										 |  |  |     int webapiSpectrumServerPost(SWGSDRangel::SWGSuccessResponse& response, QString& errorMessage); | 
					
						
							|  |  |  |     int webapiSpectrumServerDelete(SWGSDRangel::SWGSuccessResponse& response, QString& errorMessage); | 
					
						
							| 
									
										
										
										
											2020-05-05 18:58:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  | private: | 
					
						
							|  |  |  |     struct ChannelInstanceRegistration | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-10-03 03:09:36 +02:00
										 |  |  |         ChannelAPI *m_channelAPI; | 
					
						
							| 
									
										
										
										
											2020-10-04 06:16:15 +02:00
										 |  |  |         ChannelGUI* m_gui; | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |         int m_channelType; | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         ChannelInstanceRegistration() : | 
					
						
							| 
									
										
										
										
											2020-10-04 19:07:42 +02:00
										 |  |  |             m_channelAPI(nullptr), | 
					
						
							| 
									
										
										
										
											2020-11-14 05:51:19 +01:00
										 |  |  |             m_gui(nullptr), | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |             m_channelType(0) | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  |         { } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-15 08:52:30 +02:00
										 |  |  |         ChannelInstanceRegistration(ChannelAPI *channelAPI, ChannelGUI* channelGUI, int channelType) : | 
					
						
							| 
									
										
										
										
											2020-10-04 19:07:42 +02:00
										 |  |  |             m_channelAPI(channelAPI), | 
					
						
							| 
									
										
										
										
											2020-11-14 05:51:19 +01:00
										 |  |  |             m_gui(channelGUI), | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |             m_channelType(channelType) | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  |         { } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         bool operator<(const ChannelInstanceRegistration& other) const; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     using ChannelInstanceRegistrations = QList<ChannelInstanceRegistration>; | 
					
						
							| 
									
										
										
										
											2017-10-30 22:45:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-08 00:44:56 +02:00
										 |  |  |     ChannelInstanceRegistrations m_channelInstanceRegistrations; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     int m_deviceSetIndex; | 
					
						
							| 
									
										
										
										
											2020-10-11 08:27:58 +02:00
										 |  |  |     DeviceSet *m_deviceSet; | 
					
						
							| 
									
										
										
										
											2019-05-18 15:40:00 +02:00
										 |  |  |     int m_nbAvailableRxChannels;   //!< Number of Rx channels available for selection
 | 
					
						
							|  |  |  |     int m_nbAvailableTxChannels;   //!< Number of Tx channels available for selection
 | 
					
						
							|  |  |  |     int m_nbAvailableMIMOChannels; //!< Number of MIMO channels available for selection
 | 
					
						
							| 
									
										
										
										
											2020-10-04 19:07:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-12 16:20:45 +02:00
										 |  |  |     void loadRxChannelSettings(const Preset* preset, PluginAPI *pluginAPI, QList<Workspace*> *workspaces, Workspace *currentWorkspace); | 
					
						
							|  |  |  |     void loadTxChannelSettings(const Preset* preset, PluginAPI *pluginAPI, QList<Workspace*> *workspaces, Workspace *currentWorkspace); | 
					
						
							|  |  |  |     void loadMIMOChannelSettings(const Preset* preset, PluginAPI *pluginAPI, QList<Workspace*> *workspaces, Workspace *currentWorkspace); | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     void saveRxChannelSettings(Preset* preset) const; | 
					
						
							|  |  |  |     void saveTxChannelSettings(Preset* preset) const; | 
					
						
							|  |  |  |     void saveMIMOChannelSettings(Preset* preset) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-04 19:07:42 +02:00
										 |  |  | private slots: | 
					
						
							| 
									
										
										
										
											2024-08-24 13:17:02 +02:00
										 |  |  |     void handleChannelGUIClosing(const ChannelGUI* channelGUI); | 
					
						
							|  |  |  |     void handleDeleteChannel(ChannelAPI *channelAPI) const; | 
					
						
							| 
									
										
										
										
											2023-12-06 10:09:30 +00:00
										 |  |  |     void onTimeSelected(int deviceSetIndex, float time); | 
					
						
							| 
									
										
										
										
											2017-10-24 18:29:18 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* SDRGUI_DEVICE_DEVICEUISET_H_ */
 |