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.
limesdrinput.h
Go to the documentation of this file.
1 // Copyright (C) 2017 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_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUT_H_
19 #define PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUT_H_
20 
21 #include <stdint.h>
22 
23 #include <QString>
24 #include <QByteArray>
25 #include <QNetworkRequest>
26 
27 #include "dsp/devicesamplesource.h"
29 #include "limesdrinputsettings.h"
30 
31 class DeviceAPI;
32 class LimeSDRInputThread;
33 class FileRecord;
34 class QNetworkAccessManager;
35 class QNetworkReply;
36 
38 {
39  Q_OBJECT
40 public:
41  class MsgConfigureLimeSDR : public Message {
43 
44  public:
45  const LimeSDRInputSettings& getSettings() const { return m_settings; }
46  bool getForce() const { return m_force; }
47 
48  static MsgConfigureLimeSDR* create(const LimeSDRInputSettings& settings, bool force)
49  {
50  return new MsgConfigureLimeSDR(settings, force);
51  }
52 
53  private:
55  bool m_force;
56 
57  MsgConfigureLimeSDR(const LimeSDRInputSettings& 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 
94  class MsgReportStreamInfo : public Message {
96 
97  public:
98  bool getSuccess() const { return m_success; }
99  bool getActive() const { return m_active; }
100  uint32_t getFifoFilledCount() const { return m_fifoFilledCount; }
101  uint32_t getFifoSize() const { return m_fifoSize; }
102  uint32_t getUnderrun() const { return m_underrun; }
103  uint32_t getOverrun() const { return m_overrun; }
104  uint32_t getDroppedPackets() const { return m_droppedPackets; }
105  float getLinkRate() const { return m_linkRate; }
106  uint64_t getTimestamp() const { return m_timestamp; }
107 
109  bool success,
110  bool active,
111  uint32_t fifoFilledCount,
112  uint32_t fifoSize,
113  uint32_t underrun,
114  uint32_t overrun,
115  uint32_t droppedPackets,
116  float linkRate,
117  uint64_t timestamp
118  )
119  {
120  return new MsgReportStreamInfo(
121  success,
122  active,
123  fifoFilledCount,
124  fifoSize,
125  underrun,
126  overrun,
127  droppedPackets,
128  linkRate,
129  timestamp
130  );
131  }
132 
133  private:
134  bool m_success;
135  // everything from lms_stream_status_t
136  bool m_active;
142  float m_linkRate;
144 
146  bool success,
147  bool active,
148  uint32_t fifoFilledCount,
149  uint32_t fifoSize,
150  uint32_t underrun,
151  uint32_t overrun,
152  uint32_t droppedPackets,
153  float linkRate,
154  uint64_t timestamp
155  ) :
156  Message(),
157  m_success(success),
158  m_active(active),
159  m_fifoFilledCount(fifoFilledCount),
160  m_fifoSize(fifoSize),
161  m_underrun(underrun),
162  m_overrun(overrun),
163  m_droppedPackets(droppedPackets),
164  m_linkRate(linkRate),
165  m_timestamp(timestamp)
166  { }
167  };
168 
169  class MsgFileRecord : public Message {
171 
172  public:
173  bool getStartStop() const { return m_startStop; }
174 
175  static MsgFileRecord* create(bool startStop) {
176  return new MsgFileRecord(startStop);
177  }
178 
179  protected:
181 
182  MsgFileRecord(bool startStop) :
183  Message(),
184  m_startStop(startStop)
185  { }
186  };
187 
188  class MsgStartStop : public Message {
190 
191  public:
192  bool getStartStop() const { return m_startStop; }
193 
194  static MsgStartStop* create(bool startStop) {
195  return new MsgStartStop(startStop);
196  }
197 
198  protected:
200 
201  MsgStartStop(bool startStop) :
202  Message(),
203  m_startStop(startStop)
204  { }
205  };
206 
207  LimeSDRInput(DeviceAPI *deviceAPI);
208  virtual ~LimeSDRInput();
209  virtual void destroy();
210 
211  virtual void init();
212  virtual bool start();
213  virtual void stop();
214 
215  virtual QByteArray serialize() const;
216  virtual bool deserialize(const QByteArray& data);
217 
218  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
219  virtual const QString& getDeviceDescription() const;
220  virtual int getSampleRate() const;
221  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
222  virtual quint64 getCenterFrequency() const;
223  virtual void setCenterFrequency(qint64 centerFrequency);
224 
225  virtual bool handleMessage(const Message& message);
226 
227  virtual int webapiSettingsGet(
229  QString& errorMessage);
230 
231  virtual int webapiSettingsPutPatch(
232  bool force,
233  const QStringList& deviceSettingsKeys,
234  SWGSDRangel::SWGDeviceSettings& response, // query + response
235  QString& errorMessage);
236 
237  virtual int webapiReportGet(
239  QString& errorMessage);
240 
241  virtual int webapiRunGet(
242  SWGSDRangel::SWGDeviceState& response,
243  QString& errorMessage);
244 
245  virtual int webapiRun(
246  bool run,
247  SWGSDRangel::SWGDeviceState& response,
248  QString& errorMessage);
249 
250  std::size_t getChannelIndex();
251  void getLORange(float& minF, float& maxF) const;
252  void getSRRange(float& minF, float& maxF) const;
253  void getLPRange(float& minF, float& maxF) const;
254  uint32_t getHWLog2Decim() const;
256 
257 private:
259  QMutex m_mutex;
263  bool m_running;
266  lms_stream_t m_streamId;
268  QNetworkAccessManager *m_networkManager;
269  QNetworkRequest m_networkRequest;
270 
271  bool openDevice();
272  void closeDevice();
273  bool acquireChannel();
274  void releaseChannel();
275  void suspendRxBuddies();
276  void resumeRxBuddies();
277  void suspendTxBuddies();
278  void resumeTxBuddies();
279  bool applySettings(const LimeSDRInputSettings& settings, bool force = false, bool forceNCOFrequency = false);
282  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LimeSDRInputSettings& settings, bool force);
283  void webapiReverseSendStartStop(bool start);
284 
285 private slots:
286  void networkManagerFinished(QNetworkReply *reply);
287 };
288 
289 #endif /* PLUGINS_SAMPLESOURCE_LIMESDRINPUT_LIMESDRINPUT_H_ */
bool m_active
Indicates whether the stream is currently active.
Definition: limesdrinput.h:136
MsgStartStop(bool startStop)
Definition: limesdrinput.h:201
static MsgConfigureLimeSDR * create(const LimeSDRInputSettings &settings, bool force)
Definition: limesdrinput.h:48
void suspendRxBuddies()
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
uint32_t getHWLog2Decim() const
uint64_t m_timestamp
Current HW timestamp.
Definition: limesdrinput.h:143
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
static MsgGetDeviceInfo * create()
Definition: limesdrinput.h:83
bool openDevice()
DeviceLimeSDRParams::LimeType getLimeType() const
virtual void setCenterFrequency(qint64 centerFrequency)
uint32_t m_fifoFilledCount
Number of samples in FIFO buffer.
Definition: limesdrinput.h:137
void resumeRxBuddies()
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const LimeSDRInputSettings &settings, bool force)
MsgFileRecord(bool startStop)
Definition: limesdrinput.h:182
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
bool applySettings(const LimeSDRInputSettings &settings, bool force=false, bool forceNCOFrequency=false)
static MsgReportStreamInfo * create(bool success, bool active, uint32_t fifoFilledCount, uint32_t fifoSize, uint32_t underrun, uint32_t overrun, uint32_t droppedPackets, float linkRate, uint64_t timestamp)
Definition: limesdrinput.h:108
static MsgStartStop * create(bool startStop)
Definition: limesdrinput.h:194
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
LimeSDRInputThread * m_limeSDRInputThread
Definition: limesdrinput.h:261
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: limesdrinput.h:267
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Definition: limesdrinput.h:221
unsigned int uint32_t
Definition: rtptypes_win.h:46
void networkManagerFinished(QNetworkReply *reply)
virtual bool start()
MsgReportStreamInfo(bool success, bool active, uint32_t fifoFilledCount, uint32_t fifoSize, uint32_t underrun, uint32_t overrun, uint32_t droppedPackets, float linkRate, uint64_t timestamp)
Definition: limesdrinput.h:145
MsgConfigureLimeSDR(const LimeSDRInputSettings &settings, bool force)
Definition: limesdrinput.h:57
LimeSDRInputSettings m_settings
Definition: limesdrinput.h:54
void getLORange(float &minF, float &maxF) const
bool m_channelAcquired
Definition: limesdrinput.h:265
LimeSDRInput(DeviceAPI *deviceAPI)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
const LimeSDRInputSettings & getSettings() const
Definition: limesdrinput.h:45
virtual bool deserialize(const QByteArray &data)
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: limesdrinput.h:218
virtual void destroy()
QString m_deviceDescription
Definition: limesdrinput.h:262
std::size_t getChannelIndex()
lms_stream_t m_streamId
Definition: limesdrinput.h:266
virtual int getSampleRate() const
Sample rate exposed by the source.
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
bool acquireChannel()
QNetworkRequest m_networkRequest
Definition: limesdrinput.h:269
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual QByteArray serialize() const
virtual bool handleMessage(const Message &message)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LimeSDRInputSettings &settings)
static MsgFileRecord * create(bool startStop)
Definition: limesdrinput.h:175
QNetworkAccessManager * m_networkManager
Definition: limesdrinput.h:268
virtual const QString & getDeviceDescription() const
virtual void stop()
float m_linkRate
Combined data rate of all stream of the same direction (TX or RX)
Definition: limesdrinput.h:142
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
uint32_t m_underrun
FIFO underrun count.
Definition: limesdrinput.h:139
QMutex m_mutex
Definition: limesdrinput.h:259
void getLPRange(float &minF, float &maxF) const
void webapiReverseSendStartStop(bool start)
DeviceLimeSDRShared m_deviceShared
Definition: limesdrinput.h:264
void resumeTxBuddies()
DeviceAPI * m_deviceAPI
Definition: limesdrinput.h:258
LimeSDRInputSettings m_settings
Definition: limesdrinput.h:260
uint32_t m_droppedPackets
Number of dropped packets by HW.
Definition: limesdrinput.h:141
void closeDevice()
void suspendTxBuddies()
uint32_t m_fifoSize
Size of FIFO buffer.
Definition: limesdrinput.h:138
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
void releaseChannel()
virtual ~LimeSDRInput()
void getSRRange(float &minF, float &maxF) const
uint32_t m_overrun
FIFO overrun count.
Definition: limesdrinput.h:140
static MsgGetStreamInfo * create()
Definition: limesdrinput.h:68
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48