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.
maincore.h
Go to the documentation of this file.
1 // Copyright (C) 2017 Edouard Griffiths, F4EXB. //
3 // //
4 // Swagger server adapter interface //
5 // //
6 // This program is free software; you can redistribute it and/or modify //
7 // it under the terms of the GNU General Public License as published by //
8 // the Free Software Foundation as version 3 of the License, or //
9 // (at your option) any later version. //
10 // //
11 // This program is distributed in the hope that it will be useful, //
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
14 // GNU General Public License V3 for more details. //
15 // //
16 // You should have received a copy of the GNU General Public License //
17 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
19 
20 #ifndef SDRSRV_MAINCORE_H_
21 #define SDRSRV_MAINCORE_H_
22 
23 #include <QObject>
24 #include <QTimer>
25 
26 #include "settings/mainsettings.h"
27 #include "util/message.h"
28 #include "util/messagequeue.h"
29 #include "export.h"
30 #include "mainparser.h"
31 
32 class DSPEngine;
35 class PluginAPI;
36 class PluginInterface;
37 class PluginManager;
38 class ChannelMarker;
39 class DeviceSet;
41 class WebAPIServer;
42 class WebAPIAdapterSrv;
43 
44 namespace qtwebapp {
45  class LoggerWithFile;
46 }
47 
48 class SDRSRV_API MainCore : public QObject {
49  Q_OBJECT
50 
51 public:
52  explicit MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent = 0);
53  ~MainCore();
54  static MainCore *getInstance() { return m_instance; } // Main Core is de facto a singleton so this just returns its reference
55 
56  MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; }
57 
58  const QTimer& getMasterTimer() const { return m_masterTimer; }
59  const MainSettings& getMainSettings() const { return m_settings; }
60 
61  void addSourceDevice();
62  void addSinkDevice();
63  void removeLastDevice();
64  void changeSampleSource(int deviceSetIndex, int selectedDeviceIndex);
65  void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex);
66  void addChannel(int deviceSetIndex, int selectedChannelIndex);
67  void deleteChannel(int deviceSetIndex, int channelIndex);
68 
69  friend class WebAPIAdapterSrv;
70 
71 signals:
72  void finished();
73 
74 private:
75  class MsgLoadPreset : public Message {
77 
78  public:
79  const Preset *getPreset() const { return m_preset; }
80  int getDeviceSetIndex() const { return m_deviceSetIndex; }
81 
82  static MsgLoadPreset* create(const Preset *preset, int deviceSetIndex)
83  {
84  return new MsgLoadPreset(preset, deviceSetIndex);
85  }
86 
87  private:
88  const Preset *m_preset;
90 
91  MsgLoadPreset(const Preset *preset, int deviceSetIndex) :
92  Message(),
93  m_preset(preset),
94  m_deviceSetIndex(deviceSetIndex)
95  { }
96  };
97 
98  class MsgSavePreset : public Message {
100 
101  public:
102  Preset *getPreset() const { return m_preset; }
103  int getDeviceSetIndex() const { return m_deviceSetIndex; }
104  bool isNewPreset() const { return m_newPreset; }
105 
106  static MsgSavePreset* create(Preset *preset, int deviceSetIndex, bool newPreset)
107  {
108  return new MsgSavePreset(preset, deviceSetIndex, newPreset);
109  }
110 
111  private:
115 
116  MsgSavePreset(Preset *preset, int deviceSetIndex, bool newPreset) :
117  Message(),
118  m_preset(preset),
119  m_deviceSetIndex(deviceSetIndex),
120  m_newPreset(newPreset)
121  { }
122  };
123 
124  class MsgDeletePreset : public Message {
126 
127  public:
128  const Preset *getPreset() const { return m_preset; }
129 
130  static MsgDeletePreset* create(const Preset *preset)
131  {
132  return new MsgDeletePreset(preset);
133  }
134 
135  private:
136  const Preset *m_preset;
137 
138  MsgDeletePreset(const Preset *preset) :
139  Message(),
140  m_preset(preset)
141  { }
142  };
143 
144  class MsgDeleteInstance : public Message {
146 
147  public:
149  {
150  return new MsgDeleteInstance();
151  }
152 
153  private:
155  Message()
156  { }
157  };
158 
159  class MsgAddDeviceSet : public Message {
161 
162  public:
163  int getDirection() const { return m_direction; }
164 
165  static MsgAddDeviceSet* create(int direction)
166  {
167  return new MsgAddDeviceSet(direction);
168  }
169 
170  private:
172 
173  MsgAddDeviceSet(int direction) :
174  Message(),
175  m_direction(direction)
176  { }
177  };
178 
181 
182  public:
184  {
185  return new MsgRemoveLastDeviceSet();
186  }
187 
188  private:
190  Message()
191  { }
192  };
193 
194  class MsgSetDevice : public Message {
196 
197  public:
198  int getDeviceSetIndex() const { return m_deviceSetIndex; }
199  int getDeviceIndex() const { return m_deviceIndex; }
200  int getDeviceType() const { return m_deviceType; }
201 
202  static MsgSetDevice* create(int deviceSetIndex, int deviceIndex, int deviceType)
203  {
204  return new MsgSetDevice(deviceSetIndex, deviceIndex, deviceType);
205  }
206 
207  private:
211 
212  MsgSetDevice(int deviceSetIndex, int deviceIndex, int deviceType) :
213  Message(),
214  m_deviceSetIndex(deviceSetIndex),
215  m_deviceIndex(deviceIndex),
216  m_deviceType(deviceType)
217  { }
218  };
219 
220  class MsgAddChannel : public Message {
222 
223  public:
224  int getDeviceSetIndex() const { return m_deviceSetIndex; }
225  int getChannelRegistrationIndex() const { return m_channelRegistrationIndex; }
226  bool isTx() const { return m_tx; }
227 
228  static MsgAddChannel* create(int deviceSetIndex, int channelRegistrationIndex, bool tx)
229  {
230  return new MsgAddChannel(deviceSetIndex, channelRegistrationIndex, tx);
231  }
232 
233  private:
236  bool m_tx;
237 
238  MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, bool tx) :
239  Message(),
240  m_deviceSetIndex(deviceSetIndex),
241  m_channelRegistrationIndex(channelRegistrationIndex),
242  m_tx(tx)
243  { }
244  };
245 
246  class MsgDeleteChannel : public Message {
248 
249  public:
250  int getDeviceSetIndex() const { return m_deviceSetIndex; }
251  int getChannelIndex() const { return m_channelIndex; }
252  bool isTx() const { return m_tx; }
253 
254  static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex, bool tx)
255  {
256  return new MsgDeleteChannel(deviceSetIndex, channelIndex, tx);
257  }
258 
259  private:
262  bool m_tx;
263 
264  MsgDeleteChannel(int deviceSetIndex, int channelIndex, bool tx) :
265  Message(),
266  m_deviceSetIndex(deviceSetIndex),
267  m_channelIndex(channelIndex),
268  m_tx(tx)
269  { }
270  };
271 
278 
281  std::vector<DeviceSet*> m_deviceSets;
283 
287 
288  void loadSettings();
289  void loadPresetSettings(const Preset* preset, int tabIndex);
290  void savePresetSettings(Preset* preset, int tabIndex);
291  void setLoggingOptions();
292 
293  bool handleMessage(const Message& cmd);
294 
295 private slots:
296  void handleMessages();
297 };
298 
299 
300 
301 
302 #endif /* SDRSRV_MAINCORE_H_ */
DSPEngine * m_dspEngine
Definition: maincore.h:275
int m_masterTabIndex
Definition: maincore.h:274
static MsgAddDeviceSet * create(int direction)
Definition: maincore.h:165
WebAPIAdapterSrv * m_apiAdapter
Definition: maincore.h:286
static MainCore * getInstance()
Definition: maincore.h:54
WebAPIServer * m_apiServer
Definition: maincore.h:285
const QTimer & getMasterTimer() const
Definition: maincore.h:58
std::vector< DeviceSet * > m_deviceSets
Definition: maincore.h:281
MsgSavePreset(Preset *preset, int deviceSetIndex, bool newPreset)
Definition: maincore.h:116
static MsgSavePreset * create(Preset *preset, int deviceSetIndex, bool newPreset)
Definition: maincore.h:106
MsgSetDevice(int deviceSetIndex, int deviceIndex, int deviceType)
Definition: maincore.h:212
const Preset * getPreset() const
Definition: maincore.h:128
Preset * getPreset() const
Definition: maincore.h:102
bool isNewPreset() const
Definition: maincore.h:104
MessageQueue m_inputMessageQueue
Definition: maincore.h:279
MsgDeletePreset(const Preset *preset)
Definition: maincore.h:138
MsgLoadPreset(const Preset *preset, int deviceSetIndex)
Definition: maincore.h:91
int getChannelIndex() const
Definition: maincore.h:251
static MsgDeleteChannel * create(int deviceSetIndex, int channelIndex, bool tx)
Definition: maincore.h:254
MsgAddDeviceSet(int direction)
Definition: maincore.h:173
MainSettings m_settings
Definition: maincore.h:273
int getDeviceSetIndex() const
Definition: maincore.h:103
int getDirection() const
Definition: maincore.h:163
const Preset * m_preset
Definition: maincore.h:136
#define MESSAGE_CLASS_DECLARATION
Definition: message.h:43
Definition: preset.h:28
static MsgDeletePreset * create(const Preset *preset)
Definition: maincore.h:130
static MsgAddChannel * create(int deviceSetIndex, int channelRegistrationIndex, bool tx)
Definition: maincore.h:228
PluginManager * m_pluginManager
Definition: maincore.h:282
int getDeviceSetIndex() const
Definition: maincore.h:80
qtwebapp::LoggerWithFile * m_logger
Definition: maincore.h:277
const MainSettings & getMainSettings() const
Definition: maincore.h:59
#define SDRSRV_API
Definition: export.h:64
bool isTx() const
Definition: maincore.h:226
WebAPIRequestMapper * m_requestMapper
Definition: maincore.h:284
int getDeviceSetIndex() const
Definition: maincore.h:224
int getDeviceIndex() const
Definition: maincore.h:199
static MsgRemoveLastDeviceSet * create()
Definition: maincore.h:183
MessageQueue * getInputMessageQueue()
Definition: maincore.h:56
int m_lastEngineState
Definition: maincore.h:276
QTimer m_masterTimer
Definition: maincore.h:280
static MsgLoadPreset * create(const Preset *preset, int deviceSetIndex)
Definition: maincore.h:82
static MsgDeleteInstance * create()
Definition: maincore.h:148
int getDeviceType() const
Definition: maincore.h:200
MsgDeleteChannel(int deviceSetIndex, int channelIndex, bool tx)
Definition: maincore.h:264
const Preset * getPreset() const
Definition: maincore.h:79
int getDeviceSetIndex() const
Definition: maincore.h:250
int getDeviceSetIndex() const
Definition: maincore.h:198
static MainCore * m_instance
Definition: maincore.h:272
int getChannelRegistrationIndex() const
Definition: maincore.h:225
const Preset * m_preset
Definition: maincore.h:88
static MsgSetDevice * create(int deviceSetIndex, int deviceIndex, int deviceType)
Definition: maincore.h:202
MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, bool tx)
Definition: maincore.h:238