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.
airspyinput.h
Go to the documentation of this file.
1 // Copyright (C) 2015 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_AIRSPYINPUT_H
19 #define INCLUDE_AIRSPYINPUT_H
20 
21 #include <QString>
22 #include <QByteArray>
23 #include <QNetworkRequest>
24 
25 #include <libairspy/airspy.h>
26 #include <dsp/devicesamplesource.h>
27 #include "airspysettings.h"
28 
29 class QNetworkAccessManager;
30 class QNetworkReply;
31 class DeviceAPI;
32 class AirspyThread;
33 class FileRecord;
34 
36  Q_OBJECT
37 public:
38  class MsgConfigureAirspy : public Message {
40 
41  public:
42  const AirspySettings& getSettings() const { return m_settings; }
43  bool getForce() const { return m_force; }
44 
45  static MsgConfigureAirspy* create(const AirspySettings& settings, bool force)
46  {
47  return new MsgConfigureAirspy(settings, force);
48  }
49 
50  private:
52  bool m_force;
53 
54  MsgConfigureAirspy(const AirspySettings& 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  AirspyInput(DeviceAPI *deviceAPI);
100  virtual ~AirspyInput();
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  const std::vector<uint32_t>& getSampleRates() const { return m_sampleRates; }
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 webapiRunGet(
131  SWGSDRangel::SWGDeviceState& response,
132  QString& errorMessage);
133 
134  virtual int webapiRun(
135  bool run,
136  SWGSDRangel::SWGDeviceState& response,
137  QString& errorMessage);
138 
139  virtual int webapiReportGet(
141  QString& errorMessage);
142 
143  static const qint64 loLowLimitFreq;
144  static const qint64 loHighLimitFreq;
145 
146 private:
148  QMutex m_mutex;
150  struct airspy_device* m_dev;
153  std::vector<uint32_t> m_sampleRates;
154  bool m_running;
156  QNetworkAccessManager *m_networkManager;
157  QNetworkRequest m_networkRequest;
158 
159  bool openDevice();
160  void closeDevice();
161  bool applySettings(const AirspySettings& settings, bool force);
162  struct airspy_device *open_airspy_from_sequence(int sequence);
163  void setDeviceCenterFrequency(quint64 freq);
166  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const AirspySettings& settings, bool force);
167  void webapiReverseSendStartStop(bool start);
168 
169 private slots:
170  void networkManagerFinished(QNetworkReply *reply);
171 };
172 
173 #endif // INCLUDE_AIRSPYINPUT_H
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: airspyinput.h:155
bool m_running
Definition: airspyinput.h:154
QNetworkRequest m_networkRequest
Definition: airspyinput.h:157
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
void networkManagerFinished(QNetworkReply *reply)
QString m_deviceDescription
Definition: airspyinput.h:152
const AirspySettings & getSettings() const
Definition: airspyinput.h:42
virtual quint64 getCenterFrequency() const
Center frequency exposed by the source.
virtual bool handleMessage(const Message &message)
static const qint64 loLowLimitFreq
Definition: airspyinput.h:143
virtual bool start()
virtual int webapiSettingsPutPatch(bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
virtual int getSampleRate() const
Sample rate exposed by the source.
virtual bool deserialize(const QByteArray &data)
virtual ~AirspyInput()
Definition: airspyinput.cpp:65
virtual QByteArray serialize() const
virtual void init()
initializations to be done when all collaborating objects are created and possibly connected ...
static MsgStartStop * create(bool startStop)
Definition: airspyinput.h:86
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Definition: airspyinput.h:113
bool openDevice()
Definition: airspyinput.cpp:84
AirspyInput(DeviceAPI *deviceAPI)
Definition: airspyinput.cpp:48
virtual int webapiRunGet(SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
std::vector< uint32_t > m_sampleRates
Definition: airspyinput.h:153
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
virtual int webapiReportGet(SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
const std::vector< uint32_t > & getSampleRates() const
Definition: airspyinput.h:116
virtual void setCenterFrequency(qint64 centerFrequency)
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const AirspySettings &settings)
AirspySettings m_settings
Definition: airspyinput.h:149
struct airspy_device * open_airspy_from_sequence(int sequence)
virtual void destroy()
Definition: airspyinput.cpp:79
MsgConfigureAirspy(const AirspySettings &settings, bool force)
Definition: airspyinput.h:54
QMutex m_mutex
Definition: airspyinput.h:148
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
DeviceAPI * m_deviceAPI
Definition: airspyinput.h:147
static const qint64 loHighLimitFreq
Definition: airspyinput.h:144
bool getStartStop() const
Definition: airspyinput.h:84
AirspyThread * m_airspyThread
Definition: airspyinput.h:151
virtual int webapiSettingsGet(SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
MsgStartStop(bool startStop)
Definition: airspyinput.h:93
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const AirspySettings &settings, bool force)
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: airspyinput.h:110
QNetworkAccessManager * m_networkManager
Definition: airspyinput.h:156
virtual const QString & getDeviceDescription() const
bool applySettings(const AirspySettings &settings, bool force)
struct airspy_device * m_dev
Definition: airspyinput.h:150
void setDeviceCenterFrequency(quint64 freq)
MsgFileRecord(bool startStop)
Definition: airspyinput.h:74
void closeDevice()
void webapiReverseSendStartStop(bool start)
virtual int webapiRun(bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
static MsgConfigureAirspy * create(const AirspySettings &settings, bool force)
Definition: airspyinput.h:45
virtual void stop()
static MsgFileRecord * create(bool startStop)
Definition: airspyinput.h:67