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.
limesdroutput.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_LIMESDROUTPUT_LIMESDROUTPUT_H_
19 #define PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUT_H_
20 
21 #include <stdint.h>
22 
23 #include <QString>
24 #include <QNetworkRequest>
25 
26 #include "dsp/devicesamplesink.h"
28 #include "limesdroutputsettings.h"
29 
30 class QNetworkAccessManager;
31 class QNetworkReply;
32 class DeviceAPI;
34 struct DeviceLimeSDRParams;
35 
37 {
38  Q_OBJECT
39 public:
40  class MsgConfigureLimeSDR : public Message {
42 
43  public:
44  const LimeSDROutputSettings& getSettings() const { return m_settings; }
45  bool getForce() const { return m_force; }
46 
47  static MsgConfigureLimeSDR* create(const LimeSDROutputSettings& settings, bool force)
48  {
49  return new MsgConfigureLimeSDR(settings, force);
50  }
51 
52  private:
54  bool m_force;
55 
56  MsgConfigureLimeSDR(const LimeSDROutputSettings& settings, bool force) :
57  Message(),
58  m_settings(settings),
59  m_force(force)
60  { }
61  };
62 
63  class MsgStartStop : public Message {
65 
66  public:
67  bool getStartStop() const { return m_startStop; }
68 
69  static MsgStartStop* create(bool startStop) {
70  return new MsgStartStop(startStop);
71  }
72 
73  protected:
75 
76  MsgStartStop(bool startStop) :
77  Message(),
78  m_startStop(startStop)
79  { }
80  };
81 
82  class MsgGetStreamInfo : public Message {
84 
85  public:
87  {
88  return new MsgGetStreamInfo();
89  }
90 
91  private:
93  Message()
94  { }
95  };
96 
97  class MsgGetDeviceInfo : public Message {
99 
100  public:
102  {
103  return new MsgGetDeviceInfo();
104  }
105 
106  private:
108  Message()
109  { }
110  };
111 
112  class MsgReportStreamInfo : public Message {
114 
115  public:
116  bool getSuccess() const { return m_success; }
117  bool getActive() const { return m_active; }
118  uint32_t getFifoFilledCount() const { return m_fifoFilledCount; }
119  uint32_t getFifoSize() const { return m_fifoSize; }
120  uint32_t getUnderrun() const { return m_underrun; }
121  uint32_t getOverrun() const { return m_overrun; }
122  uint32_t getDroppedPackets() const { return m_droppedPackets; }
123  float getLinkRate() const { return m_linkRate; }
124  uint64_t getTimestamp() const { return m_timestamp; }
125 
127  bool success,
128  bool active,
129  uint32_t fifoFilledCount,
130  uint32_t fifoSize,
131  uint32_t underrun,
132  uint32_t overrun,
133  uint32_t droppedPackets,
134  float linkRate,
135  uint64_t timestamp
136  )
137  {
138  return new MsgReportStreamInfo(
139  success,
140  active,
141  fifoFilledCount,
142  fifoSize,
143  underrun,
144  overrun,
145  droppedPackets,
146  linkRate,
147  timestamp
148  );
149  }
150 
151  private:
152  bool m_success;
153  // everything from lms_stream_status_t
154  bool m_active;
160  float m_linkRate;
162 
164  bool success,
165  bool active,
166  uint32_t fifoFilledCount,
167  uint32_t fifoSize,
168  uint32_t underrun,
169  uint32_t overrun,
170  uint32_t droppedPackets,
171  float linkRate,
172  uint64_t timestamp
173  ) :
174  Message(),
175  m_success(success),
176  m_active(active),
177  m_fifoFilledCount(fifoFilledCount),
178  m_fifoSize(fifoSize),
179  m_underrun(underrun),
180  m_overrun(overrun),
181  m_droppedPackets(droppedPackets),
182  m_linkRate(linkRate),
183  m_timestamp(timestamp)
184  { }
185  };
186 
187  LimeSDROutput(DeviceAPI *deviceAPI);
188  virtual ~LimeSDROutput();
189  virtual void destroy();
190 
191  virtual void init();
192  virtual bool start();
193  virtual void stop();
194 
195  virtual QByteArray serialize() const;
196  virtual bool deserialize(const QByteArray& data);
197 
198  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
199  virtual const QString& getDeviceDescription() const;
200  virtual int getSampleRate() const;
201  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
202  virtual quint64 getCenterFrequency() const;
203  virtual void setCenterFrequency(qint64 centerFrequency);
204 
205  virtual bool handleMessage(const Message& message);
206 
207  virtual int webapiSettingsGet(
209  QString& errorMessage);
210 
211  virtual int webapiSettingsPutPatch(
212  bool force,
213  const QStringList& deviceSettingsKeys,
214  SWGSDRangel::SWGDeviceSettings& response, // query + response
215  QString& errorMessage);
216 
217  virtual int webapiReportGet(
219  QString& errorMessage);
220 
221  virtual int webapiRunGet(
222  SWGSDRangel::SWGDeviceState& response,
223  QString& errorMessage);
224 
225  virtual int webapiRun(
226  bool run,
227  SWGSDRangel::SWGDeviceState& response,
228  QString& errorMessage);
229 
230  std::size_t getChannelIndex();
231  void getLORange(float& minF, float& maxF) const;
232  void getSRRange(float& minF, float& maxF) const;
233  void getLPRange(float& minF, float& maxF) const;
234  uint32_t getHWLog2Interp() const;
236 
237 private:
239  QMutex m_mutex;
243  bool m_running;
246  lms_stream_t m_streamId;
247  QNetworkAccessManager *m_networkManager;
248  QNetworkRequest m_networkRequest;
249 
250  bool openDevice();
251  void closeDevice();
252  bool acquireChannel();
253  void releaseChannel();
254  void suspendRxBuddies();
255  void resumeRxBuddies();
256  void suspendTxBuddies();
257  void resumeTxBuddies();
258  bool applySettings(const LimeSDROutputSettings& settings, bool force = false, bool forceNCOFrequency = false);
261  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LimeSDROutputSettings& settings, bool force);
262  void webapiReverseSendStartStop(bool start);
263 
264 private slots:
265  void networkManagerFinished(QNetworkReply *reply);
266 };
267 
268 #endif /* PLUGINS_SAMPLESOURCE_LIMESDROUTPUT_LIMESDROUTPUT_H_ */
LimeSDROutputThread * m_limeSDROutputThread
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
virtual QByteArray serialize() const
void suspendTxBuddies()
bool m_channelAcquired
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)
uint32_t getHWLog2Interp() const
DeviceLimeSDRShared m_deviceShared
void networkManagerFinished(QNetworkReply *reply)
virtual void setCenterFrequency(qint64 centerFrequency)
void resumeRxBuddies()
void resumeTxBuddies()
virtual void destroy()
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
static MsgGetDeviceInfo * create()
MsgConfigureLimeSDR(const LimeSDROutputSettings &settings, bool force)
Definition: limesdroutput.h:56
static MsgConfigureLimeSDR * create(const LimeSDROutputSettings &settings, bool force)
Definition: limesdroutput.h:47
MsgStartStop(bool startStop)
Definition: limesdroutput.h:76
void suspendRxBuddies()
void webapiReverseSendStartStop(bool start)
QNetworkRequest m_networkRequest
float m_linkRate
Combined data rate of all stream of the same direction (TX or RX)
unsigned int uint32_t
Definition: rtptypes_win.h:46
uint32_t m_fifoFilledCount
Number of samples in FIFO buffer.
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
bool m_active
Indicates whether the stream is currently active.
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
uint32_t m_underrun
FIFO underrun count.
DeviceAPI * m_deviceAPI
void getSRRange(float &minF, float &maxF) const
bool applySettings(const LimeSDROutputSettings &settings, bool force=false, bool forceNCOFrequency=false)
std::size_t getChannelIndex()
void getLPRange(float &minF, float &maxF) const
virtual int getSampleRate() const
Sample rate exposed by the sink.
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
uint32_t m_fifoSize
Size of FIFO buffer.
void getLORange(float &minF, float &maxF) const
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
static MsgStartStop * create(bool startStop)
Definition: limesdroutput.h:69
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const LimeSDROutputSettings &settings, bool force)
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
virtual bool deserialize(const QByteArray &data)
LimeSDROutputSettings m_settings
Definition: limesdroutput.h:53
const LimeSDROutputSettings & getSettings() const
Definition: limesdroutput.h:44
LimeSDROutput(DeviceAPI *deviceAPI)
static MsgGetStreamInfo * create()
Definition: limesdroutput.h:86
uint64_t m_timestamp
Current HW timestamp.
uint32_t m_overrun
FIFO overrun count.
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)
virtual bool handleMessage(const Message &message)
virtual bool start()
QNetworkAccessManager * m_networkManager
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
DeviceLimeSDRParams::LimeType getLimeType() const
LimeSDROutputSettings m_settings
virtual void setMessageQueueToGUI(MessageQueue *queue)
virtual const QString & getDeviceDescription() const
uint32_t m_droppedPackets
Number of dropped packets by HW.
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual void stop()
lms_stream_t m_streamId
QString m_deviceDescription
virtual ~LimeSDROutput()
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LimeSDROutputSettings &settings)
unsigned __int64 uint64_t
Definition: rtptypes_win.h:48