Files
qt-migration-legatus/qt5-before/dlbo/Lts/Proxies/TrainingAreaBaseOC/canag_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

221 lines
5.1 KiB
C++

/**
* Canag Handler for de/encoding LtsUtils::SfmMessage
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 2018-01-29
*/
#pragma once
#include <memory>
#include <QObject>
#include <QByteArray>
#include <QList>
#include <QMap>
#include <QPair>
#include <QTimer>
#include <QTcpSocket>
#include <LtsUtilsCore/sfm_bytemessage_converter.h>
#include "handler_aes_data.h"
#include "send_to_tab.h"
#include "logger.h"
namespace TrainingAreaBaseOC
{
class ConnectionHandler;
class MainHandler;
class RecvFromTab;
enum class DdlState
{
NotStarted = 0,
Initiated = 1,
Downloading = 2
};
class TxDdlHandler : public QObject
{
Q_OBJECT
public:
TxDdlHandler();
void addData(const QByteArray &data);
signals:
void send(const QByteArray &data);
public slots:
void process(const QByteArray &data);
private slots:
void startNextDomainDownload();
void sendAbortOrRestartTimeout();
private:
const qint32 s_maxResendCnt = 5;
struct DdlData
{
QByteArray data = QByteArray();
qint32 offset = 0;
};
void initiateDomainDownload();
void domainDownload();
void sendAbort(quint8 error = 0);
DdlState m_state;
qint32 m_segmentToggle;
qint32 m_sentCnt;
QTimer *m_responseTimer;
QList<DdlData> m_dataToSend;
LOGGER_T m_logger;
};
class RxDdlHandler : public QObject
{
Q_OBJECT
public:
explicit RxDdlHandler(bool isMultiplexed = false);
void process(const QByteArray &data);
signals:
void send(const QByteArray &data);
void received(const QByteArray &data);
void receivedMultiplexed(const QByteArray &data, quint32 multiplexer);
private:
void sendDPConfirmation(const quint32 ccs, const quint32 toggle, const quint32 wirkfeldMultiplex = 0);
bool m_isMultiplexed = false;
DdlState m_state = DdlState::NotStarted;
quint32 m_multiplexer = 0;
QByteArray m_messageData;
LOGGER_T m_logger;
};
class CanagHandler : public QObject
, public SendToTab
{
Q_OBJECT
public:
explicit CanagHandler(MainHandler *mainHandler);
~CanagHandler();
bool init();
bool txData(const OcTelegrams::DemandCyclicPositions &data) override;
bool txData(const OcTelegrams::TechnicalStateOc &data) override;
bool txData(const OcTelegrams::DemandSelftestSfm &data) override;
bool txData(const TrainingAreaBase::TetraIcd::OpaquePayloadDataBase &data) override;
signals:
void sendMessage(const LtsUtils::SfmMessage &);
public slots:
void handleSfmTelegram(const LtsUtils::SfmMessage &message);
private slots:
void sendDemandDeviceId();
void sendDeviceMessage();
void sendOcExcon(const QByteArray &data);
void sendFireSmokeMarkerExcon(const QByteArray &data);
void sendExconOc(const QByteArray &data);
void sendExconFireSmokeMarker(const QByteArray &data);
void sendSfmAwes(const QByteArray &data);
void sendConnectionTestSfm();
void receivedExconOc(const QByteArray &data);
void receivedExconFireSmokeMarker(const QByteArray &data);
void receivedSfmAwes(const QByteArray &data, quint32 multiplexer);
void sfmAliveTimeout();
void sendFreeText();
void sendSyncTime(uint32_t syncTimeSec);
private:
void send(const LtsUtils::SfmMessage &message);
void send(quint32 canId, const QByteArray &data);
void openSocket();
void readSettings();
void fillMessageMap();
void demandInitialSfmData();
void sendDemandTechnicalStateSfm();
void sendDemandSpecificsEquipment();
void sendDemandSpecificsExercise();
void handleDisplayMessage(const LtsUtils::SfmMessage &message);
enum CanId
{
DemandDeviceId = 1,
DeviceId = 2,
Time = 7,
EnterLeaveAes = 80,
ParameterSfmTx = 243,
ParameterSfmRx = 244,
ParameterOcRx = 263,
ParameterOcTx = 264,
TechnicalStateSfm = 452,
TechnicalStateOc = 466,
FireSmokeMarkerExconDataRx = 510,
FireSmokeMarkerExconDataTx = 511,
ExconFireSmokeMarkerDataRx = 512,
ExconFireSmokeMarkerDataTx = 513,
ExconOcDataRx = 520,
ExconOcDataTx = 521,
OcExconDataRx = 522,
OcExconDataTx = 523,
DemandAwesData = 530,
AwesDataRx = 531,
AwesDataTx = 532,
Position = 540,
DemandCyclicPosition = 545,
DisplayMessage = 684,
SpecificsExercise = 732,
SpecificsOc = 738,
SpecificsEquipment = 742,
EquipmentId = 765,
ConnectionTestSfm = 1101,
ConnectionTestSfmReply = 1102,
WakeUp = 1760,
WakeUpSfm = 1773
};
MainHandler *m_mainHandler;
std::shared_ptr<ConnectionHandler> m_connectionHandler;
std::shared_ptr<HandlerAesData> m_handlerAesData;
std::shared_ptr<RecvFromTab> m_rxHandler;
QByteArray m_freeText;
QTimer *m_deviceMessageTimer;
QTimer *m_freeTextCollectionTimer;
QTimer *m_sfmAliveTimer;
QTimer *m_sfmConnectionCheckTimer;
QTcpSocket *m_syncSocket;
OcTelegrams::TechnicalStateSfm m_technicalStateSfm; // not just the telegram technicalState of the sfm but also total sfm connection check
bool m_sfmConnectionEstablished;
QMap<CanId, LtsUtils::SfmMessage *> m_messages;
QMap<CanId, TxDdlHandler *> m_txDdlHandler;
QMap<CanId, RxDdlHandler *> m_rxDdlHandler;
LOGGER_T m_logger;
};
} // namespace TrainingAreaBaseOC