Server: basic sdrsrv library

pull/127/head
f4exb 2017-12-17 11:09:51 +01:00
rodzic f2cdacb057
commit 22f174a2a4
6 zmienionych plików z 235 dodań i 0 usunięć

Wyświetl plik

@ -192,6 +192,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fmax-errors=10 -ffast-mat
# base libraries
add_subdirectory(sdrbase)
add_subdirectory(sdrgui)
add_subdirectory(sdrsrv)
add_subdirectory(httpserver)
add_subdirectory(logging)
add_subdirectory(swagger)

Wyświetl plik

@ -0,0 +1,48 @@
project (sdrsrv)
set(sdrsrv_SOURCES
maincore.cpp
webapi/webapiadaptersrv.cpp
)
set(sdrsrv_HEADERS
maincore.h
webapi/webapiadaptersrv.h
)
set(sdrsrv_SOURCES
${sdrsrv_SOURCES}
${sdrsrv_HEADERS}
)
add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_SHARED)
add_library(sdrsrv SHARED
${sdrsrv_SOURCES}
${sdrsrv_HEADERS_MOC}
)
include_directories(
.
${CMAKE_SOURCE_DIR}/sdrbase
${CMAKE_SOURCE_DIR}/logging
${CMAKE_SOURCE_DIR}/httpserver
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
${CMAKE_CURRENT_BINARY_DIR}
${OPENGL_INCLUDE_DIR}
)
target_link_libraries(sdrsrv
${QT_LIBRARIES}
sdrbase
logging
)
set_target_properties(sdrsrv PROPERTIES DEFINE_SYMBOL "sdrangel_EXPORTS")
target_compile_features(sdrsrv PRIVATE cxx_generalized_initializers) # cmake >= 3.1.0
qt5_use_modules(sdrsrv Core Multimedia)
install(TARGETS sdrsrv DESTINATION lib)

Wyświetl plik

@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QDebug>
#include "dsp/dspengine.h"
#include "dsp/dspdevicesourceengine.h"
#include "plugin/pluginmanager.h"
#include "loggerwithfile.h"
#include "webapi/webapirequestmapper.h"
#include "webapi/webapiserver.h"
#include "webapi/webapiadaptersrv.h"
#include "maincore.h"
MainCore *MainCore::m_instance = 0;
MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser) :
m_settings(),
m_masterTabIndex(-1),
m_dspEngine(DSPEngine::instance()),
m_lastEngineState((DSPDeviceSourceEngine::State)-1),
m_logger(logger)
{
qDebug() << "MainCore::MainCore: start";
m_instance = this;
m_settings.setAudioDeviceInfo(&m_audioDeviceInfo);
m_pluginManager = new PluginManager(this);
m_pluginManager->loadPlugins(QString("pluginssrv"));
connect(&m_inputMessageQueue, SIGNAL(messageEnqueued()), this, SLOT(handleMessages()), Qt::QueuedConnection);
m_masterTimer.start(50);
m_apiAdapter = new WebAPIAdapterSrv(*this);
m_requestMapper = new WebAPIRequestMapper(QCoreApplication::instance());
m_requestMapper->setAdapter(m_apiAdapter);
m_apiServer = new WebAPIServer(parser.getServerAddress(), parser.getServerPort(), m_requestMapper);
m_apiServer->start();
qDebug() << "MainCore::MainCore: end";
}
MainCore::~MainCore()
{
m_apiServer->stop();
delete m_apiServer;
delete m_requestMapper;
delete m_apiAdapter;
delete m_pluginManager;
qDebug() << "MainCore::~MainCore: end";
delete m_logger;
}

Wyświetl plik

@ -20,7 +20,13 @@
#define SDRSRV_MAINCORE_H_
#include <QObject>
#include <QTimer>
#include "settings/mainsettings.h"
#include "util/message.h"
#include "util/messagequeue.h"
#include "util/export.h"
#include "mainparser.h"
class AudioDeviceInfo;
class DSPEngine;
@ -37,8 +43,41 @@ class WebAPIRequestMapper;
class WebAPIServer;
class WebAPIAdapterSrv; // TODO: create this class
namespace qtwebapp {
class LoggerWithFile;
}
class SDRANGEL_API MainCore : public QObject {
Q_OBJECT
public:
explicit MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser);
~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; }
friend class WebAPIAdapterSrv;
private:
static MainCore *m_instance;
MessageQueue m_inputMessageQueue;
QTimer m_masterTimer;
MainSettings m_settings;
int m_masterTabIndex;
DSPEngine* m_dspEngine;
PluginManager* m_pluginManager;
int m_lastEngineState;
AudioDeviceInfo m_audioDeviceInfo;
qtwebapp::LoggerWithFile *m_logger;
WebAPIRequestMapper *m_requestMapper;
WebAPIServer *m_apiServer;
WebAPIAdapterSrv *m_apiAdapter;
};

Wyświetl plik

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QCoreApplication>
#include <QList>
#include <unistd.h>
#include "maincore.h"
#include "webapiadaptersrv.h"
WebAPIAdapterSrv::WebAPIAdapterSrv(MainCore& mainCore) :
m_mainCore(mainCore)
{
}
WebAPIAdapterSrv::~WebAPIAdapterSrv()
{
}

Wyświetl plik

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 //
// //
// 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_WEBAPI_WEBAPIADAPTERSRV_H_
#define SDRSRV_WEBAPI_WEBAPIADAPTERSRV_H_
#include <QtGlobal>
#include "webapi/webapiadapterinterface.h"
class MainCore;
class WebAPIAdapterSrv: public WebAPIAdapterInterface
{
public:
WebAPIAdapterSrv(MainCore& mainCore);
virtual ~WebAPIAdapterSrv();
private:
MainCore& m_mainCore;
};
#endif /* SDRSRV_WEBAPI_WEBAPIADAPTERSRV_H_ */