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.
fcdproinput.h
Go to the documentation of this file.
1 // Copyright (C) 2015-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_FCDPROINPUT_H
19 #define INCLUDE_FCDPROINPUT_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 "fcdprosettings.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 FCDProThread;
43 class FileRecord;
44 
46  Q_OBJECT
47 public:
48  class MsgConfigureFCDPro : public Message {
50 
51  public:
52  const FCDProSettings& getSettings() const { return m_settings; }
53  bool getForce() const { return m_force; }
54 
55  static MsgConfigureFCDPro* create(const FCDProSettings& settings, bool force)
56  {
57  return new MsgConfigureFCDPro(settings, force);
58  }
59 
60  private:
62  bool m_force;
63 
64  MsgConfigureFCDPro(const FCDProSettings& settings, bool force) :
65  Message(),
66  m_settings(settings),
67  m_force(force)
68  { }
69  };
70 
71  class MsgFileRecord : public Message {
73 
74  public:
75  bool getStartStop() const { return m_startStop; }
76 
77  static MsgFileRecord* create(bool startStop) {
78  return new MsgFileRecord(startStop);
79  }
80 
81  protected:
83 
84  MsgFileRecord(bool startStop) :
85  Message(),
86  m_startStop(startStop)
87  { }
88  };
89 
90  class MsgStartStop : public Message {
92 
93  public:
94  bool getStartStop() const { return m_startStop; }
95 
96  static MsgStartStop* create(bool startStop) {
97  return new MsgStartStop(startStop);
98  }
99 
100  protected:
102 
103  MsgStartStop(bool startStop) :
104  Message(),
105  m_startStop(startStop)
106  { }
107  };
108 
109  FCDProInput(DeviceAPI *deviceAPI);
110  virtual ~FCDProInput();
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 webapiSettingsGet(
131  QString& errorMessage);
132 
133  virtual int webapiSettingsPutPatch(
134  bool force,
135  const QStringList& deviceSettingsKeys,
136  SWGSDRangel::SWGDeviceSettings& response, // query + response
137  QString& errorMessage);
138 
139  virtual int webapiRunGet(
140  SWGSDRangel::SWGDeviceState& response,
141  QString& errorMessage);
142 
143  virtual int webapiRun(
144  bool run,
145  SWGSDRangel::SWGDeviceState& response,
146  QString& errorMessage);
147 
148  void set_center_freq(double freq);
149  void set_bias_t(bool on);
150  void set_lnaGain(int index);
151  void set_rfFilter(int index);
152  void set_lnaEnhance(int index);
153  void set_band(int index);
154  void set_mixerGain(int index);
155  void set_mixerFilter(int index);
156  void set_biasCurrent(int index);
157  void set_mode(int index);
158  void set_gain1(int index);
159  void set_rcFilter(int index);
160  void set_gain2(int index);
161  void set_gain3(int index);
162  void set_gain4(int index);
163  void set_ifFilter(int index);
164  void set_gain5(int index);
165  void set_gain6(int index);
166 
167 private:
172  QMutex m_mutex;
176  bool m_running;
178  QNetworkAccessManager *m_networkManager;
179  QNetworkRequest m_networkRequest;
180 
181  bool openDevice();
182  void closeDevice();
183  bool openFCDAudio(const char *filename);
184  void closeFCDAudio();
185  void applySettings(const FCDProSettings& settings, bool force);
186 
187  void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FCDProSettings& settings);
188  void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FCDProSettings& settings, bool force);
189  void webapiReverseSendStartStop(bool start);
190 
191 private slots:
192  void networkManagerFinished(QNetworkReply *reply);
193 };
194 
195 #endif // INCLUDE_FCDPROINPUT_H
AudioInput m_fcdAudioInput
Definition: fcdproinput.h:170
QNetworkAccessManager * m_networkManager
Definition: fcdproinput.h:178
MsgConfigureFCDPro(const FCDProSettings &settings, bool force)
Definition: fcdproinput.h:64
FileRecord * m_fileSink
File sink to record device I/Q output.
Definition: fcdproinput.h:177
QNetworkRequest m_networkRequest
Definition: fcdproinput.h:179
AudioFifo m_fcdFIFO
Definition: fcdproinput.h:171
bool m_running
Definition: fcdproinput.h:176
virtual void setMessageQueueToGUI(MessageQueue *queue)
Definition: fcdproinput.h:120
FCDProSettings m_settings
Definition: fcdproinput.h:173
const FCDProSettings & getSettings() const
Definition: fcdproinput.h:52
MsgFileRecord(bool startStop)
Definition: fcdproinput.h:84
static MsgFileRecord * create(bool startStop)
Definition: fcdproinput.h:77
static MsgConfigureFCDPro * create(const FCDProSettings &settings, bool force)
Definition: fcdproinput.h:55
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
std::size_t length
Definition: fcdproinput.h:36
void * start
Definition: fcdproinput.h:35
bool getStartStop() const
Definition: fcdproinput.h:94
QMutex m_mutex
Definition: fcdproinput.h:172
MsgStartStop(bool startStop)
Definition: fcdproinput.h:103
hid_device * m_dev
Definition: fcdproinput.h:169
QString m_deviceDescription
Definition: fcdproinput.h:175
DeviceAPI * m_deviceAPI
Definition: fcdproinput.h:168
virtual void setSampleRate(int sampleRate)
For when the source sample rate is set externally.
Definition: fcdproinput.h:123
FCDProThread * m_FCDThread
Definition: fcdproinput.h:174
static MsgStartStop * create(bool startStop)
Definition: fcdproinput.h:96