Continue the Qt5->Qt6 migration so the LTS Projects (Group 10) and LTS
Application (Group 11) compile, link, and ctest runs.
Qt5->Qt6 API migration (resolves removed/deprecated Qt6 APIs) across Lts
Tools and Apps, e.g. QAction->QActionGroup, QAbstractSocket::errorOccurred,
Qt::SkipEmptyParts, QRandomGenerator, QInputDevice::DeviceType,
QRegularExpression, QLatin1Literal->QStringLiteral, and the SampleModel
m_description->description rename.
CMake build fixes:
- CMakeLists.txt: add Lts/Common to CMAKE_AUTOMOC_INCLUDE_DIRECTORIES so moc
resolves Q_INTERFACES(ProjectPlugin::Plugin) for the migrated Projects.
- cmake/NGLMacros.cmake: NGL_COMPILE_RESOURCES - replace return() (which aborts
the calling CMakeLists.txt) with an if/else/endif.
- OpApp/THP: guard the ArcGISQt5Hack link with $<IF:$<TARGET_EXISTS:...>> (the
target is absent when the SituationMap viewer is stubbed); matches
CentralEffectSimulation.
- LtsSession: prefer the in-tree svcCoreClient target over a FIND_LIBRARY in
/usr/local/lib.
- CnrProxyTester/DotMatrixDisplay: set AUTOUIC_SEARCH_PATHS for the ui/ subdir.
- TopicDiscover: link NGLLogger.
Export-header visibility stubs (expand the empty *_EXPORT macro to
__attribute__((visibility("default"))); the build sets -fvisibility=hidden and
these stubs shadow the CMake-generated header):
- include/LtsProjectionWorkstation/ltsprojectionworkstation_export.h (fixes
undefined reference to LtsProjectionWorkstation::getInstance /
setProjectionOperatorPreset)
- include/LtsSession/ltssession_export.h, include/LtsUtilsGuiDds/ltsutilsguidds_export.h (same pattern)
New plugin modules (copied from legacy) so LtsAppDescriptorChecker finds the
gui:3 IIDs referenced by the Projects' apps.json:
- TakeHomePackageManager/OldTHP gui:3:tpm.man, gui:3:tpm.usb
- PresentationManagement/.../ScriptEditor gui:3:pre.script.edit
- Timeline/Gui/EventTimelineClassic gui:3:tln.view
new_docker_build.sh: correct group targets to the actual CMake target names,
guard LtsReportDisplay on BUILD_CODIFICATION, and skip modules unavailable in
the prebuilt image (AsmWorkstationCertifier/botan2, TrajectoryWidget,
VideoImport, thp_viewer/VLC).
182 lines
5.5 KiB
C++
Executable File
182 lines
5.5 KiB
C++
Executable File
/*
|
|
* @RDE_HEADER@
|
|
* Sending of telegrams to websocket
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Hanna E. Rathje, SLTE, 2022-03-29
|
|
*/
|
|
|
|
#include "worker.h"
|
|
|
|
#include <NGLLogger/NGLLoggerBootstrap.h>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
|
|
#include <QtCore/QDateTime>
|
|
#include <QtCore/QPointF>
|
|
|
|
namespace WlsRandomPositions
|
|
{
|
|
|
|
static inline QByteArray escapeData(const QByteArray &bufferData)
|
|
{
|
|
QByteArray ret;
|
|
ret.reserve(bufferData.size() * 6 / 5);
|
|
for (const unsigned char c : bufferData)
|
|
{
|
|
if (c >= 0x20 && c < 0x7f)
|
|
ret += c;
|
|
else
|
|
ret += "\\x" + QByteArray::number(static_cast<unsigned char>(c), 16);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
|
|
Worker::Worker(QObject *parent)
|
|
: QObject(parent)
|
|
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("Worker"))
|
|
{
|
|
m_tcpClient = new QTcpSocket(this);
|
|
|
|
connect(m_tcpClient, &QTcpSocket::connected, this, &Worker::onTcpConnected);
|
|
connect(m_tcpClient, &QAbstractSocket::errorOccurred, this, &Worker::error);
|
|
connect(m_tcpClient, &QTcpSocket::disconnected, this, &Worker::onTcpDisconnected);
|
|
}
|
|
|
|
Worker::~Worker()
|
|
{
|
|
delete m_tcpClient;
|
|
}
|
|
|
|
void Worker::connectToServer(const QString &serverName, int serverPort)
|
|
{
|
|
m_server = serverName;
|
|
m_serverPort = serverPort;
|
|
|
|
m_tcpClient->connectToHost(m_server, m_serverPort);
|
|
}
|
|
|
|
void Worker::onTcpConnected()
|
|
{
|
|
INFO_LOG(m_logger) << "Connected to " << m_server << ", Port: " << m_serverPort;
|
|
QString status = tr("Connected to %1, Port: %2").arg(m_server).arg(m_serverPort);
|
|
emit connectionStateChanged(true, status);
|
|
}
|
|
|
|
void Worker::onTcpDisconnected()
|
|
{
|
|
INFO_LOG(m_logger) << "Disconnected";
|
|
QString status = tr("Disconnected");
|
|
emit connectionStateChanged(false, status);
|
|
}
|
|
|
|
void Worker::error()
|
|
{
|
|
ERROR_LOG(m_logger) << "SocketError " << m_tcpClient->errorString();
|
|
emit connectionStateChanged(false, m_tcpClient->errorString());
|
|
}
|
|
|
|
void Worker::start(int numberParticipants, int firstEquipNo, qint64 firstMacAddress, int mSecs, int jitter, double maxDistance)
|
|
{
|
|
m_sentTelegrams = 0;
|
|
int equipNo = firstEquipNo;
|
|
qint64 mac = firstMacAddress;
|
|
|
|
for (int i=0; i<numberParticipants; ++i)
|
|
{
|
|
DEBUG_LOG(m_logger) << "SimulatedPlayer: equipNo: " << equipNo << ", macAddress: " << mac;
|
|
SimulatedPlayer *sp = new SimulatedPlayer(equipNo++, mac++, mSecs, jitter, maxDistance, this);
|
|
connect(sp, &SimulatedPlayer::sendInitTelegram, this, &Worker::onInit);
|
|
connect(sp, &SimulatedPlayer::sendPositionTelegram, this, &Worker::onPosition);
|
|
m_players << sp;
|
|
sp->start();
|
|
}
|
|
|
|
INFO_LOG(m_logger) << numberParticipants << " Players started";
|
|
}
|
|
|
|
void Worker::onInit(const QString &macAddress, const QByteArray &content)
|
|
{
|
|
QDateTime dt = QDateTime::currentDateTime();
|
|
QByteArray data;
|
|
|
|
data.clear();
|
|
|
|
data.append(0x7F); // Startkennung
|
|
data.append(QByteArray::number(3)); //
|
|
data.append(';'); // Trennzeichen
|
|
data.append(dt.toString(QStringLiteral("yyyy-MM-dd hh:mm:ss.zzz")).toLatin1()); // Aktuelle Zeit
|
|
data.append(';'); // Trennzeichen
|
|
data.append(macAddress.toUtf8()); // Tag-ID
|
|
data.append(';'); // Trennzeichen
|
|
data.append(content); // ba < 80 Zeichen!
|
|
data.append(0x8F); // Endekennung
|
|
|
|
qint64 ret = m_tcpClient->write(data);
|
|
if (ret < 0)
|
|
{
|
|
ERROR_LOG(m_logger) << "Could not send init data for macAddress " << macAddress;
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << "Sending telegram to wls: " << escapeData(data);
|
|
m_tcpClient->flush();
|
|
emit telegramsIncremented(++m_sentTelegrams);
|
|
}
|
|
}
|
|
|
|
void Worker::onPosition(const QString &macAddress, QPointF pos, double height)
|
|
{
|
|
QString mgrs = LtsCoordTrans::mgrsFromGeographic(pos.x(), pos.y(), 7, false);
|
|
QString value = mgrs.right(14);
|
|
QString x = value.left(7);
|
|
QString y = value.right(7);
|
|
QString z = QString::number(height);
|
|
|
|
QDateTime dt = QDateTime::currentDateTime();
|
|
QByteArray data;
|
|
|
|
data.clear();
|
|
|
|
data.append(0x7F); // Startkennung
|
|
data.append(QByteArray::number(1)); //
|
|
data.append(';'); // Trennzeichen
|
|
data.append(dt.toString(QStringLiteral("yyyy-MM-dd hh:mm:ss.zzz")).toLatin1()); // Aktuelle Zeit
|
|
data.append(';'); // Trennzeichen
|
|
data.append(macAddress.toUtf8()); // Tag-ID
|
|
data.append(';'); // Trennzeichen
|
|
data.append(x.toUtf8());
|
|
data.append(';'); // Trennzeichen
|
|
data.append(y.toUtf8());
|
|
data.append(';'); // Trennzeichen
|
|
data.append(z.toUtf8());
|
|
data.append(";1;0;0;-1;-1");
|
|
data.append(0x8F); // Endekennung
|
|
|
|
qint64 ret = m_tcpClient->write(data);
|
|
if (ret < 0)
|
|
{
|
|
ERROR_LOG(m_logger) << "Could not send pos data for macAddress " << macAddress;
|
|
}
|
|
else
|
|
{
|
|
DEBUG_LOG(m_logger) << "Sending telegram to wls: " << escapeData(data);
|
|
m_tcpClient->flush();
|
|
emit telegramsIncremented(++m_sentTelegrams);
|
|
}
|
|
}
|
|
|
|
void Worker::stop()
|
|
{
|
|
INFO_LOG(m_logger) << "stop worker";
|
|
|
|
for (SimulatedPlayer* sp : m_players)
|
|
sp->deleteLater();
|
|
m_players.clear();
|
|
|
|
m_tcpClient->close();
|
|
}
|
|
|
|
} // Namespace WlsRandomPositions
|