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.
remoteinput.h
Go to the documentation of this file.
1 // Copyright (C) 2016 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 INCLUDE_REMOTEINPUT_H
19 #define INCLUDE_REMOTEINPUT_H
20 
21 #include <ctime>
22 #include <iostream>
23 #include <stdint.h>
24 
25 #include <QString>
26 #include <QByteArray>
27 #include <QTimer>
28 #include <QNetworkRequest>
29 
30 #include "dsp/devicesamplesource.h"
31 
32 #include "remoteinputsettings.h"
33 
34 class QNetworkAccessManager;
35 class QNetworkReply;
36 class DeviceAPI;
38 class FileRecord;
39 
41  Q_OBJECT
42 public:
45 
46  public:
47  const RemoteInputSettings& getSettings() const { return m_settings; }
48  bool getForce() const { return m_force; }
49 
50  static MsgConfigureRemoteInput* create(const RemoteInputSettings& settings, bool force = false)
51  {
52  return new MsgConfigureRemoteInput(settings, force);
53  }
54 
55  private:
57  bool m_force;
58 
59  MsgConfigureRemoteInput(const RemoteInputSettings& settings, bool force) :
60  Message(),
61  m_settings(settings),
62  m_force(force)
63  { }
64  };
65 
68 
69  public:
70 
72  {
73  return new MsgConfigureRemoteInputTiming();
74  }
75 
76  private:
77 
79  Message()
80  { }
81  };
82 
85 
86  public:
87  bool getAcquisition() const { return m_acquisition; }
88 
89  static MsgReportRemoteInputAcquisition* create(bool acquisition)
90  {
91  return new MsgReportRemoteInputAcquisition(acquisition);
92  }
93 
94  protected:
96 
97  MsgReportRemoteInputAcquisition(bool acquisition) :
98  Message(),
99  m_acquisition(acquisition)
100  { }
101  };
102 
105 
106  public:
107  int getSampleRate() const { return m_sampleRate; }
108  quint64 getCenterFrequency() const { return m_centerFrequency; }
109  uint32_t get_tv_msec() const { return m_tv_msec; }
110 
111  static MsgReportRemoteInputStreamData* create(int sampleRate, quint64 centerFrequency, uint64_t tv_msec)
112  {
113  return new MsgReportRemoteInputStreamData(sampleRate, centerFrequency, tv_msec);
114  }
115 
116  protected:
120 
121  MsgReportRemoteInputStreamData(int sampleRate, quint64 centerFrequency, uint64_t tv_msec) :
122  Message(),
123  m_sampleRate(sampleRate),
124  m_centerFrequency(centerFrequency),
125  m_tv_msec(tv_msec)
126  { }
127  };
128 
131 
132  public:
133  uint64_t get_tv_msec() const { return m_tv_msec; }
134  int getFramesDecodingStatus() const { return m_framesDecodingStatus; }
135  bool allBlocksReceived() const { return m_allBlocksReceived; }
136  float getBufferLengthInSecs() const { return m_bufferLenSec; }
137  int32_t getBufferGauge() const { return m_bufferGauge; }
138  int getMinNbBlocks() const { return m_minNbBlocks; }
139  int getMinNbOriginalBlocks() const { return m_minNbOriginalBlocks; }
140  int getMaxNbRecovery() const { return m_maxNbRecovery; }
141  float getAvgNbBlocks() const { return m_avgNbBlocks; }
142  float getAvgNbOriginalBlocks() const { return m_avgNbOriginalBlocks; }
143  float getAvgNbRecovery() const { return m_avgNbRecovery; }
144  int getNbOriginalBlocksPerFrame() const { return m_nbOriginalBlocksPerFrame; }
145  int getNbFECBlocksPerFrame() const { return m_nbFECBlocksPerFrame; }
146  int getSampleBits() const { return m_sampleBits; }
147  int getSampleBytes() const { return m_sampleBytes; }
148 
150  float bufferLenSec,
151  int32_t bufferGauge,
152  int framesDecodingStatus,
153  bool allBlocksReceived,
154  int minNbBlocks,
155  int minNbOriginalBlocks,
156  int maxNbRecovery,
157  float avgNbBlocks,
158  float avgNbOriginalBlocks,
159  float avgNbRecovery,
160  int nbOriginalBlocksPerFrame,
161  int nbFECBlocksPerFrame,
162  int sampleBits,
163  int sampleBytes)
164  {
165  return new MsgReportRemoteInputStreamTiming(tv_msec,
166  bufferLenSec,
167  bufferGauge,
168  framesDecodingStatus,
169  allBlocksReceived,
170  minNbBlocks,
171  minNbOriginalBlocks,
172  maxNbRecovery,
173  avgNbBlocks,
174  avgNbOriginalBlocks,
175  avgNbRecovery,
176  nbOriginalBlocksPerFrame,
177  nbFECBlocksPerFrame,
178  sampleBits,
179  sampleBytes);
180  }
181 
182  protected:
198 
200  float bufferLenSec,
201  int32_t bufferGauge,
202  int framesDecodingStatus,
203  bool allBlocksReceived,
204  int minNbBlocks,
205  int minNbOriginalBlocks,
206  int maxNbRecovery,
207  float avgNbBlocks,
208  float avgNbOriginalBlocks,
209  float avgNbRecovery,
210  int nbOriginalBlocksPerFrame,
211  int nbFECBlocksPerFrame,
212  int sampleBits,
213  int sampleBytes) :
214  Message(),
215  m_tv_msec(tv_msec),
216  m_framesDecodingStatus(framesDecodingStatus),
217  m_allBlocksReceived(allBlocksReceived),
218  m_bufferLenSec(bufferLenSec),
219  m_bufferGauge(bufferGauge),
220  m_minNbBlocks(minNbBlocks),
221  m_minNbOriginalBlocks(minNbOriginalBlocks),
222  m_maxNbRecovery(maxNbRecovery),
223  m_avgNbBlocks(avgNbBlocks),
224  m_avgNbOriginalBlocks(avgNbOriginalBlocks),
225  m_avgNbRecovery(avgNbRecovery),
226  m_nbOriginalBlocksPerFrame(nbOriginalBlocksPerFrame),
227  m_nbFECBlocksPerFrame(nbFECBlocksPerFrame),
228  m_sampleBits(sampleBits),
229  m_sampleBytes(sampleBytes)
230  { }
231  };
232 
233  class MsgFileRecord : public Message {
235 
236  public:
237  bool getStartStop() const { return m_startStop; }
238 
239  static MsgFileRecord* create(bool startStop) {
240  return new MsgFileRecord(startStop);
241  }
242 
243  protected:
245 
246  MsgFileRecord(bool startStop) :
247  Message(),
248  m_startStop(startStop)
249  { }
250  };
251 
252  class MsgStartStop : public Message {
254 
255  public:
256  bool getStartStop() const { return m_startStop; }
257 
258  static MsgStartStop* create(bool startStop) {
259  return new MsgStartStop(startStop);
260  }
261 
262  protected:
264 
265  MsgStartStop(bool startStop) :
266  Message(),
267  m_startStop(startStop)
268  { }
269  };
270 
271  RemoteInput(DeviceAPI *deviceAPI);
272  virtual ~RemoteInput();
273  virtual void destroy();
274 
275  virtual void init();
276  virtual bool start();
277  virtual void stop();
278 
279  virtual QByteArray serialize() const;
280  virtual bool deserialize(const QByteArray& data);
281 
282  virtual void setMessageQueueToGUI(MessageQueue *queue);
283  virtual const QString& getDeviceDescription() const;
284  virtual int getSampleRate() const;
285  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
286  virtual quint64 getCenterFrequency() const;
287  virtual void setCenterFrequency(qint64 centerFrequency);
288  std::time_t getStartingTimeStamp() const;
289  bool isStreaming() const;
290 
291  virtual bool handleMessage(const Message& message);
292 
293  virtual int webapiSettingsGet(
295  QString& errorMessage);
296 
297  virtual int webapiSettingsPutPatch(
298  bool force,
299  const QStringList& deviceSettingsKeys,
300  SWGSDRangel::SWGDeviceSettings& response, // query + response
301  QString& errorMessage);
302 
303  virtual int webapiReportGet(
305  QString& errorMessage);
306 
307  virtual int webapiRunGet(
308  SWGSDRangel::SWGDeviceState& response,
309  QString& errorMessage);
310 
311  virtual int webapiRun(
312  bool run,
313  SWGSDRangel::SWGDeviceState& response,
314  QString& errorMessage);
315 
316 private:
318  QMutex m_mutex;
323  std::time_t m_startingTimeStamp;
325  QNetworkAccessManager *m_networkManager;
326  QNetworkRequest m_networkRequest;
327 
328  void applySettings(const RemoteInputSettings& settings, bool force = false);
331  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const RemoteInputSettings& settings, bool force);
332  void webapiReverseSendStartStop(bool start);
333 
334 private slots:
335  void networkManagerFinished(QNetworkReply *reply);
336 };
337 
338 #endif // INCLUDE_REMOTEINPUT_H
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: remoteinput.h:324
MsgReportRemoteInputStreamData(int sampleRate, quint64 centerFrequency, uint64_t tv_msec)
Definition: remoteinput.h:121
bool isStreaming() const
QMutex m_mutex
Definition: remoteinput.h:318
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
void applySettings(const RemoteInputSettings &settings, bool force=false)
RemoteInputSettings m_settings
Definition: remoteinput.h:319
QNetworkRequest m_networkRequest
Definition: remoteinput.h:326
virtual QByteArray serialize() const
Definition: remoteinput.cpp:98
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
QNetworkAccessManager * m_networkManager
Definition: remoteinput.h:325
RemoteInputUDPHandler * m_remoteInputUDPHandler
Definition: remoteinput.h:320
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
static MsgConfigureRemoteInput * create(const RemoteInputSettings &settings, bool force=false)
Definition: remoteinput.h:50
virtual ~RemoteInput()
Definition: remoteinput.cpp:65
static MsgReportRemoteInputStreamTiming * create(uint64_t tv_msec, float bufferLenSec, int32_t bufferGauge, int framesDecodingStatus, bool allBlocksReceived, int minNbBlocks, int minNbOriginalBlocks, int maxNbRecovery, float avgNbBlocks, float avgNbOriginalBlocks, float avgNbRecovery, int nbOriginalBlocksPerFrame, int nbFECBlocksPerFrame, int sampleBits, int sampleBytes)
Definition: remoteinput.h:149
unsigned int uint32_t
Definition: rtptypes_win.h:46
MsgStartStop(bool startStop)
Definition: remoteinput.h:265
static MsgReportRemoteInputAcquisition * create(bool acquisition)
Definition: remoteinput.h:89
virtual const QString & getDeviceDescription() const
virtual void setMessageQueueToGUI(MessageQueue *queue)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
std::time_t m_startingTimeStamp
Definition: remoteinput.h:323
virtual int getSampleRate() const
Sample rate exposed by the source.
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const RemoteInputSettings &settings)
QString m_remoteAddress
Definition: remoteinput.h:321
int int32_t
Definition: rtptypes_win.h:45
virtual void setCenterFrequency(qint64 centerFrequency)
RemoteInput(DeviceAPI *deviceAPI)
Definition: remoteinput.cpp:47
static MsgStartStop * create(bool startStop)
Definition: remoteinput.h:258
virtual bool start()
Definition: remoteinput.cpp:85
virtual void stop()
Definition: remoteinput.cpp:92
MsgReportRemoteInputStreamTiming(uint64_t tv_msec, float bufferLenSec, int32_t bufferGauge, int framesDecodingStatus, bool allBlocksReceived, int minNbBlocks, int minNbOriginalBlocks, int maxNbRecovery, float avgNbBlocks, float avgNbOriginalBlocks, float avgNbRecovery, int nbOriginalBlocksPerFrame, int nbFECBlocksPerFrame, int sampleBits, int sampleBytes)
Definition: remoteinput.h:199
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Definition: remoteinput.h:285
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
std::time_t getStartingTimeStamp() const
DeviceAPI * m_deviceAPI
Definition: remoteinput.h:317
QString m_deviceDescription
Definition: remoteinput.h:322
static MsgReportRemoteInputStreamData * create(int sampleRate, quint64 centerFrequency, uint64_t tv_msec)
Definition: remoteinput.h:111
static MsgFileRecord * create(bool startStop)
Definition: remoteinput.h:239
void networkManagerFinished(QNetworkReply *reply)
MsgFileRecord(bool startStop)
Definition: remoteinput.h:246
virtual void destroy()
Definition: remoteinput.cpp:75
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
Definition: remoteinput.cpp:80
MsgConfigureRemoteInput(const RemoteInputSettings &settings, bool force)
Definition: remoteinput.h:59
void webapiReverseSendStartStop(bool start)
const RemoteInputSettings & getSettings() const
Definition: remoteinput.h:47
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const RemoteInputSettings &settings, bool force)
virtual bool deserialize(const QByteArray &data)
static MsgConfigureRemoteInputTiming * create()
Definition: remoteinput.h:71
virtual bool handleMessage(const Message &message)
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48