| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2016 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | #ifndef SDRBASE_DEVICE_DEVICESOURCEAPI_H_
 | 
					
						
							|  |  |  | #define SDRBASE_DEVICE_DEVICESOURCEAPI_H_
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-26 10:35:29 +02:00
										 |  |  | #include <stdint.h>
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | #include <QObject>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-14 18:47:19 +02:00
										 |  |  | #include "dsp/dspdevicesourceengine.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-02 22:29:04 +02:00
										 |  |  | class BasebandSampleSink; | 
					
						
							| 
									
										
										
										
											2016-10-03 15:55:16 +02:00
										 |  |  | class ThreadedBasebandSampleSink; | 
					
						
							| 
									
										
										
										
											2016-10-02 23:16:40 +02:00
										 |  |  | class DeviceSampleSource; | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | class MessageQueue; | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  | class PluginInstanceGUI; | 
					
						
							| 
									
										
										
										
											2017-09-15 01:30:25 +02:00
										 |  |  | class PluginInterface; | 
					
						
							| 
									
										
										
										
											2016-05-16 17:47:22 +02:00
										 |  |  | class Preset; | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | class DeviceSinkAPI; | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  | class ChannelSinkAPI; | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 20:23:38 +01:00
										 |  |  | class SDRBASE_API DeviceSourceAPI : public QObject { | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  |     Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-10-24 17:07:11 +02:00
										 |  |  |     DeviceSourceAPI(int deviceTabIndex, | 
					
						
							| 
									
										
										
										
											2017-10-31 21:57:29 +01:00
										 |  |  |             DSPDeviceSourceEngine *deviceSourceEngine); | 
					
						
							| 
									
										
										
										
											2017-10-24 17:07:11 +02:00
										 |  |  |     ~DeviceSourceAPI(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  |     // Device engine stuff
 | 
					
						
							| 
									
										
										
										
											2016-10-02 22:29:04 +02:00
										 |  |  |     void addSink(BasebandSampleSink* sink);       //!< Add a sample sink to device engine
 | 
					
						
							|  |  |  |     void removeSink(BasebandSampleSink* sink);    //!< Remove a sample sink from device engine
 | 
					
						
							| 
									
										
										
										
											2016-10-03 15:55:16 +02:00
										 |  |  |     void addThreadedSink(ThreadedBasebandSampleSink* sink);     //!< Add a sample sink that will run on its own thread to device engine
 | 
					
						
							|  |  |  |     void removeThreadedSink(ThreadedBasebandSampleSink* sink);  //!< Remove a sample sink that runs on its own thread from device engine
 | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  |     void addChannelAPI(ChannelSinkAPI* channelAPI); | 
					
						
							|  |  |  |     void removeChannelAPI(ChannelSinkAPI* channelAPI); | 
					
						
							| 
									
										
										
										
											2017-09-15 08:45:22 +02:00
										 |  |  |     void setSampleSource(DeviceSampleSource* source); //!< Set device sample source
 | 
					
						
							|  |  |  |     DeviceSampleSource *getSampleSource();      //!< Return pointer to the device sample source
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  |     bool initAcquisition();               //!< Initialize device engine acquisition sequence
 | 
					
						
							|  |  |  |     bool startAcquisition();              //!< Start device engine acquisition sequence
 | 
					
						
							|  |  |  |     void stopAcquisition();               //!< Stop device engine acquisition sequence
 | 
					
						
							| 
									
										
										
										
											2016-10-03 18:29:05 +02:00
										 |  |  |     DSPDeviceSourceEngine::State state() const; //!< device engine state
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  |     QString errorMessage();               //!< Return the current device engine error message
 | 
					
						
							|  |  |  |     uint getDeviceUID() const;            //!< Return the current device engine unique ID
 | 
					
						
							| 
									
										
										
										
											2017-09-13 23:40:06 +02:00
										 |  |  |     MessageQueue *getDeviceEngineInputMessageQueue(); | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |     MessageQueue *getSampleSourceInputMessageQueue(); | 
					
						
							|  |  |  |     MessageQueue *getSampleSourceGUIMessageQueue(); | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  |     void configureCorrections(bool dcOffsetCorrection, bool iqImbalanceCorrection); //!< Configure current device engine DSP corrections
 | 
					
						
							| 
									
										
										
										
											2016-05-16 16:02:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     void setHardwareId(const QString& id); | 
					
						
							| 
									
										
										
										
											2016-05-16 16:37:07 +02:00
										 |  |  |     void setSampleSourceId(const QString& id); | 
					
						
							| 
									
										
										
										
											2017-09-15 08:23:04 +02:00
										 |  |  |     void resetSampleSourceId(); | 
					
						
							| 
									
										
										
										
											2016-05-16 16:37:07 +02:00
										 |  |  |     void setSampleSourceSerial(const QString& serial); | 
					
						
							| 
									
										
										
										
											2017-09-15 01:24:51 +02:00
										 |  |  |     void setSampleSourceDisplayName(const QString& serial); | 
					
						
							| 
									
										
										
										
											2016-05-16 16:37:07 +02:00
										 |  |  |     void setSampleSourceSequence(int sequence); | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     void setNbItems(uint32_t nbItems); | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     void setItemIndex(uint32_t index); | 
					
						
							| 
									
										
										
										
											2017-09-15 18:48:30 +02:00
										 |  |  |     void setSampleSourcePluginInterface(PluginInterface *iface); | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     void setSampleSourcePluginInstanceGUI(PluginInstanceGUI *gui); | 
					
						
							| 
									
										
										
										
											2016-05-16 16:37:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     const QString& getHardwareId() const { return m_hardwareId; } | 
					
						
							|  |  |  |     const QString& getSampleSourceId() const { return m_sampleSourceId; } | 
					
						
							|  |  |  |     const QString& getSampleSourceSerial() const { return m_sampleSourceSerial; } | 
					
						
							| 
									
										
										
										
											2017-09-15 01:24:51 +02:00
										 |  |  |     const QString& getSampleSourceDisplayName() const { return m_sampleSourceDisplayName; } | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  |     uint32_t getSampleSourceSequence() const { return m_sampleSourceSequence; } | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     uint32_t getNbItems() const { return m_nbItems; } | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     uint32_t getItemIndex() const { return m_itemIndex; } | 
					
						
							|  |  |  |     PluginInterface *getPluginInterface() { return m_pluginInterface; } | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     PluginInstanceGUI *getSampleSourcePluginInstanceGUI() { return m_sampleSourcePluginInstanceUI; } | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     void getDeviceEngineStateStr(QString& state); | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  |     ChannelSinkAPI *getChanelAPIAt(int index); | 
					
						
							|  |  |  |     int getNbChannels() const { return m_channelAPIs.size(); } | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-16 17:47:22 +02:00
										 |  |  |     void loadSourceSettings(const Preset* preset); | 
					
						
							|  |  |  |     void saveSourceSettings(Preset* preset); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     DSPDeviceSourceEngine *getDeviceSourceEngine() { return m_deviceSourceEngine; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const std::vector<DeviceSourceAPI*>& getSourceBuddies() const { return m_sourceBuddies; } | 
					
						
							|  |  |  |     const std::vector<DeviceSinkAPI*>& getSinkBuddies() const { return m_sinkBuddies; } | 
					
						
							|  |  |  |     void addSourceBuddy(DeviceSourceAPI* buddy); | 
					
						
							|  |  |  |     void addSinkBuddy(DeviceSinkAPI* buddy); | 
					
						
							|  |  |  |     void removeSourceBuddy(DeviceSourceAPI* buddy); | 
					
						
							|  |  |  |     void removeSinkBuddy(DeviceSinkAPI* buddy); | 
					
						
							| 
									
										
										
										
											2016-12-29 19:26:45 +01:00
										 |  |  |     void clearBuddiesLists(); | 
					
						
							| 
									
										
										
										
											2016-12-30 16:13:28 +01:00
										 |  |  |     void *getBuddySharedPtr() const { return m_buddySharedPtr; } | 
					
						
							|  |  |  |     void setBuddySharedPtr(void *ptr) { m_buddySharedPtr = ptr; } | 
					
						
							| 
									
										
										
										
											2017-07-03 08:59:48 +02:00
										 |  |  |     bool isBuddyLeader() const { return m_isBuddyLeader; } | 
					
						
							|  |  |  |     void setBuddyLeader(bool isBuddyLeader) { m_isBuddyLeader = isBuddyLeader; } | 
					
						
							| 
									
										
										
										
											2016-05-17 19:08:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     const QTimer& getMasterTimer() const { return m_masterTimer; } //!< This is the DSPEngine master timer
 | 
					
						
							| 
									
										
										
										
											2017-09-14 13:34:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | protected: | 
					
						
							| 
									
										
										
										
											2016-05-16 16:02:55 +02:00
										 |  |  |     int m_deviceTabIndex; | 
					
						
							| 
									
										
										
										
											2016-10-18 00:03:51 +02:00
										 |  |  |     DSPDeviceSourceEngine *m_deviceSourceEngine; | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     QString m_hardwareId;              //!< The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
 | 
					
						
							|  |  |  |     QString m_sampleSourceId;          //!< The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...)
 | 
					
						
							|  |  |  |     QString m_sampleSourceSerial;      //!< The device serial number defined by the vendor or a fake one (SDRplay)
 | 
					
						
							|  |  |  |     QString m_sampleSourceDisplayName; //!< The human readable name identifying this instance
 | 
					
						
							|  |  |  |     uint32_t m_sampleSourceSequence;   //!< The device sequence. >0 when more than one device of the same type is connected
 | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     uint32_t m_nbItems;                //!< Number of items or streams in the device. Can be >1 for NxM devices (i.e. 2 for LimeSDR)
 | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     uint32_t m_itemIndex;              //!< The Rx stream index. Can be >0 for NxM devices (i.e. 0 or 1 for LimeSDR)
 | 
					
						
							| 
									
										
										
										
											2017-09-15 01:30:25 +02:00
										 |  |  |     PluginInterface* m_pluginInterface; | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     PluginInstanceGUI* m_sampleSourcePluginInstanceUI; | 
					
						
							| 
									
										
										
										
											2016-05-16 16:37:07 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     std::vector<DeviceSourceAPI*> m_sourceBuddies; //!< Device source APIs referencing the same physical device
 | 
					
						
							|  |  |  |     std::vector<DeviceSinkAPI*> m_sinkBuddies;     //!< Device sink APIs referencing the same physical device
 | 
					
						
							| 
									
										
										
										
											2016-12-30 16:13:28 +01:00
										 |  |  |     void *m_buddySharedPtr; | 
					
						
							| 
									
										
										
										
											2017-07-03 08:59:48 +02:00
										 |  |  |     bool m_isBuddyLeader; | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     const QTimer& m_masterTimer; //!< This is the DSPEngine master timer
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  |     QList<ChannelSinkAPI*> m_channelAPIs; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 23:30:50 +01:00
										 |  |  |     friend class DeviceSinkAPI; | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     void renumerateChannels(); | 
					
						
							| 
									
										
										
										
											2016-05-16 01:12:55 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-11 01:17:55 +02:00
										 |  |  | #endif /* SDRBASE_DEVICE_DEVICESOURCEAPI_H_ */
 |