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.
plutosdroutput.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_PLUTOSDROUTPUT_PLUTOSDRINPUT_H_
19 #define PLUGINS_SAMPLESOURCE_PLUTOSDROUTPUT_PLUTOSDRINPUT_H_
20 
21 #include <QString>
22 #include <QNetworkRequest>
23 
24 #include "iio.h"
25 #include "dsp/devicesamplesink.h"
26 #include "util/message.h"
29 #include "plutosdroutputsettings.h"
30 
31 class QNetworkAccessManager;
32 class QNetworkReply;
33 class DeviceAPI;
35 
37  Q_OBJECT
38 public:
39  class MsgConfigurePlutoSDR : public Message {
41 
42  public:
43  const PlutoSDROutputSettings& getSettings() const { return m_settings; }
44  bool getForce() const { return m_force; }
45 
46  static MsgConfigurePlutoSDR* create(const PlutoSDROutputSettings& settings, bool force)
47  {
48  return new MsgConfigurePlutoSDR(settings, force);
49  }
50 
51  private:
53  bool m_force;
54 
55  MsgConfigurePlutoSDR(const PlutoSDROutputSettings& settings, bool force) :
56  Message(),
57  m_settings(settings),
58  m_force(force)
59  { }
60  };
61 
62  class MsgStartStop : public Message {
64 
65  public:
66  bool getStartStop() const { return m_startStop; }
67 
68  static MsgStartStop* create(bool startStop) {
69  return new MsgStartStop(startStop);
70  }
71 
72  protected:
74 
75  MsgStartStop(bool startStop) :
76  Message(),
77  m_startStop(startStop)
78  { }
79  };
80 
81  PlutoSDROutput(DeviceAPI *deviceAPI);
83  virtual void destroy();
84 
85  virtual void init();
86  virtual bool start();
87  virtual void stop();
88 
89  virtual QByteArray serialize() const;
90  virtual bool deserialize(const QByteArray& data);
91 
92  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
93  virtual const QString& getDeviceDescription() const;
94  virtual int getSampleRate() const;
95  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
96  virtual quint64 getCenterFrequency() const;
97  virtual void setCenterFrequency(qint64 centerFrequency);
98 
99  virtual bool handleMessage(const Message& message);
100 
101  virtual int webapiSettingsGet(
103  QString& errorMessage);
104 
105  virtual int webapiSettingsPutPatch(
106  bool force,
107  const QStringList& deviceSettingsKeys,
108  SWGSDRangel::SWGDeviceSettings& response, // query + response
109  QString& errorMessage);
110 
111  virtual int webapiReportGet(
113  QString& errorMessage);
114 
115  virtual int webapiRunGet(
116  SWGSDRangel::SWGDeviceState& response,
117  QString& errorMessage);
118 
119  virtual int webapiRun(
120  bool run,
121  SWGSDRangel::SWGDeviceState& response,
122  QString& errorMessage);
123 
126  void getRSSI(std::string& rssiStr);
127  void getLORange(qint64& minLimit, qint64& maxLimit);
128  void getbbLPRange(quint32& minLimit, quint32& maxLimit);
129  bool fetchTemperature();
130  float getTemperature();
131 
132  private:
136  bool m_running;
138  struct iio_buffer *m_plutoTxBuffer;
141  QMutex m_mutex;
142  QNetworkAccessManager *m_networkManager;
143  QNetworkRequest m_networkRequest;
144 
145  bool openDevice();
146  void closeDevice();
147  void suspendBuddies();
148  void resumeBuddies();
149  bool applySettings(const PlutoSDROutputSettings& settings, bool force = false);
152  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PlutoSDROutputSettings& settings, bool force);
153  void webapiReverseSendStartStop(bool start);
154 
155 private slots:
156  void networkManagerFinished(QNetworkReply *reply);
157 };
158 
159 
160 #endif /* PLUGINS_SAMPLESOURCE_PLUTOSDROUTPUT_PLUTOSDRINPUT_H_ */
void webapiReverseSendStartStop(bool start)
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
struct iio_buffer * m_plutoTxBuffer
PlutoSDROutput(DeviceAPI *deviceAPI)
virtual const QString & getDeviceDescription() const
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
unsigned int uint32_t
Definition: rtptypes_win.h:46
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
void getRSSI(std::string &rssiStr)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
PlutoSDROutputThread * m_plutoSDROutputThread
DevicePlutoSDRBox::SampleRates m_deviceSampleRates
static MsgConfigurePlutoSDR * create(const PlutoSDROutputSettings &settings, bool force)
MsgConfigurePlutoSDR(const PlutoSDROutputSettings &settings, bool force)
uint32_t getFIRSampleRate() const
QNetworkRequest m_networkRequest
virtual bool deserialize(const QByteArray &data)
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const PlutoSDROutputSettings &settings, bool force)
void networkManagerFinished(QNetworkReply *reply)
const PlutoSDROutputSettings & getSettings() const
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
DevicePlutoSDRShared m_deviceShared
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual void stop()
bool applySettings(const PlutoSDROutputSettings &settings, bool force=false)
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
PlutoSDROutputSettings m_settings
virtual QByteArray serialize() const
QNetworkAccessManager * m_networkManager
uint32_t m_hb1Rate
Rate of the HB1 filter (Rx: out, Tx: in) - this is the FIR working sample rate.
void getbbLPRange(quint32 &minLimit, quint32 &maxLimit)
virtual bool start()
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PlutoSDROutputSettings &settings)
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
virtual void setMessageQueueToGUI(MessageQueue *queue)
DeviceAPI * m_deviceAPI
static MsgStartStop * create(bool startStop)
void getLORange(qint64 &minLimit, qint64 &maxLimit)
QString m_deviceDescription
uint32_t m_addaConnvRate
A/D or D/A converter rat - this is the HB3 working sample rate.
uint32_t getDACSampleRate() const
virtual void setCenterFrequency(qint64 centerFrequency)
virtual int getSampleRate() const
Sample rate exposed by the sink.
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
PlutoSDROutputSettings m_settings
virtual void destroy()
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
virtual bool handleMessage(const Message &message)