| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | // Copyright (C) 2017 Edouard Griffiths, F4EXB.                                  //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // Swagger server adapter interface                                              //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is free software; you can redistribute it and/or modify          //
 | 
					
						
							|  |  |  | // it under the terms of the GNU General Public License as published by          //
 | 
					
						
							|  |  |  | // the Free Software Foundation as version 3 of the License, or                  //
 | 
					
						
							| 
									
										
										
										
											2019-04-11 14:44:23 +02:00
										 |  |  | // (at your option) any later version.                                           //
 | 
					
						
							| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // This program is distributed in the hope that it will be useful,               //
 | 
					
						
							|  |  |  | // but WITHOUT ANY WARRANTY; without even the implied warranty of                //
 | 
					
						
							|  |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the                  //
 | 
					
						
							|  |  |  | // GNU General Public License V3 for more details.                               //
 | 
					
						
							|  |  |  | //                                                                               //
 | 
					
						
							|  |  |  | // You should have received a copy of the GNU General Public License             //
 | 
					
						
							|  |  |  | // along with this program. If not, see <http://www.gnu.org/licenses/>.          //
 | 
					
						
							|  |  |  | ///////////////////////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef SDRSRV_MAINCORE_H_
 | 
					
						
							|  |  |  | #define SDRSRV_MAINCORE_H_
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QObject>
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | #include <QTimer>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "settings/mainsettings.h"
 | 
					
						
							|  |  |  | #include "util/message.h"
 | 
					
						
							|  |  |  | #include "util/messagequeue.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | #include "mainparser.h"
 | 
					
						
							| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | class DSPEngine; | 
					
						
							|  |  |  | class DSPDeviceSourceEngine; | 
					
						
							|  |  |  | class DSPDeviceSinkEngine; | 
					
						
							|  |  |  | class PluginAPI; | 
					
						
							|  |  |  | class PluginInterface; | 
					
						
							|  |  |  | class PluginManager; | 
					
						
							|  |  |  | class ChannelMarker; | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | class DeviceSet; | 
					
						
							| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  | class WebAPIRequestMapper; | 
					
						
							|  |  |  | class WebAPIServer; | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | class WebAPIAdapterSrv; | 
					
						
							| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | namespace qtwebapp { | 
					
						
							|  |  |  |     class LoggerWithFile; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 21:19:59 +01:00
										 |  |  | class MainCore : public QObject { | 
					
						
							| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  |     Q_OBJECT | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-12-17 12:08:18 +01:00
										 |  |  |     explicit MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent = 0); | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  |     ~MainCore(); | 
					
						
							|  |  |  |     static MainCore *getInstance() { return m_instance; } // Main Core is de facto a singleton so this just returns its reference
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const QTimer& getMasterTimer() const { return m_masterTimer; } | 
					
						
							|  |  |  |     const MainSettings& getMainSettings() const { return m_settings; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |     void addSourceDevice(); | 
					
						
							|  |  |  |     void addSinkDevice(); | 
					
						
							|  |  |  |     void removeLastDevice(); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |     void changeSampleSource(int deviceSetIndex, int selectedDeviceIndex); | 
					
						
							|  |  |  |     void changeSampleSink(int deviceSetIndex, int selectedDeviceIndex); | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |     void addChannel(int deviceSetIndex, int selectedChannelIndex); | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |     void deleteChannel(int deviceSetIndex, int channelIndex); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  |     friend class WebAPIAdapterSrv; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 12:08:18 +01:00
										 |  |  | signals: | 
					
						
							|  |  |  |     void finished(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  |     class MsgLoadPreset : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         const Preset *getPreset() const { return m_preset; } | 
					
						
							|  |  |  |         int getDeviceSetIndex() const { return m_deviceSetIndex; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgLoadPreset* create(const Preset *preset, int deviceSetIndex) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgLoadPreset(preset, deviceSetIndex); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         const Preset *m_preset; | 
					
						
							|  |  |  |         int m_deviceSetIndex; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgLoadPreset(const Preset *preset, int deviceSetIndex) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_preset(preset), | 
					
						
							|  |  |  |             m_deviceSetIndex(deviceSetIndex) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-20 23:57:06 +01:00
										 |  |  |     class MsgSavePreset : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         Preset *getPreset() const { return m_preset; } | 
					
						
							|  |  |  |         int getDeviceSetIndex() const { return m_deviceSetIndex; } | 
					
						
							|  |  |  |         bool isNewPreset() const { return m_newPreset; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgSavePreset* create(Preset *preset, int deviceSetIndex, bool newPreset) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgSavePreset(preset, deviceSetIndex, newPreset); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         Preset *m_preset; | 
					
						
							|  |  |  |         int m_deviceSetIndex; | 
					
						
							|  |  |  |         bool m_newPreset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgSavePreset(Preset *preset, int deviceSetIndex, bool newPreset) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_preset(preset), | 
					
						
							|  |  |  |             m_deviceSetIndex(deviceSetIndex), | 
					
						
							|  |  |  |             m_newPreset(newPreset) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-21 00:31:38 +01:00
										 |  |  |     class MsgDeletePreset : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         const Preset *getPreset() const { return m_preset; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgDeletePreset* create(const Preset *preset) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgDeletePreset(preset); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         const Preset *m_preset; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgDeletePreset(const Preset *preset) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_preset(preset) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     class MsgDeleteInstance : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         static MsgDeleteInstance* create() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgDeleteInstance(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         MsgDeleteInstance() : | 
					
						
							|  |  |  |             Message() | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |     class MsgAddDeviceSet : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         int getDirection() const { return m_direction; } | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         static MsgAddDeviceSet* create(int direction) | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             return new MsgAddDeviceSet(direction); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         int m_direction; | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |         MsgAddDeviceSet(int direction) : | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |             Message(), | 
					
						
							| 
									
										
										
										
											2019-05-09 01:12:40 +02:00
										 |  |  |             m_direction(direction) | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     class MsgRemoveLastDeviceSet : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         static MsgRemoveLastDeviceSet* create() | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgRemoveLastDeviceSet(); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         MsgRemoveLastDeviceSet() : | 
					
						
							|  |  |  |             Message() | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |     class MsgSetDevice : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         int getDeviceSetIndex() const { return m_deviceSetIndex; } | 
					
						
							|  |  |  |         int getDeviceIndex() const { return m_deviceIndex; } | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |         int getDeviceType() const { return m_deviceType; } | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |         static MsgSetDevice* create(int deviceSetIndex, int deviceIndex, int deviceType) | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         { | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |             return new MsgSetDevice(deviceSetIndex, deviceIndex, deviceType); | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         int m_deviceSetIndex; | 
					
						
							|  |  |  |         int m_deviceIndex; | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |         int m_deviceType; | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |         MsgSetDevice(int deviceSetIndex, int deviceIndex, int deviceType) : | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |             Message(), | 
					
						
							|  |  |  |             m_deviceSetIndex(deviceSetIndex), | 
					
						
							|  |  |  |             m_deviceIndex(deviceIndex), | 
					
						
							| 
									
										
										
										
											2019-05-18 06:30:37 +02:00
										 |  |  |             m_deviceType(deviceType) | 
					
						
							| 
									
										
										
										
											2017-12-22 00:07:59 +01:00
										 |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 18:19:49 +01:00
										 |  |  |     class MsgAddChannel : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         int getDeviceSetIndex() const { return m_deviceSetIndex; } | 
					
						
							|  |  |  |         int getChannelRegistrationIndex() const { return m_channelRegistrationIndex; } | 
					
						
							|  |  |  |         bool isTx() const { return m_tx; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgAddChannel* create(int deviceSetIndex, int channelRegistrationIndex, bool tx) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgAddChannel(deviceSetIndex, channelRegistrationIndex, tx); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         int m_deviceSetIndex; | 
					
						
							|  |  |  |         int m_channelRegistrationIndex; | 
					
						
							|  |  |  |         bool m_tx; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgAddChannel(int deviceSetIndex, int channelRegistrationIndex, bool tx) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_deviceSetIndex(deviceSetIndex), | 
					
						
							|  |  |  |             m_channelRegistrationIndex(channelRegistrationIndex), | 
					
						
							|  |  |  |             m_tx(tx) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-23 22:33:30 +01:00
										 |  |  |     class MsgDeleteChannel : public Message { | 
					
						
							|  |  |  |         MESSAGE_CLASS_DECLARATION | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public: | 
					
						
							|  |  |  |         int getDeviceSetIndex() const { return m_deviceSetIndex; } | 
					
						
							|  |  |  |         int getChannelIndex() const { return m_channelIndex; } | 
					
						
							|  |  |  |         bool isTx() const { return m_tx; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         static MsgDeleteChannel* create(int deviceSetIndex, int channelIndex, bool tx) | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             return new MsgDeleteChannel(deviceSetIndex, channelIndex, tx); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         int m_deviceSetIndex; | 
					
						
							|  |  |  |         int m_channelIndex; | 
					
						
							|  |  |  |         bool m_tx; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         MsgDeleteChannel(int deviceSetIndex, int channelIndex, bool tx) : | 
					
						
							|  |  |  |             Message(), | 
					
						
							|  |  |  |             m_deviceSetIndex(deviceSetIndex), | 
					
						
							|  |  |  |             m_channelIndex(channelIndex), | 
					
						
							|  |  |  |             m_tx(tx) | 
					
						
							|  |  |  |         { } | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  |     static MainCore *m_instance; | 
					
						
							|  |  |  |     MainSettings m_settings; | 
					
						
							|  |  |  |     int m_masterTabIndex; | 
					
						
							|  |  |  |     DSPEngine* m_dspEngine; | 
					
						
							|  |  |  |     int m_lastEngineState; | 
					
						
							|  |  |  |     qtwebapp::LoggerWithFile *m_logger; | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     MessageQueue m_inputMessageQueue; | 
					
						
							|  |  |  |     QTimer m_masterTimer; | 
					
						
							|  |  |  |     std::vector<DeviceSet*> m_deviceSets; | 
					
						
							|  |  |  |     PluginManager* m_pluginManager; | 
					
						
							| 
									
										
										
										
											2017-12-17 11:09:51 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     WebAPIRequestMapper *m_requestMapper; | 
					
						
							|  |  |  |     WebAPIServer *m_apiServer; | 
					
						
							|  |  |  |     WebAPIAdapterSrv *m_apiAdapter; | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:56:10 +01:00
										 |  |  | 	void loadSettings(); | 
					
						
							| 
									
										
										
										
											2017-12-20 14:31:17 +01:00
										 |  |  | 	void loadPresetSettings(const Preset* preset, int tabIndex); | 
					
						
							| 
									
										
										
										
											2017-12-20 01:01:53 +01:00
										 |  |  | 	void savePresetSettings(Preset* preset, int tabIndex); | 
					
						
							| 
									
										
										
										
											2017-12-18 13:56:10 +01:00
										 |  |  |     void setLoggingOptions(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-17 23:15:42 +01:00
										 |  |  |     bool handleMessage(const Message& cmd); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private slots: | 
					
						
							|  |  |  |     void handleMessages(); | 
					
						
							| 
									
										
										
										
											2017-12-17 10:25:08 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* SDRSRV_MAINCORE_H_ */
 |