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.
plutosdrinput.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_PLUTOSDRINPUT_PLUTOSDRINPUT_H_
19 #define PLUGINS_SAMPLESOURCE_PLUTOSDRINPUT_PLUTOSDRINPUT_H_
20 
21 #include <QString>
22 #include <QByteArray>
23 #include <QNetworkRequest>
24 
25 #include "iio.h"
26 #include "dsp/devicesamplesource.h"
27 #include "util/message.h"
30 #include "plutosdrinputsettings.h"
31 
32 class QNetworkAccessManager;
33 class QNetworkReply;
34 class DeviceAPI;
35 class FileRecord;
37 
39  Q_OBJECT
40 public:
41  class MsgConfigurePlutoSDR : public Message {
43 
44  public:
45  const PlutoSDRInputSettings& getSettings() const { return m_settings; }
46  bool getForce() const { return m_force; }
47 
48  static MsgConfigurePlutoSDR* create(const PlutoSDRInputSettings& settings, bool force)
49  {
50  return new MsgConfigurePlutoSDR(settings, force);
51  }
52 
53  private:
55  bool m_force;
56 
57  MsgConfigurePlutoSDR(const PlutoSDRInputSettings& settings, bool force) :
58  Message(),
59  m_settings(settings),
60  m_force(force)
61  { }
62  };
63 
64  class MsgFileRecord : public Message {
66 
67  public:
68  bool getStartStop() const { return m_startStop; }
69 
70  static MsgFileRecord* create(bool startStop) {
71  return new MsgFileRecord(startStop);
72  }
73 
74  protected:
76 
77  MsgFileRecord(bool startStop) :
78  Message(),
79  m_startStop(startStop)
80  { }
81  };
82 
83  class MsgStartStop : public Message {
85 
86  public:
87  bool getStartStop() const { return m_startStop; }
88 
89  static MsgStartStop* create(bool startStop) {
90  return new MsgStartStop(startStop);
91  }
92 
93  protected:
95 
96  MsgStartStop(bool startStop) :
97  Message(),
98  m_startStop(startStop)
99  { }
100  };
101 
102  PlutoSDRInput(DeviceAPI *deviceAPI);
103  ~PlutoSDRInput();
104  virtual void destroy();
105 
106  virtual void init();
107  virtual bool start();
108  virtual void stop();
109 
110  virtual QByteArray serialize() const;
111  virtual bool deserialize(const QByteArray& data);
112 
113  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
114  virtual const QString& getDeviceDescription() const;
115  virtual int getSampleRate() const;
116  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
117  virtual quint64 getCenterFrequency() const;
118  virtual void setCenterFrequency(qint64 centerFrequency);
119 
120  virtual bool handleMessage(const Message& message);
121 
122  virtual int webapiRunGet(
123  SWGSDRangel::SWGDeviceState& response,
124  QString& errorMessage);
125 
126  virtual int webapiRun(
127  bool run,
128  SWGSDRangel::SWGDeviceState& response,
129  QString& errorMessage);
130 
131  virtual int webapiSettingsGet(
133  QString& errorMessage);
134 
135  virtual int webapiSettingsPutPatch(
136  bool force,
137  const QStringList& deviceSettingsKeys,
138  SWGSDRangel::SWGDeviceSettings& response, // query + response
139  QString& errorMessage);
140 
141  virtual int webapiReportGet(
143  QString& errorMessage);
144 
147  void getRSSI(std::string& rssiStr);
148  void getLORange(qint64& minLimit, qint64& maxLimit);
149  void getbbLPRange(quint32& minLimit, quint32& maxLimit);
150  void getGain(int& gainStr);
151  bool fetchTemperature();
152  float getTemperature();
153 
154  private:
159  bool m_running;
161  struct iio_buffer *m_plutoRxBuffer;
164  QMutex m_mutex;
165  QNetworkAccessManager *m_networkManager;
166  QNetworkRequest m_networkRequest;
167 
168  bool openDevice();
169  void closeDevice();
170  void suspendBuddies();
171  void resumeBuddies();
172  bool applySettings(const PlutoSDRInputSettings& settings, bool force = false);
175  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PlutoSDRInputSettings& settings, bool force);
176  void webapiReverseSendStartStop(bool start);
177 
178 private slots:
179  void networkManagerFinished(QNetworkReply *reply);
180 };
181 
182 
183 #endif /* PLUGINS_SAMPLESOURCE_PLUTOSDRINPUT_PLUTOSDRINPUT_H_ */
MsgConfigurePlutoSDR(const PlutoSDRInputSettings &settings, bool force)
Definition: plutosdrinput.h:57
PlutoSDRInputThread * m_plutoSDRInputThread
virtual void setMessageQueueToGUI(MessageQueue *queue)
virtual QByteArray serialize() const
virtual void destroy()
FileRecord * m_fileSink
PlutoSDRInput(DeviceAPI *deviceAPI)
struct iio_buffer * m_plutoRxBuffer
static MsgConfigurePlutoSDR * create(const PlutoSDRInputSettings &settings, bool force)
Definition: plutosdrinput.h:48
DevicePlutoSDRBox::SampleRates m_deviceSampleRates
QNetworkAccessManager * m_networkManager
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
bool fetchTemperature()
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
QString m_deviceDescription
PlutoSDRInputSettings m_settings
Definition: plutosdrinput.h:54
float getTemperature()
bool applySettings(const PlutoSDRInputSettings &settings, bool force=false)
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const PlutoSDRInputSettings &settings, bool force)
unsigned int uint32_t
Definition: rtptypes_win.h:46
PlutoSDRInputSettings m_settings
void getRSSI(std::string &rssiStr)
DeviceAPI * m_deviceAPI
void getbbLPRange(quint32 &minLimit, quint32 &maxLimit)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PlutoSDRInputSettings &settings)
virtual int getSampleRate() const
Sample rate exposed by the source.
virtual void stop()
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
MsgStartStop(bool startStop)
Definition: plutosdrinput.h:96
virtual bool handleMessage(const Message &message)
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void webapiReverseSendStartStop(bool start)
void getLORange(qint64 &minLimit, qint64 &maxLimit)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
MsgFileRecord(bool startStop)
Definition: plutosdrinput.h:77
uint32_t getFIRSampleRate() const
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
const PlutoSDRInputSettings & getSettings() const
Definition: plutosdrinput.h:45
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
DevicePlutoSDRShared m_deviceShared
uint32_t m_hb1Rate
Rate of the HB1 filter (Rx: out, Tx: in) - this is the FIR working sample rate.
void getGain(int &gainStr)
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
static MsgStartStop * create(bool startStop)
Definition: plutosdrinput.h:89
virtual bool deserialize(const QByteArray &data)
void networkManagerFinished(QNetworkReply *reply)
virtual bool start()
static MsgFileRecord * create(bool startStop)
Definition: plutosdrinput.h:70
virtual void setCenterFrequency(qint64 centerFrequency)
QNetworkRequest m_networkRequest
uint32_t m_addaConnvRate
A/D or D/A converter rat - this is the HB3 working sample rate.
virtual const QString & getDeviceDescription() const
uint32_t getADCSampleRate() const