Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/GuezIedManagement/object_ied.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

251 lines
7.5 KiB
C++

/**
* Handler for the HMI language
* $Id$
* $HeadURL$
* $Author$
* created by Philipp Dassow 2017-07-20
*/
#include "object_ied.h"
#include <gim.hpp>
#include "dds_handler.h"
#include "logger.h"
namespace GuezIedManagement
{
ObjectIed::ObjectIed(const std::shared_ptr<DdsHandler> &ddsHandler,
const std::shared_ptr<DatabaseInterface> &db,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
QObject *parent)
: QObject(parent)
, m_ddsHandler(ddsHandler)
, m_db(db)
, m_ppmDtc(ppmDtc)
, m_logger(getLogger("ObjectIed"))
{
}
ObjectIed::~ObjectIed()
{
m_ddsHandler->dts()->removeIedByKey(m_data.id);
}
Core::FunctionReplyObject ObjectIed::createObject(const Database::GimIed &data)
{
m_data = data;
if (m_data.id <= 0)
{
if(!m_db->insert(m_data))
{
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IED-data into database"));
}
// Id is serial -> will be generated by db => inside m_data after db-insert
DEBUG_LOG(m_logger) << "New IED-Id: " << m_data.id;
}
INFO_LOG(m_logger) << "Ied created sucessfully.";
// Publish Data via DTS
onPublishData();
return Core::FunctionReplyObject(m_data.id);
}
Core::FunctionReplyObject ObjectIed::updateDefinition(const Database::GimIed &data)
{
assignBaseData(data);
m_data.typeId = data.typeId;
m_data.remoteTrigger = data.remoteTrigger;
m_data.tautWireTrigger = data.tautWireTrigger;
m_data.lightBarrierTrigger = data.lightBarrierTrigger;
m_data.switchTrigger = data.switchTrigger;
m_data.explosiveForce = data.explosiveForce;
m_data.symbol = data.symbol;
assignPairingState(data);
return updateObject();
}
Core::FunctionReplyObject ObjectIed::updateState(const Database::GimIed &data)
{
assignBaseData(data);
m_data.batterywarnings = data.batterywarnings;
m_data.electronicsErrorStateId = data.electronicsErrorStateId;
m_data.pyrotechnics1ErrorStateId = data.pyrotechnics1ErrorStateId;
m_data.pyrotechnics2ErrorStateId = data.pyrotechnics2ErrorStateId;
m_data.pyrotechnics3ErrorStateId = data.pyrotechnics3ErrorStateId;
return updateObject();
}
Core::FunctionReplyObject ObjectIed::updatePairingState(const Database::GimIed &data)
{
assignPairingState(data);
return updateObject();
}
Core::FunctionReplyObject ObjectIed::removeObject()
{
if (!m_db->removeGimIed(m_data.id))
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "IED with id %1 can not be removed from DB")).arg(m_data.id);
if (!m_ddsHandler->dts()->removeIedByKey(m_data.id))
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "IED with id %1 can not be removed from DDS")).arg(m_data.id);
return Core::FunctionReplyObject(m_data.id);
}
void ObjectIed::setPosition(int64_t sampleTime, const Core::GeoPosition &pos)
{
setPosition(IedPosition(m_data.id,
"IedPosition",
false,
true,
sampleTime,
pos));
}
void ObjectIed::setPosition(const IedPosition &position)
{
m_position = position;
publishPosition();
}
void ObjectIed::onPublishData()
{
GuezIedManagement::Ied ddsData;
ddsData.id(m_data.id);
ddsData.equipmentNumber(m_data.equipmentNumber);
ddsData.type(IedType(m_data.typeId));
ddsData.remoteTrigger(m_data.remoteTrigger);
ddsData.switchTrigger(m_data.switchTrigger);
ddsData.lightBarrierTrigger(m_data.lightBarrierTrigger);
ddsData.tautWireTrigger(m_data.tautWireTrigger);
ddsData.explosiveForce(m_data.explosiveForce);
ddsData.partyId(m_data.partyId);
ddsData.pairingState(IedPairingState(m_data.pairingStateId));
switch(ddsData.pairingState().underlying())
{
case IedPairingState_def::PairedToParticipant:
{
ddsData.pairedParticipantId().set(m_data.pairedParticipantId.toInt());
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &ObjectIed::onParticipantPositionChanged, Qt::UniqueConnection);
break;
}
case IedPairingState_def::PairedToOps:
{
ddsData.pairedOpsId().set(m_data.pairedOpsId.toInt());
//todo: connect to ISM for OPS-Position
disconnect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &ObjectIed::onParticipantPositionChanged);
break;
}
case IedPairingState_def::NotPaired:
{
disconnect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &ObjectIed::onParticipantPositionChanged);
//todo: disconnect from ISM for OPS-Position
break;
}
}
ddsData.tacticalState(IedTacticalState(m_data.tacticalStateId));
ddsData.pyrotechnics(m_data.pyrotechnics);
ddsData.batteryWarnings(m_data.batterywarnings);
ddsData.electronicsError(IedError(m_data.electronicsErrorStateId));
ddsData.pyrotechnics1Error(IedError(m_data.pyrotechnics1ErrorStateId));
ddsData.pyrotechnics2Error(IedError(m_data.pyrotechnics2ErrorStateId));
ddsData.pyrotechnics3Error(IedError(m_data.pyrotechnics3ErrorStateId));
ddsData.symbol(m_data.symbol.toStdString());
ddsData.sampleTime(m_data.sampleTime);
INFO_LOG(m_logger) << "Publish IED-data to dds (" << m_data.id << ") ...";
if (!m_ddsHandler->dts()->publish(ddsData))
ERROR_LOG(m_logger) << "Error publishing IED-data to dds";
}
void ObjectIed::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
{
if (modType != DataModification::eAdded && modType != DataModification::eModified)
return;
if (data.participantId() == m_data.pairedParticipantId.toInt())
setPosition(data.sampleTime(), data.pos());
}
void ObjectIed::assignBaseData(const Database::GimIed &data)
{
m_data.equipmentNumber = data.equipmentNumber;
m_data.tacticalStateId = data.tacticalStateId;
m_data.pyrotechnics = data.pyrotechnics;
m_data.sampleTime = data.sampleTime;
}
void ObjectIed::assignPairingState(const Database::GimIed &data)
{
m_data.pairedParticipantId = data.pairedParticipantId;
m_data.pairedOpsId = data.pairedOpsId;
m_data.partyId = data.partyId;
switch(data.pairingStateId.underlying())
{
case IedPairingState_def::PairedToParticipant:
{
ParticipantManagement::ParticipantPosition position = m_ppmDtc->participantPosition(m_data.pairedParticipantId.toInt());
setPosition(position.sampleTime(), position.pos());
break;
}
case IedPairingState_def::PairedToOps:
{
// todo get Ops-Position
break;
}
case IedPairingState_def::NotPaired:
{
break;
}
}
m_data.pairingStateId = data.pairingStateId;
}
Core::FunctionReplyObject ObjectIed::updateObject()
{
if (!isValid())
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed IED object"));
INFO_LOG(m_logger) << "Trying to updateObject IedData with id = " << m_data.id;
if (!m_db->update(m_data))
{
ERROR_LOG(m_logger) << "Failed to update IedData with id = " << m_data.id;
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Error updating IED-data with id %1 in database")).arg(m_data.id);
}
INFO_LOG(m_logger) << "IED-Data changed sucessfully.";
// Publish Data via DTS
onPublishData();
return Core::FunctionReplyObject(m_data.id);
}
void ObjectIed::publishPosition()
{
if (!m_ddsHandler->dts()->publish(m_position))
ERROR_LOG(m_logger) << "Error publishing IED-position to dds";
}
bool ObjectIed::isValid() const
{
return m_data.id > 0;
}
} // Namespace GuezIedManagement