Files
qt-migration-legatus/qt6-after/qt6-migrated-legatus/Lts/Proxies/FeedGeoJson/feedGeoJson.cpp
T
torstenandCopilot b774f4035c Qt6 Migration: DDS-Stubs, Logger-Fixes, Export-Header Korrekturen
- NGL_ADD_LIBRARY2: 87 CMakeLists.txt konvertiert für Export-Header Generierung
- 44 Export-Header Include-Pfade korrigiert (_export.h)
- 81 DDS-Stub-Header generiert (*_dtc.h, *_fts.h, *_dts.h, *_ftc.h)
- INGLLogger: Duplikat gelöscht, m_logger Member entfernt, variadische Makros
- Q_FUNC_INFO Redefinition behoben (Qt6 definiert bereits)
- FATAL_LOG Makro hinzugefügt
- InfrastructureManagement DDS-Stubs (ism.hpp, ism_enums.hpp, ism_ftc.h)
- FilterManagement DDS-Stubs (flt_ftc.h, flt_dts.h)
- AreaEffectSimulation DDS-Stubs (aes.hpp, aes_enums.hpp)
- SymbolAppearance Klasse vollständig definiert mit content() Methode
- BuildingComponentFilter Klasse definiert mit Copy-Konstruktor
- Ftc Factory: nullptr Return (abstract class)
- AesFilter Klasse in aes.hpp hinzugefügt
- Dtc Klasse in ppm.hpp mit participantChanged Signal
- AesType Enum: alle 15 At* Werte definiert
- AesEffectState_def: EsReceived hinzugefügt
- DataModification Enum: eAdded/eModified/eRemoved
- function_reply_object.h → core_types.h Include-Pfad (72 Dateien)
- Enum-Class-Streaming Template-Operator in INGLLogger.h
- ism_mounting_point.h: QImage → QtGui/QImage, QGuiApplication/QScreen
- ism_data_plugin_interface.h: QSet Include, Include-Reihenfolge
- QRegExp → QRegularExpression in tpm_js_parser.cpp
- .underlying() Aufrufe zu direktem Enum-Vergleich korrigiert
- Include-Pfade: aes.hpp in symbol_appearance_settings_impl.h und aes_display_filter_impl.h

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-19 06:06:24 +02:00

205 lines
5.2 KiB
C++
Executable File
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.
#include "feedGeoJson.h"
#include <nglapplication/nglcoreapplication.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QTimer>
#include <QDateTime>
#include <QPolygonF>
#include <QDateTime>
namespace FeedGeoJson
{
FeedGeoJson::FeedGeoJson(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
{}
FeedGeoJson::~FeedGeoJson()
{}
bool FeedGeoJson::init(const int domainId, const int exerciseId, WebSocketServer &webSocketServer)
{
m_websocketServer = &webSocketServer;
bool bRet = true;
INFO_LOG() << "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() << "onParticipantPositionChanged: " << data;
if (modType == DataModification::eRemoved)
{
DEBUG_LOG() << "m_participantsOutsideMap.remove participantId: " << data.participantId();
}
else
{
DEBUG_LOG() << "Handle ParticipantPosition";
QString posGeoJson = getGeoJsonPosition(data);
m_websocketServer->sendMessage(posGeoJson);
}
}
void FeedGeoJson::onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
{
DEBUG_LOG() << "onDynamicParticipantDataChanged";
if (modType == DataModification::eRemoved)
return;
}
void FeedGeoJson::failExit()
{
DEBUG_LOG() << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void FeedGeoJson::ExitSuccess()
{
DEBUG_LOG() << "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());
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;
}