| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							| 
									
										
										
										
											2023-11-18 05:28:24 +00:00
										 |  |  | // Copyright (C) 2018-2020, 2022 Edouard Griffiths, F4EXB <f4exb06@gmail.com>    //
 | 
					
						
							|  |  |  | // Copyright (C) 2020 Kacper Michajłow <kasper93@gmail.com>                      //
 | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00: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                  //
 | 
					
						
							|  |  |  | // (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/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef INCLUDE_BEAMSTEERINGCWMOD_H
 | 
					
						
							|  |  |  | #define INCLUDE_BEAMSTEERINGCWMOD_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <vector>
 | 
					
						
							|  |  |  | #include <QNetworkRequest>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "dsp/mimochannel.h"
 | 
					
						
							|  |  |  | #include "channel/channelapi.h"
 | 
					
						
							|  |  |  | #include "util/messagequeue.h"
 | 
					
						
							|  |  |  | #include "util/message.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "beamsteeringcwmodsettings.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class QThread; | 
					
						
							|  |  |  | class DeviceAPI; | 
					
						
							|  |  |  | class BeamSteeringCWModBaseband; | 
					
						
							|  |  |  | class QNetworkReply; | 
					
						
							|  |  |  | class QNetworkAccessManager; | 
					
						
							|  |  |  | class BasebandSampleSink; | 
					
						
							| 
									
										
										
										
											2022-03-02 22:07:15 +00:00
										 |  |  | class ObjectPipe; | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | class BeamSteeringCWMod: public MIMOChannel, public ChannelAPI | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     class MsgConfigureBeamSteeringCWMod : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         const BeamSteeringCWModSettings& getSettings() const { return m_settings; } | 
					
						
							|  |  |  |         bool getForce() const { return m_force; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgConfigureBeamSteeringCWMod* create(const BeamSteeringCWModSettings& settings, bool force) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgConfigureBeamSteeringCWMod(settings, force); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         BeamSteeringCWModSettings m_settings; | 
					
						
							|  |  |  |         bool m_force; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgConfigureBeamSteeringCWMod(const BeamSteeringCWModSettings& settings, bool force) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_settings(settings), | 
					
						
							|  |  |  |             m_force(force) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class MsgBasebandNotification : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         static MsgBasebandNotification* create(int sampleRate, qint64 centerFrequency) { | 
					
						
							|  |  |  |             return new MsgBasebandNotification(sampleRate, centerFrequency); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int getSampleRate() const { return m_sampleRate; } | 
					
						
							|  |  |  |         qint64 getCenterFrequency() const { return m_centerFrequency; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgBasebandNotification(int sampleRate, qint64 centerFrequency) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_sampleRate(sampleRate), | 
					
						
							|  |  |  |             m_centerFrequency(centerFrequency) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         int m_sampleRate; | 
					
						
							|  |  |  |         qint64 m_centerFrequency; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     BeamSteeringCWMod(DeviceAPI *deviceAPI); | 
					
						
							|  |  |  | 	virtual ~BeamSteeringCWMod(); | 
					
						
							|  |  |  | 	virtual void destroy() { delete this; } | 
					
						
							| 
									
										
										
										
											2022-04-16 14:45:53 +00:00
										 |  |  |     virtual void setDeviceAPI(DeviceAPI *deviceAPI); | 
					
						
							|  |  |  |     virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; } | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-16 14:45:53 +00:00
										 |  |  |     virtual void startSinks() {} | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  | 	virtual void stopSinks() {} | 
					
						
							|  |  |  |     virtual void startSources(); //!< thread start()
 | 
					
						
							|  |  |  |     virtual void stopSources(); //!< thread exit() and wait()
 | 
					
						
							|  |  |  | 	virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, unsigned int sinkIndex); | 
					
						
							|  |  |  |     virtual void pull(SampleVector::iterator& begin, unsigned int nbSamples, unsigned int sourceIndex); | 
					
						
							| 
									
										
										
										
											2022-02-12 23:57:33 +00:00
										 |  |  |     virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); } | 
					
						
							|  |  |  |     virtual QString getMIMOName() { return objectName(); } | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 19:24:18 +00:00
										 |  |  |     virtual void getIdentifier(QString& id) { id = objectName(); } | 
					
						
							| 
									
										
										
										
											2022-03-26 08:51:06 +00:00
										 |  |  |     virtual QString getIdentifier() const { return objectName(); } | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     virtual void getTitle(QString& title) { title = "BeamSteeringCWMod"; } | 
					
						
							|  |  |  |     virtual qint64 getCenterFrequency() const { return m_frequencyOffset; } | 
					
						
							| 
									
										
										
										
											2022-01-06 21:47:41 +00:00
										 |  |  |     virtual void setCenterFrequency(qint64) {} | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     uint32_t getBasebandSampleRate() const { return m_basebandSampleRate; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual QByteArray serialize() const; | 
					
						
							|  |  |  |     virtual bool deserialize(const QByteArray& data); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual int getNbSinkStreams() const { return 0; } | 
					
						
							|  |  |  |     virtual int getNbSourceStreams() const { return 2; } | 
					
						
							| 
									
										
										
										
											2023-12-13 18:24:26 +00:00
										 |  |  |     virtual int getStreamIndex() const { return -1; } | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         (void) streamIndex; | 
					
						
							|  |  |  |         (void) sinkElseSource; | 
					
						
							|  |  |  |         return m_frequencyOffset; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; } | 
					
						
							|  |  |  |     MessageQueue *getMessageQueueToGUI() { return m_guiMessageQueue; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual int webapiSettingsGet( | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings& response, | 
					
						
							|  |  |  |             QString& errorMessage); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     virtual int webapiSettingsPutPatch( | 
					
						
							|  |  |  |             bool force, | 
					
						
							|  |  |  |             const QStringList& channelSettingsKeys, | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings& response, | 
					
						
							|  |  |  |             QString& errorMessage); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-05-13 20:24:48 +00:00
										 |  |  |     virtual int webapiWorkspaceGet( | 
					
						
							|  |  |  |             SWGSDRangel::SWGWorkspaceInfo& query, | 
					
						
							|  |  |  |             QString& errorMessage); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     static void webapiFormatChannelSettings( | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelSettings& response, | 
					
						
							|  |  |  |         const BeamSteeringCWModSettings& settings); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     static void webapiUpdateChannelSettings( | 
					
						
							|  |  |  |             BeamSteeringCWModSettings& settings, | 
					
						
							|  |  |  |             const QStringList& channelSettingsKeys, | 
					
						
							|  |  |  |             SWGSDRangel::SWGChannelSettings& response); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-21 19:24:18 +00:00
										 |  |  |     static const char* const m_channelIdURI; | 
					
						
							|  |  |  |     static const char* const m_channelId; | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     static const int m_fftSize; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     DeviceAPI *m_deviceAPI; | 
					
						
							|  |  |  |     QThread *m_thread; | 
					
						
							|  |  |  |     BeamSteeringCWModBaseband* m_basebandSource; | 
					
						
							| 
									
										
										
										
											2022-10-10 19:45:26 +00:00
										 |  |  |     QMutex m_mutex; | 
					
						
							|  |  |  |     bool m_running; | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     BasebandSampleSink* m_spectrumSink; | 
					
						
							|  |  |  |     BasebandSampleSink* m_scopeSink; | 
					
						
							|  |  |  |     BeamSteeringCWModSettings m_settings; | 
					
						
							|  |  |  |     MessageQueue *m_guiMessageQueue;  //!< Input message queue to the GUI
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QNetworkAccessManager *m_networkManager; | 
					
						
							|  |  |  |     QNetworkRequest m_networkRequest; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     int64_t m_frequencyOffset; | 
					
						
							|  |  |  |     uint32_t m_basebandSampleRate; | 
					
						
							|  |  |  |     int m_count0, m_count1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-12 23:57:33 +00:00
										 |  |  |    	virtual bool handleMessage(const Message& cmd); //!< Processing of a message. Returns true if message has actually been processed
 | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     void applySettings(const BeamSteeringCWModSettings& settings, bool force = false); | 
					
						
							|  |  |  |     static void validateFilterChainHash(BeamSteeringCWModSettings& settings); | 
					
						
							|  |  |  |     void calculateFrequencyOffset(); | 
					
						
							|  |  |  |     void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const BeamSteeringCWModSettings& settings, bool force); | 
					
						
							| 
									
										
										
										
											2020-12-13 12:04:36 +00:00
										 |  |  |     void sendChannelSettings( | 
					
						
							| 
									
										
										
										
											2022-03-02 22:07:15 +00:00
										 |  |  |         const QList<ObjectPipe*>& pipes, | 
					
						
							| 
									
										
										
										
											2020-12-13 12:04:36 +00:00
										 |  |  |         QList<QString>& channelSettingsKeys, | 
					
						
							|  |  |  |         const BeamSteeringCWModSettings& settings, | 
					
						
							|  |  |  |         bool force | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2020-11-10 20:49:43 +00:00
										 |  |  |     void webapiFormatChannelSettings( | 
					
						
							|  |  |  |         QList<QString>& channelSettingsKeys, | 
					
						
							|  |  |  |         SWGSDRangel::SWGChannelSettings *swgChannelSettings, | 
					
						
							|  |  |  |         const BeamSteeringCWModSettings& settings, | 
					
						
							|  |  |  |         bool force | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							|  |  |  |     void handleInputMessages(); | 
					
						
							|  |  |  |     void networkManagerFinished(QNetworkReply *reply); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // INCLUDE_BEAMSTEERINGCWSOURCE_H
 |