- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung - 44 Export-Header Include-Pfade korrigiert (_export.h) - 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h) - INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros - Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits) - FATAL_LOG Makro hinzugefügt - InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h) - FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h) - AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp) - SymbolAppearance Klasse vollständig definiert mit content() Methode - BuildingComponentFilter Klasse definiert mit Copy-Konstruktor - Ftc Factory: nullptr Return (abstract class) - AesFilter Klasse in aes.hpp hinzugefügt - Dtc Klasse in ppm.hpp mit participantChanged Signal - AesType Enum: alle 15 At* Werte definiert - AesEffectState_def: EsReceived hinzugefügt - DataModification Enum: eAdded/eModified/eRemoved - function_reply_object.h → core_types.h Include-Pfad (72 Dateien) - Enum-Class-Streaming Template-Operator in INGLLogger.h - ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen - ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge - QRegExp → QRegularExpression in tpm_js_parser.cpp - .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert - Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
140 lines
5.2 KiB
C++
Executable File
140 lines
5.2 KiB
C++
Executable File
/**
|
|
* Handler for player data
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by hjl, SLSE, 2017-02-20
|
|
*/
|
|
|
|
#include "settings.h"
|
|
#include "handler_target_config.h"
|
|
#include <LtsUtilsCore/qbytearray_byteaccess.h>
|
|
|
|
using namespace TargetManagement;
|
|
|
|
HandlerTargetConfig::HandlerTargetConfig(const std::shared_ptr<DdsHandler> &ddsHandler,
|
|
QObject *parent)
|
|
: QObject(parent)
|
|
, ConfigureTargetRequestHandler(ddsHandler->ftsTgt())
|
|
, m_ddsHandler(ddsHandler)
|
|
, m_dtcTab(ddsHandler->dtcTab())
|
|
, m_dtsTgt(ddsHandler->dtsTgt())
|
|
{
|
|
} // end of ctor()
|
|
//-----------------------------------------------------------------------------
|
|
|
|
bool HandlerTargetConfig::init()
|
|
{
|
|
INFO_LOG() << "init";
|
|
connect(m_dtcTab.get(), &TrainingAreaBase::Interface::Dtc::targetDataChanged,
|
|
this, &HandlerTargetConfig::onTargetDataChanged);
|
|
|
|
return true;
|
|
} // end of init()
|
|
|
|
//-----------------------------------------------------------------------------
|
|
void HandlerTargetConfig::onTargetDataChanged(const TrainingAreaBase::TargetData &targetData, DataModification modType)
|
|
{
|
|
if (modType == DataModification::eRemoved)
|
|
return;
|
|
|
|
uint8_t responseCmd = 100;
|
|
TargetManagement::TargetConfig tgtTargetData;
|
|
INFO_LOG() << "onTargetDataChanged payload.size=" << targetData.payload().size();
|
|
tgtTargetData.participantId(m_ddsHandler->equipNo2participantId(targetData.equipmentNumber()));
|
|
for (size_t i = 0; i < targetData.payload().size(); i++)
|
|
INFO_LOG() << "payload[" << i << "]=" << targetData.payload()[i];
|
|
|
|
if (targetData.payload().size() < 6)
|
|
return;
|
|
tgtTargetData.id(0);
|
|
tgtTargetData.tgtCommand(static_cast <TargetManagement::TgtCommand_def::type>(targetData.payload()[0] - responseCmd));
|
|
tgtTargetData.mode(static_cast <TargetManagement::Mode_def::type>(targetData.payload()[1]));
|
|
tgtTargetData.weapon(targetData.payload()[2]);
|
|
INFO_LOG() << "tgtTargetData.tgtCommand =" << tgtTargetData.tgtCommand()
|
|
<< " mode=" << tgtTargetData.mode()
|
|
<< " weapon=" << tgtTargetData.weapon();
|
|
if (!m_dtsTgt->publish(tgtTargetData))
|
|
ERROR_LOG() << "Error publish targetData";
|
|
} // end of onTargetDataChanged
|
|
|
|
void HandlerTargetConfig::onSendTargetDataReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (replyObject.error())
|
|
WARNING_LOG() << "Can not send target data to target participant : " << replyObject();
|
|
else
|
|
DEBUG_LOG() << "onSendTargetDataReply for id " << replyObject.id() << " success";
|
|
}
|
|
|
|
// Send to TAB
|
|
void HandlerTargetConfig::onConfigureTargetRequest(const rti::core::SampleIdentity &cookie,
|
|
const ConfigureTargetRequest &request)
|
|
{
|
|
INFO_LOG() << "onConfigureTargetRequest";
|
|
Core::FunctionReplyObject reply = Core::FunctionReplyObject(request.id());
|
|
|
|
DEBUG_LOG() << "HandlerTargetConfig onTargetConfigChanged participantId=" << request.participantId();
|
|
|
|
TrainingAreaBase::SendTargetDataRequest tgt;
|
|
const int participantId = request.participantId();
|
|
tgt.equipmentNumber(m_ddsHandler->participantId2EquipNo(participantId));
|
|
tgt.participantId(request.participantId());
|
|
|
|
tgt.payload().push_back(request.tgtCommand().underlying());
|
|
|
|
switch (request.tgtCommand().underlying())
|
|
{
|
|
case TargetManagement::TgtCommand_def::Unknown:
|
|
case TargetManagement::TgtCommand_def::PlaySound:
|
|
{
|
|
WARNING_LOG() << "onTargetConfigChanged Command =" << request.tgtCommand() << " not handled.";
|
|
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, reply);
|
|
return;
|
|
}
|
|
case TargetManagement::TgtCommand_def::RequestTechnicalState:
|
|
case TargetManagement::TgtCommand_def::RequestParameter:
|
|
{
|
|
// No specific data to add to payload
|
|
break;
|
|
}
|
|
case TargetManagement::TgtCommand_def::SetMode:
|
|
{
|
|
if (!request.mode().is_set())
|
|
{
|
|
ERROR_LOG() << "Set mode requested, but mode ist not set";
|
|
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, Core::FunctionReplyObject(request.participantId(), tr_lts("dds", "Set mode requested, but mode is not set")));
|
|
return;
|
|
}
|
|
tgt.payload().push_back(request.mode().get().underlying());
|
|
break;
|
|
}
|
|
case TargetManagement::TgtCommand_def::SetWeapon:
|
|
{
|
|
if (!request.weapon().is_set())
|
|
{
|
|
ERROR_LOG() << "Set weapon requested, but weapon ist not set";
|
|
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, Core::FunctionReplyObject(request.participantId(), tr_lts("dds", "Set weapon requested, but weapon is not set")));
|
|
return;
|
|
}
|
|
tgt.payload().push_back(request.weapon().get());
|
|
break;
|
|
}
|
|
case TargetManagement::TgtCommand_def::SetParameter:
|
|
{
|
|
if (!request.parameterSet().is_set())
|
|
{
|
|
ERROR_LOG() << "Set parameterset requested, but parameterset ist not set";
|
|
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, Core::FunctionReplyObject(request.participantId(), tr_lts("dds", "Set parameterset requested, but parameterset is not set")));
|
|
return;
|
|
}
|
|
tgt.payload().push_back(request.parameterSet().get());
|
|
break;
|
|
}
|
|
}
|
|
m_ddsHandler->ftcTab()->sendTargetDataRequest(tgt, this);
|
|
// Todo: Wait for Reply and forward?
|
|
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, reply);
|
|
} // end of onConfigureTargetRequest
|
|
|
|
|