Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Services/CentralEffectSimulation/Plugins/Jamming/handler_jamming.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- 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>
2026-08-19 06:06:24 +02:00

236 lines
9.0 KiB
C++
Executable File

/**
* Handler for player data
* $Id: handler_functional_area.cpp 64453 2025-01-31 12:06:15Z fritsche_h $
* $HeadURL: svn://slssvn/TDS/branches/product/features/25_03_etb_uas/Lts/Services/CentralEffectSimulation/Plugins/FunctionalAreas/handler_functional_area.cpp $
* $Author: fritsche_h $
* Created by gr, SLSE, 2017-02-20
*/
#include "handler_jamming.h"
#include <QTimer>
#include <QDateTime>
#include <QRandomGenerator>
#include <LtsUtilsCore/dds_bitarray.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <ProjectDataManagement/pdm_enums.hpp>
#include "LtsUtils/LtsUtilsCore/outdated_position.h"
namespace dds
{
namespace core
{
inline uint qHash(ProjectDataManagement::EventType et)
{
return ::qHash(et.underlying());
}
}
}
namespace CES_JAMMING
{
HandlerJamming::HandlerJamming(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData,
QObject *parent)
: QObject(parent)
, m_ddsHandler(ddsHandler)
, m_handlerParticipant(participantHandler)
, m_handlerBuildingData(handlerBuildingData)
, m_logger(CentralEffectSimulation::getLogger("Plugin.Jamming.HandlerJamming"))
{
} // end of ctor()
//-----------------------------------------------------------------------------
HandlerJamming::~HandlerJamming()
{
} // end of dtor()
//-----------------------------------------------------------------------------
bool HandlerJamming::init()
{
// TAB FTC
m_ddsHandler->ftcTab()->enableDemandInit();
// m_ddsHandler->dtcAes()->enableJammingArea();
// connect (m_ddsHandler->dtcAes().get(), &AreaEffectSimulation::Interface::Dtc::jammingAreaChanged,
// this, &HandlerJamming::onJammingChanged);
// m_ddsHandler->dtcAes()->enableAesItemView();
// connect (m_ddsHandler->dtcAes().get(), &AreaEffectSimulation::Interface::Dtc::aesItemViewChanged,
// this, &HandlerJamming::onAesItemViewChanged);
m_ddsHandler->dtcPpm()->enableParticipantGearEvent();
connect (m_ddsHandler->dtcPpm().get(), &ParticipantManagement::Interface::Dtc::participantGearEventChanged,
this, &HandlerJamming::onParticipantGearEventChanged);
DEBUG_LOG() << "HandlerJamming::init() finished.";
return true;
} // end of init()
//-----------------------------------------------------------------------------
void HandlerJamming::onParticipantGearEventChanged(const ParticipantManagement::ParticipantGearEvent &data, DataModification modType)
{
ERROR_LOG() << "onParticipantGearEventChanged << modType=" << modType
<< " originatorId=" << data.participantId()
<< " chargeTypeId=" << data.charge().chargeTypeId()
<< " gearTypeId=" << data.charge().gearTypeId()
<< " isJamming=" << m_ddsHandler->isJamming({data.charge().chargeTypeId(),0,0});
// Check, if Munition isJamming
// NOTE: igniterType/IgniterFunciton = 0 as long as ParticipantGearEvent does not contain values
if (!m_ddsHandler->isJamming({data.charge().chargeTypeId(),0,0}))
return;
QVector<int> uasIds = m_ddsHandler->dtcPpm()->getUasIds();
QVector<int> jammedUasIds;
int jammedUasId = 0;
double radius = m_ddsHandler->dtcPdm()->getMaxRange(data.charge().chargeTypeId(), data.charge().gearTypeId());
// int radius = 15;
DEBUG_LOG() << "Radius=" << radius;
for ( int uasId : uasIds)
{
DEBUG_LOG() << "uasId=" << uasId;
CentralEffectSimulation::HandlerParticipant::CesParticipantData cesParticipantData = m_handlerParticipant->position(uasId);
if (!cesParticipantData.positionValid)
{
DEBUG_LOG() << "continue !positionValid participantId=" << uasId;
continue;
}
if (LtsUtils::isPositionTimeOutdated(QDateTime::currentMSecsSinceEpoch(), cesParticipantData.sampleTime()))
{
DEBUG_LOG() << "continue positionTime outdated participantId=" << uasId;
continue;
}
long distance = m_handlerParticipant->getDistance(data.participantId(), uasId);
DEBUG_LOG() << "distance = " << distance;
if ( distance < radius)
{
DEBUG_LOG() << " Send Jamming to TAB and destroy uasId";
//sendCesHitRequest(data.charge().chargeTypeId(), data.participantId(),cesParticipantData);
if (cesParticipantData.vulnerabilityState != ProjectDataManagement::VulnerabilityState_def::CatastrophicKill)
jammedUasIds.append(uasId);
}
else
DEBUG_LOG() << "Not in Radius distance=" << distance
<< " radius=" << radius;
}
// [ETB UASETBUAS-33] Equal distribution of jamming failures
// Extension of the CES plugin for jamming to randomly drop out exactly one random drone per shot.
// the equal distribution refers to the participant ID of the drone
if ( jammedUasIds.size() == 0)
return;
else
{
// search for an id from the list with an algorithm that contains an equal distribution
jammedUasId = jammedUasIds.at(QRandomGenerator::global()->bounded(jammedUasIds.size() - 1));
DEBUG_LOG() << "jammedUasId=" << jammedUasId
<< " jammedUasIds.size()=" << jammedUasIds.size();
}
CentralEffectSimulation::HandlerParticipant::CesParticipantData cesParticipantData = m_handlerParticipant->position(jammedUasId);
sendCesHitRequest(data.charge().chargeTypeId(), data.participantId(),cesParticipantData);
}
void HandlerJamming::onSendCesHitReply(const Core::FunctionReplyObject &replyObject)
{
DEBUG_LOG() << "onSendCesHitReply for id " << replyObject.id() << " success= " << replyObject.error();
if (replyObject.error())
WARNING_LOG() << "Can not send enter/leave Area to participant in training area: " << replyObject();
// Send next Request, if available
if (!m_sendCesHitRequestQueue.isEmpty())
{
DEBUG_LOG() << "m_sendCesAreaActionRequestQueue.size()=" << m_sendCesHitRequestQueue.size();
m_sendCesHitRequestQueue.dequeue();
// Send next Message
if (!m_sendCesHitRequestQueue.isEmpty())
{
const auto &hr = m_sendCesHitRequestQueue.head();
DEBUG_LOG() << "sendCesHitRequest: " << hr;
m_ddsHandler->ftcTab()->sendCesHitRequest(hr, this);
}
}
}
// Send via TAB-Proxy to UAS-Proxy
void HandlerJamming::sendCesHitRequest(const int chargeTypeId,
const int originatorId,
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData)
{
qint64 effectTime = m_ddsHandler->currentPartitionTime();
int remaining = 0;
if (remaining < 0)
return;
DEBUG_LOG() << "sendCesHitRequest Settings::calculateCentralAes="
<< " insideWlsArea=" << std::boolalpha << participantData.insideWlsArea()
<< " participantId=" << participantData.participantId();
const int equipNo = m_ddsHandler->participantId2EquipNo(participantData.participantId());
const int originatorEquimentNumber = m_ddsHandler->participantId2EquipNo(originatorId);
const int originatorPartyId = m_handlerParticipant->getParticipantPosition(originatorId).partyId();
DEBUG_LOG() << " ftc sendCESHit to Participant participantId = " << participantData.participantId()
<< " equipNo = " << equipNo
<< " chargeTypeId =" << chargeTypeId;
if (participantData.vulnerabilityState == ProjectDataManagement::VulnerabilityState_def::CatastrophicKill)
{
DEBUG_LOG() << "participantPosition.participantId == 0 CatastrophicKill)";
return;
}
const TrainingAreaBase::TabPosition pos(participantData.pos(),
Core::PositionReportingSource_def::Gps, // irrelevant
participantData.buildingId(),
participantData.roomId());
const int aesId = 0; // not used
const int mineId = 0; // not used
TrainingAreaBase::SendCesHitRequest requestTab(
equipNo, // equipmentNumber
participantData.participantId(), // participantId
chargeTypeId, // chargeTypeId
aesId, // aesId
originatorEquimentNumber, // originatorEquipmentNumber
remaining, // remainEffectPercent ( no protection outside Building )
pos,
effectTime, // effectTime
ProjectDataManagement::EventType::Jamming, // EventType
originatorPartyId, // originPartyId
mineId
);
DEBUG_LOG() << " participantId=" << participantData.participantId()
<< " chargeTypeId=" << chargeTypeId;
m_sendCesHitRequestQueue.enqueue(requestTab);
if (m_sendCesHitRequestQueue.size() == 1)
{
DEBUG_LOG() << "SendCesHitRequest: " << requestTab;
m_ddsHandler->ftcTab()->sendCesHitRequest(requestTab, this);
}
} // sendCesHitRequest
} // namespace CES_JAMMING