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>
141 lines
3.6 KiB
C++
141 lines
3.6 KiB
C++
/**
|
|
* SocketHandler
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Gerlinde Rudolphus, SLTE, 2022-06-09
|
|
*/
|
|
|
|
#include "socket_handler.h"
|
|
#include <QTimer>
|
|
#include <QLatin1String>
|
|
#include "nmea_handler.h"
|
|
#include <QHostAddress>
|
|
|
|
namespace NmeaManagement
|
|
{
|
|
|
|
|
|
SocketHandler::SocketHandler(const std::shared_ptr<DdsHandler> &ddsHandler,
|
|
const std::shared_ptr<NmeaHandler> &nmeaHandler,
|
|
QObject *parent) :
|
|
QObject(parent)
|
|
, TurnRadioMasterOffRequestHandler(ddsHandler->fts())
|
|
, m_ddsHandler(ddsHandler)
|
|
, m_nmeaHandler(nmeaHandler)
|
|
, m_logger(getLogger("SocketHandler"))
|
|
{
|
|
// create a timer
|
|
m_reconnectTimer = new QTimer(this);
|
|
|
|
// setup signal and slot
|
|
connect(m_reconnectTimer, SIGNAL(timeout()),
|
|
this, SLOT(reconnectTimerSlot()));
|
|
|
|
}
|
|
|
|
void SocketHandler::init(QString nmeaHost, int nmeaPort)
|
|
{
|
|
m_nmeaHost = nmeaHost;
|
|
m_nmeaPort = nmeaPort;
|
|
socket = new QUdpSocket(this);
|
|
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
|
|
connect(socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
|
|
connect(socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
|
|
|
|
connect(socket, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWritten(qint64)));
|
|
|
|
INFO_LOG(m_logger) << "Connecting,..";
|
|
INFO_LOG(m_logger) << nmeaHost << " port: " << nmeaPort;
|
|
//socket->connectToHost(QHostAddress::LocalHost, nmeaPort);
|
|
//socket->connectToHost(nmeaHost, nmeaPort);
|
|
reconnect();
|
|
|
|
}
|
|
|
|
void SocketHandler::reconnect()
|
|
{
|
|
INFO_LOG(m_logger) << "Connecting,.." << " host = " << m_nmeaHost
|
|
<< " port = " << m_nmeaPort;;
|
|
|
|
if(!socket->bind(m_nmeaPort, QAbstractSocket::BindFlag::ShareAddress))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error from Socket: " << socket->errorString();
|
|
m_reconnectTimer->start(10000);
|
|
}
|
|
|
|
}
|
|
|
|
void SocketHandler::connected()
|
|
{
|
|
m_reconnectTimer->stop();
|
|
|
|
INFO_LOG(m_logger) << "Connected!";
|
|
}
|
|
|
|
|
|
void SocketHandler::disconnected()
|
|
{
|
|
INFO_LOG(m_logger) << "Disconnected!";
|
|
}
|
|
|
|
void SocketHandler::bytesWritten(qint64 bytes)
|
|
{
|
|
TRACE_LOG(m_logger) << "We wrote: " << bytes;
|
|
}
|
|
|
|
void SocketHandler::reconnectTimerSlot()
|
|
{
|
|
m_reconnectTimer->stop();
|
|
INFO_LOG(m_logger) << "Reconnect NMEA-Socket "
|
|
<< " host = " << m_nmeaHost
|
|
<< " port = " << m_nmeaPort;
|
|
reconnect();
|
|
}
|
|
|
|
|
|
void SocketHandler::readyRead()
|
|
{
|
|
bool hasData = true;
|
|
INFO_LOG(m_logger) << "Reading...";
|
|
// QByteArray ba = socket->readDatagram();
|
|
|
|
QByteArray ba;
|
|
|
|
while (socket->hasPendingDatagrams())
|
|
{
|
|
|
|
ba.resize(int(socket->pendingDatagramSize()));
|
|
socket->readDatagram(ba.data(), ba.size());
|
|
INFO_LOG(m_logger) << ba;
|
|
QByteArray nmeaDataBa = ba; // ba.mid(startNmeaData, endNmeaData);
|
|
std::string nmeaDataStd = nmeaDataBa.toStdString() ;
|
|
QString nmeaData = QString::fromLocal8Bit(nmeaDataStd.c_str());
|
|
|
|
|
|
INFO_LOG(m_logger) << "nmeaDecoder :" << nmeaData;
|
|
//ba = ba.mid(endNmeaData, ba.length());
|
|
m_nmeaHandler->decode(nmeaData);
|
|
|
|
INFO_LOG(m_logger) << "NMEA-Data=" << nmeaData;
|
|
INFO_LOG(m_logger) << "NMEA-Data ba=" << ba;
|
|
}
|
|
}
|
|
|
|
void SocketHandler::onTurnRadioMasterOffRequest(const rti::core::SampleIdentity &cookie, const TurnRadioMasterOffRequest &request)
|
|
{
|
|
//patric: Du hattest den Reply 端berschrieben nicht den Request ;)
|
|
|
|
Core::FunctionReplyObject reply;
|
|
if (reply.error())
|
|
WARNING_LOG(m_logger) << "onTurnRadioMasterOffReply: " << reply();
|
|
|
|
m_ddsHandler->fts()->turnRadioMasterOffReply(cookie, reply);
|
|
|
|
QByteArray queryTimeline ("$IIXDR,S,1,,SERVICE_CONTROL_PRESHUTDOWN*79");
|
|
qDebug() << queryTimeline;
|
|
socket->writeDatagram(queryTimeline, QHostAddress(m_nmeaHost), m_nmeaPort);
|
|
|
|
}
|
|
}
|