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.
fcdproplusinput.h
Go to the documentation of this file.
1 // Copyright (C) 2016-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 INCLUDE_FCDINPUT_H
19 #define INCLUDE_FCDINPUT_H
20 
21 #include <inttypes.h>
22 
23 #include <QString>
24 #include <QByteArray>
25 #include <QNetworkRequest>
26 
27 #include "dsp/devicesamplesource.h"
28 #include "audio/audioinput.h"
29 #include "audio/audiofifo.h"
30 
31 #include "fcdproplussettings.h"
32 #include "fcdhid.h"
33 
34 struct fcd_buffer {
35  void *start;
36  std::size_t length;
37 };
38 
39 class QNetworkAccessManager;
40 class QNetworkReply;
41 class DeviceAPI;
42 class FCDProPlusThread;
43 class FileRecord;
44 
46  Q_OBJECT
47 public:
50 
51  public:
52  const FCDProPlusSettings& getSettings() const { return m_settings; }
53  bool getForce() const { return m_force; }
54 
55  static MsgConfigureFCDProPlus* create(const FCDProPlusSettings& settings, bool force)
56  {
57  return new MsgConfigureFCDProPlus(settings, force);
58  }
59 
60  private:
62  bool m_force;
63 
64  MsgConfigureFCDProPlus(const FCDProPlusSettings& settings, bool force) :
65  Message(),
66  m_settings(settings),
67  m_force(force)
68  { }
69  };
70 
71  class MsgStartStop : public Message {
73 
74  public:
75  bool getStartStop() const { return m_startStop; }
76 
77  static MsgStartStop* create(bool startStop) {
78  return new MsgStartStop(startStop);
79  }
80 
81  protected:
83 
84  MsgStartStop(bool startStop) :
85  Message(),
86  m_startStop(startStop)
87  { }
88  };
89 
90  class MsgFileRecord : public Message {
92 
93  public:
94  bool getStartStop() const { return m_startStop; }
95 
96  static MsgFileRecord* create(bool startStop) {
97  return new MsgFileRecord(startStop);
98  }
99 
100  protected:
102 
103  MsgFileRecord(bool startStop) :
104  Message(),
105  m_startStop(startStop)
106  { }
107  };
108 
109  FCDProPlusInput(DeviceAPI *deviceAPI);
110  virtual ~FCDProPlusInput();
111  virtual void destroy();
112 
113  virtual void init();
114  virtual bool start();
115  virtual void stop();
116 
117  virtual QByteArray serialize() const;
118  virtual bool deserialize(const QByteArray& data);
119 
120  virtual void setMessageQueueToGUI(MessageQueue *queue) { m_guiMessageQueue = queue; }
121  virtual const QString& getDeviceDescription() const;
122  virtual int getSampleRate() const;
123  virtual void setSampleRate(int sampleRate) { (void) sampleRate; }
124  virtual quint64 getCenterFrequency() const;
125  virtual void setCenterFrequency(qint64 centerFrequency);
126 
127  virtual bool handleMessage(const Message& message);
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  virtual int webapiSettingsGet(
140  QString& errorMessage);
141 
142  virtual int webapiSettingsPutPatch(
143  bool force,
144  const QStringList& deviceSettingsKeys,
145  SWGSDRangel::SWGDeviceSettings& response, // query + response
146  QString& errorMessage);
147 
148  void set_center_freq(double freq);
149  void set_bias_t(bool on);
150  void set_lna_gain(bool on);
151  void set_mixer_gain(bool on);
152  void set_if_gain(int gain);
153  void set_rf_filter(int filterIndex);
154  void set_if_filter(int filterIndex);
155 
156 private:
161  QMutex m_mutex;
165  bool m_running;
167  QNetworkAccessManager *m_networkManager;
168  QNetworkRequest m_networkRequest;
169 
170  bool openDevice();
171  void closeDevice();
172  bool openFCDAudio(const char *filename);
173  void closeFCDAudio();
174  void applySettings(const FCDProPlusSettings& settings, bool force);
175  void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProPlusSettings& settings);
176  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FCDProPlusSettings& settings, bool force);
177  void webapiReverseSendStartStop(bool start);
178 
179 private slots:
180  void networkManagerFinished(QNetworkReply *reply);
181 };
182 
183 #endif // INCLUDE_FCD_H
FCDProPlusThread * m_FCDThread
QNetworkAccessManager * m_networkManager
DeviceAPI * m_deviceAPI
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
FileRecord * m_fileSink
File sink to record device I/Q output.
static MsgConfigureFCDProPlus * create(const FCDProPlusSettings &settings, bool force)
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
std::size_t length
Definition: fcdproinput.h:36
void * start
Definition: fcdproinput.h:35
QNetworkRequest m_networkRequest
virtual void setMessageQueueToGUI(MessageQueue *queue)
hid_device * m_dev
FCDProPlusSettings m_settings
MsgConfigureFCDProPlus(const FCDProPlusSettings &settings, bool force)
const FCDProPlusSettings & getSettings() const
QString m_deviceDescription
static MsgStartStop * create(bool startStop)
AudioInput m_fcdAudioInput
static MsgFileRecord * create(bool startStop)