62 lines
1.5 KiB
C++
Executable File
62 lines
1.5 KiB
C++
Executable File
/**
|
|
* MainHandler for AssetManagement
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "main_handler.h"
|
|
#include "initialization.h"
|
|
|
|
#include <DDS/DDSConnector/dds_connector.h>
|
|
#include <ngldb/db_service_handler.h>
|
|
#include <Core/pacemaker.h>
|
|
|
|
namespace ComponentMonitor
|
|
{
|
|
|
|
MainHandler::MainHandler(QObject *parent)
|
|
: QObject(parent)
|
|
, m_logger(getLogger("MainHandler"))
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
MainHandler::~MainHandler()
|
|
{
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
|
m_cmoService = nullptr;
|
|
m_ddsHandler = nullptr;
|
|
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
|
}
|
|
|
|
bool MainHandler::init(int domainId)
|
|
{
|
|
// initialize DDS
|
|
const int excerciseId = 0;
|
|
m_ddsHandler = std::make_shared<DdsHandler>(domainId, excerciseId);
|
|
if (!m_ddsHandler->init())
|
|
{
|
|
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
|
return false;
|
|
}
|
|
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
|
|
|
|
// Initialization:
|
|
// Keep in mind: ComponentMonitor::Initialization::run() is executed with a delay
|
|
m_cmoService = std::make_shared<ComponentMonitor::Initialization>();
|
|
if (!m_cmoService->initialize(m_ddsHandler))
|
|
{
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
|
return false;
|
|
}
|
|
|
|
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace ComponentMonitor
|