- 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>
66 lines
1.8 KiB
C++
Executable File
66 lines
1.8 KiB
C++
Executable File
/**
|
|
* DdsHandler for HighLevelArchitecture
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
|
*/
|
|
|
|
#include "dds_handler.h"
|
|
|
|
#include <DDS/Core/pacemaker.h>
|
|
#include <DDS/DTS/generic_dts_impl.h>
|
|
|
|
namespace HighLevelArchitecture
|
|
{
|
|
|
|
DdsHandler::DdsHandler(int domainId, int exerciseId)
|
|
: m_ddsConnector(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId))
|
|
, m_exerciseHasHlaConnection(false)
|
|
, m_logger(getLogger("DdsHandler"))
|
|
{
|
|
DEBUG_LOG(m_logger) << "DdsHandler(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
|
}
|
|
|
|
DdsHandler::~DdsHandler()
|
|
{
|
|
m_dtcExm = nullptr;
|
|
m_pacemaker = nullptr;
|
|
m_ddsConnector = nullptr;
|
|
}
|
|
|
|
bool DdsHandler::init(const QStringList &qosFileList)
|
|
{
|
|
if (!m_ddsConnector->init(qosFileList))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
|
return false;
|
|
}
|
|
|
|
// default initialize Publisher and Subscriber
|
|
m_ddsConnector->initPublisherSubscriber();
|
|
|
|
m_pacemaker = std::make_shared<Core::Pacemaker>(m_ddsConnector);
|
|
|
|
m_dtcExm = ExerciseManagement::Interface::Dtc::create(m_ddsConnector);
|
|
connect(m_dtcExm.get(), &ExerciseManagement::Interface::Dtc::exerciseChanged,
|
|
this, &DdsHandler::onExerciseChanged);
|
|
m_dtcExm->enableExercise();
|
|
|
|
return true;
|
|
}
|
|
|
|
void DdsHandler::onExerciseChanged(const ExerciseManagement::Exercise &ex, DataModification modType)
|
|
{
|
|
if (modType == DataModification::eRemoved)
|
|
return;
|
|
if (ex.id() != m_ddsConnector->getPartitionId())
|
|
return;
|
|
if (m_exerciseHasHlaConnection == ex.hasHlaInterface())
|
|
return;
|
|
m_exerciseHasHlaConnection = ex.hasHlaInterface();
|
|
emit exerciseHlaStateChanged(m_exerciseHasHlaConnection);
|
|
}
|
|
|
|
} // namespace HighLevelArchitecture
|