1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 05:41:56 -05:00

Server: added a basic server application

This commit is contained in:
f4exb 2017-12-17 12:08:18 +01:00
parent 22f174a2a4
commit 361648a2b5
4 changed files with 100 additions and 2 deletions

View File

@ -205,6 +205,9 @@ include_directories(
${OPENGL_INCLUDE_DIR}
)
##############################################################################
# main GUI application
set(sdrangel_SOURCES
app/main.cpp
)
@ -236,6 +239,30 @@ endif(WIN32)
qt5_use_modules(sdrangel Widgets Multimedia)
##############################################################################
# main server application
set(sdrangelsrv_SOURCES
appsrv/main.cpp
)
add_executable(sdrangelsrv
${sdrangelsrv_SOURCES}
)
target_include_directories(sdrangelsrv
PUBLIC ${CMAKE_SOURCE_DIR}/sdrsrv
)
target_link_libraries(sdrangelsrv
sdrbase
sdrsrv
logging
${QT_LIBRARIES}
)
qt5_use_modules(sdrangelsrv Multimedia)
##############################################################################
if (BUILD_DEBIAN)
@ -265,6 +292,7 @@ endif(LIBUSB_FOUND AND UNIX)
#install targets
install(TARGETS sdrangel DESTINATION bin)
install(TARGETS sdrangelsrv DESTINATION bin)
#install(TARGETS sdrbase DESTINATION lib)
#install files and directories

55
appsrv/main.cpp Normal file
View File

@ -0,0 +1,55 @@
///////////////////////////////////////////////////////////////////////////////////
// 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 "loggerwithfile.h"
#include "maincore.h"
static int runQtApplication(int argc, char* argv[], qtwebapp::LoggerWithFile *logger)
{
QCoreApplication a(argc, argv);
QCoreApplication::setOrganizationName("f4exb");
QCoreApplication::setApplicationName("SDRangelSrv");
QCoreApplication::setApplicationVersion("3.9.0");
MainParser parser;
parser.parse(a);
MainCore m(logger, parser, &a);
// This will cause the application to exit when the main core is finished
QObject::connect(&m, SIGNAL(finished()), &a, SLOT(quit()));
// This will run the main core from the application event loop.
QTimer::singleShot(0, &m, SLOT(run()));
return a.exec();
}
int main(int argc, char* argv[])
{
qtwebapp::LoggerWithFile *logger = new qtwebapp::LoggerWithFile(qApp);
logger->installMsgHandler();
int res = runQtApplication(argc, argv, logger);
qWarning("SDRangel quit.");
return res;
}

View File

@ -30,7 +30,8 @@
MainCore *MainCore::m_instance = 0;
MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser) :
MainCore::MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent) :
QObject(parent),
m_settings(),
m_masterTabIndex(-1),
m_dspEngine(DSPEngine::instance()),
@ -69,3 +70,11 @@ MainCore::~MainCore()
qDebug() << "MainCore::~MainCore: end";
delete m_logger;
}
void MainCore::run()
{
qDebug() << "MainCore::run: start";
// TODO: the main loop is here
qDebug() << "MainCore::run: end";
emit finished();
}

View File

@ -51,7 +51,7 @@ class SDRANGEL_API MainCore : public QObject {
Q_OBJECT
public:
explicit MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser);
explicit MainCore(qtwebapp::LoggerWithFile *logger, const MainParser& parser, QObject *parent = 0);
~MainCore();
static MainCore *getInstance() { return m_instance; } // Main Core is de facto a singleton so this just returns its reference
@ -62,6 +62,12 @@ public:
friend class WebAPIAdapterSrv;
public slots:
void run();
signals:
void finished();
private:
static MainCore *m_instance;
MessageQueue m_inputMessageQueue;