SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
xtrxoutput.h
Go to the documentation of this file.
1 // Copyright (C) 2019 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #ifndef PLUGINS_SAMPLESINK_XTRXOUTPUT_XTRXOUTPUT_H_
19 #define PLUGINS_SAMPLESINK_XTRXOUTPUT_XTRXOUTPUT_H_
20 #include <stdint.h>
21 
22 #include <QString>
23 #include <QByteArray>
24 #include <QNetworkRequest>
25 
26 #include "dsp/devicesamplesink.h"
27 #include "xtrx/devicextrxshared.h"
28 #include "xtrxoutputsettings.h"
29 
30 class QNetworkAccessManager;
31 class QNetworkReply;
32 class DeviceAPI;
33 class XTRXOutputThread;
34 struct DeviceXTRXParams;
35 class FileRecord;
36 
38 {
39  Q_OBJECT
40 public:
41  class MsgConfigureXTRX : public Message {
43 
44  public:
45  const XTRXOutputSettings& getSettings() const { return m_settings; }
46  bool getForce() const { return m_force; }
47 
48  static MsgConfigureXTRX* create(const XTRXOutputSettings& settings, bool force)
49  {
50  return new MsgConfigureXTRX(settings, force);
51  }
52 
53  private:
55  bool m_force;
56 
57  MsgConfigureXTRX(const XTRXOutputSettings& settings, bool force) :
58  Message(),
59  m_settings(settings),
60  m_force(force)
61  { }
62  };
63 
64  class MsgGetStreamInfo : public Message {
66 
67  public:
69  {
70  return new MsgGetStreamInfo();
71  }
72 
73  private:
75  Message()
76  { }
77  };
78 
79  class MsgGetDeviceInfo : public Message {
81 
82  public:
84  {
85  return new MsgGetDeviceInfo();
86  }
87 
88  private:
90  Message()
91  { }
92  };
93 
96 
97  public:
99  {
100  return new MsgReportClockGenChange();
101  }
102 
103  private:
105  Message()
106  { }
107  };
108 
109  class MsgReportStreamInfo : public Message {
111 
112  public:
113  bool getSuccess() const { return m_success; }
114  bool getActive() const { return m_active; }
115  uint32_t getFifoFilledCount() const { return m_fifoFilledCount; }
116  uint32_t getFifoSize() const { return m_fifoSize; }
117 
119  bool success,
120  bool active,
121  uint32_t fifoFilledCount,
122  uint32_t fifoSize
123  )
124  {
125  return new MsgReportStreamInfo(
126  success,
127  active,
128  fifoFilledCount,
129  fifoSize
130  );
131  }
132 
133  private:
134  bool m_success;
135  // everything from lms_stream_status_t
136  bool m_active;
139 
141  bool success,
142  bool active,
143  uint32_t fifoFilledCount,
144  uint32_t fifoSize
145  ) :
146  Message(),
147  m_success(success),
148  m_active(active),
149  m_fifoFilledCount(fifoFilledCount),
150  m_fifoSize(fifoSize)
151  { }
152  };
153 
154  class MsgStartStop : public Message {
156 
157  public:
158  bool getStartStop() const { return m_startStop; }
159 
160  static MsgStartStop* create(bool startStop) {
161  return new MsgStartStop(startStop);
162  }
163 
164  protected:
166 
167  MsgStartStop(bool startStop) :
168  Message(),
169  m_startStop(startStop)
170  { }
171  };
172 
173  XTRXOutput(DeviceAPI *deviceAPI);
174  virtual ~XTRXOutput();
175  virtual void destroy();
176 
177  virtual void init();
178  virtual bool start();
179  virtual void stop();
181  void setThread(XTRXOutputThread *thread) { m_XTRXOutputThread = thread; }
182 
183  virtual QByteArray serialize() const;
184  virtual bool deserialize(const QByteArray& data);
185 
186  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
187  virtual const QString& getDeviceDescription() const;
188  virtual int getSampleRate() const;
189  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
190  uint32_t getDevSampleRate() const;
191  uint32_t getLog2HardInterp() const;
192  double getClockGen() const;
193  virtual quint64 getCenterFrequency() const;
194  virtual void setCenterFrequency(qint64 centerFrequency);
195 
196  virtual bool handleMessage(const Message& message);
197 
198  virtual int webapiSettingsGet(
200  QString& errorMessage);
201 
202  virtual int webapiSettingsPutPatch(
203  bool force,
204  const QStringList& deviceSettingsKeys,
205  SWGSDRangel::SWGDeviceSettings& response, // query + response
206  QString& errorMessage);
207 
208  virtual int webapiReportGet(
210  QString& errorMessage);
211 
212  virtual int webapiRunGet(
213  SWGSDRangel::SWGDeviceState& response,
214  QString& errorMessage);
215 
216  virtual int webapiRun(
217  bool run,
218  SWGSDRangel::SWGDeviceState& response,
219  QString& errorMessage);
220 
221  std::size_t getChannelIndex();
222  void getLORange(float& minF, float& maxF, float& stepF) const;
223  void getSRRange(float& minF, float& maxF, float& stepF) const;
224  void getLPRange(float& minF, float& maxF, float& stepF) const;
225 
226 private:
228  QMutex m_mutex;
232  bool m_running;
234  QNetworkAccessManager *m_networkManager;
235  QNetworkRequest m_networkRequest;
236 
237  bool openDevice();
238  void closeDevice();
240  void moveThreadToBuddy();
241 
242  void suspendRxThread();
243  void resumeRxThread();
244  bool applySettings(const XTRXOutputSettings& settings, bool force = false, bool forceNCOFrequency = false);
247  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const XTRXOutputSettings& settings, bool force);
248  void webapiReverseSendStartStop(bool start);
249 
250 private slots:
251  void networkManagerFinished(QNetworkReply *reply);
252 };
253 
254 #endif /* PLUGINS_SAMPLESINK_XTRXOUTPUT_XTRXOUTPUT_H_ */
bool m_running
Definition: xtrxoutput.h:232
virtual QByteArray serialize() const
Definition: xtrxoutput.cpp:461
double getClockGen() const
Definition: xtrxoutput.cpp:526
uint32_t getLog2HardInterp() const
Definition: xtrxoutput.cpp:515
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const XTRXOutputSettings &settings, bool force)
static MsgGetDeviceInfo * create()
Definition: xtrxoutput.h:83
virtual bool deserialize(const QByteArray &data)
Definition: xtrxoutput.cpp:466
XTRXOutput(DeviceAPI *deviceAPI)
Definition: xtrxoutput.cpp:48
virtual int getSampleRate() const
Sample rate exposed by the sink.
Definition: xtrxoutput.cpp:493
void getLPRange(float &minF, float &maxF, float &stepF) const
Definition: xtrxoutput.cpp:578
static MsgConfigureXTRX * create(const XTRXOutputSettings &settings, bool force)
Definition: xtrxoutput.h:48
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void setThread(XTRXOutputThread *thread)
Definition: xtrxoutput.h:181
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
Definition: xtrxoutput.cpp:535
uint32_t getDevSampleRate() const
Definition: xtrxoutput.cpp:504
static MsgGetStreamInfo * create()
Definition: xtrxoutput.h:68
void resumeRxThread()
Definition: xtrxoutput.cpp:444
XTRXOutputThread * getThread()
Definition: xtrxoutput.h:180
DeviceAPI * m_deviceAPI
Definition: xtrxoutput.h:227
void closeDevice()
Definition: xtrxoutput.cpp:152
static MsgReportClockGenChange * create()
Definition: xtrxoutput.h:98
std::size_t getChannelIndex()
Definition: xtrxoutput.cpp:555
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
bool openDevice()
Definition: xtrxoutput.cpp:78
virtual ~XTRXOutput()
Definition: xtrxoutput.cpp:61
DeviceXTRXShared m_deviceShared
Definition: xtrxoutput.h:233
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
Definition: xtrxoutput.cpp:179
XTRXOutputThread * m_XTRXOutputThread
Definition: xtrxoutput.h:230
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint32_t m_fifoSize
Size of FIFO buffer.
Definition: xtrxoutput.h:138
QNetworkAccessManager * m_networkManager
Definition: xtrxoutput.h:234
QString m_deviceDescription
Definition: xtrxoutput.h:231
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
MsgReportStreamInfo(bool success, bool active, uint32_t fifoFilledCount, uint32_t fifoSize)
Definition: xtrxoutput.h:140
virtual bool handleMessage(const Message &message)
Definition: xtrxoutput.cpp:587
static MsgReportStreamInfo * create(bool success, bool active, uint32_t fifoFilledCount, uint32_t fifoSize)
Definition: xtrxoutput.h:118
XTRXOutputThread * findThread()
Definition: xtrxoutput.cpp:184
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
Definition: xtrxoutput.h:189
XTRXOutputSettings m_settings
Definition: xtrxoutput.h:229
void webapiReverseSendStartStop(bool start)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
bool m_active
Indicates whether the stream is currently active.
Definition: xtrxoutput.h:136
uint32_t m_fifoFilledCount
Number of samples in FIFO buffer.
Definition: xtrxoutput.h:137
virtual void stop()
Definition: xtrxoutput.cpp:349
uint32_t getFifoSize() const
Definition: xtrxoutput.h:116
const XTRXOutputSettings & getSettings() const
Definition: xtrxoutput.h:45
bool getStartStop() const
Definition: xtrxoutput.h:158
MsgConfigureXTRX(const XTRXOutputSettings &settings, bool force)
Definition: xtrxoutput.h:57
void networkManagerFinished(QNetworkReply *reply)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const XTRXOutputSettings &settings)
bool applySettings(const XTRXOutputSettings &settings, bool force=false, bool forceNCOFrequency=false)
Definition: xtrxoutput.cpp:757
virtual void setCenterFrequency(qint64 centerFrequency)
Definition: xtrxoutput.cpp:540
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: xtrxoutput.h:186
static MsgStartStop * create(bool startStop)
Definition: xtrxoutput.h:160
virtual void destroy()
Definition: xtrxoutput.cpp:73
void getLORange(float &minF, float &maxF, float &stepF) const
Definition: xtrxoutput.cpp:560
QNetworkRequest m_networkRequest
Definition: xtrxoutput.h:235
void getSRRange(float &minF, float &maxF, float &stepF) const
Definition: xtrxoutput.cpp:569
XTRXOutputSettings m_settings
Definition: xtrxoutput.h:54
void suspendRxThread()
Definition: xtrxoutput.cpp:421
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
uint32_t getFifoFilledCount() const
Definition: xtrxoutput.h:115
virtual bool start()
Definition: xtrxoutput.cpp:233
QMutex m_mutex
Definition: xtrxoutput.h:228
virtual const QString & getDeviceDescription() const
Definition: xtrxoutput.cpp:488
void moveThreadToBuddy()
Definition: xtrxoutput.cpp:216
MsgStartStop(bool startStop)
Definition: xtrxoutput.h:167