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>
This commit is contained in:
18662 files changed
+4115092
-5435
No files matched your search
@@ -0,0 +1,219 @@
|
||||
/**
|
||||
* Websocket interface to participant positions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Justus Hertel, SLSE, 2020-07-08
|
||||
*/
|
||||
|
||||
#include "web_socket_handler.h"
|
||||
#include "building_process.h"
|
||||
|
||||
#include <QWebSocket>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
//#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
namespace Buildings
|
||||
{
|
||||
|
||||
WebSocketHandler::WebSocketHandler(const std::shared_ptr<BuildingControlHandler> &buildingControlHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_buildingControlHandler(buildingControlHandler)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("BuildingsSocket"), QWebSocketServer::NonSecureMode, this))
|
||||
, m_logger(getLogger(QStringLiteral("WebSocketHandler")))
|
||||
{}
|
||||
|
||||
WebSocketHandler::~WebSocketHandler()
|
||||
{
|
||||
for (const auto& ws : qAsConst(m_webSockets))
|
||||
{
|
||||
ws->disconnect(this);
|
||||
}
|
||||
m_webSockets.clear();
|
||||
}
|
||||
|
||||
bool WebSocketHandler::init(quint16 listenPort)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "init";
|
||||
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_webSocketServer, &QWebSocketServer::newConnection,
|
||||
this, &WebSocketHandler::onNewConnection);
|
||||
|
||||
|
||||
INFO_LOG(m_logger) << "Listening on port " << m_webSocketServer->serverPort();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WebSocketHandler::init(const QPair<quint16, quint16> &portRange)
|
||||
{
|
||||
for (quint16 currentPort = portRange.first; currentPort != portRange.second; ++currentPort)
|
||||
{
|
||||
if (init(currentPort))
|
||||
return true;
|
||||
}
|
||||
|
||||
return init();
|
||||
}
|
||||
|
||||
bool WebSocketHandler::sendTelegramInternal() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "sendTelegramInternal";
|
||||
QJsonObject obj;
|
||||
obj[QStringLiteral("participantId")] = 1;
|
||||
obj[QStringLiteral("equipmentNumber")] = 2;
|
||||
obj[QStringLiteral("lat")] = 3.0;
|
||||
obj[QStringLiteral("lon")] = 4.0;
|
||||
obj[QStringLiteral("height")] = 5.0;
|
||||
|
||||
const QString jsonStr = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
||||
|
||||
bool ret = false;
|
||||
for (const auto &wsw : qAsConst(m_webSockets))
|
||||
{
|
||||
if (wsw->sendTextMessage(jsonStr))
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool WebSocketHandler::sendbuildingInfos() const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "sendbuildingInfos";
|
||||
QJsonObject obj;
|
||||
QJsonArray arr;
|
||||
|
||||
|
||||
QMapIterator<int, BuildingProcess *> i(m_buildingControlHandler->getBuildings());
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
BuildingProcess* buildingProcess = i.value();
|
||||
BuildingInfo buildingInfo = buildingProcess->buildingInfo();
|
||||
quint16 port = buildingProcess->getWebsocketPort();
|
||||
DEBUG_LOG(m_logger) << "key=" << i.key()
|
||||
<< " port= " << port
|
||||
<< " buildingInfo.name=" << buildingInfo.name;
|
||||
QJsonObject objIter;
|
||||
objIter[QStringLiteral("building_name")] = buildingInfo.name;
|
||||
objIter[QStringLiteral("port")] = port;
|
||||
arr.push_back(objIter);
|
||||
}
|
||||
obj[QStringLiteral("type")] = QStringLiteral("Buildings");
|
||||
obj[QStringLiteral("data")] = arr;
|
||||
|
||||
|
||||
|
||||
const QString jsonStr = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
||||
|
||||
bool ret = false;
|
||||
for (const auto &wsw : qAsConst(m_webSockets))
|
||||
{
|
||||
if (wsw->sendTextMessage(jsonStr))
|
||||
ret = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void WebSocketHandler::onNewMessage(const QString &message)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onNewMessage='" << message << "'";
|
||||
DEBUG_LOG(m_logger) << "m_buildingControlHandler->m_buildings.size()=" << m_buildingControlHandler->getBuildings().size();
|
||||
|
||||
if (message.indexOf(QStringLiteral("buildingRequest")) > 0)
|
||||
{
|
||||
sendbuildingInfos();
|
||||
}
|
||||
if (message.indexOf(QStringLiteral("triggerFlashlight")) > 0)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight" ;
|
||||
triggerFlashlight(message);
|
||||
}
|
||||
}
|
||||
|
||||
QJsonObject WebSocketHandler::ObjectFromString(const QString& in)
|
||||
{
|
||||
QJsonObject obj;
|
||||
|
||||
QJsonDocument doc = QJsonDocument::fromJson(in.toUtf8());
|
||||
|
||||
// check validity of the document
|
||||
if(!doc.isNull())
|
||||
{
|
||||
if(doc.isObject())
|
||||
{
|
||||
obj = doc.object();
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Document is not an object";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << "Invalid JSON...\n" << in ;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
void WebSocketHandler::triggerFlashlight(const QString &message)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "triggerFlashlight message=" << message;
|
||||
QJsonObject obj = ObjectFromString(message);
|
||||
QJsonObject dataObj = obj.value(QStringLiteral("data")).toObject();
|
||||
int structureElementId = dataObj.value(QStringLiteral("structureElementId")).toInt();
|
||||
QString hostnameBsm = dataObj.value(QStringLiteral("hostnameBsm")).toString();
|
||||
|
||||
DEBUG_LOG(m_logger) << "hostnameBsm=" << hostnameBsm
|
||||
<< " structureElementId=" << structureElementId;
|
||||
|
||||
}
|
||||
|
||||
void WebSocketHandler::onNewConnection()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onNewConnection";
|
||||
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
|
||||
|
||||
if (!ws)
|
||||
return;
|
||||
|
||||
connect(ws, &QWebSocket::disconnected,
|
||||
this, &WebSocketHandler::onWebSocketDisconnected);
|
||||
connect(ws, &QWebSocket::textMessageReceived,
|
||||
this, &WebSocketHandler::onNewMessage);
|
||||
|
||||
m_webSockets += ws;
|
||||
|
||||
INFO_LOG(m_logger) << "New websocket connected";
|
||||
}
|
||||
|
||||
void WebSocketHandler::onWebSocketDisconnected()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onWebSocketDisconnected";
|
||||
QWebSocket *ws = qobject_cast<QWebSocket *>(sender());
|
||||
if (!ws)
|
||||
return;
|
||||
|
||||
m_webSockets.removeAll(ws);
|
||||
ws->deleteLater();
|
||||
|
||||
INFO_LOG(m_logger) << "A websocket disconnected";
|
||||
}
|
||||
|
||||
bool WebSocketHandler::sendPosition()
|
||||
{
|
||||
if (!isConnected() || m_webSockets.isEmpty())
|
||||
return false;
|
||||
|
||||
return sendTelegramInternal();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user