Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
#
# $Id: CMakeLists.txt 60251 2023-09-07 05:15:55Z karwat $
# $HeadURL: svn://slssvn/TDS/branches/product/features/3dws_devel/Lts/Services/CentralEffectSimulation/ModuleTests/CMakeLists.txt $
# $Author: karwat $
#
####################################
# Feed GeoJson
####################################
SET(FEED_GEO_JSON
feedGeoJson.cpp
feedGeoJson.h
logger.cpp
logger.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsGasPipe
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(feedGeoJson ${FEED_GEO_JSON})
TARGET_LINK_LIBRARIES(feedGeoJson
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcPdmClient
svcPpmClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcMdmServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
+216
View File
@@ -0,0 +1,216 @@
/**
* 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;
}
+89
View File
@@ -0,0 +1,89 @@
/**
* ModuleTests for Msg
* $Id: ces_tests_gas_pipe.h 49256 2020-01-06 14:09:14Z ehrlicher $
* $HeadURL: svn://slssvn/TDS/branches/product/features/3dws_devel/Lts/Services/FeedGeoJson/ModuleTests/ces_tests_gas_pipe.h $
* $Author: ehrlicher $
*/
#pragma once
#include "websocket_server.h"
#include <AreaEffectSimulation/aes_dtc.h>
#include <FeedGeoJson/logger.h>
#include <ProjectDataManagement/pdm_dtc.h>
#include <ParticipantManagement/ppm_dtc.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QPointF>
namespace FeedGeoJson
{
class FeedGeoJson : public QObject
{
Q_OBJECT
public:
explicit FeedGeoJson(QObject *parent = nullptr);
~FeedGeoJson();
bool init(const int domainId, const int exerciseId, WebSocketServer &webSocketServer);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
private slots:
/**
* Handle the signals from 'ParticipantManagement'
*/
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
void onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType);
protected Q_SLOTS:
void failExit();
void ExitSuccess();
protected:
private: // methods
QString getGeoJsonPosition(const ParticipantManagement::ParticipantPosition &data);
private: // structs
struct Participant
{
int participantId;
int participantTypeId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<ProjectDataManagement::Interface::Dtc> m_pdmDtc;
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_refPos;
NGL::INGLLogger &m_logger;
QVector<Participant> m_participants;
WebSocketServer* m_websocketServer;
};
} // namespace FeedGeoJson
+26
View File
@@ -0,0 +1,26 @@
Dieses Programm soll anhand der Daten vom DDS-Bus die GeoJson-Objekte erstellen.
Angefangen mit den Participant-Positionen.
Was brauche ich für die Darstellung der Participants?
- Die Position: -> ParticipantManagement::ParticipantPosition
- Den Verwundungsstatus: -> ParticipantMangaement::DynamicParticipantData->stateHistory-> (neuster Eintrag) -> vilnerabilityState
- Die Farbe -> ParticipantManagement::Participant.partyId
- Das Symbol -> ParticipantManagement::Participant.symbol
- Der Designator
Empfang von Positionsmeldungen:
void HandlerParticipant::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
Empfang von ParticipantMangaement::DynamicParticipantData:
void HandlerParticipant::onDynamicParticipantDataChanged(const ParticipantManagement::DynamicParticipantData &data, DataModification modType)
Empfang von Party und Symbol:
void HandlerParticipant::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
data.partyId()
data.symbol()
+65
View File
@@ -0,0 +1,65 @@
// #include "websocketserver.h"
// WebSocketServer::WebSocketServer()
// {
// }
#include "websocket_server.h"
#include <QDebug>
WebSocketServer::WebSocketServer(quint16 port, QObject *parent)
: QObject(parent),
m_server(new QWebSocketServer(QStringLiteral("Qt WebSocket Server"), QWebSocketServer::NonSecureMode, this)) {
if (m_server->listen(QHostAddress::Any, port)) {
qDebug() << "WebSocket Server listening on port" << port;
connect(m_server, &QWebSocketServer::newConnection, this, &WebSocketServer::onNewConnection);
} else {
qDebug() << "Failed to start WebSocket Server!";
}
}
WebSocketServer::~WebSocketServer() {
m_server->close();
qDeleteAll(m_clients);
}
void WebSocketServer::onNewConnection() {
QWebSocket *socket = m_server->nextPendingConnection();
connect(socket, &QWebSocket::textMessageReceived, this, &WebSocketServer::onTextMessageReceived);
connect(socket, &QWebSocket::disconnected, this, &WebSocketServer::onSocketDisconnected);
m_clients.append(socket);
qDebug() << "New client connected:" << socket->peerAddress().toString();
}
void WebSocketServer::onTextMessageReceived(QString message) {
QWebSocket *senderSocket = qobject_cast<QWebSocket *>(sender());
qDebug() << "Received message:" << message;
// Echo back to all clients
for (QWebSocket *client : qAsConst(m_clients)) {
if (client->isValid())
client->sendTextMessage(message);
}
}
void WebSocketServer::onSocketDisconnected() {
QWebSocket *socket = qobject_cast<QWebSocket *>(sender());
if (socket) {
m_clients.removeAll(socket);
socket->deleteLater();
qDebug() << "Client disconnected";
}
}
void WebSocketServer::sendMessage(QString message)
{
qDebug() << "sendMessage";
for (QWebSocket *client : qAsConst(m_clients)) {
if (client->isValid())
client->sendTextMessage(message);
}
}
+38
View File
@@ -0,0 +1,38 @@
// #ifndef WEBSOCKETSERVER_H
// #define WEBSOCKETSERVER_H
// class WebSocketServer
// {
// public:
// WebSocketServer();
// };
// #endif // WEBSOCKETSERVER_H
#ifndef WEBSOCKETSERVER_H
#define WEBSOCKETSERVER_H
#include <QObject>
#include <QtWebSockets/QWebSocketServer>
#include <QtWebSockets/QWebSocket>
class WebSocketServer : public QObject {
Q_OBJECT
public:
explicit WebSocketServer(quint16 port, QObject *parent = nullptr);
~WebSocketServer();
void sendMessage(QString message);
private slots:
void onNewConnection();
void onTextMessageReceived(QString message);
void onSocketDisconnected();
private:
QWebSocketServer *m_server;
QList<QWebSocket *> m_clients;
};
#endif // WEBSOCKETSERVER_HC