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.
localoutput.h
Go to the documentation of this file.
1 // Copyright (C) 2019 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 INCLUDE_LOCALOUTPUT_H
19 #define INCLUDE_LOCALOUTPUT_H
20 
21 #include <ctime>
22 #include <iostream>
23 #include <stdint.h>
24 
25 #include <QString>
26 #include <QByteArray>
27 #include <QTimer>
28 #include <QNetworkRequest>
29 
30 #include "dsp/devicesamplesink.h"
31 
32 #include "localoutputsettings.h"
33 
34 class QNetworkAccessManager;
35 class QNetworkReply;
36 class DeviceAPI;
37 class FileRecord;
38 
39 class LocalOutput : public DeviceSampleSink {
40  Q_OBJECT
41 public:
44 
45  public:
46  const LocalOutputSettings& getSettings() const { return m_settings; }
47  bool getForce() const { return m_force; }
48 
49  static MsgConfigureLocalOutput* create(const LocalOutputSettings& settings, bool force = false)
50  {
51  return new MsgConfigureLocalOutput(settings, force);
52  }
53 
54  private:
56  bool m_force;
57 
58  MsgConfigureLocalOutput(const LocalOutputSettings& settings, bool force) :
59  Message(),
60  m_settings(settings),
61  m_force(force)
62  { }
63  };
64 
65  class MsgStartStop : public Message {
67 
68  public:
69  bool getStartStop() const { return m_startStop; }
70 
71  static MsgStartStop* create(bool startStop) {
72  return new MsgStartStop(startStop);
73  }
74 
75  protected:
77 
78  MsgStartStop(bool startStop) :
79  Message(),
80  m_startStop(startStop)
81  { }
82  };
83 
86 
87  public:
88  int getSampleRate() const { return m_sampleRate; }
89  int getCenterFrequency() const { return m_centerFrequency; }
90 
91  static MsgReportSampleRateAndFrequency* create(int sampleRate, qint64 centerFrequency) {
92  return new MsgReportSampleRateAndFrequency(sampleRate, centerFrequency);
93  }
94 
95  protected:
98 
99  MsgReportSampleRateAndFrequency(int sampleRate, qint64 centerFrequency) :
100  Message(),
101  m_sampleRate(sampleRate),
102  m_centerFrequency(centerFrequency)
103  { }
104  };
105 
106  LocalOutput(DeviceAPI *deviceAPI);
107  virtual ~LocalOutput();
108  virtual void destroy();
109 
110  virtual void init();
111  virtual bool start();
112  virtual void stop();
113 
114  virtual QByteArray serialize() const;
115  virtual bool deserialize(const QByteArray& data);
116 
117  virtual void setMessageQueueToGUI(MessageQueue *queue);
118  virtual const QString& getDeviceDescription() const;
119  virtual int getSampleRate() const;
120  virtual void setSampleRate(int sampleRate);
121  virtual quint64 getCenterFrequency() const;
122  virtual void setCenterFrequency(qint64 centerFrequency);
123  std::time_t getStartingTimeStamp() const;
124 
125  virtual bool handleMessage(const Message& message);
126 
127  virtual int webapiSettingsGet(
129  QString& errorMessage);
130 
131  virtual int webapiSettingsPutPatch(
132  bool force,
133  const QStringList& deviceSettingsKeys,
134  SWGSDRangel::SWGDeviceSettings& response, // query + response
135  QString& errorMessage);
136 
137  virtual int webapiReportGet(
139  QString& errorMessage);
140 
141  virtual int webapiRunGet(
142  SWGSDRangel::SWGDeviceState& response,
143  QString& errorMessage);
144 
145  virtual int webapiRun(
146  bool run,
147  SWGSDRangel::SWGDeviceState& response,
148  QString& errorMessage);
149 
150 private:
152  QMutex m_mutex;
159  QNetworkAccessManager *m_networkManager;
160  QNetworkRequest m_networkRequest;
161 
162  void applySettings(const LocalOutputSettings& settings, bool force = false);
165  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const LocalOutputSettings& settings, bool force);
166  void webapiReverseSendStartStop(bool start);
167 
168 private slots:
169  void networkManagerFinished(QNetworkReply *reply);
170 };
171 
172 #endif // INCLUDE_LOCALOUTPUT_H
virtual void setMessageQueueToGUI(MessageQueue *queue)
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: localoutput.h:158
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
void applySettings(const LocalOutputSettings &settings, bool force=false)
static MsgStartStop * create(bool startStop)
Definition: localoutput.h:71
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
virtual void setSampleRate(int sampleRate)
For when the sink sample rate is set externally.
QNetworkRequest m_networkRequest
Definition: localoutput.h:160
virtual void destroy()
Definition: localoutput.cpp:62
MsgReportSampleRateAndFrequency(int sampleRate, qint64 centerFrequency)
Definition: localoutput.h:99
virtual void setCenterFrequency(qint64 centerFrequency)
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
QString m_deviceDescription
Definition: localoutput.h:157
std::time_t getStartingTimeStamp() const
bool getStartStop() const
Definition: localoutput.h:69
void webapiReverseSendStartStop(bool start)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
QString m_remoteAddress
Definition: localoutput.h:156
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const LocalOutputSettings &settings)
virtual bool deserialize(const QByteArray &data)
Definition: localoutput.cpp:88
LocalOutputSettings m_settings
Definition: localoutput.h:153
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
static MsgReportSampleRateAndFrequency * create(int sampleRate, qint64 centerFrequency)
Definition: localoutput.h:91
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
QMutex m_mutex
Definition: localoutput.h:152
virtual const QString & getDeviceDescription() const
MsgStartStop(bool startStop)
Definition: localoutput.h:78
const LocalOutputSettings & getSettings() const
Definition: localoutput.h:46
virtual int getSampleRate() const
Sample rate exposed by the sink.
qint64 m_centerFrequency
Definition: localoutput.h:154
QNetworkAccessManager * m_networkManager
Definition: localoutput.h:159
virtual void stop()
Definition: localoutput.cpp:78
MsgConfigureLocalOutput(const LocalOutputSettings &settings, bool force)
Definition: localoutput.h:58
virtual ~LocalOutput()
Definition: localoutput.cpp:55
static MsgConfigureLocalOutput * create(const LocalOutputSettings &settings, bool force=false)
Definition: localoutput.h:49
void networkManagerFinished(QNetworkReply *reply)
DeviceAPI * m_deviceAPI
Definition: localoutput.h:151
virtual quint64 getCenterFrequency() const
Center frequency exposed by the sink.
virtual bool start()
Definition: localoutput.cpp:72
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
int m_sampleRate
Definition: localoutput.h:155
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
Definition: localoutput.cpp:67
virtual QByteArray serialize() const
Definition: localoutput.cpp:83
LocalOutput(DeviceAPI *deviceAPI)
Definition: localoutput.cpp:41
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const LocalOutputSettings &settings, bool force)
virtual bool handleMessage(const Message &message)