Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+36
@@ -0,0 +1,36 @@
|
||||
#
|
||||
# monitoring of the target areas
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
plugin.cpp
|
||||
plugin.h
|
||||
handler_participant_building.cpp
|
||||
handler_participant_building.h
|
||||
handler_blocked_areas.cpp
|
||||
handler_blocked_areas.h
|
||||
# logger.cpp
|
||||
# logger.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV cesPluginParticipantBuildings MODULE ${SRCS})
|
||||
NGL_TARGET_LINK_LIBRARIES(cesPluginParticipantBuildings
|
||||
PUBLIC
|
||||
Qt5::Network
|
||||
Qt5::Widgets
|
||||
cesPluginInterface
|
||||
ngldb
|
||||
svcCesDDSCommon
|
||||
svcBldClient
|
||||
svcTabClient
|
||||
LtsCoordTrans
|
||||
# ProjectConfig
|
||||
|
||||
)
|
||||
NGL_INSTALL_TARGET(cesPluginParticipantBuildings)
|
||||
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#include "handler_blocked_areas.h"
|
||||
#include "handler_participant_building.h"
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
|
||||
HandlerBlockedAreas::HandlerBlockedAreas(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
||||
const std::shared_ptr<HandlerParticipantBuilding> &participantBuildingHandler,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_handlerParticipant(participantHandler)
|
||||
, m_handlerParticipantBuilding(participantBuildingHandler)
|
||||
, m_logger(CentralEffectSimulation::getLogger("Plugin.ParticipantBuildings.HandlerBlockedAreas"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HandlerBlockedAreas::~HandlerBlockedAreas()
|
||||
{
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HandlerBlockedAreas::init()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "init";
|
||||
connect(m_handlerParticipant.get(), &CentralEffectSimulation::HandlerParticipant::newIndoorPosition,
|
||||
this, &HandlerBlockedAreas::onParticipantPositionChanged);
|
||||
connect(m_handlerParticipant.get(), &CentralEffectSimulation::HandlerParticipant::newOutdoorPosition,
|
||||
this, &HandlerBlockedAreas::onParticipantPositionChanged);
|
||||
connect(m_handlerParticipantBuilding.get(), &HandlerParticipantBuilding::newBuildingState,
|
||||
this, &HandlerBlockedAreas::onBuildingStateChanged);
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HandlerBlockedAreas::onSendParticipantBlockedAreaReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
WARNING_LOG(m_logger) << "Can not send blocked Area to participant : " << replyObject();
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "onSendParticipantBlockedAreaReply for id " << replyObject.id() << " success";
|
||||
}
|
||||
|
||||
void HandlerBlockedAreas::onParticipantPositionChanged(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &partPos)
|
||||
{
|
||||
const int participantId = partPos.participantId();
|
||||
int damagePercentBlockedAreas = 90; // From the percentage damage, blocked area applies Todo Config Value
|
||||
DEBUG_LOG(m_logger) << "HandlerBlockedAreas onParticipantPositionChanged participantId=" << participantId;
|
||||
|
||||
TrainingAreaBase::SendParticipantBlockedAreaRequest pba;
|
||||
pba.equipmentNumber(m_ddsHandler->participantId2EquipNo(partPos.participantId()));
|
||||
pba.participantId(partPos.participantId());
|
||||
// if (partPos.vulnerabilityState == ProjectDataManagement::VulnerabilityState_def::CombatReady)
|
||||
// m_blockedAreas.remove(participantId);
|
||||
|
||||
if (!partPos.insideBuilding())
|
||||
{
|
||||
auto it = m_blockedAreas.find(participantId);
|
||||
if (it != m_blockedAreas.end())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Blocked Area Leave equipment-No. =" << pba.equipmentNumber();
|
||||
pba.blockedAreaMode(TrainingAreaBase::BlockedAreaMode_def::Leave);
|
||||
m_ddsHandler->ftcTab()->sendParticipantBlockedAreaRequest(pba, this);
|
||||
m_blockedAreas.erase(it);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// check leave
|
||||
if (m_blockedAreas.contains(participantId) &&
|
||||
(m_handlerParticipantBuilding->getDamagePercentFromRoom(partPos.roomId()) < damagePercentBlockedAreas))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Blocked Area Leave equipment-No. =" << pba.equipmentNumber();
|
||||
pba.blockedAreaMode(TrainingAreaBase::BlockedAreaMode_def::Leave);
|
||||
m_ddsHandler->ftcTab()->sendParticipantBlockedAreaRequest(pba, this);
|
||||
m_blockedAreas.remove(participantId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "Room =" << partPos.roomId()
|
||||
<< " DamagePercentRoom=" << m_handlerParticipantBuilding->getDamagePercentFromRoom(partPos.roomId());
|
||||
DEBUG_LOG(m_logger) << "1: " << m_handlerParticipantBuilding->getDamagePercentFromRoom(partPos.roomId())
|
||||
<< " damagePercentBlockedAreas= " << damagePercentBlockedAreas << "\n"
|
||||
<< " getDamagePercentFromBuilding=" << m_handlerParticipantBuilding->getDamagePercentFromBuilding(partPos.buildingId()) << "\n"
|
||||
<< "m_blockedAreas.contains(participantId) = " << m_blockedAreas.contains(participantId) ;
|
||||
|
||||
|
||||
|
||||
if ((m_handlerParticipantBuilding->getDamagePercentFromRoom(partPos.roomId()) >= damagePercentBlockedAreas
|
||||
|| m_handlerParticipantBuilding->getDamagePercentFromBuilding(partPos.buildingId()) == 100)
|
||||
&& !m_blockedAreas.contains(participantId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Send Enter Blocked Area to Participant:" << participantId;
|
||||
pba.blockedAreaMode(TrainingAreaBase::BlockedAreaMode_def::Enter);
|
||||
m_ddsHandler->ftcTab()->sendParticipantBlockedAreaRequest(pba, this);
|
||||
m_blockedAreas.insert(participantId, partPos.roomId());
|
||||
}
|
||||
|
||||
} // end of onParticipantPositionChanged()
|
||||
|
||||
void HandlerBlockedAreas::onBuildingStateChanged(const int32_t buildingId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onBuildingStateChanged buildingId:" << buildingId;
|
||||
int damagePercent = m_handlerParticipantBuilding->getDamagePercentFromBuilding(buildingId);
|
||||
if (damagePercent == 0 && !m_blockedAreas.isEmpty()) // init
|
||||
{
|
||||
const auto participants = m_handlerParticipant->getParticipantsBuilding(buildingId);
|
||||
for (int participantId : participants)
|
||||
{
|
||||
if (m_blockedAreas.contains(participantId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "remove participantId: " << participantId;
|
||||
TrainingAreaBase::SendParticipantBlockedAreaRequest pba;
|
||||
pba.equipmentNumber(m_ddsHandler->participantId2EquipNo(participantId));
|
||||
pba.participantId(participantId);
|
||||
pba.blockedAreaMode(TrainingAreaBase::BlockedAreaMode_def::Leave);
|
||||
m_ddsHandler->ftcTab()->sendParticipantBlockedAreaRequest(pba, this);
|
||||
m_blockedAreas.remove(participantId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace CesParticipantBuildings
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Handler for Blocked Areas
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2018-07-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CentralEffectSimulation/logger.h>
|
||||
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/ces_db.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <TrainingAreaBase/tab_ftc.h>
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
#include <handler_participant_building.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
// AES-Handling for participants within buildings
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
|
||||
class HandlerBlockedAreas final
|
||||
: public QObject
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendParticipantBlockedAreaReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit HandlerBlockedAreas(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
||||
const std::shared_ptr<HandlerParticipantBuilding> &participantBuildingHandler,
|
||||
QObject *parent);
|
||||
|
||||
~HandlerBlockedAreas();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
|
||||
protected:
|
||||
void onSendParticipantBlockedAreaReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
/**
|
||||
* Handle new Participant Position
|
||||
*/
|
||||
void onParticipantPositionChanged(const CentralEffectSimulation::HandlerParticipant::CesParticipantData &partPos);
|
||||
void onBuildingStateChanged(const int32_t buildingId);
|
||||
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
|
||||
std::shared_ptr<HandlerParticipantBuilding> m_handlerParticipantBuilding;
|
||||
|
||||
QHash <int, int> m_blockedAreas; // key = participantId, value = roomId
|
||||
|
||||
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace CesParticipantBuildings
|
||||
|
||||
Executable
+313
@@ -0,0 +1,313 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#include "handler_participant_building.h"
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
#include <ProjectDataManagement/pdm_dtc.h>
|
||||
|
||||
#define PERCENT_100 100
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
|
||||
HandlerParticipantBuilding::HandlerParticipantBuilding(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_buildingStates()
|
||||
, m_requestMap()
|
||||
, m_timer(new QTimer(this))
|
||||
, m_logger(CentralEffectSimulation::getLogger("Plugin.ParticipantBuildings.HandlerParticipantBuilding"))
|
||||
{
|
||||
m_timer->setSingleShot(true);
|
||||
connect(m_timer, &QTimer::timeout, this, &HandlerParticipantBuilding::sendFtcCesHitRequestTimeout);
|
||||
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HandlerParticipantBuilding::~HandlerParticipantBuilding()
|
||||
{
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HandlerParticipantBuilding::init()
|
||||
{
|
||||
auto dtcBld = m_ddsHandler->dtcBld();
|
||||
dtcBld->waitForHistoricalDataBuildingState(1000);
|
||||
|
||||
connect(dtcBld.get(), &Buildings::Interface::Dtc::buildingStateChanged,
|
||||
this, &HandlerParticipantBuilding::onBuildingStateChanged);
|
||||
|
||||
// Get 'static' data for all buildingStates
|
||||
{
|
||||
auto cb = [this](const Buildings::BuildingState & bs)
|
||||
{
|
||||
onBuildingStateChanged(bs, DataModification::eAdded);
|
||||
};
|
||||
if (!dtcBld->buildingStates(cb))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
int HandlerParticipantBuilding::getDamagePercentFromBuilding(const int buildingId) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "getDamagePercentFromBuilding buildingId=" << buildingId;
|
||||
auto it = m_buildingStates.find(buildingId);
|
||||
return it != m_buildingStates.end() ? it.value().damagePercent() : 0;
|
||||
}
|
||||
|
||||
int HandlerParticipantBuilding::getDamagePercentFromRoom(const int roomId) const
|
||||
{
|
||||
//int buildingId = m_handlerBuildingData->getBuildingIdFromRoomId(roomId);
|
||||
int buildingId;
|
||||
m_ddsHandler->dtcIsm()->getBuildingId(roomId, buildingId);
|
||||
|
||||
auto it = m_roomIdDamageState.find(roomId);
|
||||
|
||||
// Exception:
|
||||
// if a building has failed completely, not all individual rooms are set as failed
|
||||
DEBUG_LOG(m_logger) << "getDamagePercentFromBuilding=" << getDamagePercentFromBuilding(buildingId)
|
||||
<< " buildingId=" << buildingId
|
||||
<< " roomId=" << roomId;
|
||||
if (buildingId < 0)
|
||||
return -1;
|
||||
if (getDamagePercentFromBuilding(buildingId) == PERCENT_100)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "return PERCENT_100:" << PERCENT_100;
|
||||
return PERCENT_100;
|
||||
}
|
||||
return it != m_roomIdDamageState.end() ? it.value().damagePercent : 0;
|
||||
}
|
||||
|
||||
void HandlerParticipantBuilding::onSendCesHitReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
//if (replyObject.error())
|
||||
// WARNING_LOG(m_logger) << "Can not send hit on participant to training area: " << replyObject();
|
||||
//else
|
||||
m_requestMap.remove(replyObject.id());
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitReply for id " << replyObject.id() << " success"
|
||||
<< " m_requestMap.remove(" << replyObject.id() << ")"
|
||||
<< " m_requestMap.size=" << m_requestMap.size();
|
||||
|
||||
}
|
||||
|
||||
// ///////////////////////////////////
|
||||
// B L D (Buildings)
|
||||
// ///////////////////////////////////
|
||||
void HandlerParticipantBuilding::onBuildingStateChanged(const Buildings::BuildingState &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
m_buildingStates.remove(data.id());
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got BuildingState originatorParticipantId=" << data.originatorParticipantId()
|
||||
<< ", aesId = " << data.aesId()
|
||||
<< ", chargeTypeId = " << data.chargeTypeId()
|
||||
<< ", sampleTime = " << data.sampleTime()
|
||||
<< ", CountRooms =" << data.roomStates().size()
|
||||
<< ", structureElementId=" << data.structureElementId()
|
||||
<< ", assetId=" << data.assetId()
|
||||
<< ", roomStates.size=" << data.roomStates().size()
|
||||
<< ", damagePercent" << data.damagePercent();
|
||||
|
||||
if ( (data.originatorParticipantId() == 0) && (data.aesId() == 0) && (data.chargeTypeId()==0))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Not valid return ";
|
||||
return;
|
||||
}
|
||||
|
||||
// fill m_roomIdDamageState
|
||||
RoomState rs;
|
||||
rs.buildingId = data.id();
|
||||
m_buildingStates.insert(data.id(), data);
|
||||
DEBUG_LOG(m_logger) << "m_buildingStates.insert id=" << data.id()
|
||||
<< " aesId=" << data.aesId()
|
||||
<< " name=" << data.name();
|
||||
|
||||
for (const Buildings::RoomState &roomState : data.roomStates())
|
||||
{
|
||||
rs.damagePercent = roomState.damagePercent();
|
||||
m_roomIdDamageState.insert(roomState.id(), rs);
|
||||
DEBUG_LOG(m_logger) << "m_roomIdDamageState.insert"
|
||||
<< " RoomId = " << roomState.id()
|
||||
<< ", BuildingId = " << data.id()
|
||||
<< ", destruction = " << roomState.damagePercent();
|
||||
}
|
||||
// init: remove all rooms from Map
|
||||
if (data.damagePercent() == 0)
|
||||
{
|
||||
auto it = m_roomIdDamageState.begin();
|
||||
while (it != m_roomIdDamageState.end())
|
||||
{
|
||||
if (it.value().buildingId == data.id())
|
||||
it = m_roomIdDamageState.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const auto participantsMap = m_handlerParticipant->positions();
|
||||
for (const Buildings::RoomState &roomState : data.roomStates())
|
||||
{
|
||||
if (roomState.damagePercent() <= 0)
|
||||
continue;
|
||||
// no effect should not burden the radio
|
||||
if (roomState.remainingEffectPercent() == 0)
|
||||
continue;
|
||||
|
||||
DEBUG_LOG(m_logger) << " RoomId[" << roomState.id() << "]:"
|
||||
<< " remainingEffectPercent = " << roomState.remainingEffectPercent()
|
||||
<< " roomState.damagePercent()=" << roomState.damagePercent()
|
||||
<< " roomState.remainingEffectPercent()=" << roomState.remainingEffectPercent();
|
||||
// search for participants in each room:
|
||||
// if participant in room sendCESHit to TAB
|
||||
|
||||
for (const CentralEffectSimulation::HandlerParticipant::CesParticipantData &participantPos : participantsMap)
|
||||
{
|
||||
const int participantId = participantPos.participantId();
|
||||
if (participantPos.roomId() != roomState.id())
|
||||
continue;
|
||||
if (participantPos.vulnerabilityState == ProjectDataManagement::VulnerabilityState_def::CatastrophicKill)
|
||||
continue;
|
||||
const int equipNo = m_ddsHandler->participantId2EquipNo(participantId);
|
||||
if (equipNo <= 0)
|
||||
continue;
|
||||
if (m_handlerParticipant->isOutdated(participantPos))
|
||||
continue;
|
||||
|
||||
DEBUG_LOG(m_logger) << " participantId = " << participantId
|
||||
<< " roomId = " << participantPos.roomId()
|
||||
<< " roomState.id=" << roomState.id()
|
||||
<< " participantPos.vulnerabilityState=" << participantPos.vulnerabilityState
|
||||
<< " equipNo=" << m_ddsHandler->participantId2EquipNo(participantId)
|
||||
<< " isOutdated=" << m_handlerParticipant->isOutdated(participantPos);
|
||||
|
||||
DEBUG_LOG(m_logger) << "sendCesHitToParticipant";
|
||||
sendCesHitToParticipant(data, participantId, roomState.remainingEffectPercent());
|
||||
}
|
||||
}
|
||||
|
||||
m_buildingStates.insert(data.id(), data);
|
||||
if (!m_timer->isActive() && !m_requestMap.isEmpty())
|
||||
m_timer->start(1000);
|
||||
|
||||
emit newBuildingState(data.id());
|
||||
}
|
||||
|
||||
void HandlerParticipantBuilding::sendCesHitToParticipant(const Buildings::BuildingState &data,
|
||||
const int32_t participantId,
|
||||
const int32_t remainingEffectPercent)
|
||||
{
|
||||
const int equipNo = m_ddsHandler->participantId2EquipNo(participantId);
|
||||
const QHash<int, CentralEffectSimulation::HandlerParticipant::CesParticipantData> participantsMap = m_handlerParticipant->positions();
|
||||
const int originatorEquipNo = m_ddsHandler->participantId2EquipNo(data.originatorParticipantId());
|
||||
|
||||
|
||||
|
||||
CentralEffectSimulation::HandlerParticipant::CesParticipantData participantPos = participantsMap.value(participantId);
|
||||
const ProjectDataManagement::EventType eventType = ProjectDataManagement::EventType_def::HitBuilding;
|
||||
|
||||
AreaEffectSimulation::AesItem aesItem;
|
||||
|
||||
|
||||
|
||||
bool itemAvailable = m_ddsHandler->dtcAes()->aesItemFromId(data.aesId(), aesItem);
|
||||
if (itemAvailable)
|
||||
DEBUG_LOG(m_logger) << "partyId=" << aesItem.partyId()
|
||||
<< " chargeTypeId=" << aesItem.chargeStruct().chargeTypeId()
|
||||
<< " duration=" << aesItem.effectDuration();
|
||||
|
||||
// mineFieldBitIndex wird als reserve1 uegertragen und hier wird die Wirkdauer uebertragen.
|
||||
const int duration = aesItem.effectDuration() / 1000;
|
||||
|
||||
//int32_t legacyChargeTypeId = 0;
|
||||
//const ProjectDataManagement::FuseType fuseType = m_ddsHandler->dtcAes()->explosionCluster(aesItem.id()).fuseType();
|
||||
const int chargeTypeId = itemAvailable ? aesItem.chargeStruct().chargeTypeId() : data.chargeTypeId();
|
||||
|
||||
// legacyChargeTypeId = m_ddsHandler->getLegacyIdFromChargeTypeId(chargeTypeId, fuseType);
|
||||
// NOTE: igniterTypeId/IgniterFunction = 0 as long as BuildingState does not contain values
|
||||
AreaEffectSimulation::ChargeStruct chargeStruct = { data.chargeTypeId(),0,0};
|
||||
if (itemAvailable) chargeStruct = aesItem.chargeStruct();
|
||||
int remainTasCodeIndirect = m_ddsHandler->remainingTasCode(chargeStruct);
|
||||
|
||||
DEBUG_LOG(m_logger) << " ftc sendCESHit to Participant equipNo = " << equipNo
|
||||
<< " participantId=" << participantId
|
||||
<< " chargeTypeId=" << data.chargeTypeId()
|
||||
<< " originatorEquipNo=" << originatorEquipNo
|
||||
<< " remainingEffectPercent=" << remainingEffectPercent
|
||||
<< " remainTasCodeIndirect=" << remainTasCodeIndirect
|
||||
<< " eventType=" << eventType;
|
||||
const TrainingAreaBase::TabPosition pos(participantPos.pos(),
|
||||
participantPos.reportingSource(),
|
||||
participantPos.buildingId(),
|
||||
participantPos.roomId());
|
||||
|
||||
|
||||
// Bei Nebel soll die Weste nur einmal piepen und nicht regelmaessig. Das wird mit Wirkung = 3 uebertragen
|
||||
// In fog, the waistcoat should only beep once and not regularly. This is transmitted with effect = 3
|
||||
// int effect;
|
||||
// if (m_ddsHandler->isSmoke(chargeTypeId))
|
||||
// effect = 3;
|
||||
// else
|
||||
// effect = 2;
|
||||
|
||||
|
||||
|
||||
TrainingAreaBase::SendCesHitRequest requestTab;
|
||||
|
||||
requestTab.aesId(data.aesId());
|
||||
//requestTab.chargeTypeId(legacyChargeTypeId > 0 ? legacyChargeTypeId : chargeTypeId);
|
||||
requestTab.chargeTypeId(chargeTypeId);
|
||||
requestTab.effectTime(data.sampleTime());
|
||||
requestTab.equipmentNumber(equipNo);
|
||||
requestTab.eventType(eventType);
|
||||
requestTab.mineId(duration);
|
||||
requestTab.originatorEquipmentNumber(originatorEquipNo);
|
||||
requestTab.participantId(participantId);
|
||||
int32_t partyId = 0;
|
||||
if ( aesItem.partyId().is_set())
|
||||
partyId = aesItem.partyId().get();
|
||||
requestTab.partyId(partyId);
|
||||
requestTab.position(pos);
|
||||
|
||||
// Same like direct Hit
|
||||
// if (aesItem.id() > 0)
|
||||
// {
|
||||
// NOTICE_LOG(m_logger) << "remainEffectPercent Wirksimulation remainEffectPercent=" << remainTasCodeIndirect;
|
||||
// requestTab.remainEffectPercent(remainTasCodeIndirect);
|
||||
// }
|
||||
// else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "direkter Beschuss remainEffectPercent=" << remainingEffectPercent;
|
||||
requestTab.remainEffectPercent(remainingEffectPercent);
|
||||
}
|
||||
|
||||
m_requestMap.insert(participantId, requestTab);
|
||||
}
|
||||
|
||||
void HandlerParticipantBuilding::sendFtcCesHitRequestTimeout()
|
||||
{
|
||||
auto ftcTab = m_ddsHandler->ftcTab();
|
||||
for (const TrainingAreaBase::SendCesHitRequest &hr : qAsConst(m_requestMap))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "sendFtcCesHitRequest: " << hr;
|
||||
ftcTab->sendCesHitRequest(hr, this);
|
||||
}
|
||||
m_requestMap.clear();
|
||||
}
|
||||
|
||||
} // namespace CesParticipantBuildings
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CentralEffectSimulation/logger.h>
|
||||
|
||||
#include <Buildings/bld_dtc.h>
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/handler_participant.h>
|
||||
#include <CentralEffectSimulation/handler_building_data.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
// Handling for participants within buildings
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
|
||||
class HandlerParticipantBuilding : public QObject
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HandlerParticipantBuilding(const std::shared_ptr<CentralEffectSimulation::DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerParticipant> &participantHandler,
|
||||
const std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> &handlerBuildingData,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerParticipantBuilding();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
int getDamagePercentFromBuilding(const int buildingId) const;
|
||||
int getDamagePercentFromRoom(const int roomId) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void newBuildingState(const int32_t buildingId);
|
||||
|
||||
protected:
|
||||
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
/**
|
||||
* Handle BuildingState from 'BLD'
|
||||
*/
|
||||
void onBuildingStateChanged(const Buildings::BuildingState &data, DataModification modType);
|
||||
/**
|
||||
* Handle MainStructureElement from 'ISM'
|
||||
*/
|
||||
void sendFtcCesHitRequestTimeout();
|
||||
|
||||
void sendCesHitToParticipant(const Buildings::BuildingState &data,
|
||||
const int32_t participantId,
|
||||
const int32_t remainingEffectPercent);
|
||||
|
||||
|
||||
private: // attributes
|
||||
struct RoomState
|
||||
{
|
||||
int buildingId = 0;
|
||||
int damagePercent = 0;
|
||||
};
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant;
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerBuildingData> m_handlerBuildingData;
|
||||
|
||||
QHash<int, Buildings::BuildingState> m_buildingStates;
|
||||
QHash<int, RoomState> m_roomIdDamageState; // Key = roomId, value = damageState
|
||||
QHash<int, TrainingAreaBase::SendCesHitRequest> m_requestMap; // Key = participantId
|
||||
QTimer *m_timer;
|
||||
|
||||
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace CesParticipantBuildings
|
||||
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Plugin Ces Participant Buildings
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <ngldb/db_service_handler.h>
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> CesParticipantBuildingsPlugin::createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
|
||||
NGL::Settings *settings,
|
||||
CentralEffectSimulation::MainHandler *mainHandler)
|
||||
{
|
||||
return std::make_shared<CesParticipantBuildingsInterfaceImpl>(pdp, dDSConnector, settings, mainHandler);
|
||||
}
|
||||
|
||||
|
||||
CesParticipantBuildingsInterfaceImpl::CesParticipantBuildingsInterfaceImpl(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.ParticipantBuildings.CesParticipantBuildingsInterfaceImpl"))
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
|
||||
CesParticipantBuildingsInterfaceImpl::~CesParticipantBuildingsInterfaceImpl()
|
||||
{
|
||||
m_handlerParticipantBuilding.reset();
|
||||
m_handlerBlockedAreas.reset();
|
||||
}
|
||||
|
||||
|
||||
bool CesParticipantBuildingsInterfaceImpl::init(int domainId, int exerciseId)
|
||||
{
|
||||
m_domainId = domainId;
|
||||
m_exerciseId = exerciseId;
|
||||
INFO_LOG(m_logger) << "CesParticipantBuildingsInterfaceImpl::init()"
|
||||
<< " m_domainId=" << m_domainId
|
||||
<< " m_exerciseId=" << m_exerciseId;
|
||||
|
||||
|
||||
INFO_LOG(m_logger) << "initialize HandlerParticipantBuilding ----------------------------";
|
||||
m_handlerParticipantBuilding = std::make_shared<HandlerParticipantBuilding>(m_ddsHandler,
|
||||
m_handlerParticipant,
|
||||
m_handlerBuildingData,
|
||||
this);
|
||||
|
||||
if (!m_handlerParticipantBuilding->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerParticipantData failed.";
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(m_logger) << "end initialize HandlerParticipantBuilding ----------------------------";
|
||||
|
||||
|
||||
if (Settings::handleBlockedAreas())
|
||||
{
|
||||
INFO_LOG(m_logger) << "initialize HandlerBlockedAreas ----------------------------";
|
||||
// initialize HandlerBlockedAreas
|
||||
m_handlerBlockedAreas = std::make_shared<HandlerBlockedAreas>(m_ddsHandler,
|
||||
m_handlerParticipant,
|
||||
m_handlerParticipantBuilding,
|
||||
this);
|
||||
|
||||
// Blocked Areas
|
||||
if (!m_handlerBlockedAreas->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation m_handlerBlockedAreas failed.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
INFO_LOG(m_logger) << "CesParticipantBuildingsInterfaceImpl::init() return true";
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CesParticipantBuildingsInterfaceImpl::echo(const QString &message)
|
||||
{
|
||||
|
||||
QString ret(QStringLiteral("<<<< %1 >>>> CES_FUNCTIONAL_AREAInterfaceImpl::echo").arg(message));
|
||||
INFO_LOG(m_logger) << "CES_FUNCTIONAL_AREAInterfaceImpl::echo return:" << ret;
|
||||
DEBUG_LOG(m_logger) << "DEBUG: CesParticipantBuildingsInterfaceImpl::echo return:" << ret;
|
||||
return ret;
|
||||
}
|
||||
} //namespace CesParticipantBuildings
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Plugin Blocked Areas
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <CentralEffectSimulation/logger.h>
|
||||
|
||||
#include "handler_participant_building.h"
|
||||
#include "handler_blocked_areas.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <CentralEffectSimulation/ces_plugin_interface.h>
|
||||
#include <CentralEffectSimulation/main_handler.h>
|
||||
#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include <CentralEffectSimulation/handler_building_data.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
|
||||
class CesParticipantBuildingsPlugin : public QObject, public CentralEffectSimulation::Plugin::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "special:3:ces.CentralEffectSimulationParticipantBuildingsPlugin")
|
||||
Q_INTERFACES(CentralEffectSimulation::Plugin::Plugin)
|
||||
|
||||
public:
|
||||
CesParticipantBuildingsPlugin() = default;
|
||||
~CesParticipantBuildingsPlugin() = 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 CesParticipantBuildingsInterfaceImpl final : public CentralEffectSimulation::Plugin::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CesParticipantBuildingsInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> &dDSConnector,
|
||||
NGL::Settings *settings,
|
||||
CentralEffectSimulation::MainHandler *mainHandler);
|
||||
~CesParticipantBuildingsInterfaceImpl();
|
||||
//bool init();
|
||||
const char *name() const override { return "CentralEffectSimulationParticipantBuildings"; }
|
||||
QString echo(const QString &message) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
bool init(int domainId, int exerciseId) override;
|
||||
private:
|
||||
|
||||
private:
|
||||
CentralEffectSimulation::Plugin::DataProvider *m_pdp;
|
||||
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; ///< Pointer to AES Building handler
|
||||
std::shared_ptr<CentralEffectSimulation::HandlerParticipant> m_handlerParticipant; ///< Pointer to handler for all participants
|
||||
|
||||
std::shared_ptr<HandlerParticipantBuilding> m_handlerParticipantBuilding; ///< Pointer to handler for participant inside from Buildings
|
||||
std::shared_ptr<HandlerBlockedAreas> m_handlerBlockedAreas; ///< Pointer to handler for Blocked Areas
|
||||
|
||||
|
||||
|
||||
CentralEffectSimulation::LOGGER_T &m_logger; ///< Interface to the Logging-Facility
|
||||
int m_domainId = 0;
|
||||
int m_exerciseId = 0;
|
||||
};
|
||||
|
||||
} // namespace CesParticipantBuildings
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* Settings for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QVariant>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
class NGLSettingsClass : public NGL::Settings
|
||||
{
|
||||
public:
|
||||
NGLSettingsClass()
|
||||
: NGL::Settings(s_iniFile.isEmpty() ? NGL::findProjectConfigFile() : s_iniFile)
|
||||
{}
|
||||
static void setIniFile(const QString &fn)
|
||||
{
|
||||
s_iniFile = fn;
|
||||
}
|
||||
static QString s_iniFile;
|
||||
};
|
||||
QString NGLSettingsClass::s_iniFile;
|
||||
Q_GLOBAL_STATIC(NGLSettingsClass, s)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NGL::Settings *Settings::settings()
|
||||
{
|
||||
return s();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::setIniFile(const QString &ini)
|
||||
{
|
||||
NGLSettingsClass::setIniFile(ini);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Settings::handleBlockedAreas()
|
||||
{
|
||||
return s()->settings()->value(QStringLiteral("CES_PARTICIPANT_BUILDINGS/handleBlockedAreas"), false).toBool();
|
||||
}
|
||||
|
||||
} // namespace CesParticipantBuildings
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Settings for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace CesParticipantBuildings
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
|
||||
NGL::Settings *settings();
|
||||
void setIniFile(const QString &ini);
|
||||
bool handleBlockedAreas();
|
||||
}
|
||||
|
||||
} // namespace CesParticipantBuildings
|
||||
Reference in new issue
Block a user