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.
testsourceinput.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 _TESTSOURCE_TESTSOURCEINPUT_H_
19 #define _TESTSOURCE_TESTSOURCEINPUT_H_
20 
21 #include <QString>
22 #include <QByteArray>
23 #include <QTimer>
24 #include <QNetworkRequest>
25 
26 #include <dsp/devicesamplesource.h>
27 #include "testsourcesettings.h"
28 
29 class DeviceAPI;
30 class TestSourceThread;
31 class FileRecord;
32 class QNetworkAccessManager;
33 class QNetworkReply;
34 
36  Q_OBJECT
37 public:
40 
41  public:
42  const TestSourceSettings& getSettings() const { return m_settings; }
43  bool getForce() const { return m_force; }
44 
45  static MsgConfigureTestSource* create(const TestSourceSettings& settings, bool force)
46  {
47  return new MsgConfigureTestSource(settings, force);
48  }
49 
50  private:
52  bool m_force;
53 
54  MsgConfigureTestSource(const TestSourceSettings& settings, bool force) :
55  Message(),
56  m_settings(settings),
57  m_force(force)
58  { }
59  };
60 
61  class MsgFileRecord : public Message {
63 
64  public:
65  bool getStartStop() const { return m_startStop; }
66 
67  static MsgFileRecord* create(bool startStop) {
68  return new MsgFileRecord(startStop);
69  }
70 
71  protected:
73 
74  MsgFileRecord(bool startStop) :
75  Message(),
76  m_startStop(startStop)
77  { }
78  };
79 
80  class MsgStartStop : public Message {
82 
83  public:
84  bool getStartStop() const { return m_startStop; }
85 
86  static MsgStartStop* create(bool startStop) {
87  return new MsgStartStop(startStop);
88  }
89 
90  protected:
92 
93  MsgStartStop(bool startStop) :
94  Message(),
95  m_startStop(startStop)
96  { }
97  };
98 
99  TestSourceInput(DeviceAPI *deviceAPI);
100  virtual ~TestSourceInput();
101  virtual void destroy();
102 
103  virtual void init();
104  virtual bool start();
105  virtual void stop();
106 
107  virtual QByteArray serialize() const;
108  virtual bool deserialize(const QByteArray& data);
109 
110  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
111  virtual const QString& getDeviceDescription() const;
112  virtual int getSampleRate() const;
113  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
114  virtual quint64 getCenterFrequency() const;
115  virtual void setCenterFrequency(qint64 centerFrequency);
116 
117  virtual bool handleMessage(const Message& message);
118 
119  virtual int webapiSettingsGet(
121  QString& errorMessage);
122 
123  virtual int webapiSettingsPutPatch(
124  bool force,
125  const QStringList& deviceSettingsKeys,
126  SWGSDRangel::SWGDeviceSettings& response, // query + response
127  QString& errorMessage);
128 
129  virtual int webapiRunGet(
130  SWGSDRangel::SWGDeviceState& response,
131  QString& errorMessage);
132 
133  virtual int webapiRun(
134  bool run,
135  SWGSDRangel::SWGDeviceState& response,
136  QString& errorMessage);
137 
138 private:
141  QMutex m_mutex;
145  bool m_running;
146  const QTimer& m_masterTimer;
147  QNetworkAccessManager *m_networkManager;
148  QNetworkRequest m_networkRequest;
149 
150  bool applySettings(const TestSourceSettings& settings, bool force);
152  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const TestSourceSettings& settings, bool force);
153  void webapiReverseSendStartStop(bool start);
154 
155 private slots:
156  void networkManagerFinished(QNetworkReply *reply);
157 };
158 
159 #endif // _TESTSOURCE_TESTSOURCEINPUT_H_
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const TestSourceSettings &settings)
virtual bool deserialize(const QByteArray &data)
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual void destroy()
static MsgFileRecord * create(bool startStop)
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
virtual bool handleMessage(const Message &message)
virtual int getSampleRate() const
Sample rate exposed by the source.
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
virtual ~TestSourceInput()
const QTimer & m_masterTimer
void networkManagerFinished(QNetworkReply *reply)
virtual void stop()
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
QNetworkAccessManager * m_networkManager
virtual const QString & getDeviceDescription() const
virtual void setMessageQueueToGUI(MessageQueue *queue)
static MsgConfigureTestSource * create(const TestSourceSettings &settings, bool force)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
void webapiReverseSendStartStop(bool start)
QNetworkRequest m_networkRequest
TestSourceThread * m_testSourceThread
TestSourceSettings m_settings
virtual void setCenterFrequency(qint64 centerFrequency)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
MsgConfigureTestSource(const TestSourceSettings &settings, bool force)
FileRecord * m_fileSink
File sink to record device I/Q output.
virtual QByteArray serialize() const
static MsgStartStop * create(bool startStop)
TestSourceInput(DeviceAPI *deviceAPI)
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
DeviceAPI * m_deviceAPI
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const TestSourceSettings &settings, bool force)
virtual bool start()
bool applySettings(const TestSourceSettings &settings, bool force)
QString m_deviceDescription
const TestSourceSettings & getSettings() const