- 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>
193 lines
6.9 KiB
C++
Executable File
193 lines
6.9 KiB
C++
Executable File
/**
|
|
* Handler for player data
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by gr, SLSE, 2017-02-20
|
|
*/
|
|
|
|
#include "handler_participant.h"
|
|
#include "settings.h"
|
|
|
|
using namespace AlarmManagement;
|
|
|
|
HandlerParticipant::HandlerParticipant(const std::shared_ptr<DdsHandler> &ddsHandler)
|
|
: QObject()
|
|
, m_ddsHandler(ddsHandler)
|
|
{
|
|
} // end of ctor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
HandlerParticipant::~HandlerParticipant()
|
|
{
|
|
} // end of dtor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool HandlerParticipant::init()
|
|
{
|
|
auto dtcPpm = m_ddsHandler->dtcPpm();
|
|
|
|
connect(dtcPpm.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
|
this, &HandlerParticipant::onParticipantChanged);
|
|
connect(dtcPpm.get(), &ParticipantManagement::Interface::Dtc::dynamicParticipantDataChanged,
|
|
this, &HandlerParticipant::onDynamicParticipantChanged);
|
|
|
|
// Get 'static' data for all participants
|
|
{
|
|
auto cb = [this](const ParticipantManagement::Participant & es)
|
|
{
|
|
onParticipantChanged(es, DataModification::eAdded);
|
|
};
|
|
if (!dtcPpm->participants(cb))
|
|
return false;
|
|
}
|
|
|
|
if (!dtcPpm->enableParticipant())
|
|
{
|
|
ERROR_LOG() << "Could not initialize ParticipantManagement enableParticipant data topic client";
|
|
return false;
|
|
}
|
|
|
|
if (!dtcPpm->enableDynamicParticipantData())
|
|
{
|
|
ERROR_LOG() << "Could not initialize ParticipantManagement enableDynamicParticipant data topic client";
|
|
return false;
|
|
}
|
|
|
|
// Get 'static' data for all participants (playerdata)
|
|
QMap<qint32, ParticipantManagement::Participant> participantsMap;
|
|
participantsMap = dtcPpm->participants();
|
|
|
|
// Player in Referenzmap eintragen
|
|
for (auto i = participantsMap.begin(); i != participantsMap.end(); ++i)
|
|
{
|
|
const ParticipantManagement::Participant &participant = i.value();
|
|
|
|
if (participant.equipmentNumber().is_set())
|
|
{
|
|
m_partId2EquipNoMap.insert(participant.id(), participant.equipmentNumber().get());
|
|
DEBUG_LOG() << "m_partId2EquipNoMap.insert participantId=" << participant.id() << "EquimentNo=" << participant.equipmentNumber().get();
|
|
}
|
|
else
|
|
m_partId2EquipNoMap.insert(participant.id(), 0);
|
|
}
|
|
|
|
// Get 'static' data for all dynamicParticipants (playerdata)
|
|
QMap<qint32, ParticipantManagement::DynamicParticipantData> dynamicParticipantsMap = dtcPpm->dynamicParticipantDatas();
|
|
|
|
// Player in Referenzmap eintragen
|
|
for (auto i = dynamicParticipantsMap.begin(); i != dynamicParticipantsMap.end(); ++i)
|
|
{
|
|
const ParticipantManagement::DynamicParticipantData &dynamicParticipant = i.value();
|
|
|
|
if (dynamicParticipant.stateHistory().size() > 0)
|
|
{
|
|
std::vector<ParticipantManagement::StateInformation> states = dynamicParticipant.stateHistory();
|
|
ParticipantManagement::StateInformation state = states[0];
|
|
int vulnerability = state.vulnerabilityState().underlying();
|
|
m_partId2VulnerabilityMap.insert(i.value().participantId(), vulnerability);
|
|
DEBUG_LOG() << "m_partId2EquipNoMap.insert participantId=" << i.value().participantId() << "vulnerability=" << vulnerability;
|
|
}
|
|
else
|
|
m_partId2VulnerabilityMap.insert(i.value().participantId(), -1);
|
|
}
|
|
|
|
INFO_LOG() << "HandlerParticipant::init() finished. ";
|
|
return true;
|
|
} // end of init()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void HandlerParticipant::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
|
{
|
|
if (modType == DataModification::eRemoved)
|
|
{
|
|
DEBUG_LOG() << "onParticipantChanged - remove: " << data.id();
|
|
m_participantHierarchy.remove(data.id());
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG() << "onParticipantChanged:" << data;
|
|
m_participantHierarchy.insert(data.id(),
|
|
AlarmManagement::HandlerParticipant::ParticipantHierarchy(data));
|
|
const int equipNo = data.equipmentNumber().is_set() ? data.equipmentNumber().get() : 0;
|
|
m_partId2EquipNoMap.insert(data.id(), equipNo);
|
|
|
|
}
|
|
} // end of onParticipantChanged()
|
|
|
|
void HandlerParticipant::onDynamicParticipantChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
|
|
{
|
|
DEBUG_LOG() << "onDynamicParticipant participantId=" << data.participantId();
|
|
if (modType == DataModification::eRemoved)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
INFO_LOG() << "onDynamicParticipant()"
|
|
<< " participantId: " << data.participantId();
|
|
if (data.stateHistory().size() > 0)
|
|
{
|
|
std::vector<ParticipantManagement::StateInformation> states = data.stateHistory();
|
|
ParticipantManagement::StateInformation state = states[0];
|
|
int vulnerability = state.vulnerabilityState().underlying();
|
|
m_partId2VulnerabilityMap.insert(data.participantId(), vulnerability);
|
|
DEBUG_LOG() << "m_partId2EquipNoMap.insert participantId=" << data.participantId()
|
|
<< " vulnerability=" << vulnerability;
|
|
}
|
|
else
|
|
m_partId2VulnerabilityMap.insert(data.participantId(), -1);
|
|
|
|
}
|
|
} // end of onParticipantChanged()
|
|
|
|
QVector<AlarmManagement::HandlerParticipant::ParticipantHierarchy> HandlerParticipant::getInferiorParts(int participantId) const
|
|
{
|
|
QVector<AlarmManagement::HandlerParticipant::ParticipantHierarchy> retVector;
|
|
auto it = m_participantHierarchy.find(participantId);
|
|
if (it == m_participantHierarchy.end())
|
|
return retVector;
|
|
|
|
const AlarmManagement::HandlerParticipant::ParticipantHierarchy &participant = it.value();
|
|
retVector.reserve(participant.inferiorIds.size() + retVector.size());
|
|
|
|
retVector.append(participant);
|
|
for (int inferiorId : participant.inferiorIds)
|
|
retVector.append(getInferiorParts(inferiorId));
|
|
|
|
return retVector;
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------
|
|
QVector<int> HandlerParticipant::getRecursiveInferiorIds(const int participantId) const
|
|
{
|
|
QVector <int> result;
|
|
if (participantId == 0)
|
|
{
|
|
result.append(participantId);
|
|
return result;
|
|
}
|
|
|
|
const QVector<AlarmManagement::HandlerParticipant::ParticipantHierarchy> inferiorParts = HandlerParticipant::getInferiorParts(participantId);
|
|
result.reserve(inferiorParts.size());
|
|
for (const auto &inferior : inferiorParts)
|
|
result.append(inferior.participantId);
|
|
|
|
return result;
|
|
}
|
|
|
|
int HandlerParticipant::participantId2EquipNo(const int participantId) const
|
|
{
|
|
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
|
INFO_LOG() << "participantId2EquipNo participantId=" << participantId
|
|
<< " EquipmentNumber=" << ret;
|
|
return ret;
|
|
} // end of participantId2EquipNo()
|
|
|
|
int HandlerParticipant::participantId2Vulnerability(const int participantId) const
|
|
{
|
|
int ret = m_partId2VulnerabilityMap.value(participantId, 0);
|
|
INFO_LOG() << "m_partId2VulnerabilityMap participantId=" << participantId
|
|
<< " Vulnerability=" << ret;
|
|
return ret;
|
|
} // end of participantId2Vulnerability()
|