Files
qt-migration-legatus/qt5-before/dlbo/Lts/Proxies/FeedGeoJson/feedGeoJson.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

217 lines
6.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Msg Function Topic Module Test
* $Id: ces_tests_gas_pipe.cpp 53032 2021-03-08 14:20:54Z diers $
* $HeadURL: svn://slssvn/TDS/branches/product/features/3dws_devel/Lts/Services/FeedGeoJson/ModuleTests/ces_tests_gas_pipe.cpp $
* $Author: diers $
*/
#include "feedGeoJson.h"
#include <nglapplication/nglcoreapplication.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QTimer>
#include <QDateTime>
#include <QPolygonF>
#include <QDateTime>
/* ----------------------------------------------------------------------------------
* HOW TO RUN THE TESTS (example)
* ----------------------------------------------------------------------------------
* 0. Preconditions:
* make test-db
* Start services: (SV)
* ./svcFeedGeoJson -e 42 &
* ./cesTestsGasPipe -t 1 -e 42 // Gas Pipe explosion
*/
namespace FeedGeoJson
{
FeedGeoJson::FeedGeoJson(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("CesTestGasPipe"))
{}
FeedGeoJson::~FeedGeoJson()
{}
bool FeedGeoJson::init(const int domainId, const int exerciseId, WebSocketServer &webSocketServer)
{
m_websocketServer = &webSocketServer;
bool bRet = true;
INFO_LOG(m_logger) << "init begin";
m_ddsConnector42 = std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId);
m_ddsConnector42->init();
m_ddsConnector42->initPublisherSubscriber();
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_pdmDtc->enableChargeType();
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_ppmDtc->enableParticipantPosition();
bRet &= m_ppmDtc->enableParticipant();
bRet &= m_ppmDtc->enableDynamicParticipantData();
bRet &= m_ppmDtc->enableType();
m_aesDtc = AreaEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_aesDtc->enableExplosionSingle();
bRet &= m_aesDtc->enableAesItemView();
bRet &= m_aesDtc->enableTriggeredImpacts();
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
this, &FeedGeoJson::onParticipantPositionChanged);
NOTICE_LOG(m_logger) << "END init";
return bRet;
}
QString FeedGeoJson::getGeoJsonPosition(const ParticipantManagement::ParticipantPosition &data)
{
NOTICE_LOG(m_logger) << "sendPositionToGeoJson participantId=" << data.participantId();
QString message = QStringLiteral("{ 'type': 'FeatureCollection',\
'features': [\
{ 'type': 'Feature',\
'geometry': {'type': 'Point', 'coordinates': [102.0, 0.5]},\
'properties': {'prop0': 'value0'}\
},\
{ 'type': 'Feature',\
'geometry': {\
'type': 'LineString',\
'coordinates': [\
[102.0, 0.0], [103.0, 1.0], [104.0, 0.0], [105.0, 1.0]\
]\
},\
'properties': {\
'prop0': 'value0',\
'prop1': 0.0\
}¸\
},\
{ 'type': 'Feature',\
'geometry': {\
'type': 'Polygon',\
'coordinates': [\
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],\
[100.0, 1.0], [100.0, 0.0] ]\
]\
},\
'properties': {\
'prop0': 'value0',\
'prop1': {'this': 'that'}\
}\
}\
]\
}");
return message;
}
void FeedGeoJson::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
{
NOTICE_LOG(m_logger) << "onParticipantPositionChanged: " << data;
DEBUG_LOG(m_logger) << "onParticipantPositionChanged: " << data;
if (modType == DataModification::eRemoved)
{
DEBUG_LOG(m_logger) << "m_participantsOutsideMap.remove participantId: " << data.participantId();
//m_participantsOutsideMap.remove(data.participantId());
}
else
{
DEBUG_LOG(m_logger) << "Handle ParticipantPosition";
QString posGeoJson = getGeoJsonPosition(data);
m_websocketServer->sendMessage(posGeoJson);
}
}
void FeedGeoJson::onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
{
DEBUG_LOG(m_logger) << "onDynamicParticipantDataChanged";
if (modType == DataModification::eRemoved)
return;
}
void FeedGeoJson::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void FeedGeoJson::ExitSuccess()
{
DEBUG_LOG(m_logger) << "ExitSuccess";
m_bTestsSuccessful = true;
QTimer::singleShot(200, qApp, &QCoreApplication::quit);
}
}
// ------------------------------------------------------------------
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
{
public:
CmdLineParser()
: LtsCommandLineParser()
{
addOption({ QStringList() << QLatin1String("p") << QLatin1String("websocket port")
, QLatin1String("Port")
, QLatin1String("Default: 12345 (all tests)")
, QLatin1String("12345")
});
}
int exerciseId() const { return isSet(QLatin1String("e")) ? value(QLatin1String("e")).toInt() : -1; }
int port() const { return isSet(QLatin1String("p")) ? value(QLatin1String("p")).toInt() : -1; }
};
// ------------------------------------------------------------------
int main(int argc, char **argv)
{
NGLCoreApplication app(argc, argv);
app.createLogger("FGJ", "log4cxx_fgj.props");
fprintf(stderr, "Start Feed GeoJson Service\n");
CmdLineParser options;
if (!options.init())
{
fprintf(stderr, "no exercise ID abailable\n ./feedGeoJson -e <exerciseId>\n");
return -1;
}
fprintf(stderr, "./feedGeoJson -e %d -p %d (exerciseId=%d, Websocket Port=%d)\n", options.exerciseId(),options.port(), options.exerciseId(),options.port());
WebSocketServer webSocketServer(options.port()); // Listening on port 12345
int iRet = -1;
{
std::unique_ptr<FeedGeoJson::FeedGeoJson> cesTests(new FeedGeoJson::FeedGeoJson);
if (!cesTests->init(options.domainId(), options.exerciseId(), webSocketServer))
return iRet;
STARTUP_LOG(app.baseLogger());
app.exec();
iRet = cesTests->testsSuccessful() ? 0 : 1;
fprintf(stderr, "%d\n", iRet);
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
SHUTDOWN_LOG(app.baseLogger());
}
return iRet;
}