Files
qt-migration-legatus/qt5-before/dlbo/Lts/Proxies/Buildings/ism_handler.h
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

205 lines
5.9 KiB
C++

/**
* Retrieve data from InfrastructeManagement
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Ehrlicher, SLSE, 2016-04-14
*/
#pragma once
#include <QObject>
#include <QMap>
#include <QSet>
#include <QHash>
#include <QVector>
#include <InfrastructureManagement/ism.hpp>
#include <InfrastructureManagement/ism_dtc.h>
#include <InfrastructureManagement/ism_ftc.h>
#include <LtsUtilsCore/data_modification_enum.h>
#include <LtsUtilsCore/qpoint3d.h>
#include "logger.h"
class QTimer;
namespace Buildings
{
class MainHandler;
struct BsmInfo
{
int assetId = 0; // unique id from asset (database)
int bsmId = 0; // unique (per building) id from xml
Core::RelativePosition relPosition;
Core::Orientation orientation;
QString hostname;
unsigned short port = 0;
bool operator ==(const BsmInfo &o) const
{
return assetId == o.assetId &&
bsmId == o.bsmId &&
port == o.port &&
hostname == o.hostname &&
relPosition == o.relPosition &&
orientation == o.orientation;
}
};
enum EffectType
{
FOG = 0,
FIRE_LAMP = 1,
SIGNAL_LAMP = 2
};
//struct Effect
//{
// QString effectType;
// int id = 0; // No of relay
// int damage = 0; // damage in percent
// int repeat = 0; // number of repetitions
// int pulse = 0; // pulse duration [ms]
// int delay = 0; // delay duration [ms]
// bool operator==(const Effect &o) const
// {
// return effectType == o.effectType &&
// id == o.id &&
// damage == o.damage &&
// repeat == o.repeat &&
// pulse == o.pulse &&
// delay == o.delay;
// }
//};
struct EgcuInfo
{
QString buildingName;
QString mountPointName;
int mountPointId = 0;
QString assetName;
int assetId = 0;
QString hostname;
QSet<int> roomIds;
bool operator ==(const EgcuInfo &o) const
{
return (buildingName == o.buildingName &&
mountPointName == o.mountPointName &&
mountPointId == o.mountPointId &&
hostname == o.hostname &&
roomIds == o.roomIds);
}
};
struct RoomInfo
{
QString roomStr;
int roomId = 0;
};
struct Egcu
{
QString mountpointEgcu;
int mountpointId = 0;
int assetId = 0;
QVector<RoomInfo> rooms;
};
struct BuildingInfo
{
int mseId = 0;
int modelId = 0;
int externalWlsId = 0;
int currentExerciseId = -1;
int structureElementId = 0;
int assetId = 0;
QString name;
Core::GeoPosition absPosition; // lonLatZ
double angle = 0;
// QMap<assetId, BsmInfo>
QMap<int, BsmInfo> bsms;
QVector<EgcuInfo> egcus;
QMap<int, int> subId2RoomId;
QMap<int, int> roomId2SubId;
QMap<QString, int> roomName2RoomId;
bool operator ==(const BuildingInfo &o) const
{
return mseId == o.mseId &&
modelId == o.modelId &&
externalWlsId == o.externalWlsId &&
currentExerciseId == o.currentExerciseId &&
structureElementId == o.structureElementId &&
assetId == o.assetId &&
name == o.name &&
absPosition == o.absPosition &&
qFuzzyCompare(angle, o.angle) &&
bsms == o.bsms &&
egcus == o.egcus &&
subId2RoomId == o.subId2RoomId &&
roomId2SubId == o.roomId2SubId &&
roomName2RoomId == o.roomName2RoomId;
}
bool operator !=(const BuildingInfo &o) const
{
return !operator==(o);
}
};
class IsmHandler : public QObject
{
Q_OBJECT
public:
explicit IsmHandler(MainHandler *mainHandler);
~IsmHandler();
bool init();
InfrastructureManagement::MainStructureElement mainStructureElement(int id) const;
bool isElementAssignedToExercise(const int mseId, int exerciseId);
std::shared_ptr<InfrastructureManagement::Interface::Ftc> ftcIsm() const { return m_ftcIsm;}
Q_SIGNALS:
void buildingRemoved(int buildingId);
void buildingChanged(const BuildingInfo &buildingInfo, bool percentDamageInit = false);
void setEffectStates(const int buildingId, const int assetId, QByteArray &properties);
private Q_SLOTS:
void onInstrumentationAssetChanged(const InfrastructureManagement::InstrumentationAsset &data, DataModification modType = DataModification::eAdded);
void onMountingPointAssetChanged(const InfrastructureManagement::MountingPointAsset &data, DataModification modType = DataModification::eAdded);
void onMainStructureElementChanged(const InfrastructureManagement::MainStructureElement &data, DataModification modType = DataModification::eAdded);
void onBridgeStatusChanged(const InfrastructureManagement::BridgeChangeStatus &data, DataModification modType = DataModification::eAdded);
void onBuildingsChanged();
void onBuildingsChangedInit();
private:
void handleBuildingSensorModule(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
void handleBuildingControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
void handleEffectGenerationControlUnit(const InfrastructureManagement::StructureElement &se, BuildingInfo &bi) const;
static unsigned short getBsmPortFromJSon(const std::string &s);
void getEgcuToRoom(const InfrastructureManagement::MainStructureElement &mse, QVector<EgcuInfo> &eis);
void buildingsChanged(bool init);
void checkOverride(const InfrastructureManagement::MainStructureElement &mseOld,
const InfrastructureManagement::MainStructureElement &mseNew);
MainHandler *m_mainHandler;
QMap<int, InfrastructureManagement::MainStructureElement> m_mainStructureElements;
QMap<int, InfrastructureManagement::InstrumentationAsset> m_instAssets;
QMap<int, int> m_assetMainStructureElementInExercise;
QMap<int, int> m_structureElementId2AssetId;
std::shared_ptr<InfrastructureManagement::Interface::Dtc> m_dtcIsm;
std::shared_ptr<InfrastructureManagement::Interface::Ftc> m_ftcIsm;
QMap<int, BuildingInfo> m_currentBuildingConfiguration;
QMap<int, QString> m_roomId2RoomName;
QTimer *m_changeTimeoutTimer;
QTimer *m_changeTimeoutTimerInit;
LOGGER_T m_logger;
};
} // namespace Buildings