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.
perseusinput.h
Go to the documentation of this file.
1 // Copyright (C) 2018 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_PERSEUS_PERSEUSINPUT_H_
19 #define PLUGINS_SAMPLESOURCE_PERSEUS_PERSEUSINPUT_H_
20 
21 #include <vector>
22 
23 #include <QNetworkRequest>
24 
25 #include "perseus-sdr.h"
26 #include "dsp/devicesamplesource.h"
27 #include "util/message.h"
28 #include "perseussettings.h"
29 
30 class QNetworkAccessManager;
31 class QNetworkReply;
32 class DeviceAPI;
33 class FileRecord;
34 class PerseusThread;
35 
37  Q_OBJECT
38 public:
39  class MsgConfigurePerseus : public Message {
41 
42  public:
43  const PerseusSettings& getSettings() const { return m_settings; }
44  bool getForce() const { return m_force; }
45 
46  static MsgConfigurePerseus* create(const PerseusSettings& settings, bool force)
47  {
48  return new MsgConfigurePerseus(settings, force);
49  }
50 
51  private:
53  bool m_force;
54 
55  MsgConfigurePerseus(const PerseusSettings& settings, bool force) :
56  Message(),
57  m_settings(settings),
58  m_force(force)
59  { }
60  };
61 
62  class MsgFileRecord : public Message {
64 
65  public:
66  bool getStartStop() const { return m_startStop; }
67 
68  static MsgFileRecord* create(bool startStop) {
69  return new MsgFileRecord(startStop);
70  }
71 
72  protected:
74 
75  MsgFileRecord(bool startStop) :
76  Message(),
77  m_startStop(startStop)
78  { }
79  };
80 
81  class MsgStartStop : public Message {
83 
84  public:
85  bool getStartStop() const { return m_startStop; }
86 
87  static MsgStartStop* create(bool startStop) {
88  return new MsgStartStop(startStop);
89  }
90 
91  protected:
93 
94  MsgStartStop(bool startStop) :
95  Message(),
96  m_startStop(startStop)
97  { }
98  };
99 
100  PerseusInput(DeviceAPI *deviceAPI);
101  ~PerseusInput();
102  virtual void destroy();
103 
104  virtual void init();
105  virtual bool start();
106  virtual void stop();
107 
108  virtual QByteArray serialize() const;
109  virtual bool deserialize(const QByteArray& data);
110 
111  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
112  virtual const QString& getDeviceDescription() const;
113  virtual int getSampleRate() const;
114  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
115  virtual quint64 getCenterFrequency() const;
116  virtual void setCenterFrequency(qint64 centerFrequency);
117 
118  virtual bool handleMessage(const Message& message);
119 
120  virtual int webapiSettingsGet(
122  QString& errorMessage);
123 
124  virtual int webapiSettingsPutPatch(
125  bool force,
126  const QStringList& deviceSettingsKeys,
127  SWGSDRangel::SWGDeviceSettings& response, // query + response
128  QString& errorMessage);
129 
130  virtual int webapiReportGet(
132  QString& errorMessage);
133 
134  virtual int webapiRunGet(
135  SWGSDRangel::SWGDeviceState& response,
136  QString& errorMessage);
137 
138  virtual int webapiRun(
139  bool run,
140  SWGSDRangel::SWGDeviceState& response,
141  QString& errorMessage);
142 
143  const std::vector<uint32_t>& getSampleRates() const { return m_sampleRates; }
144 
145 private:
150  bool m_running;
152  perseus_descr *m_perseusDescriptor;
153  std::vector<uint32_t> m_sampleRates;
154  QNetworkAccessManager *m_networkManager;
155  QNetworkRequest m_networkRequest;
156 
157  bool openDevice();
158  void closeDevice();
159  void setDeviceCenterFrequency(quint64 freq, const PerseusSettings& settings);
160  bool applySettings(const PerseusSettings& settings, bool force = false);
163  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const PerseusSettings& settings, bool force);
164  void webapiReverseSendStartStop(bool start);
165 
166 private slots:
167  void networkManagerFinished(QNetworkReply *reply);
168 };
169 
170 #endif /* PLUGINS_SAMPLESOURCE_PERSEUS_PERSEUSINPUT_H_ */
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const PerseusSettings &settings, bool force)
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void webapiReverseSendStartStop(bool start)
QNetworkAccessManager * m_networkManager
Definition: perseusinput.h:154
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const PerseusSettings &settings)
const std::vector< uint32_t > & getSampleRates() const
Definition: perseusinput.h:143
MsgStartStop(bool startStop)
Definition: perseusinput.h:94
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: perseusinput.h:111
DeviceAPI * m_deviceAPI
Definition: perseusinput.h:146
void networkManagerFinished(QNetworkReply *reply)
void closeDevice()
virtual int getSampleRate() const
Sample rate exposed by the source.
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
MsgConfigurePerseus(const PerseusSettings &settings, bool force)
Definition: perseusinput.h:55
PerseusInput(DeviceAPI *deviceAPI)
FileRecord * m_fileSink
Definition: perseusinput.h:147
virtual const QString & getDeviceDescription() const
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
void setDeviceCenterFrequency(quint64 freq, const PerseusSettings &settings)
virtual bool deserialize(const QByteArray &data)
virtual void stop()
perseus_descr * m_perseusDescriptor
Definition: perseusinput.h:152
std::vector< uint32_t > m_sampleRates
Definition: perseusinput.h:153
static MsgConfigurePerseus * create(const PerseusSettings &settings, bool force)
Definition: perseusinput.h:46
virtual void setCenterFrequency(qint64 centerFrequency)
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
static MsgStartStop * create(bool startStop)
Definition: perseusinput.h:87
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual bool start()
QNetworkRequest m_networkRequest
Definition: perseusinput.h:155
PerseusThread * m_perseusThread
Definition: perseusinput.h:151
virtual bool handleMessage(const Message &message)
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
virtual void destroy()
PerseusSettings m_settings
Definition: perseusinput.h:149
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Definition: perseusinput.h:114
const PerseusSettings & getSettings() const
Definition: perseusinput.h:43
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
virtual QByteArray serialize() const
static MsgFileRecord * create(bool startStop)
Definition: perseusinput.h:68
bool applySettings(const PerseusSettings &settings, bool force=false)
MsgFileRecord(bool startStop)
Definition: perseusinput.h:75
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
QString m_deviceDescription
Definition: perseusinput.h:148