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