Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,27 @@
#
# monitoring of the target areas
# $Id: CMakeLists.txt 64216 2024-12-02 05:24:17Z fritsche_h $
# $HeadURL: svn://slssvn/TDS/branches/product/features/25_03_etb_uas/Lts/Services/CentralEffectSimulation/Plugins/Jamming/CMakeLists.txt $
# $Author: fritsche_h $
#
SET(SRCS
plugin.cpp
plugin.h
handler_jamming.cpp
handler_jamming.h
)
NGL_ADD_LIBRARY(AAR SV cesPluginCES_Jamming MODULE ${SRCS})
NGL_TARGET_LINK_LIBRARIES(cesPluginCES_Jamming
PUBLIC
Qt5::Network
Qt5::Widgets
cesPluginInterface
LtsUtilsCore
ngldb
svcCesDDSCommon
# ProjectConfig
)
NGL_INSTALL_TARGET(cesPluginCES_Jamming)
@@ -0,0 +1,235 @@
/**
* 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(m_logger) << "HandlerJamming::init() finished.";
return true;
} // end of init()
//-----------------------------------------------------------------------------
void HandlerJamming::onParticipantGearEventChanged(const ParticipantManagement::ParticipantGearEvent &data, DataModification modType)
{
ERROR_LOG(m_logger) << "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(m_logger) << "Radius=" << radius;
for ( int uasId : uasIds)
{
DEBUG_LOG(m_logger) << "uasId=" << uasId;
CentralEffectSimulation::HandlerParticipant::CesParticipantData cesParticipantData = m_handlerParticipant->position(uasId);
if (!cesParticipantData.positionValid)
{
DEBUG_LOG(m_logger) << "continue !positionValid participantId=" << uasId;
continue;
}
if (LtsUtils::isPositionTimeOutdated(QDateTime::currentMSecsSinceEpoch(), cesParticipantData.sampleTime()))
{
DEBUG_LOG(m_logger) << "continue positionTime outdated participantId=" << uasId;
continue;
}
long distance = m_handlerParticipant->getDistance(data.participantId(), uasId);
DEBUG_LOG(m_logger) << "distance = " << distance;
if ( distance < radius)
{
DEBUG_LOG(m_logger) << " 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(m_logger) << "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(m_logger) << "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(m_logger) << "onSendCesHitReply for id " << replyObject.id() << " success= " << replyObject.error();
if (replyObject.error())
WARNING_LOG(m_logger) << "Can not send enter/leave Area to participant in training area: " << replyObject();
// Send next Request, if available
if (!m_sendCesHitRequestQueue.isEmpty())
{
DEBUG_LOG(m_logger) << "m_sendCesAreaActionRequestQueue.size()=" << m_sendCesHitRequestQueue.size();
m_sendCesHitRequestQueue.dequeue();
// Send next Message
if (!m_sendCesHitRequestQueue.isEmpty())
{
const auto &hr = m_sendCesHitRequestQueue.head();
DEBUG_LOG(m_logger) << "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(m_logger) << "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(m_logger) << " ftc sendCESHit to Participant participantId = " << participantData.participantId()
<< " equipNo = " << equipNo
<< " chargeTypeId =" << chargeTypeId;
if (participantData.vulnerabilityState == ProjectDataManagement::VulnerabilityState_def::CatastrophicKill)
{
DEBUG_LOG(m_logger) << "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(m_logger) << " participantId=" << participantData.participantId()
<< " chargeTypeId=" << chargeTypeId;
m_sendCesHitRequestQueue.enqueue(requestTab);
if (m_sendCesHitRequestQueue.size() == 1)
{
DEBUG_LOG(m_logger) << "SendCesHitRequest: " << requestTab;
m_ddsHandler->ftcTab()->sendCesHitRequest(requestTab, this);
}
} // sendCesHitRequest
} // namespace CES_JAMMING
@@ -0,0 +1,99 @@
/**
* Handler for player data
* $Id: handler_functional_area.h 64170 2024-11-25 11:34:11Z fritsche_h $
* $HeadURL: svn://slssvn/TDS/branches/product/features/25_03_etb_uas/Lts/Services/CentralEffectSimulation/Plugins/FunctionalAreas/handler_functional_area.h $
* $Author: fritsche_h $
* Created by gr, SLSE, 2017-02-20
*/
#pragma once
#include <CentralEffectSimulation/logger.h>
#include <CentralEffectSimulation/dds_handler.h>
#include <CentralEffectSimulation/aes_item_view_utm.h>
#include <CentralEffectSimulation/handler_participant.h>
#include <CentralEffectSimulation/handler_building_data.h>
#include <AreaEffectSimulation/aes_dtc.h>
#include <QtCore/QHash>
#include <QtCore/QObject>
#include <QtCore/QQueue>
#include <QtCore/QPointF>
#include <QtGui/QPolygonF>
// AES-Handling for participants
namespace CES_JAMMING
{
struct ParticipantDistance
{
double squareDistance = 0;
CentralEffectSimulation::HandlerParticipant::CesParticipantData participantPosition;
};
struct EnterLeaveType
{
ProjectDataManagement::EventType eventType = ProjectDataManagement::EventType_def::Unknown;
bool isAlreadySupplied = false;
};
class HandlerJamming : public QObject
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
{
Q_OBJECT
public:
explicit HandlerJamming(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData,
QObject *parent = nullptr);
~HandlerJamming();
/**
* Initialize the handler to manage information from player management
*/
bool init();
protected:
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
private Q_SLOTS:
/**
* Handle the signals from 'AES'
*/
// void onAesItemViewChanged(const AreaEffectSimulation::AesItemView &data, DataModification modType);
// void onJammingChanged(const AreaEffectSimulation::JammingArea &data, DataModification modType);
void onParticipantGearEventChanged(const ParticipantManagement::ParticipantGearEvent &data, DataModification modType);
private: // methoden
void sendCesHitRequest(const int chargeTypeId, const int originatorId,
const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantData);
ProjectDataManagement::EventType leaveEventTypeForAesType(AreaEffectSimulation::AesType aesTypeId);
private: // attributes
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to VOM DDS handler
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
QHash<int32_t, int> m_aesItemId2partIdMap;
// AES-Values
QHash<int, CentralEffectSimulation::AesItemViewUtm> m_aesItemViews; // key = aesItemId
QQueue<TrainingAreaBase::SendCesHitRequest> m_sendCesHitRequestQueue;
QQueue<TrainingAreaBase::DemandInitRequest> m_sendInitRequestQueue;
QHash<QPair<int, int>, EnterLeaveType> m_cesEnterLeaveFunctionalArea; // QPair < aesItemId, participantId> Last Event
QHash<int, QVector<int>> m_aesPolygonEncloseBuilding; // key = aesItemId value = BuildingIds inside form
int m_requestId = 1;
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
};
} // namespace CES_JAMMING
@@ -0,0 +1,82 @@
/**
* Plugin CES Functional Area
* $Id: plugin.cpp 64170 2024-11-25 11:34:11Z fritsche_h $
* $HeadURL: svn://slssvn/TDS/branches/product/features/25_03_etb_uas/Lts/Services/CentralEffectSimulation/Plugins/FunctionalAreas/plugin.cpp $
* $Author: fritsche_h $
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
*/
#include "plugin.h"
#include "settings.h"
namespace CES_JAMMING
{
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> CesFunctionalAreaPlugin::createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
NGL::Settings *settings,
CentralEffectSimulation::MainHandler *mainHandler)
{
return std::make_shared<CES_JammingInterfaceImpl>(pdp, dDSConnector, settings, mainHandler);
}
CES_JammingInterfaceImpl::CES_JammingInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
NGL::Settings *settings,
CentralEffectSimulation::MainHandler *mainHandler)
: m_pdp(pdp)
, m_ddsConnector(dDSConnector)
, m_mainHandler(mainHandler)
, m_ddsHandler(m_mainHandler->dds())
, m_db(m_mainHandler->db())
, m_handlerBuildingData(m_mainHandler->handlerBuildingData())
, m_handlerParticipant(m_mainHandler->handlerParticipant())
, m_logger(CentralEffectSimulation::getLogger("Plugin.Jamming.HandlerJamming"))
{
Q_UNUSED(settings)
}
CES_JammingInterfaceImpl::~CES_JammingInterfaceImpl()
{
m_handlerJamming.reset();
}
bool CES_JammingInterfaceImpl::init(int domainId, int exerciseId)
{
m_domainId = domainId;
m_exerciseId = exerciseId;
INFO_LOG(m_logger) << "CES_JammingInterfaceImpl::init()"
<< " m_domainId=" << m_domainId
<< " m_exerciseId=" << m_exerciseId;
// initialize HandlerJamming
m_handlerJamming = std::make_shared<HandlerJamming>(m_ddsHandler,
m_handlerParticipant,
m_handlerBuildingData,
this);
if (!m_handlerJamming->init())
{
ERROR_LOG(m_logger) << "Initialisation m_handlerFunctionalArea failed.";
return false;
}
INFO_LOG(m_logger) << "CES_JammingInterfaceImpl::init() return true";
return true;
}
QString CES_JammingInterfaceImpl::echo(const QString &message)
{
QString ret(QStringLiteral("<<<< %1 >>>> CES_JammingInterfaceImpl::echo").arg(message));
INFO_LOG(m_logger) << "CES_JammingInterfaceImpl::echo return:" << ret;
DEBUG_LOG(m_logger) << "DEBUG: CES_JammingInterfaceImpl::echo return:" << ret;
return ret;
}
} //namespace CES_JAMMING
@@ -0,0 +1,77 @@
/**
* Plugin CES Functional Area
* $Id: plugin.h 64170 2024-11-25 11:34:11Z fritsche_h $
* $HeadURL: svn://slssvn/TDS/branches/product/features/25_03_etb_uas/Lts/Services/CentralEffectSimulation/Plugins/FunctionalAreas/plugin.h $
* $Author: fritsche_h $
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
*/
#pragma once
#include <CentralEffectSimulation/logger.h>
#include "handler_jamming.h"
#include <DDS/DDSConnector/dds_connector.h>
#include <CentralEffectSimulation/ces_plugin_interface.h>
#include <CentralEffectSimulation/main_handler.h>
#include <CentralEffectSimulation/dds_handler.h>
#include <QObject>
namespace CES_JAMMING
{
class CesFunctionalAreaPlugin : public QObject, public CentralEffectSimulation::Plugin::Plugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "special:3:ces.CesJammingPlugin")
Q_INTERFACES(CentralEffectSimulation::Plugin::Plugin)
public:
CesFunctionalAreaPlugin() = default;
~CesFunctionalAreaPlugin() = default;
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
NGL::Settings *settings,
CentralEffectSimulation::MainHandler *mainHandler) override;
};
class CES_JammingInterfaceImpl final : public CentralEffectSimulation::Plugin::Interface
{
Q_OBJECT
public:
CES_JammingInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
NGL::Settings *settings,
CentralEffectSimulation::MainHandler *mainHandler);
~CES_JammingInterfaceImpl();
//bool init();
const char *name() const override { return "CesFunctionalAreaPlugin"; }
QString echo(const QString &message) override;
private Q_SLOTS:
bool init(int domainId, int exerciseId) override;
private:
private:
CentralEffectSimulation::Plugin::DataProvider *m_pdp{nullptr};
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
CentralEffectSimulation::MainHandler *m_mainHandler{nullptr};
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler;
std::shared_ptr<CentralEffectSimulation::DatabaseInterface> m_db;
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant; ///< Pointer to handler for all participants
std::shared_ptr<HandlerJamming> m_handlerJamming; ///
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
int m_domainId = 0;
int m_exerciseId = 0;
};
} // namespace CES_JAMMING