Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Tools/VulnerabilityStateGenerator/proxy_emulator.cpp
T
berrux-dev 598fc2560e Complete Qt6 migration: full clean build green across groups G1-G12 incl. runtime plugin set
new_docker_build.sh gains Group 12 (212 GUI/Data plugins); fixes LtsUtilsGuiDds visibility (LTO-stripped exports), LtsProjectionWorkstation unity name shadow, 6 unity-off dirs (dup file-scope statics, ddsftc INTERFACE sources) and reconfigures BUILD_FILTERMANAGEMENT/BUILD_PLUGINS_SERVICEMONITOR=ON
2026-10-20 09:36:57 +02:00

89 lines
2.8 KiB
C++
Executable File

/**
* @RDE_HEADER@
* The ProxyEmulator class emulates FTs of the TetraRadio Proxy to send position data
* $Id$
* $HeadURL$
* $Author$
* Created by Hannes Baeuerle, SLSE, 2016-08-09
*/
#include "proxy_emulator.h"
#include <QtCore/QDateTime>
#include <QtCore/QThread>
#include <QtCore/QPointF>
#include <QtCore/QMap>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <NGLLogger/NGLLoggerBootstrap.h>
VulnerabilityStateGenerator::ProxyEmulator::ProxyEmulator(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, QObject *parent)
: QObject(parent)
, m_ddsConnector(ddsConnector)
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(metaObject()->className()))
{}
bool VulnerabilityStateGenerator::ProxyEmulator::init()
{
m_tabDts = (TrainingAreaBase::Interface::Dts::create(m_ddsConnector));
DEBUG_LOG(m_logger) << "Initializing TAB DTS ...";
if (!m_tabDts->enableAll())
{
ERROR_LOG(m_logger) << "Could not init TAB DTS";
return false;
}
DEBUG_LOG(m_logger) << "... done";
return true;
}
void VulnerabilityStateGenerator::ProxyEmulator::giveInitState(const QMap<qint32, ParticipantManagement::Participant> &participants)
{
DEBUG_LOG(m_logger) << participants.size()
<< " participants found. Trying to give them init states."
;
int participantsWithEquipmentNumber = 0;
for (auto it = participants.begin(); it != participants.end(); ++it)
{
const ParticipantManagement::Participant &currentParticipant = it.value();
if (currentParticipant.equipmentNumber.has_value())
{
++participantsWithEquipmentNumber;
TrainingAreaBase::EquipmentState state;
state.equipmentNumber = currentParticipant.equipmentNumber.value();
state.sampleTime = QDateTime::currentMSecsSinceEpoch();
state.vulnerabilityState = ProjectDataManagement::VulnerabilityState::VulnerabilityState_CombatReady;
m_tabDts->publish(state);
}
}
if (participants.size() != participantsWithEquipmentNumber)
{
DEBUG_LOG(m_logger) << "Actually gave "
<< participantsWithEquipmentNumber
<< " participants an init position, because the rest does not have an equipment number"
;
}
else
{
DEBUG_LOG(m_logger) << "... done";
}
}
void VulnerabilityStateGenerator::ProxyEmulator::publishNewState(ProjectDataManagement::VulnerabilityState newState, ParticipantManagement::Participant participant)
{
TrainingAreaBase::EquipmentState state;
state.equipmentNumber = participant.equipmentNumber.value();
state.sampleTime = QDateTime::currentMSecsSinceEpoch();
state.vulnerabilityState = newState;
DEBUG_LOG(m_logger) << "participantId: " << participant.id << ", state: " << newState << ", equipNo: " << participant.equipmentNumber.value();
m_tabDts->publish(state);
}