| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-19 06:43:20 +01:00
										 |  |  | // Copyright (C) 2012 maintech GmbH, Otto-Hahn-Str. 15, 97204 Hoechberg, Germany //
 | 
					
						
							|  |  |  | // written by Christian Daniel                                                   //
 | 
					
						
							|  |  |  | // Copyright (C) 2015-2019, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>    //
 | 
					
						
							| 
									
										
										
										
											2019-08-01 02:16:56 +02:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | // (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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | #ifndef INCLUDE_PRESET_H
 | 
					
						
							|  |  |  | #define INCLUDE_PRESET_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | #include <QList>
 | 
					
						
							|  |  |  | #include <QMetaType>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-03 20:23:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class SDRBASE_API Preset { | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | public: | 
					
						
							|  |  |  | 	struct ChannelConfig { | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | 		QString m_channelIdURI; //!< Channel type ID in URI form
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 		QByteArray m_config; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-23 01:19:32 +01:00
										 |  |  | 		ChannelConfig(const QString& channelIdURI, const QByteArray& config) : | 
					
						
							|  |  |  | 			m_channelIdURI(channelIdURI), | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 			m_config(config) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 	typedef QList<ChannelConfig> ChannelConfigs; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 	struct DeviceConfig | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 		QString m_deviceId; | 
					
						
							|  |  |  | 		QString m_deviceSerial; | 
					
						
							|  |  |  | 		int m_deviceSequence; | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 		QByteArray m_config; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 		DeviceConfig(const QString& deviceId, | 
					
						
							|  |  |  | 				const QString& deviceSerial, | 
					
						
							|  |  |  | 				int deviceSequence, | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 				const QByteArray& config) : | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 					m_deviceId(deviceId), | 
					
						
							|  |  |  | 					m_deviceSerial(deviceSerial), | 
					
						
							|  |  |  | 					m_deviceSequence(deviceSequence), | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 					m_config(config) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  | 	typedef QList<DeviceConfig> DeviceConfigs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct SelectedDevice | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  | 		QString m_deviceId; | 
					
						
							|  |  |  | 		QString m_deviceSerial; | 
					
						
							|  |  |  | 		int m_deviceSequence; | 
					
						
							|  |  |  |         int m_deviceItemIndex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         SelectedDevice() = default; | 
					
						
							|  |  |  |         SelectedDevice(const SelectedDevice&) = default; | 
					
						
							|  |  |  |         SelectedDevice& operator=(const SelectedDevice&) = default; | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     enum PresetType | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         PresetSource, // Rx
 | 
					
						
							|  |  |  |         PresetSink,   // Tx
 | 
					
						
							|  |  |  |         PresetMIMO    // MIMO
 | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	Preset(); | 
					
						
							| 
									
										
										
										
											2019-08-09 18:45:10 +02:00
										 |  |  | 	Preset(const Preset& other); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	void resetToDefaults(); | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  | 	void setSourcePreset() { m_presetType = PresetSource; } | 
					
						
							|  |  |  | 	bool isSourcePreset() const { return m_presetType == PresetSource; } | 
					
						
							|  |  |  | 	void setSinkPreset() { m_presetType = PresetSink; } | 
					
						
							|  |  |  | 	bool isSinkPreset() const { return m_presetType == PresetSink; } | 
					
						
							|  |  |  | 	void setMIMOPreset() { m_presetType = PresetMIMO; } | 
					
						
							|  |  |  | 	bool isMIMOPreset() const { return m_presetType == PresetMIMO; } | 
					
						
							|  |  |  |     PresetType getPresetType() const { return m_presetType; } | 
					
						
							|  |  |  |     void setPresetType(PresetType presetType) { m_presetType = presetType; } | 
					
						
							| 
									
										
										
										
											2022-05-08 19:33:10 +02:00
										 |  |  |     static QString getPresetTypeChar(PresetType presetType); | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	QByteArray serialize() const; | 
					
						
							|  |  |  | 	bool deserialize(const QByteArray& data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void setGroup(const QString& group) { m_group = group; } | 
					
						
							|  |  |  | 	const QString& getGroup() const { return m_group; } | 
					
						
							|  |  |  | 	void setDescription(const QString& description) { m_description = description; } | 
					
						
							|  |  |  | 	const QString& getDescription() const { return m_description; } | 
					
						
							|  |  |  | 	void setCenterFrequency(const quint64 centerFrequency) { m_centerFrequency = centerFrequency; } | 
					
						
							|  |  |  | 	quint64 getCenterFrequency() const { return m_centerFrequency; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void setSpectrumConfig(const QByteArray& data) { m_spectrumConfig = data; } | 
					
						
							|  |  |  | 	const QByteArray& getSpectrumConfig() const { return m_spectrumConfig; } | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     void setSpectrumGeometry(const QByteArray& data) { m_spectrumGeometry = data; } | 
					
						
							|  |  |  | 	const QByteArray& getSpectrumGeometry() const { return m_spectrumGeometry; } | 
					
						
							|  |  |  |     void setSpectrumWorkspaceIndex(int workspaceIndex) { m_spectrumWorkspaceIndex = workspaceIndex; } | 
					
						
							|  |  |  | 	int getSpectrumWorkspaceIndex() const { return m_spectrumWorkspaceIndex; } | 
					
						
							|  |  |  |     void setSelectedDevice(const SelectedDevice& selectedDevice) { m_selectedDevice = selectedDevice; } | 
					
						
							|  |  |  |     SelectedDevice getSelectedDevice() const { return m_selectedDevice; } | 
					
						
							|  |  |  |     void setDeviceGeometry(const QByteArray& data) { m_deviceGeometry = data; } | 
					
						
							|  |  |  | 	const QByteArray& getDeviceGeometry() const { return m_deviceGeometry; } | 
					
						
							|  |  |  |     void setDeviceWorkspaceIndex(int workspaceIndex) { m_deviceWorkspaceIndex = workspaceIndex; } | 
					
						
							|  |  |  | 	int getDeviceWorkspaceIndex() const { return m_deviceWorkspaceIndex; } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 10:54:45 +02:00
										 |  |  | 	bool hasDCOffsetCorrection() const { return m_dcOffsetCorrection; } | 
					
						
							| 
									
										
										
										
											2019-08-10 05:16:25 +02:00
										 |  |  |     void setDCOffsetCorrection(bool dcOffsetCorrection) { m_dcOffsetCorrection = dcOffsetCorrection; } | 
					
						
							| 
									
										
										
										
											2019-08-01 10:54:45 +02:00
										 |  |  | 	bool hasIQImbalanceCorrection() const { return m_iqImbalanceCorrection; } | 
					
						
							| 
									
										
										
										
											2019-08-10 05:16:25 +02:00
										 |  |  |     void setIQImbalanceCorrection(bool iqImbalanceCorrection) { m_iqImbalanceCorrection = iqImbalanceCorrection; } | 
					
						
							| 
									
										
										
										
											2019-08-01 10:54:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-16 00:49:22 +01:00
										 |  |  | 	void setShowSpectrum(bool show) { m_showSpectrum = show; } | 
					
						
							|  |  |  | 	bool getShowSpectrum() const { return m_showSpectrum; } | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	void setLayout(const QByteArray& data) { m_layout = data; } | 
					
						
							|  |  |  | 	const QByteArray& getLayout() const { return m_layout; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	void clearChannels() { m_channelConfigs.clear(); } | 
					
						
							|  |  |  | 	void addChannel(const QString& channel, const QByteArray& config) { m_channelConfigs.append(ChannelConfig(channel, config)); } | 
					
						
							|  |  |  | 	int getChannelCount() const { return m_channelConfigs.count(); } | 
					
						
							|  |  |  | 	const ChannelConfig& getChannelConfig(int index) const { return m_channelConfigs.at(index); } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-01 08:49:35 +02:00
										 |  |  |     void clearDevices() { m_deviceConfigs.clear(); } | 
					
						
							|  |  |  | 	void setDeviceConfig(const QString& deviceId, const QString& deviceSerial, int deviceSequence, const QByteArray& config) { | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 		addOrUpdateDeviceConfig(deviceId, deviceSerial, deviceSequence, config); | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-08-01 08:49:35 +02:00
										 |  |  |     int getDeviceCount() const { return m_deviceConfigs.count(); } | 
					
						
							|  |  |  |     const DeviceConfig& getDeviceConfig(int index) const { return m_deviceConfigs.at(index); } | 
					
						
							| 
									
										
										
										
											2015-09-30 06:57:40 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 	void addOrUpdateDeviceConfig(const QString& deviceId, | 
					
						
							|  |  |  | 			const QString& deviceSerial, | 
					
						
							|  |  |  | 			int deviceSequence, | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 			const QByteArray& config); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-10 05:16:25 +02:00
										 |  |  | 	const QByteArray* findBestDeviceConfig( | 
					
						
							|  |  |  |             const QString& deviceId, | 
					
						
							|  |  |  | 			const QString& deviceSerial, | 
					
						
							|  |  |  | 			int deviceSequence) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	const QByteArray* findDeviceConfig( | 
					
						
							|  |  |  |             const QString& deviceId, | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 			const QString& deviceSerial, | 
					
						
							|  |  |  | 			int deviceSequence) const; | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-11 18:58:40 +02:00
										 |  |  | 	static bool presetCompare(const Preset *p1, Preset *p2) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2017-11-25 11:14:52 +01:00
										 |  |  | 	    if (p1->m_group != p2->m_group) | 
					
						
							|  |  |  | 	    { | 
					
						
							|  |  |  | 	        return p1->m_group < p2->m_group; | 
					
						
							|  |  |  | 	    } | 
					
						
							|  |  |  | 	    else | 
					
						
							|  |  |  | 	    { | 
					
						
							|  |  |  |             if (p1->m_centerFrequency != p2->m_centerFrequency) { | 
					
						
							|  |  |  |                 return p1->m_centerFrequency < p2->m_centerFrequency; | 
					
						
							|  |  |  |             } else { | 
					
						
							|  |  |  |                 return p1->m_description < p2->m_description; | 
					
						
							|  |  |  |             } | 
					
						
							| 
									
										
										
										
											2016-09-11 18:58:40 +02:00
										 |  |  | 	    } | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2019-09-13 13:40:31 +02:00
										 |  |  |     PresetType m_presetType; | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // group and preset description
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	QString m_group; | 
					
						
							|  |  |  | 	QString m_description; | 
					
						
							|  |  |  | 	quint64 m_centerFrequency; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// general configuration
 | 
					
						
							|  |  |  | 	QByteArray m_spectrumConfig; | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  |     QByteArray m_spectrumGeometry; | 
					
						
							|  |  |  |     int m_spectrumWorkspaceIndex; | 
					
						
							|  |  |  |     QByteArray m_deviceGeometry; | 
					
						
							|  |  |  |     int m_deviceWorkspaceIndex; | 
					
						
							|  |  |  |     SelectedDevice m_selectedDevice; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-30 03:46:46 +02:00
										 |  |  | 	// dc offset and i/q imbalance correction TODO: move it into the source data
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	bool m_dcOffsetCorrection; | 
					
						
							|  |  |  | 	bool m_iqImbalanceCorrection; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// channels and configurations
 | 
					
						
							|  |  |  | 	ChannelConfigs m_channelConfigs; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-19 00:07:42 +02:00
										 |  |  | 	// devices and configurations
 | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  | 	DeviceConfigs m_deviceConfigs; | 
					
						
							| 
									
										
										
										
											2015-10-01 08:54:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	// screen and dock layout
 | 
					
						
							| 
									
										
										
										
											2022-02-16 00:49:22 +01:00
										 |  |  | 	bool m_showSpectrum; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 	QByteArray m_layout; | 
					
						
							| 
									
										
										
										
											2019-01-13 22:09:45 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							| 
									
										
										
										
											2022-04-09 13:38:22 +02:00
										 |  |  | 	const QByteArray* findBestDeviceConfigSoapy(const QString& deviceId, const QString& deviceSerial) const; | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-01 22:22:18 +01:00
										 |  |  | Q_DECLARE_METATYPE(const Preset*) | 
					
						
							|  |  |  | Q_DECLARE_METATYPE(Preset*) | 
					
						
							| 
									
										
										
										
											2014-05-18 16:52:39 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_PRESET_H
 |