Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Routing Test - main object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
|
||||
#include "main_handler.h"
|
||||
#include <LtsPluginManager/lts_plugin_loader.h>
|
||||
#include <DDS/Generic/topic_type_plugin.h>
|
||||
#include <DDS/QosProfile/DDS_DefaultQos.h>
|
||||
#include <ExerciseManagement/exm_dtc.h>
|
||||
#include <rti/config/Logger.hpp>
|
||||
#include <nglapplication/nglloggerhandler.h>
|
||||
|
||||
#include <Core/core_dts_types.h>
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
#include <DDS/DTS/generic_dts_impl.h>
|
||||
|
||||
namespace RoutingService
|
||||
{
|
||||
|
||||
MainHandler::MainHandler()
|
||||
: m_logger(getLogger("MainHandler"))
|
||||
{
|
||||
}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
m_pacemaker = nullptr;
|
||||
shutdown();
|
||||
}
|
||||
|
||||
bool MainHandler::init(int domainIdIn, int domainIdOut, unsigned short tcpPortOut)
|
||||
{
|
||||
shutdown();
|
||||
|
||||
if (!DDS::QosProfile::setDefault())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error setting default QoS from xml-file ";
|
||||
return false;
|
||||
}
|
||||
|
||||
NGL::LoggerHandler *lh = NGL::LoggerHandler::getLoggerHandler();
|
||||
if (lh)
|
||||
{
|
||||
const QByteArray postfix = lh->loggerNamePostfix().toLocal8Bit() + "_dds_";
|
||||
const QByteArray prefix = lh->loggerNamePrefix().toLocal8Bit();
|
||||
|
||||
rti::config::Logger &ddsLogger = rti::config::Logger::instance();
|
||||
//ddsLogger.output_file(fdopen(STDOUT_FILENO, "w"));
|
||||
ddsLogger.output_file_set(postfix.data(), prefix.data(), 10 * 1024 * 1024, 10);
|
||||
ddsLogger.verbosity(rti::config::Verbosity_def::WARNING);
|
||||
//ddsLogger.verbosity_by_category(rti::config::LogCategory_def::COMMUNICATION, rti::config::Verbosity_def::STATUS_ALL);
|
||||
}
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> ddsConnectorIn(
|
||||
new DDSConnector::DdsConnector(domainIdIn, IDL::PartitionType::Global));
|
||||
ddsConnectorIn->initDomainParticipant();
|
||||
ddsConnectorIn->initPublisherSubscriber(); // for ExerciseManagement::Exercise, Core::SituationReplay, Heartbeat
|
||||
|
||||
QUrl tcpDiscoveryUrl;
|
||||
tcpDiscoveryUrl.setPort(tcpPortOut);
|
||||
std::shared_ptr<DDSConnector::DdsConnector> ddsConnectorOut(
|
||||
new DDSConnector::DdsConnector(domainIdOut, IDL::PartitionType::Global, 0, tcpDiscoveryUrl));
|
||||
ddsConnectorOut->initDomainParticipant();
|
||||
|
||||
m_sessionHandler.reset(new SessionHandler(IDL::PartitionType::Exercise, ddsConnectorIn, ddsConnectorOut));
|
||||
|
||||
m_pacemaker = std::make_shared<Core::Pacemaker>(ddsConnectorIn);
|
||||
m_pacemaker->setNewState(Core::RunningState::Starting);
|
||||
|
||||
m_partitionHandler.reset(new PartitionHandler(ddsConnectorIn));
|
||||
connect(m_partitionHandler.get(), &PartitionHandler::createSession,
|
||||
m_sessionHandler.get(), &SessionHandler::onCreateSession);
|
||||
connect(m_partitionHandler.get(), &PartitionHandler::destroySession,
|
||||
m_sessionHandler.get(), &SessionHandler::onDestroySession);
|
||||
|
||||
if (!m_partitionHandler->init() ||
|
||||
!m_sessionHandler->init())
|
||||
{
|
||||
m_pacemaker->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
const QString ex_0(QString::fromStdString(DDSConnector::DdsConnector::getPartitionString(IDL::PartitionType::Global)));
|
||||
m_sessionHandler->onCreateSession(ex_0, ex_0);
|
||||
|
||||
m_pacemaker->setNewState(Core::RunningState::Running);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MainHandler::shutdown()
|
||||
{
|
||||
if (m_sessionHandler)
|
||||
m_sessionHandler->shutdown();
|
||||
m_sessionHandler = nullptr;
|
||||
m_partitionHandler = nullptr;
|
||||
}
|
||||
|
||||
} // namespace RoutingService
|
||||
Reference in new issue
Block a user