Files
qt-migration-legatus/qt5-before/dlbo/TetraIF/PrtCnv/PrtCnvInjectionSocket.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

128 lines
4.5 KiB
C++

// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "PrtCnvInjectionSocket.hpp"
#include <CoPrtCnv/CoPrtCnvInjectionHeader.hpp>
#include <CoPrtCnv/CoPrtCnvCentralTelegram.hpp>
#include "PrtCnvInjectionThread.hpp"
#include <QtCore/QByteArray>
#include <QTcpSocket>
namespace PrtCnv
{
PrtCnvInjectionSocket::PrtCnvInjectionSocket()
: m_Socket(nullptr)
, m_Server(nullptr)
, m_logger(getLogger("PrtCnvInjectionSocket"))
{}
PrtCnvInjectionSocket::~PrtCnvInjectionSocket()
{
delete m_Socket;
}
// ---------------------------------------------------------------
// Disconnects a TCP-client
// ---------------------------------------------------------------
void PrtCnvInjectionSocket::disconnectClient()
{
INFO_LOG(m_logger) << "A client has disconnected from the injection-server";
emit disconnected(this);
}
// ---------------------------------------------------------------
// Reads in TCP-data and handles them
// ---------------------------------------------------------------
void PrtCnvInjectionSocket::processInputData()
{
INFO_LOG(m_logger) << "Injection-server has data received";
N_CoPrtCnv::CoPrtCnvInjectionHeader injectionHeader;
qint64 bytesRead = m_Socket->peek((char*)&injectionHeader, sizeof(injectionHeader));
if (sizeof(injectionHeader) == bytesRead)
{
if (injectionHeader.isIdCorrect())
{
// check whether all bytes are available
qint64 available = m_Socket->bytesAvailable();
if (available < (injectionHeader.m_Size+sizeof(injectionHeader)))
{
INFO_LOG(m_logger) << "not enough bytes available - waiting for more data: "
<< "headersize=" << sizeof(injectionHeader) << " id1="
<< injectionHeader.m_Id1 << " id2=" << injectionHeader.m_Id2
<< " kind=" << (int)injectionHeader.m_Kind << " size="
<< injectionHeader.m_Size;
return; // try it later, when (maybe) enough bytes are available...
}
// enough bytes => read now all in
m_Socket->read((char*)&injectionHeader, sizeof(injectionHeader));
if (injectionHeader.isIdCorrect())
{
//INFO_LOG(m_logger) << "kind=" << (int)injectionHeader.m_Kind << " size=" << injectionHeader.m_Size;
// read the data
QByteArray data(injectionHeader.m_Size, Qt::Uninitialized);
m_Socket->read(data.data(), injectionHeader.m_Size);
switch (injectionHeader.m_Kind)
{
case N_CoPrtCnv::CoPrtCnvInjectionHeader::eCentral:
case N_CoPrtCnv::CoPrtCnvInjectionHeader::eRadio:
{
N_CoPrtCnv::CoPrtCnvCentralTelegram *tele = new N_CoPrtCnv::CoPrtCnvCentralTelegram(data);
if (N_CoPrtCnv::CoPrtCnvInjectionHeader::eCentral == injectionHeader.m_Kind &&
tele->telegramId() != TrainingAreaBase::TetraIcd::TelegramId::DATENVERKEHR_TDS_SRT)
{
INFO_LOG(m_logger) << "Got an injection-central-telegram with telId=" << tele->telegramId();
m_Server->addToCentralList(tele);
}
else
{
INFO_LOG(m_logger) << "Got an injection-radio-telegram with telId=" << tele->telegramId();
m_Server->addToRadioList(tele);
}
}
break;
default:
ERROR_LOG(m_logger) << "Unknown kind (" << injectionHeader.m_Kind << ") of injection-telegram";
break;
}
}
}
else
{
ERROR_LOG(m_logger) << "Corrupt injection-telegram received => reconnect";
m_Socket->disconnectFromHost();
}
}
}
// ---------------------------------------------------------------
void PrtCnvInjectionSocket::setSocket(QTcpSocket* a_socket, PrtCnvInjectionThread* a_server)
{
m_Socket = a_socket;
m_Server = a_server;
connect(this, &PrtCnvInjectionSocket::disconnected, m_Server, &PrtCnvInjectionThread::disconnectClient, Qt::QueuedConnection);
if (m_Socket)
{
connect(m_Socket, &QTcpSocket::readyRead, this, &PrtCnvInjectionSocket::processInputData, Qt::QueuedConnection);
connect(m_Socket, &QTcpSocket::disconnected, this, &PrtCnvInjectionSocket::disconnectClient, Qt::QueuedConnection);
}
}
} // namespace PrtCnv