2018-08-18 09:51:46 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 Edouard Griffiths, F4EXB. //
|
|
|
|
// //
|
|
|
|
// SDRdaemon instance //
|
|
|
|
// //
|
|
|
|
// SDRdaemon is a detached SDR front end that handles the interface with a //
|
|
|
|
// physical device and sends or receives the I/Q samples stream to or from a //
|
|
|
|
// SDRangel instance via UDP. It is controlled via a Web REST API. //
|
|
|
|
// //
|
|
|
|
// 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 //
|
|
|
|
// //
|
|
|
|
// 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 SDRDAEMON_SDRDAEMONMAIN_H_
|
|
|
|
#define SDRDAEMON_SDRDAEMONMAIN_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
#include "sdrdaemonsettings.h"
|
|
|
|
#include "util/messagequeue.h"
|
|
|
|
|
|
|
|
namespace SDRDaemon {
|
|
|
|
class WebAPIRequestMapper;
|
|
|
|
class WebAPIServer;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace qtwebapp {
|
|
|
|
class LoggerWithFile;
|
|
|
|
}
|
|
|
|
|
2018-08-18 18:49:08 -04:00
|
|
|
class SDRDaemonParser;
|
2018-08-18 09:51:46 -04:00
|
|
|
class DSPEngine;
|
|
|
|
class PluginManager;
|
|
|
|
class Message;
|
|
|
|
class WebAPIAdapterDaemon;
|
2018-08-19 05:20:54 -04:00
|
|
|
class DSPDeviceSourceEngine;
|
|
|
|
class DeviceSourceAPI;
|
|
|
|
class DSPDeviceSinkEngine;
|
|
|
|
class DeviceSinkAPI;
|
2018-08-19 17:36:30 -04:00
|
|
|
class SDRDaemonChannelSink;
|
2018-08-19 18:38:33 -04:00
|
|
|
class SDRDaemonChannelSource;
|
2018-08-18 09:51:46 -04:00
|
|
|
|
|
|
|
class SDRDaemonMain : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-08-18 18:49:08 -04:00
|
|
|
explicit SDRDaemonMain(qtwebapp::LoggerWithFile *logger, const SDRDaemonParser& parser, QObject *parent = 0);
|
2018-08-18 09:51:46 -04:00
|
|
|
~SDRDaemonMain();
|
|
|
|
static SDRDaemonMain *getInstance() { return m_instance; } // Main Core is de facto a singleton so this just returns its reference
|
|
|
|
|
2018-08-19 05:20:54 -04:00
|
|
|
MessageQueue* getInputMessageQueue() { return &m_inputMessageQueue; }
|
|
|
|
|
|
|
|
const QTimer& getMasterTimer() const { return m_masterTimer; }
|
|
|
|
const SDRDaemonSettings& getSettings() const { return m_settings; }
|
|
|
|
|
|
|
|
bool addSourceDevice();
|
|
|
|
bool addSinkDevice();
|
|
|
|
void removeDevice();
|
|
|
|
|
2018-08-19 18:38:33 -04:00
|
|
|
bool doAbort() const { return m_abort; }
|
|
|
|
|
2018-08-18 19:28:29 -04:00
|
|
|
friend class WebAPIAdapterDaemon;
|
|
|
|
|
2018-08-18 15:30:51 -04:00
|
|
|
signals:
|
|
|
|
void finished();
|
|
|
|
|
2018-08-18 09:51:46 -04:00
|
|
|
private:
|
|
|
|
static SDRDaemonMain *m_instance;
|
|
|
|
qtwebapp::LoggerWithFile *m_logger;
|
|
|
|
SDRDaemonSettings m_settings;
|
|
|
|
DSPEngine* m_dspEngine;
|
|
|
|
int m_lastEngineState;
|
|
|
|
PluginManager* m_pluginManager;
|
|
|
|
MessageQueue m_inputMessageQueue;
|
|
|
|
QTimer m_masterTimer;
|
|
|
|
|
|
|
|
SDRDaemon::WebAPIRequestMapper *m_requestMapper;
|
|
|
|
SDRDaemon::WebAPIServer *m_apiServer;
|
|
|
|
WebAPIAdapterDaemon *m_apiAdapter;
|
|
|
|
|
2018-08-19 05:20:54 -04:00
|
|
|
bool m_tx;
|
|
|
|
QString m_deviceType;
|
|
|
|
QString m_deviceSerial;
|
|
|
|
int m_deviceSequence;
|
|
|
|
|
|
|
|
DSPDeviceSourceEngine *m_deviceSourceEngine;
|
|
|
|
DeviceSourceAPI *m_deviceSourceAPI;
|
|
|
|
DSPDeviceSinkEngine *m_deviceSinkEngine;
|
|
|
|
DeviceSinkAPI *m_deviceSinkAPI;
|
2018-08-19 17:36:30 -04:00
|
|
|
SDRDaemonChannelSink *m_channelSink;
|
2018-08-19 18:38:33 -04:00
|
|
|
SDRDaemonChannelSource *m_channelSource;
|
|
|
|
|
|
|
|
bool m_abort;
|
2018-08-19 05:20:54 -04:00
|
|
|
|
2018-08-18 09:51:46 -04:00
|
|
|
void loadSettings();
|
|
|
|
void setLoggingOptions();
|
2018-08-19 05:20:54 -04:00
|
|
|
int getDeviceIndex();
|
2018-08-18 09:51:46 -04:00
|
|
|
bool handleMessage(const Message& cmd);
|
2018-08-19 17:36:30 -04:00
|
|
|
void addChannelSink();
|
2018-08-18 09:51:46 -04:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void handleMessages();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* SDRDAEMON_SDRDAEMONMAIN_H_ */
|