- Merged 292 changed files from dlbo snapshot - Fixed IDL enum collisions (PortType, PdmEventType) - Fixed Grantlee template for C++11 scoped enums - Fixed CMake VERSION_GREATER syntax - Added missing directories (THP, LtsRestClient, etc.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
88 lines
1.8 KiB
C++
Executable File
88 lines
1.8 KiB
C++
Executable File
/**
|
|
* MainHandler for HighLevelArchitecture
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
|
*/
|
|
|
|
#include "main_handler.h"
|
|
#include "ngs_handler.h"
|
|
#include "web_socket_interface.h"
|
|
#include "Common/identifierstruct.h"
|
|
|
|
#include <QCoreApplication>
|
|
#include <QTimer>
|
|
#include <Common/settings.h>
|
|
#include <Common/logger.h>
|
|
#include <DDS/Core/pacemaker.h>
|
|
|
|
namespace HighLevelArchitecture
|
|
{
|
|
|
|
MainHandler::MainHandler(QObject *parent)
|
|
: QObject(parent)
|
|
, m_exerciseId(0)
|
|
, m_logger(getLogger("MainHandler"))
|
|
{}
|
|
|
|
MainHandler::~MainHandler()
|
|
{
|
|
m_ngsHandler = nullptr;
|
|
m_wsInterface = nullptr;
|
|
}
|
|
|
|
bool MainHandler::init(int exerciseId)
|
|
{
|
|
NOTICE_LOG(m_logger) << LOGFUNCTION << ", exerciseId=" << exerciseId;
|
|
|
|
m_exerciseId = 5; // exerciseId;
|
|
IdentifierStruct::setOwnSiteId(exerciseId);
|
|
|
|
//
|
|
// NgsHandler
|
|
//
|
|
|
|
/*
|
|
if (!m_ngsHandler)
|
|
{
|
|
m_ngsHandler = std::make_shared<NgsHandler>();
|
|
// connect(m_ngsHandler.get(), &NgsHandler::ngsHandlerReady,
|
|
// m_wsHandler.get(), &WebSocketHandler::sendHlaConnectionState, Qt::UniqueConnection);
|
|
if (!m_ngsHandler->init())
|
|
{
|
|
m_ngsHandler = nullptr;
|
|
ERROR_LOG(m_logger) << "Could not init ngs - stopping application";
|
|
QCoreApplication::quit();
|
|
return false;
|
|
}
|
|
}
|
|
*/
|
|
|
|
//
|
|
// WsInterface
|
|
//
|
|
if (!m_wsInterface)
|
|
{
|
|
// requests from ws will be sent to ngsHandler:
|
|
m_wsInterface = std::make_shared<WsInterface>(m_ngsHandler, this);
|
|
int port = 23456;
|
|
if (!m_wsInterface->init(port))
|
|
{
|
|
ERROR_LOG(m_logger) << LOGFUNCTION
|
|
<< " WsInterface::init failed on port: " << port;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool MainHandler::isConnectedToHla() const
|
|
{
|
|
return m_ngsHandler && m_ngsHandler->isConnectedToHla();
|
|
}
|
|
|
|
|
|
} // namespace HighLevelArchitecture
|