Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/TargetManagement/handler_target_config.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

141 lines
5.3 KiB
C++

/**
* 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())
, m_logger(getLogger("HandlerTargetConfig"))
{
} // end of ctor()
//-----------------------------------------------------------------------------
bool HandlerTargetConfig::init()
{
INFO_LOG(m_logger) << "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(m_logger) << "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(m_logger) << "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(m_logger) << "tgtTargetData.tgtCommand =" << tgtTargetData.tgtCommand()
<< " mode=" << tgtTargetData.mode()
<< " weapon=" << tgtTargetData.weapon();
if (!m_dtsTgt->publish(tgtTargetData))
ERROR_LOG(m_logger) << "Error publish targetData";
} // end of onTargetDataChanged
void HandlerTargetConfig::onSendTargetDataReply(const Core::FunctionReplyObject &replyObject)
{
if (replyObject.error())
WARNING_LOG(m_logger) << "Can not send target data to target participant : " << replyObject();
else
DEBUG_LOG(m_logger) << "onSendTargetDataReply for id " << replyObject.id() << " success";
}
// Send to TAB
void HandlerTargetConfig::onConfigureTargetRequest(const rti::core::SampleIdentity &cookie,
const ConfigureTargetRequest &request)
{
INFO_LOG(m_logger) << "onConfigureTargetRequest";
Core::FunctionReplyObject reply = Core::FunctionReplyObject(request.id());
DEBUG_LOG(m_logger) << "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(m_logger) << "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(m_logger) << "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(m_logger) << "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(m_logger) << "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