| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2015 F4EXB                                                      //
 | 
					
						
							|  |  |  | // written by Edouard Griffiths                                                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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:32:15 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01: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 INCLUDE_SAMPLESOURCE_H
 | 
					
						
							|  |  |  | #define INCLUDE_SAMPLESOURCE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QtGlobal>
 | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  | #include <QByteArray>
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "samplesinkfifo.h"
 | 
					
						
							|  |  |  | #include "util/message.h"
 | 
					
						
							|  |  |  | #include "util/messagequeue.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 23:07:30 +01:00
										 |  |  | namespace SWGSDRangel | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-12-06 19:23:42 +01:00
										 |  |  |     class SWGDeviceSettings; | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  |     class SWGDeviceState; | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  |     class SWGDeviceReport; | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |     class SWGDeviceActions; | 
					
						
							| 
									
										
										
										
											2017-12-04 23:07:30 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 20:23:38 +01:00
										 |  |  | class SDRBASE_API DeviceSampleSource : public QObject { | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2018-05-10 11:47:13 +02:00
										 |  |  |     typedef enum { | 
					
						
							|  |  |  |         FC_POS_INFRA = 0, | 
					
						
							|  |  |  |         FC_POS_SUPRA, | 
					
						
							|  |  |  |         FC_POS_CENTER | 
					
						
							|  |  |  |     } fcPos_t; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-02 01:10:03 +02:00
										 |  |  |     typedef enum { | 
					
						
							|  |  |  |         FSHIFT_STD = 0, // Standard Rx independent
 | 
					
						
							|  |  |  |         FSHIFT_TXSYNC   // Follows same scheme as Tx
 | 
					
						
							|  |  |  |     } FrequencyShiftScheme; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	DeviceSampleSource(); | 
					
						
							|  |  |  | 	virtual ~DeviceSampleSource(); | 
					
						
							|  |  |  | 	virtual void destroy() = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-25 09:10:19 +01:00
										 |  |  | 	virtual void init() = 0;  //!< initializations to be done when all collaborating objects are created and possibly connected
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	virtual bool start() = 0; | 
					
						
							|  |  |  | 	virtual void stop() = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  |     virtual QByteArray serialize() const = 0; | 
					
						
							|  |  |  |     virtual bool deserialize(const QByteArray& data) = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	virtual const QString& getDeviceDescription() const = 0; | 
					
						
							|  |  |  | 	virtual int getSampleRate() const = 0; //!< Sample rate exposed by the source
 | 
					
						
							| 
									
										
										
										
											2019-05-02 04:02:40 +02:00
										 |  |  |     virtual void setSampleRate(int sampleRate) = 0; //!< For when the source sample rate is set externally
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	virtual quint64 getCenterFrequency() const = 0; //!< Center frequency exposed by the source
 | 
					
						
							| 
									
										
										
										
											2017-12-28 03:21:48 +01:00
										 |  |  |     virtual void setCenterFrequency(qint64 centerFrequency) = 0; | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	virtual bool handleMessage(const Message& message) = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual int webapiSettingsGet( | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |             SWGSDRangel::SWGDeviceSettings& response, | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	        QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         (void) response; | 
					
						
							|  |  |  |         errorMessage = "Not implemented"; | 
					
						
							|  |  |  |         return 501; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |     virtual int webapiSettingsPutPatch( | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |             bool force, //!< true to force settings = put
 | 
					
						
							|  |  |  |             const QStringList& deviceSettingsKeys, | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceSettings& response, | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  |             QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         (void) force; | 
					
						
							|  |  |  |         (void) deviceSettingsKeys; | 
					
						
							|  |  |  |         (void) response; | 
					
						
							|  |  |  |         errorMessage = "Not implemented"; | 
					
						
							|  |  |  |         return 501; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-07 13:55:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-09 10:49:20 +01:00
										 |  |  |     virtual int webapiRunGet( | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |             SWGSDRangel::SWGDeviceState& response, | 
					
						
							| 
									
										
										
										
											2017-12-09 10:49:20 +01:00
										 |  |  |             QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         (void) response; | 
					
						
							|  |  |  |         errorMessage = "Not implemented"; | 
					
						
							|  |  |  |         return 501; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual int webapiRun(bool run, | 
					
						
							|  |  |  |             SWGSDRangel::SWGDeviceState& response, | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  |             QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         (void) run; | 
					
						
							|  |  |  |         (void) response; | 
					
						
							|  |  |  |         errorMessage = "Not implemented"; | 
					
						
							|  |  |  |         return 501; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2017-12-08 17:12:33 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  |     virtual int webapiReportGet( | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |             SWGSDRangel::SWGDeviceReport& response, | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  |             QString& errorMessage) | 
					
						
							| 
									
										
										
										
											2018-11-12 14:04:16 +01:00
										 |  |  |     { | 
					
						
							|  |  |  |         (void) response; | 
					
						
							|  |  |  |         errorMessage = "Not implemented"; | 
					
						
							|  |  |  |         return 501; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-26 01:43:28 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |     virtual int webapiActionsPost( | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |             const QStringList& deviceSettingsKeys, | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |             SWGSDRangel::SWGDeviceActions& actions, | 
					
						
							|  |  |  |             QString& errorMessage) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-03-09 19:56:09 +01:00
										 |  |  |         (void) deviceSettingsKeys; | 
					
						
							| 
									
										
										
										
											2020-03-09 04:01:23 +01:00
										 |  |  |         (void) actions; | 
					
						
							|  |  |  |         errorMessage = "Not implemented"; | 
					
						
							|  |  |  |         return 501; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } | 
					
						
							| 
									
										
										
										
											2017-12-24 19:58:26 +01:00
										 |  |  | 	virtual void setMessageQueueToGUI(MessageQueue *queue) = 0; // pure virtual so that child classes must have to deal with this
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | 	MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; } | 
					
						
							|  |  |  |     SampleSinkFifo* getSampleFifo() { return &m_sampleFifo; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:47:13 +02:00
										 |  |  |     static qint64 calculateDeviceCenterFrequency( | 
					
						
							|  |  |  |             quint64 centerFrequency, | 
					
						
							|  |  |  |             qint64 transverterDeltaFrequency, | 
					
						
							|  |  |  |             int log2Decim, | 
					
						
							|  |  |  |             fcPos_t fcPos, | 
					
						
							|  |  |  |             quint32 devSampleRate, | 
					
						
							| 
									
										
										
										
											2019-04-02 01:10:03 +02:00
										 |  |  |             FrequencyShiftScheme frequencyShiftScheme, | 
					
						
							|  |  |  |             bool transverterMode = false | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2018-05-10 11:47:13 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-30 20:44:55 +01:00
										 |  |  |     static qint64 calculateCenterFrequency( | 
					
						
							|  |  |  |             quint64 deviceCenterFrequency, | 
					
						
							|  |  |  |             qint64 transverterDeltaFrequency, | 
					
						
							|  |  |  |             int log2Decim, | 
					
						
							|  |  |  |             fcPos_t fcPos, | 
					
						
							|  |  |  |             quint32 devSampleRate, | 
					
						
							| 
									
										
										
										
											2019-04-02 01:10:03 +02:00
										 |  |  |             FrequencyShiftScheme frequencyShiftScheme, | 
					
						
							|  |  |  |             bool transverterMode = false | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2019-03-30 20:44:55 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 22:17:39 +02:00
										 |  |  |     static qint32 calculateFrequencyShift( | 
					
						
							|  |  |  |             int log2Decim, | 
					
						
							|  |  |  |             fcPos_t fcPos, | 
					
						
							| 
									
										
										
										
											2019-04-02 01:10:03 +02:00
										 |  |  |             quint32 devSampleRate, | 
					
						
							|  |  |  |             FrequencyShiftScheme frequencyShiftScheme | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2018-05-10 22:17:39 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-04 18:22:25 +01:00
										 |  |  | protected slots: | 
					
						
							|  |  |  | 	void handleInputMessages(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | protected: | 
					
						
							|  |  |  |     SampleSinkFifo m_sampleFifo; | 
					
						
							|  |  |  | 	MessageQueue m_inputMessageQueue; //!< Input queue to the source
 | 
					
						
							|  |  |  | 	MessageQueue *m_guiMessageQueue;  //!< Input message queue to the GUI
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_SAMPLESOURCE_H
 |