Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#
|
||||
# monitoring of the target areas
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
plugin.cpp
|
||||
plugin.h
|
||||
targettimer.cpp
|
||||
targettimer.h
|
||||
handler_target_areas.cpp
|
||||
handler_target_areas.h
|
||||
dds_handler.cpp
|
||||
dds_handler.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV cesPluginTargetAreas MODULE ${SRCS})
|
||||
NGL_INSTALL_TARGET(cesPluginTargetAreas)
|
||||
NGL_TARGET_LINK_LIBRARIES(cesPluginTargetAreas
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
NGLLogger
|
||||
cesPluginInterface
|
||||
svcPpmClient
|
||||
svcTabClient
|
||||
ddsconnector
|
||||
ddscore
|
||||
LtsCoordTrans
|
||||
svcCoreClient
|
||||
)
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* DdsHandlerTargetAreas for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#include "dds_handler.h"
|
||||
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
|
||||
DdsHandlerTargetAreas::DdsHandlerTargetAreas(int domainId, int exerciseId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId))
|
||||
, m_participantEventId(0)
|
||||
, m_exerciseId(exerciseId)
|
||||
, m_logger(getLogger("DdsHandlerTargetAreas"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DdsHandlerTargetAreas(" << domainId << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandlerTargetAreas::init(const QStringList &qosFileList)
|
||||
{
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
// default initialize Publisher and Subscriber
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
m_ddsConnector->enableBatchedWriter(false);
|
||||
|
||||
m_topicLockMaster = std::make_shared<Core::TopicLockMaster>(m_ddsConnector);
|
||||
|
||||
m_dtcCore = Core::Interface::Dtc::create(m_ddsConnector);
|
||||
m_dtcCore->enablePartitionTime();
|
||||
|
||||
m_ftcTab = TrainingAreaBase::Interface::Ftc::create(m_ddsConnector);
|
||||
if (!m_ftcTab->enableSendCesHit() ||
|
||||
!m_ftcTab->enableSendCesHitInformation() ||
|
||||
!m_ftcTab->enableSendGeopairingData() ||
|
||||
!m_ftcTab->enableSendParticipantBlockedArea() ||
|
||||
!m_ftcTab->enableSendParticipantBeStillWarning() ||
|
||||
!m_ftcTab->enableSendControlData())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable SendCesHit";
|
||||
return false;
|
||||
}
|
||||
m_dtcPpm = ParticipantManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
if (!m_dtcPpm->enableDynamicParticipantData())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not initialize ParticipantManagement enableDynamicParticipantData data topic client";
|
||||
return false;
|
||||
}
|
||||
if (!m_dtcPpm->enableParticipantPosition())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not initialize ParticipantManagement enableParticipantPosition data topic client";
|
||||
return false;
|
||||
}
|
||||
if (!m_dtcPpm->enableParticipant())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not initialize ParticipantManagement enableParticipant data topic client";
|
||||
return false;
|
||||
}
|
||||
if (!m_dtcPpm->enableType())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not initialize ParticipantManagement enableType data topic client";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_dtcPpm.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &DdsHandlerTargetAreas::onParticipantChanged);
|
||||
// Get 'static' data for all participants (playerdata)
|
||||
// Player in Referenzmap eintragen
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Participant & participant)
|
||||
{
|
||||
onParticipantChanged(participant, DataModification::eAdded);
|
||||
};
|
||||
m_dtcPpm->participants(cb);
|
||||
}
|
||||
|
||||
return true;
|
||||
} // end of init
|
||||
|
||||
// ///////////////////////////////////
|
||||
// P P M (ParticipantManagement)
|
||||
// ///////////////////////////////////
|
||||
void DdsHandlerTargetAreas::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
m_partId2EquipNoMap.remove(data.id());
|
||||
else
|
||||
m_partId2EquipNoMap[data.id()] = data.equipmentNumber().is_set() ? data.equipmentNumber().get() : 0;
|
||||
|
||||
if (m_logger.isTraceEnabled())
|
||||
{
|
||||
for (auto i = m_partId2EquipNoMap.begin(); i != m_partId2EquipNoMap.end(); ++i)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " partId2EquipNoMap.size(): " << m_partId2EquipNoMap.size()
|
||||
<< " partId: " << i.key()
|
||||
<< " eqNo: " << i.value();
|
||||
}
|
||||
}
|
||||
} // end of onParticipantChanged()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
qint64 DdsHandlerTargetAreas::currentPartitionTime() const
|
||||
{
|
||||
return m_dtcCore->partitionTime().timeStamp();
|
||||
}
|
||||
|
||||
int DdsHandlerTargetAreas::participantId2EquipNo(const int participantId) const
|
||||
{
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
if (ret > 0)
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId
|
||||
<< " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
} // end of participantId2EquipNo()
|
||||
|
||||
} // Namespace CentralEffectSimulation
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* DdsHandlerTargetAreas for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2015-09-02
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <DDS/Core/topic_lock_master.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <TrainingAreaBase/tab_ftc.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
class DdsHandlerTargetAreas : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DdsHandlerTargetAreas(int domainId, int exerciseId);
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList());
|
||||
|
||||
std::shared_ptr<Core::TopicLockMaster> topicLockMaster() const { return m_topicLockMaster; }
|
||||
std::shared_ptr<DDSConnector::DdsConnector> dds() const { return m_ddsConnector; }
|
||||
|
||||
std::shared_ptr<Core::Interface::Dtc> dtcCore() const { return m_dtcCore;}
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> dtcPpm() const {return m_dtcPpm;} ///< Pointer to DTC ParticipantManagement interface object
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Ftc> ftcTab() const { return m_ftcTab;}
|
||||
|
||||
|
||||
int getParticipantEventId() { return m_participantEventId++;}
|
||||
qint64 currentPartitionTime() const;
|
||||
|
||||
/**
|
||||
* Get equipment number for the given participant
|
||||
* @param participantId participant id to get the equipment number for
|
||||
* @return equipment number or 0 in case of failure
|
||||
*/
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Handle the signals from 'ParticipantManagement'
|
||||
*/
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_dtcCore;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtcPpm; ///< Pointer to DTC ParticipantManagement interface object
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Ftc> m_ftcTab;
|
||||
|
||||
QMap<int, int> m_partId2EquipNoMap; ///< Reference map participant (player) to equipment number
|
||||
int m_participantEventId;
|
||||
int m_exerciseId;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+551
@@ -0,0 +1,551 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#include "handler_target_areas.h"
|
||||
#include <CentralEffectSimulation/point_helpers.h>
|
||||
#include <ParticipantManagement/ppm_common.h>
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <QLineF>
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
|
||||
HandlerTargetAreas::HandlerTargetAreas(const std::shared_ptr<DdsHandlerTargetAreas> &ddsHandler,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_logger(getLogger("HandlerTargetAreas"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
HandlerTargetAreas::~HandlerTargetAreas()
|
||||
{
|
||||
} // end of dtor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HandlerTargetAreas::init()
|
||||
{
|
||||
auto dtcPpm = m_ddsHandler->dtcPpm();
|
||||
|
||||
connect(dtcPpm.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
this, &HandlerTargetAreas::onParticipantPositionChanged);
|
||||
connect(dtcPpm.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &HandlerTargetAreas::onParticipantChanged);
|
||||
connect(dtcPpm.get(), &ParticipantManagement::Interface::Dtc::typeChanged,
|
||||
this, &HandlerTargetAreas::onTypeChanged);
|
||||
connect(dtcPpm.get(), &ParticipantManagement::Interface::Dtc::targetInformationChanged,
|
||||
this, &HandlerTargetAreas::onTargetInformationChanged);
|
||||
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Type & data)
|
||||
{
|
||||
onTypeChanged(data, DataModification::eAdded);
|
||||
};
|
||||
dtcPpm->types(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Participant & data)
|
||||
{
|
||||
onParticipantChanged(data, DataModification::eAdded);
|
||||
};
|
||||
dtcPpm->participants(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::ParticipantPosition & data)
|
||||
{
|
||||
onParticipantPositionChanged(data, DataModification::eAdded);
|
||||
};
|
||||
dtcPpm->participantPositions(cb);
|
||||
}
|
||||
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::TargetInformation & data)
|
||||
{
|
||||
onTargetInformationChanged(data, DataModification::eAdded);
|
||||
};
|
||||
dtcPpm->targetInformations(cb);
|
||||
}
|
||||
INFO_LOG(m_logger) << "HandlerTargetAreas::init() finished. "
|
||||
<< " m_positionsMap.size(): " << m_positionsMap.size();
|
||||
return true;
|
||||
} // end of init()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void HandlerTargetAreas::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onParticipantPositionChanged: " << data;
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "m_participantsOutsideMap.remove participantId: " << data.participantId();
|
||||
//m_participantsOutsideMap.remove(data.participantId());
|
||||
}
|
||||
else
|
||||
{
|
||||
ParticipantPosition partPos(data);
|
||||
auto it = m_positionsMap.find(partPos.participantId());
|
||||
if (it != m_positionsMap.end())
|
||||
{
|
||||
const ParticipantPosition &partPosOld = *it;
|
||||
|
||||
partPos.vulnerabilityState = partPosOld.vulnerabilityState;
|
||||
partPos.lastGeoPosition = partPosOld.pos(); // save previous position
|
||||
// replace
|
||||
*it = partPos;
|
||||
DEBUG_LOG(m_logger) << "m_positionsMap.replace=" << data.participantId();
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "m_positionsMap.insert=" << data.participantId();
|
||||
m_positionsMap.insert(data.participantId(), partPos);
|
||||
}
|
||||
|
||||
int equipmentNumber = m_ddsHandler->participantId2EquipNo(data.participantId());
|
||||
if (equipmentNumber > 0)
|
||||
checkShootbackAreaPosition(data);
|
||||
else
|
||||
INFO_LOG(m_logger) << "Teilnehmer hat keine Ausstattungsnummer";
|
||||
|
||||
INFO_LOG(m_logger) << "onParticipantPositionChanged()"
|
||||
<< " participantId; " << data.participantId()
|
||||
<< " participantTypeId: " << data.participantTypeId()
|
||||
<< " partyId: " << data.partyId()
|
||||
<< " vulnerabilityState: " << partPos.vulnerabilityState;
|
||||
}
|
||||
} // end of onParticipantPositionChanged()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
void HandlerTargetAreas::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
{
|
||||
// Remove Participant:
|
||||
if (modType == DataModification::eRemoved || data.isDeleted())
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onParticipantChanged m_positionsMap.remove id=" << data.id();
|
||||
m_participantData.remove(data.id());
|
||||
m_positionsMap.remove(data.id());
|
||||
return;
|
||||
}
|
||||
|
||||
// No OC in CES
|
||||
ParticipantManagement::TypeClass typeClass = typeClassFromTypeId(data.typeId());
|
||||
if (typeClass == ParticipantManagement::TypeClass_def::SupportEntity
|
||||
|| typeClass == ParticipantManagement::TypeClass_def::SupportUnit
|
||||
|| typeClass == ParticipantManagement::TypeClass_def::Unit)
|
||||
return;
|
||||
m_participantData[data.id()] = data;
|
||||
|
||||
ParticipantPosition &pos = m_positionsMap[data.id()];
|
||||
pos.partyId(data.partyId());
|
||||
pos.participantId(data.id());
|
||||
pos.participantTypeId(data.typeId());
|
||||
DEBUG_LOG(m_logger) << "onParticipantChanged"
|
||||
<< " id=" << data.id()
|
||||
<< " typeId=" << data.typeId()
|
||||
<< " designator=" << data.designator();
|
||||
if (typeClass == ParticipantManagement::TypeClass_def::Target)
|
||||
DEBUG_LOG(m_logger) << "Typeclass = Target";
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::onTypeChanged(const ParticipantManagement::Type &data, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
m_typeMap.insert(data.id(), data.typeClass());
|
||||
DEBUG_LOG(m_logger) << "m_typeMap.size()" << m_typeMap.size()
|
||||
<< " equipmentTypeId=" << data.id()
|
||||
<< " typeClass=" << data.typeClass();
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::onTargetInformationChanged(const ParticipantManagement::TargetInformation &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onTargetInformationChanged"
|
||||
<< " participantId=" << data.participantId()
|
||||
<< " data.shootbackAreas().size()=" << data.shootbackAreas().size();
|
||||
|
||||
if (modType == DataModification::eRemoved)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "m_participantsOutsideMap.remove participantId: " << data.participantId();
|
||||
m_shootbackTargets.remove(data.participantId());
|
||||
return;
|
||||
}
|
||||
ShootbackTarget shootbackTarget;
|
||||
shootbackTarget.participantId = data.participantId();
|
||||
if (m_shootbackTargets.contains(data.participantId()))
|
||||
{
|
||||
shootbackTarget = m_shootbackTargets[data.participantId()];
|
||||
shootbackTarget.shootbackAreasUtm.clear();
|
||||
}
|
||||
shootbackTarget.targetInformation = data;
|
||||
// assign shootbackAreasUtm
|
||||
for (unsigned int i = 0; i < data.shootbackAreas().size(); i++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << " shootbackAreas i=" << i;
|
||||
ParticipantManagement::ShootbackArea shootbackArea = data.shootbackAreas().at(i);
|
||||
QPolygonF shootbackAreaUtm;
|
||||
|
||||
for (unsigned int i = 0; i < shootbackArea.area().size(); i++)
|
||||
{
|
||||
QPointF pointfUtm1;
|
||||
pointfUtm1 = CentralEffectSimulation::geographic2Utm(shootbackArea.area().at(i), &m_zone);
|
||||
shootbackAreaUtm.push_back(pointfUtm1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < shootbackAreaUtm.size(); i++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "i=" << i
|
||||
<< " x=" << shootbackAreaUtm[i].x()
|
||||
<< " y=" << shootbackAreaUtm[i].y()
|
||||
<< " zone=" << m_zone;
|
||||
}
|
||||
shootbackTarget.shootbackAreasUtm.append(shootbackAreaUtm);
|
||||
}
|
||||
|
||||
m_shootbackTargets.insert(data.participantId(), shootbackTarget);
|
||||
DEBUG_LOG(m_logger) << "newShootbackTarget participantId=" << data.participantId()
|
||||
<< " shootbackTarget.participantId=" << shootbackTarget.participantId
|
||||
<< " shootbackTarget.targetInformation.participantId()=" << shootbackTarget.targetInformation.participantId()
|
||||
<< " shootbackTarget.targetInformation.prewarningInterval()=" << shootbackTarget.targetInformation.prewarningInterval()
|
||||
<< " data.shootbackAreas().size()=" << data.shootbackAreas().size()
|
||||
<< " prewarningEffect=" << shootbackTarget.targetInformation.prewarningEffect()
|
||||
<< " takedownEffect=" << shootbackTarget.targetInformation.takedownEffect();
|
||||
printShootbackAreas();
|
||||
}
|
||||
|
||||
int HandlerTargetAreas::getParticipantId(int equipentNumber)
|
||||
{
|
||||
// QHash<int, ParticipantManagement::Participant> m_participantData;
|
||||
|
||||
QHashIterator<int, ParticipantManagement::Participant> i(m_participantData);
|
||||
while (i.hasNext())
|
||||
{
|
||||
i.next();
|
||||
if (i.value().equipmentNumber() == equipentNumber)
|
||||
return i.value().id();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::printQPolygon(const QPolygonF polygon)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "printQPolygon polygon.size()=" << polygon.size();
|
||||
for (int i = 0; i < polygon.size(); i++)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "printQPolygon i=" << i
|
||||
<< " x=" << polygon[i].x()
|
||||
<< " y=" << polygon[i].y();
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::printShootbackTarget(const ShootbackTarget &shootbackTarget)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "ShootbackTarget "
|
||||
<< ", targetParticipantId=" << shootbackTarget.participantId
|
||||
<< ", shootbackAreasUtm.size=" << shootbackTarget.shootbackAreasUtm.size();
|
||||
for (int i = 0; i < shootbackTarget.shootbackAreasUtm.size(); i++)
|
||||
{
|
||||
// Punkte des Poygons ausgeben
|
||||
printQPolygon(shootbackTarget.shootbackAreasUtm.at(i));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::printShootbackAreas()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "printShootbackAreas--------------------";
|
||||
QHashIterator<int, ShootbackTarget> it(m_shootbackTargets);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
ShootbackTarget shootbackTarget = it.value();
|
||||
printShootbackTarget(shootbackTarget);
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "ENDE printShootbackAreas--------------------";
|
||||
}
|
||||
|
||||
bool HandlerTargetAreas::checkPosInShootbackTarget(const ShootbackTarget &shootbackTarget,
|
||||
const QPointF &participantPosUtm)
|
||||
{
|
||||
bool inside = false;
|
||||
DEBUG_LOG(m_logger) << "checkPosInShootbackTarget ShootbackTarget "
|
||||
<< ", targetParticipantId=" << shootbackTarget.participantId
|
||||
<< ", shootbackAreasUtm.size=" << shootbackTarget.shootbackAreasUtm.size();
|
||||
for (int i = 0; i < shootbackTarget.shootbackAreasUtm.size(); i++)
|
||||
{
|
||||
// Punkte des Poygons ausgeben
|
||||
printQPolygon(shootbackTarget.shootbackAreasUtm.at(i));
|
||||
if (shootbackTarget.shootbackAreasUtm.at(i).containsPoint(participantPosUtm, Qt::OddEvenFill))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "inside = true";
|
||||
inside = true;
|
||||
}
|
||||
}
|
||||
return inside;
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::checkShootbackAreaPosition(const ParticipantManagement::ParticipantPosition &data)
|
||||
{
|
||||
int participantId = data.participantId();
|
||||
int equipmentNumber = m_ddsHandler->participantId2EquipNo(data.participantId());
|
||||
DEBUG_LOG(m_logger) << "checkShootbackAreaPosition id= " << data.participantId()
|
||||
<< ", equipmentNumber=" << equipmentNumber
|
||||
<< ", sampleTime=" << data.sampleTime()
|
||||
<< ", time difference = " << QDateTime::currentMSecsSinceEpoch() - data.sampleTime();
|
||||
ParticipantPosition posActual = m_positionsMap[data.participantId()];
|
||||
// ParticipantManagement::TypeClass typeClass = m_typeMap[data.participantId()];
|
||||
|
||||
QPointF participantPosUtm;
|
||||
participantPosUtm = CentralEffectSimulation::geographic2Utm(posActual.pos(), &m_zone);
|
||||
|
||||
printShootbackAreas();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Participant pos=" << posActual.pos().lat() << "/" << posActual.pos().lon()
|
||||
<< ", Utm=" << participantPosUtm.x() << "/" << participantPosUtm.y()
|
||||
<< " m_zone=" << m_zone;
|
||||
|
||||
QHashIterator<int, ShootbackTarget> it(m_shootbackTargets);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
ShootbackTarget shootbackTarget = it.value();
|
||||
if (data.participantId() == shootbackTarget.participantId)
|
||||
continue;
|
||||
int targetPreWarningInterval = shootbackTarget.targetInformation.prewarningInterval() * 1000;
|
||||
int targetTimeToEffectInterval = shootbackTarget.targetInformation.takedownInterval() * 1000;
|
||||
|
||||
DEBUG_LOG(m_logger) << "ShootbackArea ParticipantID=" << shootbackTarget.participantId
|
||||
<< " shootbackTarget.shootbackAreasUtm.size()=" << shootbackTarget.shootbackAreasUtm.size()
|
||||
<< " size= " << it.value().shootbackAreasUtm.size();
|
||||
printShootbackTarget(shootbackTarget);
|
||||
if (checkPosInShootbackTarget(shootbackTarget, participantPosUtm))
|
||||
{
|
||||
// START TARGET TIMER
|
||||
DEBUG_LOG(m_logger) << "Participant ist in ShootbackArea"
|
||||
<< ", ParticipantId= " << participantId
|
||||
<< ", ShootbackTargetId=" << shootbackTarget.participantId;
|
||||
if (m_targetTimers.contains(participantId))
|
||||
if (m_targetTimers.value(participantId)->getTimerState() != TargetTimer::TimerState::NOT_ACTIVE)
|
||||
return;
|
||||
DEBUG_LOG(m_logger) << "START TIMER PARTICIPANT_ID=" << participantId
|
||||
<< " targetPreWarningInterval=" << targetPreWarningInterval
|
||||
<< " targetTimeToEffectInterval=" << targetTimeToEffectInterval
|
||||
<< " m_targetTimers.insert(" << participantId << ")";
|
||||
TargetTimer *targetTimer = new TargetTimer(participantId,
|
||||
shootbackTarget.participantId,
|
||||
targetPreWarningInterval,
|
||||
targetTimeToEffectInterval);
|
||||
targetTimer->startTimer();
|
||||
m_targetTimers.insert(participantId, targetTimer);
|
||||
QObject::connect(targetTimer, &TargetTimer::preWarningTimeout,
|
||||
this, &HandlerTargetAreas::on_preWarningIntervalFinished);
|
||||
QObject::connect(targetTimer, &TargetTimer::timeToEffectTimeout,
|
||||
this, &HandlerTargetAreas::on_TimeToEffectFinished);
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// STOP TARGET TIMER
|
||||
DEBUG_LOG(m_logger) << "Participant ist nicht in ShootbackArea"
|
||||
<< ", ParticipantId= " << data.participantId()
|
||||
<< ", ShootbackTargetId=" << shootbackTarget.participantId
|
||||
<< ", m_targetTimers.size=" << m_targetTimers.size()
|
||||
<< ", m_targetTimers.contains(participantId)=" << m_targetTimers.contains(participantId);
|
||||
if (!m_targetTimers.contains(participantId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "continue";
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetTimer *targetTimer = m_targetTimers.value(participantId);
|
||||
if (targetTimer->getTargetParticipantId() == shootbackTarget.participantId)
|
||||
{
|
||||
targetTimer->deleteLater();
|
||||
m_targetTimers.remove(participantId);
|
||||
DEBUG_LOG(m_logger) << "STOP TIMER PARTICIPANT_ID=" << participantId
|
||||
<< " m_targetTimers.remove(" << participantId << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::onSendControlDataReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
//if (replyObject.error())
|
||||
// WARNING_LOG(m_logger) << "Can not send hit on participant to training area: " << replyObject();
|
||||
//else
|
||||
DEBUG_LOG(m_logger) << "onSendControlDataReply for id " << replyObject.id() << " success";
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::onSendCesHitInformationReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
//if (replyObject.error())
|
||||
// WARNING_LOG(m_logger) << "Can not send hit on participant to training area: " << replyObject();
|
||||
//else
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitInformationReply for id " << replyObject.id() << " success";
|
||||
}
|
||||
|
||||
|
||||
void HandlerTargetAreas::sendRequestsToTab(int participantId,
|
||||
int targetParticipantId,
|
||||
int countBlink,
|
||||
int effectPercent)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "MainWindow::on_Timer1finished participantId=" << participantId
|
||||
<< " targetParticipantId =" << targetParticipantId;
|
||||
ParticipantManagement::Participant participant = m_participantData.value(participantId);
|
||||
//ShootbackTarget shootbackTarget = m_shootbackTargets.value(participantId);
|
||||
auto ftcTab = m_ddsHandler->ftcTab();
|
||||
|
||||
|
||||
// SEND ControlDataRequest TO TARGET
|
||||
|
||||
int32_t participantIdFt = participantId;
|
||||
int32_t equipmentNumberFt = m_ddsHandler->participantId2EquipNo(participantId);
|
||||
int32_t targetParticipantIdFt = targetParticipantId;
|
||||
int32_t targetEquipmentNumberFt = m_ddsHandler->participantId2EquipNo(targetParticipantId);
|
||||
int32_t chargeTypeIdFt = 1;
|
||||
int32_t directionDegreeFt = 0;
|
||||
int32_t distanceToOrignatorFt = 0;
|
||||
int32_t countBlinkFt = countBlink;
|
||||
int32_t effectPercentFt = effectPercent;
|
||||
rti::core::int64 effectTimeFt = m_ddsHandler->currentPartitionTime();
|
||||
|
||||
TrainingAreaBase::ControlDataCode controlCodeFt = TrainingAreaBase::ControlDataCode_def::Flashing;
|
||||
std::vector< uint8_t > controlDataFt;
|
||||
|
||||
|
||||
controlDataFt.resize(1);
|
||||
controlDataFt[0] = countBlinkFt;
|
||||
|
||||
TrainingAreaBase::SendControlDataRequest sendControlDataRequest(
|
||||
targetEquipmentNumberFt,
|
||||
targetParticipantIdFt,
|
||||
controlCodeFt,
|
||||
controlDataFt
|
||||
);
|
||||
ftcTab->sendControlDataRequest(sendControlDataRequest, this);
|
||||
|
||||
// SEND HitInformation to participant
|
||||
TrainingAreaBase::SendCesHitInformation sendCesHitInformationRequest(
|
||||
equipmentNumberFt,
|
||||
participantIdFt,
|
||||
targetEquipmentNumberFt,
|
||||
targetParticipantIdFt,
|
||||
chargeTypeIdFt,
|
||||
directionDegreeFt,
|
||||
distanceToOrignatorFt,
|
||||
effectPercentFt,
|
||||
effectTimeFt
|
||||
);
|
||||
ftcTab->sendCesHitInformationRequest(sendCesHitInformationRequest, this);
|
||||
|
||||
TrainingAreaBase::SendCesHitRequest hr;
|
||||
hr.aesId(1);
|
||||
|
||||
INFO_LOG(m_logger) << "sendCesHitRequest: " << hr;
|
||||
ftcTab->sendCesHitRequest(hr, this);
|
||||
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::on_preWarningIntervalFinished(int participantId, int targetParticipantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "MainWindow::on_Timer1finished participantId=" << participantId
|
||||
<< " targetParticipantId =" << targetParticipantId;
|
||||
ParticipantManagement::Participant participant = m_participantData.value(participantId);
|
||||
ShootbackTarget shootbackTarget = m_shootbackTargets.value(targetParticipantId);
|
||||
uint8_t countBlink = 1;
|
||||
int32_t effectPercent = 0;
|
||||
|
||||
switch (shootbackTarget.targetInformation.prewarningEffect().underlying())
|
||||
{
|
||||
case ProjectDataManagement::VulnerabilityState_def::NoChange:
|
||||
countBlink = 1;
|
||||
effectPercent = 0;
|
||||
break;
|
||||
case ProjectDataManagement::VulnerabilityState_def::MobilityKill:
|
||||
effectPercent = 30;
|
||||
countBlink = 2;
|
||||
break;
|
||||
case ProjectDataManagement::VulnerabilityState_def::NearMiss:
|
||||
countBlink = 3;
|
||||
effectPercent = 60;
|
||||
break;
|
||||
case ProjectDataManagement::VulnerabilityState_def::CatastrophicKill:
|
||||
countBlink = 4;
|
||||
effectPercent = 100;
|
||||
break;
|
||||
default:
|
||||
effectPercent = 11;
|
||||
countBlink = 0;
|
||||
}
|
||||
|
||||
sendRequestsToTab(participantId,
|
||||
targetParticipantId,
|
||||
countBlink,
|
||||
effectPercent);
|
||||
}
|
||||
|
||||
|
||||
void HandlerTargetAreas::on_TimeToEffectFinished(int participantId, int targetParticipantId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "HandlerTargetAreas::on_TimeToEffectFinished participantId=" << participantId
|
||||
<< " targetParticipantId=" << targetParticipantId;
|
||||
|
||||
DEBUG_LOG(m_logger) << "MainWindow::on_Timer1finished participantId=" << participantId
|
||||
<< " targetParticipantId =" << targetParticipantId;
|
||||
ParticipantManagement::Participant participant = m_participantData.value(participantId);
|
||||
ShootbackTarget shootbackTarget = m_shootbackTargets.value(targetParticipantId);
|
||||
uint8_t countBlink = 1;
|
||||
int32_t effectPercent = 0;
|
||||
|
||||
DEBUG_LOG(m_logger) << " shootbackTarget.participantId=" << shootbackTarget.participantId
|
||||
<< " shootbackTarget.targetInformation.participantId()=" << shootbackTarget.targetInformation.participantId()
|
||||
<< " shootbackTarget.targetInformation.prewarningInterval()=" << shootbackTarget.targetInformation.prewarningInterval()
|
||||
<< " prewarningEffect=" << shootbackTarget.targetInformation.prewarningEffect()
|
||||
<< " takedownEffect=" << shootbackTarget.targetInformation.takedownEffect();
|
||||
|
||||
|
||||
switch (shootbackTarget.targetInformation.takedownEffect().underlying())
|
||||
{
|
||||
case ProjectDataManagement::VulnerabilityState_def::MobilityKill:
|
||||
effectPercent = 50;
|
||||
countBlink = 5;
|
||||
break;
|
||||
case ProjectDataManagement::VulnerabilityState_def::CatastrophicKill:
|
||||
countBlink = 6;
|
||||
effectPercent = 100;
|
||||
break;
|
||||
default:
|
||||
effectPercent = 12;
|
||||
countBlink = 0;
|
||||
}
|
||||
|
||||
sendRequestsToTab(participantId,
|
||||
targetParticipantId,
|
||||
countBlink,
|
||||
effectPercent);
|
||||
}
|
||||
|
||||
void HandlerTargetAreas::onSendCesHitReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "HandlerTargetAreas::onSendCesHitReply";
|
||||
//if (replyObject.error())
|
||||
// WARNING_LOG(m_logger) << "Can not send hit on participant to training area: " << replyObject();
|
||||
//else
|
||||
DEBUG_LOG(m_logger) << "onSendCesHitReply for id " << replyObject.id() << " success";
|
||||
}
|
||||
|
||||
} // namespace TargetAreas
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
//#include <CentralEffectSimulation/dds_handler.h>
|
||||
#include "logger.h"
|
||||
|
||||
#include "targettimer.h"
|
||||
#include "dds_handler.h"
|
||||
#include <CentralEffectSimulation/point_helpers.h>
|
||||
|
||||
|
||||
#include <LtsUtilsCore/outdated_position.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QPointF>
|
||||
#include <QtCore/QLineF>
|
||||
#include <QtCore/QSet>
|
||||
#include <QtGui/QPolygonF>
|
||||
#include <TrainingAreaBase/tab_ftc.h>
|
||||
|
||||
// AES-Handling for participants outside buildings
|
||||
namespace TargetAreas
|
||||
{
|
||||
|
||||
class HandlerTargetAreas : public QObject
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendControlDataReplyHandler
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitInformationReplyHandler
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendCesHitReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
struct ParticipantPosition : public ParticipantManagement::ParticipantPosition
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState vulnerabilityState = ProjectDataManagement::VulnerabilityState_def::CombatReady;
|
||||
Core::GeoPosition lastGeoPosition;
|
||||
bool positionValid = false;
|
||||
|
||||
ParticipantPosition() = default;
|
||||
explicit ParticipantPosition(const ParticipantManagement::ParticipantPosition &p)
|
||||
: ParticipantManagement::ParticipantPosition(p)
|
||||
, lastGeoPosition(p.pos())
|
||||
, positionValid(true)
|
||||
{}
|
||||
};
|
||||
|
||||
struct ShootbackTarget
|
||||
{
|
||||
int participantId;
|
||||
ParticipantManagement::TargetInformation targetInformation;
|
||||
QVector<QPolygonF> shootbackAreasUtm;
|
||||
|
||||
};
|
||||
protected:
|
||||
void onSendControlDataReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onSendCesHitInformationReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onSendCesHitReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
public:
|
||||
explicit HandlerTargetAreas(const std::shared_ptr<DdsHandlerTargetAreas> &ddsHandler,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerTargetAreas();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
|
||||
QHash<int, ParticipantPosition> positions() const { return m_positionsMap; }
|
||||
ParticipantPosition position(int participantId) const { return m_positionsMap.value(participantId); }
|
||||
ParticipantManagement::Participant participant(int participantId) const { return m_participantData.value(participantId); }
|
||||
ParticipantManagement::TypeClass typeClassFromTypeId(int typeId) const { return m_typeMap.value(typeId); }
|
||||
bool isOutdated(const ParticipantPosition &pos) const
|
||||
{
|
||||
return LtsUtils::isPositionTimeOutdated(m_ddsHandler->currentPartitionTime(), pos.sampleTime());
|
||||
}
|
||||
|
||||
int getParticipantId(int equipentNumber);
|
||||
|
||||
|
||||
private slots:
|
||||
/**
|
||||
* Handle the signals from 'ParticipantManagement'
|
||||
*/
|
||||
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
void onTypeChanged(const ParticipantManagement::Type &data, DataModification modType);
|
||||
void onTargetInformationChanged(const ParticipantManagement::TargetInformation &data, DataModification modType);
|
||||
void on_preWarningIntervalFinished(int participantId, int targetParticipantId);
|
||||
void on_TimeToEffectFinished(int participantId, int targetParticipantId);
|
||||
|
||||
private: // methoden
|
||||
void checkShootbackAreaPosition(const ParticipantManagement::ParticipantPosition &data);
|
||||
void printShootbackTarget(const ShootbackTarget &shootbackTarget);
|
||||
void printShootbackAreas();
|
||||
void printQPolygon(const QPolygonF polygon);
|
||||
bool checkPosInShootbackTarget(const ShootbackTarget &shootbackTarget, const QPointF &participantPosUtm);
|
||||
void sendRequestsToTab(int participantId, int targetParticipantId, int countBlink, int effectPercent);
|
||||
|
||||
private: // attributes
|
||||
|
||||
std::shared_ptr<DdsHandlerTargetAreas> m_ddsHandler; ///< Pointer to VOM DDS handler
|
||||
|
||||
QHash<int, ParticipantPosition> m_positionsMap; ///key = participantId < Reference map participant (player) to room id (participantId, roomId) inside Building
|
||||
QHash<int, ParticipantManagement::TypeClass> m_typeMap;
|
||||
QHash<int, ParticipantManagement::Participant> m_participantData; /// key = participantId
|
||||
QHash<int, ShootbackTarget> m_shootbackTargets; ///key = participantId < >
|
||||
QHash<int, TargetTimer *> m_targetTimers; ///key = participantId < >
|
||||
|
||||
|
||||
int m_zone = -1;
|
||||
|
||||
QHash<int, TrainingAreaBase::SendControlDataRequest> m_requestMap; // Key = equipmentNumber
|
||||
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
};
|
||||
} // namespace TargetAreas
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "CES.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TargetAreas
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for CentralEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <CentralEffectSimulation/ces_export.h>
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
CES_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace TargetAreas
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Plugin CES TargetAreas
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
#include "plugin.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
|
||||
|
||||
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> TargetAreasPlugin::createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> dDSConnector,
|
||||
NGL::Settings *settings)
|
||||
{
|
||||
return std::make_shared<TargetAreasInterfaceImpl>(pdp, dDSConnector, settings);
|
||||
}
|
||||
|
||||
|
||||
TargetAreasInterfaceImpl::TargetAreasInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> dDSConnector,
|
||||
NGL::Settings *settings)
|
||||
: m_pdp(pdp)
|
||||
, m_ddsConnector(dDSConnector)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("CES.Plugin.TargetAreasInterfaceImpl"))
|
||||
{
|
||||
Q_UNUSED(settings)
|
||||
}
|
||||
|
||||
TargetAreasInterfaceImpl::~TargetAreasInterfaceImpl()
|
||||
{
|
||||
//cleanupProcess();
|
||||
}
|
||||
|
||||
|
||||
bool TargetAreasInterfaceImpl::init(int domain_id, int exerciseId)
|
||||
{
|
||||
m_domainId = domain_id;
|
||||
m_exerciseId = exerciseId;
|
||||
INFO_LOG(m_logger) << "TargetAreasInterfaceImpl::init()"
|
||||
<< " m_domainId=" << m_domainId
|
||||
<< " m_exerciseId=" << m_exerciseId;
|
||||
|
||||
// // initialize DDS
|
||||
m_ddsHandlerTargetAreas = std::make_shared<DdsHandlerTargetAreas>(m_domainId, m_exerciseId);
|
||||
if (!m_ddsHandlerTargetAreas->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation DdsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_handlerTargetAreas.reset(new HandlerTargetAreas(m_ddsHandlerTargetAreas, this));
|
||||
|
||||
if (!m_handlerTargetAreas->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerTargetAreas failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "TargetAreasInterfaceImpl::init() return true";
|
||||
return true;
|
||||
}
|
||||
|
||||
QString TargetAreasInterfaceImpl::echo(const QString &message)
|
||||
{
|
||||
|
||||
QString ret(QStringLiteral("<<<< %1 >>>> TargetAreasInterfaceImpl::echo").arg(message));
|
||||
INFO_LOG(m_logger) << "TargetAreasInterfaceImpl::echo return:" << ret;
|
||||
DEBUG_LOG(m_logger) << "DEBUG: TargetAreasInterfaceImpl::echo return:" << ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
} //namespace TargetAreas
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Plugin CES TargetAreas
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <CentralEffectSimulation/ces_plugin_interface.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "handler_target_areas.h"
|
||||
|
||||
namespace TargetAreas
|
||||
{
|
||||
class TargetAreasPlugin : public QObject, public CentralEffectSimulation::Plugin::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "special:3:ces.TargetAreasPlugin")
|
||||
Q_INTERFACES(CentralEffectSimulation::Plugin::Plugin)
|
||||
|
||||
public:
|
||||
TargetAreasPlugin() = default;
|
||||
~TargetAreasPlugin() = default;
|
||||
std::shared_ptr<CentralEffectSimulation::Plugin::Interface> createInterface(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> dDSConnector,
|
||||
NGL::Settings *settings) override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
class TargetAreasInterfaceImpl final : public CentralEffectSimulation::Plugin::Interface
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TargetAreasInterfaceImpl(CentralEffectSimulation::Plugin::DataProvider *pdp,
|
||||
const std::shared_ptr<DDSConnector::DdsConnector> dDSConnector,
|
||||
NGL::Settings *settings);
|
||||
~TargetAreasInterfaceImpl();
|
||||
//bool init();
|
||||
const char *name() const override { return "TargetAreas"; }
|
||||
QString echo(const QString &message);
|
||||
|
||||
private Q_SLOTS:
|
||||
bool init(int domain_id, int exerciseId) override;
|
||||
private:
|
||||
|
||||
private:
|
||||
CentralEffectSimulation::Plugin::DataProvider *m_pdp;
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<HandlerTargetAreas> m_handlerTargetAreas;
|
||||
std::shared_ptr<DdsHandlerTargetAreas> m_ddsHandlerTargetAreas;
|
||||
NGL::INGLLogger &m_logger;
|
||||
int m_domainId;
|
||||
int m_exerciseId;
|
||||
};
|
||||
|
||||
} // namespace TargetAreas
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* CES Target Timer
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
|
||||
#include "targettimer.h"
|
||||
#include <QDebug>
|
||||
|
||||
TargetTimer::TargetTimer(int participantId,
|
||||
int targetParticipantId,
|
||||
int preWarningInterval,
|
||||
int timeToEffectInterval)
|
||||
{
|
||||
m_participantId = participantId;
|
||||
m_targetParticipantId = targetParticipantId;
|
||||
m_preWarningInterval = preWarningInterval;
|
||||
m_timeToEffectInterval = timeToEffectInterval;
|
||||
timer = new QTimer(this);
|
||||
connect(timer, SIGNAL(timeout()),
|
||||
this, SLOT(MyTimerSlot()));
|
||||
|
||||
// msec
|
||||
}
|
||||
void TargetTimer::startTimer()
|
||||
{
|
||||
|
||||
qDebug() << "TargetTimer::startTimer";
|
||||
if (timer->isActive())
|
||||
return;
|
||||
if (m_timerState == NOT_ACTIVE)
|
||||
{
|
||||
timer->setSingleShot(true);
|
||||
timer->start(m_preWarningInterval);
|
||||
m_timerState = TIMER1_ACTIVE;
|
||||
}
|
||||
}
|
||||
void TargetTimer::stopTimer()
|
||||
{
|
||||
qDebug() << "TargetTimer::stopTimer";
|
||||
timer->stop();
|
||||
}
|
||||
|
||||
void TargetTimer::MyTimerSlot()
|
||||
{
|
||||
qDebug() << "TimerSlot m_participantId=" << m_participantId;
|
||||
if (m_timerState == TIMER1_ACTIVE)
|
||||
{
|
||||
qDebug() << "m_timerState == TIMER1_ACTIVE";
|
||||
emit preWarningTimeout(m_participantId, m_targetParticipantId);
|
||||
timer->setSingleShot(true);
|
||||
timer->start(m_timeToEffectInterval - m_preWarningInterval);
|
||||
m_timerState = TIMER2_ACTIVE;
|
||||
}
|
||||
else if (m_timerState == TIMER2_ACTIVE)
|
||||
{
|
||||
qDebug() << "m_timerState == TIMER2_ACTIVE";
|
||||
emit timeToEffectTimeout(m_participantId, m_targetParticipantId);
|
||||
m_timerState = BOTH_EXPIRED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* CES Tartet Timer
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Gerlinde Rudolphus, SLTE, 2016-04-14
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TARGETTIMER_H
|
||||
#define TARGETTIMER_H
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
class TargetTimer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum TimerState
|
||||
{
|
||||
NOT_ACTIVE = 0,
|
||||
TIMER1_ACTIVE = 1,
|
||||
TIMER2_ACTIVE = 2,
|
||||
BOTH_EXPIRED = 3
|
||||
};
|
||||
|
||||
TargetTimer(int participantId,
|
||||
int targetParticipantId,
|
||||
int preWarningInterval,
|
||||
int timeToEffectInterval);
|
||||
|
||||
void startTimer();
|
||||
void stopTimer();
|
||||
bool isActive() { return timer->isActive();}
|
||||
TimerState getTimerState() {return m_timerState;}
|
||||
int getTargetParticipantId() {return m_targetParticipantId;}
|
||||
public slots:
|
||||
void MyTimerSlot();
|
||||
|
||||
signals:
|
||||
void preWarningTimeout(int participantId, int targetParticipantId);
|
||||
void timeToEffectTimeout(int participantId, int targetParticipantId);
|
||||
private:
|
||||
QTimer *timer;
|
||||
int m_participantId = 0;
|
||||
int m_targetParticipantId = 0;
|
||||
int m_preWarningInterval = 0;
|
||||
int m_timeToEffectInterval = 0;
|
||||
TimerState m_timerState = NOT_ACTIVE; // 0 = NOT ACTIVE
|
||||
// 1 = Timer 1 is actice
|
||||
// 2 = Timer 2 is active
|
||||
// 3 = both timers have expired
|
||||
};
|
||||
|
||||
#endif // TARGETTIMER_H
|
||||
Reference in new issue
Block a user