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>
87 lines
2.6 KiB
C++
87 lines
2.6 KiB
C++
/**
|
|
* @RDE_HEADER@
|
|
* Access Data from TRIMBLE and emit contents as QByteArray
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "socketreader.h"
|
|
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
|
|
#include <QtNetwork/QTcpSocket>
|
|
#include <QtCore/QTimer>
|
|
#include <QtCore/QCoreApplication>
|
|
#include <QtCore/QMetaEnum>
|
|
|
|
namespace HighLevelArchitecture {
|
|
|
|
SocketReader::SocketReader(QObject *parent)
|
|
: QThread(parent)
|
|
, m_socket(new QTcpSocket(this))
|
|
, m_hlaRequestIdentifier(0)
|
|
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("SocketReader"))
|
|
{
|
|
}
|
|
|
|
bool SocketReader::init(const QString &host, quint16 port, int hlaRequestIdentifier)
|
|
{
|
|
DEBUG_LOG(m_logger) << "SR " << hlaRequestIdentifier << ": Trying to establish connection to " << host << ":" << port;
|
|
|
|
m_hlaRequestIdentifier = hlaRequestIdentifier;
|
|
connect(m_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead()));
|
|
connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
|
|
|
|
m_socket->connectToHost(host, port, QIODevice::ReadOnly);
|
|
return m_socket->waitForConnected(1000);
|
|
}
|
|
|
|
SocketReader::~SocketReader()
|
|
{
|
|
m_socket->disconnectFromHost();
|
|
// Gracely try to disconnect. If not successfull within 1000msecs, abort the socket.
|
|
if (m_socket->state() != QAbstractSocket::UnconnectedState &&
|
|
!m_socket->waitForDisconnected(1000))
|
|
m_socket->abort();
|
|
|
|
delete m_socket;
|
|
m_socket = 0;
|
|
}
|
|
|
|
void SocketReader::onReadyRead()
|
|
{
|
|
// Checked if this works and the whole chunk is read.
|
|
// No problems in extensive testing.
|
|
// Otherwise, we had to inspect the data and search for start and ending!
|
|
DEBUG_LOG(m_logger) << "SR "<< m_hlaRequestIdentifier << ": Data received, transmitting";
|
|
QByteArray ba(m_socket->readAll());
|
|
TRACE_LOG(m_logger) << "SR "<< m_hlaRequestIdentifier << ": Data contents: " << ba.constData();
|
|
emit newData(ba, m_hlaRequestIdentifier);
|
|
}
|
|
|
|
void SocketReader::stopThread()
|
|
{
|
|
QTimer::singleShot(0, this, SLOT(quit()));
|
|
while (!isFinished())
|
|
QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
|
|
deleteLater();
|
|
}
|
|
|
|
void SocketReader::onSocketError(const QAbstractSocket::SocketError &error)
|
|
{
|
|
QString errorValue;
|
|
QMetaObject meta = QAbstractSocket::staticMetaObject;
|
|
for (int i=0; i < meta.enumeratorCount(); ++i) {
|
|
QMetaEnum m = meta.enumerator(i);
|
|
if (QString::fromLatin1(m.name()) == QLatin1String("SocketError")) {
|
|
errorValue = QLatin1String(m.valueToKey(error));
|
|
break;
|
|
}
|
|
}
|
|
|
|
ERROR_LOG(m_logger) << "SR "<< m_hlaRequestIdentifier << ": Socket Error: " << errorValue;
|
|
}
|
|
|
|
} // namespace HLA
|