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

144 lines
4.7 KiB
C++

// **************************************************************************
//
// (C) Copyright 2009 Swiss SIMTEC AG
//
// **************************************************************************
//
// $HeadURL$
// $LastChangedBy$
// $LastChangedDate$
// $LastChangedRevision$
//
// **************************************************************************
// manual class headers
#include "LogViewInjectionThread.hpp"
#include "LogViewTelegram.hpp"
#include "LogViewOptionDialog.hpp"
#include <CoPrtCnv/CoPrtCnvInjectionHeader.hpp>
#include <QtNetwork/QTcpSocket>
#include <QtCore/QTimer>
#include <QtCore/QSettings>
namespace N_LogView
{
LogViewInjectionThread::LogViewInjectionThread()
: m_DoStartConnection(false)
, m_SendingPossible(false)
, m_Socket(nullptr)
, m_Timer(nullptr)
, m_logger(getLogger("LogViewInjectionThread"))
{
// load the settings (and write default-values if not defined)
QSettings settings;
settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP);
m_Hostname = settings.value(LogViewOptionDialog::INJECTION_HOSTNAME).toString();
if (m_Hostname.isEmpty())
{
// set default-hostname if nothing was set
m_Hostname = QLatin1String("localhost");
settings.setValue(LogViewOptionDialog::INJECTION_HOSTNAME, m_Hostname);
}
m_Port = settings.value(LogViewOptionDialog::INJECTION_PORT).toInt();
if (0 == m_Port || m_Port > 65535)
{
m_Port = 46666;
settings.setValue(LogViewOptionDialog::INJECTION_PORT, m_Port);
}
}
// ---------------------------------------------------------------
void LogViewInjectionThread::run()
{
emit updateStatus(QLatin1String(":/image/RedLamp.png"),
tr("LogView ist nicht mit TETRA-If-Injection-Server (%1:%2) verbunden").arg(m_Hostname).arg(m_Port));
QTimer::singleShot(100, this, &LogViewInjectionThread::tryToConnect);
exec();
}
// ---------------------------------------------------------------
void LogViewInjectionThread::setPort(uint16_t port)
{
m_Port = port;
QSettings settings;
settings.beginGroup(LogViewOptionDialog::INJECTION_GROUP);
settings.setValue(LogViewOptionDialog::INJECTION_PORT, m_Port);
}
// ---------------------------------------------------------------
bool LogViewInjectionThread::isSendingPossible() const
{
return m_SendingPossible;
}
// ---------------------------------------------------------------
void LogViewInjectionThread::tryToConnect()
{
//m_Timer->setInterval(3000);
if (!m_Socket)
{
m_Socket = new QTcpSocket(this);
connect(m_Socket, &QTcpSocket::connected, this, &LogViewInjectionThread::doConnect);
connect(m_Socket, &QTcpSocket::disconnected, this, &LogViewInjectionThread::doDisconnect);
}
// we need a timer for retrying connection
if (!m_Timer)
{
m_Timer = new QTimer(this);
connect(m_Timer, &QTimer::timeout, this, &LogViewInjectionThread::tryToConnect);
}
m_Timer->setInterval(3000);
m_Timer->start();
INFO_LOG(m_logger) << "Try to connect to injection-server of TETRA-If (" << m_Hostname << ":" << m_Port << ")";
m_Socket->connectToHost(m_Hostname, m_Port);
}
// ---------------------------------------------------------------
void LogViewInjectionThread::doConnect()
{
INFO_LOG(m_logger) << "LogView has successful connected to injection-server of TETRA-If";
m_SendingPossible = true;
m_Timer->stop();
emit updateStatus(QLatin1String(":/image/GreenLamp.png"),
tr("LogView ist mit TETRA-If-Injection-Server (%1:%2) verbunden").arg(m_Hostname).arg(m_Port));
}
// ---------------------------------------------------------------
void LogViewInjectionThread::doDisconnect()
{
INFO_LOG(m_logger) << "LogView was disconnected from injection-server of TETRA-If";
m_SendingPossible = false;
emit updateStatus(QLatin1String(":/image/RedLamp.png"),
tr("LogView ist nicht mehr mit TETRA-If-Injection-Server (%1:%2) verbunden").arg(m_Hostname).arg(m_Port));
tryToConnect();
}
// ---------------------------------------------------------------
void LogViewInjectionThread::sendTelegram(LogViewTelegram* a_telegram, const bool a_doSendAsCentralTelegram)
{
INFO_LOG(m_logger) << "inject " << (a_doSendAsCentralTelegram ? "central" : "Tetra") << " telegram";
if (!m_Socket || m_Socket->state() != QAbstractSocket::ConnectedState)
{
ERROR_LOG(m_logger) << "Try to write a telegramm but we are not connected";
return;
}
N_CoPrtCnv::CoPrtCnvInjectionHeader injectionHeader;
injectionHeader.m_Kind = a_doSendAsCentralTelegram ? N_CoPrtCnv::CoPrtCnvInjectionHeader::eCentral : N_CoPrtCnv::CoPrtCnvInjectionHeader::eRadio;
const QByteArray &data = a_telegram->getData();
injectionHeader.m_Size = data.size();
m_Socket->write((char*)(&injectionHeader), sizeof(injectionHeader));
m_Socket->write(data);
}
} // namespace N_LogView