| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | // Copyright (C) 2017 Edouard Griffiths, F4EXB                                   //
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +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                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // 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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | #ifndef INCLUDE_SDRDAEMONSINKOUTPUT_H
 | 
					
						
							|  |  |  | #define INCLUDE_SDRDAEMONSINKOUTPUT_H
 | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | #include <ctime>
 | 
					
						
							|  |  |  | #include <iostream>
 | 
					
						
							|  |  |  | #include <fstream>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/devicesamplesink.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "sdrdaemonsinksettings.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | class SDRdaemonSinkThread; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | class DeviceSinkAPI; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | class SDRdaemonSinkOutput : public DeviceSampleSink { | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	class MsgConfigureSDRdaemonSink : public Message { | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		const SDRdaemonSinkSettings& getSettings() const { return m_settings; } | 
					
						
							| 
									
										
										
										
											2017-05-23 01:41:30 +02:00
										 |  |  | 		bool getForce() const { return m_force; } | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-23 01:41:30 +02:00
										 |  |  | 		static MsgConfigureSDRdaemonSink* create(const SDRdaemonSinkSettings& settings, bool force = false) | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-05-23 01:41:30 +02:00
										 |  |  | 			return new MsgConfigureSDRdaemonSink(settings, force); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		SDRdaemonSinkSettings m_settings; | 
					
						
							| 
									
										
										
										
											2017-05-23 01:41:30 +02:00
										 |  |  | 		bool m_force; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-23 01:41:30 +02:00
										 |  |  | 		MsgConfigureSDRdaemonSink(const SDRdaemonSinkSettings& settings, bool force) : | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 			Message(), | 
					
						
							| 
									
										
										
										
											2017-05-23 01:41:30 +02:00
										 |  |  | 			m_settings(settings), | 
					
						
							|  |  |  | 			m_force(force) | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	class MsgConfigureSDRdaemonSinkWork : public Message { | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		bool isWorking() const { return m_working; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		static MsgConfigureSDRdaemonSinkWork* create(bool working) | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 			return new MsgConfigureSDRdaemonSinkWork(working); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 		bool m_working; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		MsgConfigureSDRdaemonSinkWork(bool working) : | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_working(working) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-05 01:18:35 +02:00
										 |  |  |     class MsgConfigureSDRdaemonSinkChunkCorrection : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         int getChunkCorrection() const { return m_chunkCorrection; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgConfigureSDRdaemonSinkChunkCorrection* create(int chunkCorrection) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgConfigureSDRdaemonSinkChunkCorrection(chunkCorrection); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         int m_chunkCorrection; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgConfigureSDRdaemonSinkChunkCorrection(int chunkCorrection) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_chunkCorrection(chunkCorrection) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	class MsgConfigureSDRdaemonSinkStreamTiming : public Message { | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		static MsgConfigureSDRdaemonSinkStreamTiming* create() | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 			return new MsgConfigureSDRdaemonSinkStreamTiming(); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	private: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		MsgConfigureSDRdaemonSinkStreamTiming() : | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 			Message() | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	class MsgReportSDRdaemonSinkStreamTiming : public Message { | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	public: | 
					
						
							|  |  |  | 		std::size_t getSamplesCount() const { return m_samplesCount; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		static MsgReportSDRdaemonSinkStreamTiming* create(std::size_t samplesCount) | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		{ | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 			return new MsgReportSDRdaemonSinkStreamTiming(samplesCount); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	protected: | 
					
						
							|  |  |  | 		std::size_t m_samplesCount; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 		MsgReportSDRdaemonSinkStreamTiming(std::size_t samplesCount) : | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 			Message(), | 
					
						
							|  |  |  | 			m_samplesCount(samplesCount) | 
					
						
							|  |  |  | 		{ } | 
					
						
							|  |  |  | 	}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	SDRdaemonSinkOutput(DeviceSinkAPI *deviceAPI, const QTimer& masterTimer); | 
					
						
							|  |  |  | 	virtual ~SDRdaemonSinkOutput(); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	virtual bool start(); | 
					
						
							|  |  |  | 	virtual void stop(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual const QString& getDeviceDescription() const; | 
					
						
							|  |  |  | 	virtual int getSampleRate() const; | 
					
						
							|  |  |  | 	virtual quint64 getCenterFrequency() const; | 
					
						
							|  |  |  | 	std::time_t getStartingTimeStamp() const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual bool handleMessage(const Message& message); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     DeviceSinkAPI *m_deviceAPI; | 
					
						
							|  |  |  | 	QMutex m_mutex; | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	SDRdaemonSinkSettings m_settings; | 
					
						
							| 
									
										
										
										
											2017-05-21 12:58:57 +02:00
										 |  |  | 	SDRdaemonSinkThread* m_sdrDaemonSinkThread; | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | 	QString m_deviceDescription; | 
					
						
							|  |  |  | 	std::time_t m_startingTimeStamp; | 
					
						
							|  |  |  | 	const QTimer& m_masterTimer; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | 	void applySettings(const SDRdaemonSinkSettings& settings, bool force = false); | 
					
						
							| 
									
										
										
										
											2017-05-15 00:58:56 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-21 04:19:12 +02:00
										 |  |  | #endif // INCLUDE_SDRDAEMONSINKOUTPUT_H
 |