Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* MainHandler for GuezIedManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow 2017-07-20
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
#include <CodificationManagement/initialization.h>
|
||||
#include <EffectShowManagement/initialization.h>
|
||||
#include <GuezMinelayerProcessing/initialization.h>
|
||||
|
||||
#include "handler_ied.h"
|
||||
#include "settings.h"
|
||||
|
||||
using namespace GuezIedManagement;
|
||||
|
||||
MainHandler::MainHandler()
|
||||
: m_handlerIed(nullptr)
|
||||
, m_ddsHandler(nullptr)
|
||||
, m_dbHandler(nullptr)
|
||||
, m_codService(nullptr)
|
||||
, m_esmService(nullptr)
|
||||
, m_gmpService(nullptr)
|
||||
, m_exerciseId(0)
|
||||
, m_logger(getLogger("MainHandler"))
|
||||
{}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
delete m_codService;
|
||||
delete m_esmService;
|
||||
delete m_gmpService;
|
||||
m_handlerIed = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
m_dbHandler = nullptr;
|
||||
}
|
||||
|
||||
bool MainHandler::init(int domainId, int exerciseId)
|
||||
{
|
||||
m_exerciseId = exerciseId;
|
||||
const QString errStr = initInternal(domainId, exerciseId);
|
||||
if (!errStr.isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
if (m_ddsHandler && m_ddsHandler->pacemaker())
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError, errStr);
|
||||
return false;
|
||||
}
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running, errStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MainHandler::initInternal(int domainId, int exerciseId)
|
||||
{
|
||||
// initialize database
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
if (!m_dbHandler->init(exerciseId, Settings::settings()))
|
||||
return QStringLiteral("Initialisation dbHandler failed.");
|
||||
|
||||
// initialize DDS
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
||||
if (!m_ddsHandler->init())
|
||||
return QStringLiteral("Initialisation ddsHandler failed.");
|
||||
|
||||
// initialize handler ied
|
||||
m_handlerIed = std::make_shared<HandlerIed>(this, m_ddsHandler, m_dbHandler->db());
|
||||
if (!loadFromDatabase())
|
||||
return QStringLiteral("Initialisation m_handlerIed failed.");
|
||||
|
||||
m_codService = new CodificationManagement::Initialization;
|
||||
if (!m_codService->initialize(m_ddsHandler->dds(), m_dbHandler->db()->database()) ||
|
||||
!m_codService->loadFromDatabase())
|
||||
return QStringLiteral("Can not initialize COD service.");
|
||||
|
||||
m_esmService = new EffectShowManagement::Initialization;
|
||||
if (!m_esmService->initialize(m_ddsHandler->dds(), m_dbHandler->db()->database()) ||
|
||||
!m_esmService->loadFromDatabase())
|
||||
return QStringLiteral("Can not initialize ESM service.");
|
||||
|
||||
m_gmpService = new GuezMinelayerProcessing::Initialization;
|
||||
if (!m_gmpService->initialize(m_ddsHandler->dds()) ||
|
||||
!m_gmpService->loadFromDatabase())
|
||||
return QStringLiteral("Can not initialize GMP service.");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool MainHandler::loadFromDatabase()
|
||||
{
|
||||
if (!m_ddsHandler || !m_dbHandler || !m_handlerIed)
|
||||
return false;
|
||||
if (!m_handlerIed->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerIED failed.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Block a user