- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
162 lines
5.1 KiB
C++
Executable File
162 lines
5.1 KiB
C++
Executable File
/**
|
|
* Get information about (O/C) participants to be able to send/receive messages for them
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Christian Ehrlicher, SLSE, 2016-12-13
|
|
*/
|
|
|
|
|
|
#include "exercises_handler.h"
|
|
#include "exercise_handler.h"
|
|
|
|
// subscribe to ex_* to gather
|
|
// 1. PPM::EquipmentExerciseMapping
|
|
// 2. TAB::EquipmentMessage
|
|
// create ExerciseHandler per Exercise (on demand when a message should be send to an O/C)
|
|
|
|
namespace Messaging
|
|
{
|
|
ExercisesHandler::ExercisesHandler(const std::shared_ptr<DdsHandler> &ddsHandler)
|
|
: m_ddsHandler(ddsHandler)
|
|
{
|
|
}
|
|
|
|
ExercisesHandler::~ExercisesHandler()
|
|
{
|
|
qDeleteAll(m_exerciseHandler);
|
|
}
|
|
|
|
bool ExercisesHandler::init()
|
|
{
|
|
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsHandler->ddsConnector());
|
|
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::equipmentExerciseMappingChanged,
|
|
this, &ExercisesHandler::onEquipmentExerciseMappingChanged);
|
|
|
|
if (!m_ppmDtc->enableEquipmentExerciseMapping())
|
|
return false;
|
|
|
|
ERROR_LOG() << "# eem: " << m_ppmDtc->equipmentExerciseMappings().size();
|
|
return true;
|
|
}
|
|
|
|
int ExercisesHandler::findEquipmentNumber(int participantId, int exerciseId)
|
|
{
|
|
QPair<int,int> exePart;
|
|
exePart.first = exerciseId;
|
|
exePart.second = participantId;
|
|
return m_participant2EquipNumber.value(exePart);
|
|
}
|
|
|
|
bool ExercisesHandler::sendEquipmentMessage(const TrainingAreaBase::SendEquipmentMessageRequest &request)
|
|
{
|
|
if (request.equipmentNumbers().size() == 0)
|
|
return false;
|
|
const int equipmentNumber = request.equipmentNumbers().at(0);
|
|
auto it = m_equipNo2ExerciseId.constFind(equipmentNumber);
|
|
if (it == m_equipNo2ExerciseId.cend())
|
|
{
|
|
ERROR_LOG() << "Can not send equipment message to training area - equipment number "
|
|
<< equipmentNumber << " not known";
|
|
return false;
|
|
}
|
|
ExerciseHandler *exH = exerciseHandlerForExerciseId(it.value());
|
|
return exH->sendEquipmentMessage(request);
|
|
}
|
|
|
|
bool ExercisesHandler::sendOcEquipmentMessage(const OcSituationServer::SendEquipmentMessageRequest &request)
|
|
{
|
|
if (request.equipmentNumbers().size() == 0)
|
|
return false;
|
|
const int equipmentNumber = request.equipmentNumbers().at(0);
|
|
auto it = m_equipNo2ExerciseId.constFind(equipmentNumber);
|
|
if (it == m_equipNo2ExerciseId.cend())
|
|
{
|
|
ERROR_LOG() << "Can not send equipment message to training area - equipment number "
|
|
<< equipmentNumber << " not known";
|
|
return false;
|
|
}
|
|
ExerciseHandler *exH = exerciseHandlerForExerciseId(it.value());
|
|
return exH->sendOcEquipmentMessage(request);
|
|
}
|
|
|
|
ExerciseHandler *ExercisesHandler::exerciseHandlerForExerciseId(int exerciseId)
|
|
{
|
|
const auto itEH = m_exerciseHandler.find(exerciseId);
|
|
if (itEH != m_exerciseHandler.end())
|
|
return itEH.value();
|
|
|
|
DEBUG_LOG() << "new ExerciseHandler for id " << exerciseId;
|
|
auto exH = new ExerciseHandler(m_ddsHandler->ddsConnector(), exerciseId);
|
|
bool result = exH->init();
|
|
DEBUG_LOG()<<"result init ="<<result;
|
|
connect(exH, &ExerciseHandler::exerciseHandlerIdleTimeout,
|
|
this, &ExercisesHandler::onExerciseHandlerIdleTimeout);
|
|
m_exerciseHandler[exerciseId] = exH;
|
|
return exH;
|
|
}
|
|
|
|
void ExercisesHandler::onEquipmentExerciseMappingChanged(const ParticipantManagement::EquipmentExerciseMapping &data,
|
|
DataModification modType)
|
|
{
|
|
DEBUG_LOG() << "onEquipmentExerciseMappingChanged";
|
|
|
|
for (auto it = m_equipNo2ExerciseId.begin(); it != m_equipNo2ExerciseId.end(); )
|
|
{
|
|
if (it.value() != data.exerciseId())
|
|
++it;
|
|
else
|
|
it = m_equipNo2ExerciseId.erase(it);
|
|
}
|
|
|
|
switch (modType)
|
|
{
|
|
case DataModification::eAdded:
|
|
case DataModification::eModified:
|
|
for (const ParticipantManagement::Equipment2ParticipantId &e2p : data.mapping())
|
|
{
|
|
m_equipNo2ExerciseId[e2p.equipmentNumber()] = data.exerciseId();
|
|
QPair<int,int> exePart;
|
|
exePart.first = data.exerciseId();
|
|
exePart.second = e2p.participantId();
|
|
m_participant2EquipNumber[exePart] = e2p.equipmentNumber();
|
|
}
|
|
break;
|
|
case DataModification::eRemoved:
|
|
break;
|
|
}
|
|
}
|
|
|
|
void ExercisesHandler::onEquipmentMessageChanged(const TrainingAreaBase::EquipmentMessage &data, const DataModification modType)
|
|
{
|
|
DEBUG_LOG() << "onEquipmentMessageChanged";
|
|
if (modType != DataModification::eAdded &&
|
|
modType != DataModification::eModified)
|
|
return;
|
|
const int equipmentNumber = data.equipmentNumber();
|
|
const auto it = m_equipNo2ExerciseId.constFind(equipmentNumber);
|
|
if (it == m_equipNo2ExerciseId.constEnd())
|
|
{
|
|
ERROR_LOG() << "Got EquipmentMessage from unknown participant with equipment number " << equipmentNumber;
|
|
return;
|
|
}
|
|
emit messageFromTrainingArea(data);
|
|
}
|
|
|
|
void ExercisesHandler::onExerciseHandlerIdleTimeout()
|
|
{
|
|
DEBUG_LOG()<<"onExerciseHandlerIdleTimeout";
|
|
ExerciseHandler *exH = qobject_cast<ExerciseHandler *>(sender());
|
|
if (!exH)
|
|
return;
|
|
const int exerciseId = exH->exerciseId();
|
|
auto it = m_exerciseHandler.find(exerciseId);
|
|
if (it != m_exerciseHandler.end())
|
|
{
|
|
exH->deleteLater();
|
|
m_exerciseHandler.erase(it);
|
|
}
|
|
}
|
|
|
|
} // namespace Messaging
|