Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+53
@@ -0,0 +1,53 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
|
||||
SET(awss_SRCS
|
||||
main.cpp
|
||||
#awss_webscoket_server.cpp
|
||||
#awss_login.cpp
|
||||
awss_base_layout.h
|
||||
awss_base_layout.cpp
|
||||
awss_login.h
|
||||
awss_login.cpp
|
||||
logger.h
|
||||
logger.cpp
|
||||
awss_exercise_chooser.h
|
||||
awss_exercise_chooser.cpp
|
||||
awss_websocket_interface.h
|
||||
awss_websocket_interface.cpp
|
||||
awss_icd_test.h
|
||||
awss_icd_test.cpp
|
||||
#awss_telegrams.h
|
||||
#awss_telegrams.cpp
|
||||
log4cxx_adlerWebSocketSimulator.props
|
||||
)
|
||||
|
||||
NGL_WRAP_UI(awss_SRCS
|
||||
awss_base_layout.ui
|
||||
awss_login.ui
|
||||
awss_exercise_chooser.ui
|
||||
awss_icd_test.ui
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(TOOLSSV AdlerWebSocketSimulator ${awss_SRCS})
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(AdlerWebSocketSimulator
|
||||
NGLLogger
|
||||
LtsCommandLineParser
|
||||
nglsettings
|
||||
nglapplication
|
||||
saaTelegrams
|
||||
Qt5::Network
|
||||
Qt5::WebSockets
|
||||
)
|
||||
NGL_INSTALL_TARGET(AdlerWebSocketSimulator)
|
||||
|
||||
SET(LOG4CXX_PROPS_FILE log4cxx_adlerWebSocketSimulator.props)
|
||||
NGL_INSTALL(FILES SV ${CMAKE_CURRENT_SOURCE_DIR}/${LOG4CXX_PROPS_FILE} DESTINATION "bin")
|
||||
|
||||
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main ADLER WebsocketSimulator Widget
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#include "awss_base_layout.h"
|
||||
#include "ui_awss_base_layout.h"
|
||||
|
||||
// widgets
|
||||
#include "awss_login.h"
|
||||
#include "awss_exercise_chooser.h"
|
||||
#include "awss_icd_test.h"
|
||||
//other
|
||||
#include "awss_websocket_interface.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
BaseLayout::BaseLayout(QWidget *parent)
|
||||
: QMainWindow(parent)
|
||||
, m_ui(new Ui::BaseLayout)
|
||||
, m_logger(getLogger("BaseLayout"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->actionBeenden, &QAction::triggered, this, &BaseLayout::close );
|
||||
connect(m_ui->actionReset, &QAction::triggered, this, &BaseLayout::onRestart );
|
||||
m_websocketInterface = new WebSocketInterface(this);
|
||||
connect(m_websocketInterface, &WebSocketInterface::gotServiceData, this, &BaseLayout::onConnectedToServer);
|
||||
connect(m_websocketInterface, &WebSocketInterface::gotExerciseData, this, &BaseLayout::onConnectedToExerciseManagement);
|
||||
connect(m_websocketInterface, &WebSocketInterface::gotPartyData, this, &BaseLayout::onExerciseChoosen);
|
||||
connect(m_websocketInterface, &WebSocketInterface::connectedToParty, this, &BaseLayout::onPartyAccepted);
|
||||
|
||||
connect(m_websocketInterface, &WebSocketInterface::statusMessage, this, &BaseLayout::onStatusMessage);
|
||||
|
||||
m_login = new Login(this);
|
||||
connect (m_login, &Login::connectToServer, m_websocketInterface, &WebSocketInterface::connectToServer);
|
||||
|
||||
|
||||
m_ui->stackWidget->addWidget(m_login);
|
||||
|
||||
m_exerciseChooser = new ExerciseChooser(this);
|
||||
connect( m_exerciseChooser, &ExerciseChooser::connectToExercise, m_websocketInterface, &WebSocketInterface::connectToParticipantManagement);
|
||||
connect( m_exerciseChooser, &ExerciseChooser::requestExerciseInformation, m_websocketInterface, &WebSocketInterface::connectToExerciseManagement);
|
||||
connect( m_exerciseChooser, &ExerciseChooser::connectToProxy, m_websocketInterface, &WebSocketInterface::connectToProxy);
|
||||
m_ui->stackWidget->addWidget(m_exerciseChooser);
|
||||
|
||||
m_icdTest = new ICDTest(this);
|
||||
connect(m_icdTest, &ICDTest::messsageToProxy, m_websocketInterface, &WebSocketInterface::sendToProxy);
|
||||
connect(m_icdTest, &ICDTest::doRestart, this, &BaseLayout::onRestart);
|
||||
connect(m_websocketInterface, &WebSocketInterface::proxyMessage, m_icdTest, &ICDTest::messsageFromProxy);
|
||||
|
||||
m_ui->stackWidget->addWidget(m_icdTest);
|
||||
|
||||
|
||||
}
|
||||
|
||||
BaseLayout::~BaseLayout()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
|
||||
void BaseLayout::onConnectedToServer(const QString &message)
|
||||
{
|
||||
m_ui->stackWidget->setCurrentWidget(m_exerciseChooser);
|
||||
m_exerciseChooser->setExercises(message);
|
||||
}
|
||||
|
||||
void BaseLayout::onConnectedToExerciseManagement(const QString &message)
|
||||
{
|
||||
m_exerciseChooser->setExeciseInfo(message);
|
||||
}
|
||||
|
||||
void BaseLayout::onExerciseChoosen(const QString &message)
|
||||
{
|
||||
m_ui->stackWidget->setCurrentWidget(m_exerciseChooser);
|
||||
m_exerciseChooser->setPartyData(message);
|
||||
|
||||
}
|
||||
|
||||
void BaseLayout::onPartyAccepted(int partyId, const QString &partyName, int saaId )
|
||||
{
|
||||
m_ui->stackWidget->setCurrentWidget(m_icdTest);
|
||||
m_icdTest->initParty(partyId, partyName, saaId);
|
||||
|
||||
//m_icdTest->setParty()
|
||||
}
|
||||
|
||||
void BaseLayout::onStatusMessage(const QString &message)
|
||||
{
|
||||
m_ui->statusbar->showMessage(message);
|
||||
}
|
||||
|
||||
void BaseLayout::onRestart()
|
||||
{
|
||||
m_ui->stackWidget->setCurrentWidget(m_login);
|
||||
m_websocketInterface->reset();
|
||||
|
||||
}
|
||||
|
||||
} // #namespace AdlerWebSocketSimulator
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main ADLER WebsocketSimulator Widget
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace Ui {
|
||||
class BaseLayout;
|
||||
}
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
// Casses
|
||||
class Login;
|
||||
class ExerciseChooser;
|
||||
class WebSocketInterface;
|
||||
class ICDTest;
|
||||
|
||||
class BaseLayout : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BaseLayout(QWidget *parent = nullptr);
|
||||
~BaseLayout();
|
||||
|
||||
private:
|
||||
//void connectToServer(const QString &servername, int port);
|
||||
|
||||
private slots:
|
||||
void onConnectedToServer(const QString &message);
|
||||
void onConnectedToExerciseManagement(const QString &message);
|
||||
void onExerciseChoosen(const QString &message);
|
||||
void onPartyAccepted(int partyId, const QString &partyName, int saaId);
|
||||
void onStatusMessage(const QString &message);
|
||||
void onRestart();
|
||||
|
||||
private:
|
||||
Ui::BaseLayout *m_ui;
|
||||
Login *m_login {nullptr};
|
||||
ExerciseChooser *m_exerciseChooser {nullptr};
|
||||
ICDTest *m_icdTest{nullptr};
|
||||
WebSocketInterface *m_websocketInterface {nullptr};
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // #namespace AdlerWebSocketSimulator
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BaseLayout</class>
|
||||
<widget class="QMainWindow" name="BaseLayout">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFiles">
|
||||
<property name="title">
|
||||
<string>Datei</string>
|
||||
</property>
|
||||
<addaction name="actionBeenden"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuAblage">
|
||||
<property name="title">
|
||||
<string>Ablage</string>
|
||||
</property>
|
||||
<addaction name="actionReset"/>
|
||||
</widget>
|
||||
<addaction name="menuFiles"/>
|
||||
<addaction name="menuAblage"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<action name="actionBeenden">
|
||||
<property name="text">
|
||||
<string>Beenden</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionReset">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,235 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseChooser Widget for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#include "awss_exercise_chooser.h"
|
||||
#include "ui_awss_exercise_chooser.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
#include <QJsonObject>
|
||||
#include <QPushButton>
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
ExerciseChooser::ExerciseChooser(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::ExerciseChooser)
|
||||
, m_logger(getLogger("ExerciseChooser"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->stackedWidget->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
ExerciseChooser::~ExerciseChooser()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void ExerciseChooser::setExercises(const QString &message)
|
||||
{
|
||||
ERROR_LOG(m_logger) << message;
|
||||
if (!m_ui->vlExercises->isEmpty())
|
||||
{
|
||||
for (auto ptr : m_ui->Exercise->findChildren<QPushButton*>())
|
||||
{
|
||||
m_ui->vlExercises->removeWidget(ptr);
|
||||
ptr->deleteLater();
|
||||
}
|
||||
//remove all
|
||||
}
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());// = QJsonDocument::fromJson(message);
|
||||
if (!doc.object().contains(QStringLiteral("data")))
|
||||
return;
|
||||
|
||||
QJsonValue val = doc.object().value(QStringLiteral("data"));
|
||||
if (!val.isArray())
|
||||
return;
|
||||
|
||||
for (const auto &ex: val.toArray())
|
||||
{
|
||||
// ERROR_LOG(m_logger) << ex;
|
||||
int ppmPort = 0;
|
||||
QJsonObject ob = ex.toObject();
|
||||
if (!ob.contains(QStringLiteral("exerciseId")))
|
||||
return;
|
||||
//get current Exercise ID
|
||||
int id = ob.value(QStringLiteral("exerciseId")).toInt();
|
||||
|
||||
// now querry services for PPM Port
|
||||
if (ob.contains(QStringLiteral("services")))
|
||||
{
|
||||
QJsonValue services = ob.value(QStringLiteral("services"));
|
||||
if (!services.isArray())
|
||||
return;
|
||||
for (const auto &serv :services.toArray())
|
||||
{
|
||||
if (!serv.toObject().isEmpty()
|
||||
&& serv.toObject().contains(QStringLiteral("nameAbbrevation")))
|
||||
{
|
||||
bool isTab = serv.toObject().value(QStringLiteral("nameAbbrevation")).toString().toLower() == QStringLiteral("tab");
|
||||
bool isPpm = serv.toObject().value(QStringLiteral("nameAbbrevation")).toString().toLower() == QStringLiteral("ppm");
|
||||
bool isExm = serv.toObject().value(QStringLiteral("nameAbbrevation")).toString().toLower() == QStringLiteral("exm");
|
||||
if (!isTab && !isPpm && !isExm)
|
||||
continue;
|
||||
|
||||
QJsonValue ports = serv.toObject().value(QStringLiteral("ports"));
|
||||
if (!ports.isArray())
|
||||
return;
|
||||
|
||||
for (const auto &port: ports.toArray())
|
||||
{
|
||||
if (!port.toObject().contains(QStringLiteral("typeId")) || !port.toObject().contains(QStringLiteral("number")) )
|
||||
return;
|
||||
if (isExm && port.toObject().value(QStringLiteral("typeId")).toInt() == 1)
|
||||
{
|
||||
m_exmPort = port.toObject().value(QStringLiteral("number")).toInt() ;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isPpm && port.toObject().value(QStringLiteral("typeId")).toInt() == 1)
|
||||
{
|
||||
ppmPort = port.toObject().value(QStringLiteral("number")).toInt() ;
|
||||
}
|
||||
if (isTab && port.toObject().value(QStringLiteral("typeId")).toInt() == 3)
|
||||
{
|
||||
int tabPort = port.toObject().value(QStringLiteral("number")).toInt() ;
|
||||
m_execerciseToProxyPort.insert(id, tabPort );
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (ppmPort <= 0 || id <= 0)
|
||||
continue;
|
||||
QPushButton *btn = new QPushButton(tr("Exercise: ")+ QString::number(id));
|
||||
btn->setProperty("port", ppmPort);
|
||||
btn->setProperty("excerciseId", id);
|
||||
btn->setDisabled(true);
|
||||
btn->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
|
||||
connect( btn, &QPushButton::clicked, this, &ExerciseChooser::onExerciseClicked);
|
||||
m_ui->vlExercises->addWidget(btn);
|
||||
}
|
||||
|
||||
if (m_exmPort > 0)
|
||||
{
|
||||
emit requestExerciseInformation(m_exmPort);
|
||||
}
|
||||
|
||||
//parse exercises
|
||||
}
|
||||
|
||||
void ExerciseChooser::setExeciseInfo(const QString &message)
|
||||
{
|
||||
ERROR_LOG(m_logger) << message;
|
||||
if (m_ui->vlExercises->isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());// = QJsonDocument::fromJson(message);
|
||||
if (!doc.object().contains(QStringLiteral("data")))
|
||||
return;
|
||||
|
||||
QJsonValue val = doc.object().value(QStringLiteral("data"));
|
||||
if (!val.isArray())
|
||||
return;
|
||||
|
||||
for (const auto &ex: val.toArray())
|
||||
{
|
||||
if (ex.toObject().isEmpty())
|
||||
return;
|
||||
const QJsonObject &exOb = ex.toObject();
|
||||
if (!exOb.contains(QStringLiteral("status")) || !exOb.contains(QStringLiteral("id")))
|
||||
return;
|
||||
int id = exOb.value(QStringLiteral("id")).toInt();
|
||||
int status = exOb.value(QStringLiteral("status")).toInt();
|
||||
for (auto ptr : m_ui->Exercise->findChildren<QPushButton *>(QString()))
|
||||
{
|
||||
if (ptr->property("excerciseId").toInt() == id)
|
||||
{
|
||||
if (status > 1 && status < 6)
|
||||
ptr->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void ExerciseChooser::setPartyData(const QString &message)
|
||||
{
|
||||
if (!m_ui->vlParty->isEmpty())
|
||||
{
|
||||
for (auto ptr : m_ui->Party->findChildren<QPushButton*>())
|
||||
{
|
||||
m_ui->vlParty->removeWidget(ptr);
|
||||
ptr->deleteLater();
|
||||
}
|
||||
//remove all
|
||||
}
|
||||
QJsonDocument doc = QJsonDocument::fromJson(message.toUtf8());// = QJsonDocument::fromJson(message);
|
||||
if (!doc.object().contains(QStringLiteral("data")))
|
||||
return;
|
||||
|
||||
QJsonValue val = doc.object().value(QStringLiteral("data"));
|
||||
if (!val.isArray())
|
||||
return;
|
||||
|
||||
for (const auto &partyData: val.toArray())
|
||||
{
|
||||
// ERROR_LOG(m_logger) << ex;
|
||||
|
||||
QJsonObject ob = partyData.toObject();
|
||||
|
||||
int id = ob.value(QStringLiteral("id")).toInt();
|
||||
if (id <= 1) // 0 ist pool 1 is OC
|
||||
continue;
|
||||
QString name;
|
||||
QColor color;
|
||||
// now querry services for PPM Port
|
||||
if (!ob.contains(QStringLiteral("name")))
|
||||
return;
|
||||
|
||||
name = ob.value(QStringLiteral("name")).toString();
|
||||
|
||||
if (!ob.contains(QStringLiteral("color")))
|
||||
return;
|
||||
|
||||
color = QColor::fromRgb(QRgb(ob.value(QStringLiteral("color")).toInt()));
|
||||
|
||||
QPushButton *btn = new QPushButton(tr("Name: ") + name);
|
||||
btn->setStyleSheet(QStringLiteral("background-color: %1").arg(color.name()));
|
||||
btn->setProperty("id", id);
|
||||
btn->setProperty("name", name);
|
||||
btn->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::MinimumExpanding);
|
||||
connect( btn, &QPushButton::clicked, this, &ExerciseChooser::onPartyClicked);
|
||||
m_ui->vlParty->addWidget(btn);
|
||||
}
|
||||
|
||||
m_ui->stackedWidget->setCurrentIndex(1);
|
||||
|
||||
}
|
||||
|
||||
void ExerciseChooser::onExerciseClicked()
|
||||
{
|
||||
int port = sender()->property("port").toInt();
|
||||
int excerciseId = sender()->property("excerciseId").toInt();
|
||||
m_currentExercise = excerciseId;
|
||||
emit connectToExercise(port);
|
||||
}
|
||||
|
||||
void ExerciseChooser::onPartyClicked()
|
||||
{
|
||||
int partyId = sender()->property("id").toInt();
|
||||
QString partyName = sender()->property("name").toString();
|
||||
emit connectToProxy(m_execerciseToProxyPort.value(m_currentExercise), partyId, partyName);
|
||||
}
|
||||
|
||||
} //namespace AdlerWebSocketSimulator
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* ExerciseChooser Widget for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace Ui {
|
||||
class ExerciseChooser;
|
||||
}
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
class ExerciseChooser : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ExerciseChooser(QWidget *parent = nullptr);
|
||||
~ExerciseChooser();
|
||||
void setExercises(const QString &message);
|
||||
void setExeciseInfo(const QString &message);
|
||||
void setPartyData(const QString &message);
|
||||
|
||||
private slots:
|
||||
void onExerciseClicked();
|
||||
void onPartyClicked();
|
||||
|
||||
signals:
|
||||
void connectToExercise(int);
|
||||
void requestExerciseInformation(int);
|
||||
void connectToProxy(int, int, const QString &);
|
||||
|
||||
private:
|
||||
Ui::ExerciseChooser *m_ui;
|
||||
int m_exmPort {0};
|
||||
int m_currentExercise {0};
|
||||
QMap<int,int> m_execerciseToProxyPort;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} //namespace AdlerWebSocketSimulator
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ExerciseChooser</class>
|
||||
<widget class="QWidget" name="ExerciseChooser">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="Exercise">
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose Exercise</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="vlExercises"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>216</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="Party">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose Party</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QVBoxLayout" name="vlParty"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>216</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+1203
File diff suppressed because it is too large.
Load diff
+106
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Main Test UI for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QTimer>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class ICDTest;
|
||||
}
|
||||
namespace AdlerJson
|
||||
{
|
||||
struct EXTelegramBase;
|
||||
enum class Szenarstatus;
|
||||
} // namespace AdlerJson
|
||||
namespace AdlerWebSocketSimulator
|
||||
{
|
||||
class ICDTest : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ICDTest(QWidget *parent = nullptr);
|
||||
~ICDTest();
|
||||
void initParty(int partyId, const QString &name, int saaId);
|
||||
void messsageFromProxy(const QString &message);
|
||||
|
||||
signals:
|
||||
void messsageToProxy(const QString &message);
|
||||
void doRestart();
|
||||
|
||||
private slots:
|
||||
void generateConnectMessage();
|
||||
void generateConnectMessageStandalone();
|
||||
|
||||
void sendDirectInputMessage();
|
||||
void generateDisconnectMessage();
|
||||
void generateTechnischeQuittierung();
|
||||
void generateStatusMessageStop();
|
||||
void generateStatusMessagePlanned();
|
||||
void generateStatusMessageInactive();
|
||||
void generateStatusMessageActive();
|
||||
void generateStatusMessage(AdlerJson::Szenarstatus status);
|
||||
void generateConnectionTestMessage();
|
||||
// fire
|
||||
void generateEXFQBABBFK(); // Planungsdaten
|
||||
void generateEXFQBABBFK_Gmlrs(); // Planungsdaten Gmlrs
|
||||
void generateEXFQBABBFK_Dm72(); // Planungsdaten DM72
|
||||
void generateEXFQBABBFK_ESG(); // Planungsdaten Original ESG-Telegramm
|
||||
void generateEXFQBABBFK_SMART_ESG(); // Planungsdaten SMART Original ESG-Telegramm
|
||||
void generateEXFQFN(); // Feuern
|
||||
void generateEXFQFN_Gmlrs(); // Feuern Gmlrs
|
||||
void generateEXFQFN_Dm72(); // Feuern DM72
|
||||
void generateEXFQFN_ESG(); // Feuern Original ESG-Telegramm
|
||||
void generateFlugbahndaten_ESG();
|
||||
|
||||
void generateEXFH(); // Feuer Halt / Einstellen
|
||||
void generateEXSQFS(); // Stellungsmeldung Feuerstellung
|
||||
void generateEXSQWS(); // Stellungsmeldung Waffensystem
|
||||
void generateEXSQWS_Gmlrs(); // Stellungsmeldung Waffensystem Gmlrs
|
||||
void generateEXSQWS_dm72(); // Stellungsmeldung Waffensystem DM72
|
||||
void generateEXSQWS_ESG(); // Stellungsmeldung Waffensystem
|
||||
// dont fire
|
||||
void generateEXFQnFN(); // Nicht Feuern -> wird ausgeführt wenn Feuerhalt ausgeführt wurde
|
||||
// special EXSQWS
|
||||
void generateEXSQWS_8MTP(); // Stellungsmeldung Waffensystem
|
||||
|
||||
void generateEXSQLP(); // Stellungsmeldung Ladeplatz
|
||||
void generateEXRES(); // Senden Erkundungsergebnisse
|
||||
void generateEXHQK(); // Fuehrungslinien (Koordinierungsmassnahmen zur Feuerunterstuetzung)
|
||||
void generateEXHQ_G_ALLE_EX_L24(); // EX-HQ(G) Aus Jira-Punkt E01562_388
|
||||
void generateEXHQ_K_ALLE_EX_L25(); // EX-HQ(K) Aus Jira-Punkt E01562_388
|
||||
void generateEXHQG(); // Fuehrungslinien und Grenzen
|
||||
void generateEXAQ(); // Freitextmeldung
|
||||
void generateEXFlugbahnberechnung(); // Flugbahnberechnung
|
||||
void generateEXFlugbahndaten(); // Flugbahndaten
|
||||
void onSendHeartbeatChanged();
|
||||
|
||||
private:
|
||||
void generateConnectionPage();
|
||||
void generateEsgPage();
|
||||
void generateFirePage();
|
||||
void generatePositionReportsPage();
|
||||
void generateTrajectoryGenerationPage();
|
||||
void generateTextMessagePage();
|
||||
void generateErkundungsergebnissePage();
|
||||
void generateStatusPage();
|
||||
void generateEXSQWS_1WS(const QString &verein, const QString &kenner);
|
||||
|
||||
private:
|
||||
Ui::ICDTest *m_ui;
|
||||
int m_partyId{0};
|
||||
int m_saaId{0};
|
||||
QTimer m_heartbeatTimer;
|
||||
QString m_lastFeuerkampfReferenz;
|
||||
QString m_fixedReference;
|
||||
};
|
||||
|
||||
} // namespace AdlerWebSocketSimulator
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ICDTest</class>
|
||||
<widget class="QWidget" name="ICDTest">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>639</width>
|
||||
<height>455</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Test ADLER for Party:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblParty">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><Party></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SAA: </string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblId">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><ID></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbRestart">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Restart</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="0,2">
|
||||
<item>
|
||||
<widget class="QToolBox" name="toolBox">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pConnection">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>76</width>
|
||||
<height>364</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Connections</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTextEdit" name="textEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="toolButton_2">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="tbTrash">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="edit-clear"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Screen for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#include "awss_login.h"
|
||||
#include "ui_awss_login.h"
|
||||
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
Login::Login(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_ui(new Ui::Login)
|
||||
, m_logger(getLogger("Login"))
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
connect( m_ui->pbConnect, &QPushButton::clicked, this, &Login::onConnectToServer);
|
||||
}
|
||||
|
||||
Login::~Login()
|
||||
{
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
void Login::onConnectToServer()
|
||||
{
|
||||
QString serverName = m_ui->leServerName->text();
|
||||
int port = m_ui->lePort->text().toInt();
|
||||
int id = m_ui->leSaaId->text().toInt();
|
||||
if (m_ui->leServerName->text().isEmpty())
|
||||
serverName = m_ui->leServerName->placeholderText();
|
||||
|
||||
if (m_ui->lePort->text().isEmpty())
|
||||
port = m_ui->lePort->placeholderText().toInt();
|
||||
|
||||
if (m_ui->leSaaId->text().isEmpty())
|
||||
id = m_ui->leSaaId->placeholderText().toInt();
|
||||
|
||||
emit connectToServer(serverName, port, id);
|
||||
}
|
||||
|
||||
} // #namespace AdlerWebSocketSimulator
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Login Screen for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QWidget>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace Ui {
|
||||
class Login;
|
||||
}
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
class Login : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Login(QWidget *parent = nullptr);
|
||||
~Login();
|
||||
|
||||
private slots:
|
||||
void onConnectToServer();
|
||||
|
||||
signals:
|
||||
void connectToServer(const QString servername, int port , int id = 0);
|
||||
|
||||
private:
|
||||
Ui::Login *m_ui;
|
||||
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
} // #namespace AdlerWebSocketSimulator
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Login</class>
|
||||
<widget class="QWidget" name="Login">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>514</width>
|
||||
<height>381</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leServerName">
|
||||
<property name="placeholderText">
|
||||
<string notr="true">localhost</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="midLineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>17</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect To Server:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>17</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="lePort">
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string notr="true">7300</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lblServerName">
|
||||
<property name="text">
|
||||
<string>Server Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pbConnect">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Connect</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lblPort">
|
||||
<property name="text">
|
||||
<string>Port:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="leSaaId">
|
||||
<property name="inputMethodHints">
|
||||
<set>Qt::ImhDigitsOnly</set>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>SAAX@GUEZ.DE</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,287 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Websocket interface for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#include "awss_websocket_interface.h"
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
WebSocketInterface::WebSocketInterface(QObject *parent)
|
||||
: QObject{parent}
|
||||
, m_logger(getLogger("WebSocketInterface"))
|
||||
{
|
||||
m_socket = new QWebSocket();
|
||||
connect(m_socket, &QWebSocket::textMessageReceived, this, &WebSocketInterface::onTextMessageRecived);
|
||||
connect(m_socket, &QWebSocket::connected, this, &WebSocketInterface::onConnected);
|
||||
connect(m_socket, &QWebSocket::disconnected, this, &WebSocketInterface::onDisconnected);
|
||||
connect(m_socket, QOverload<QAbstractSocket::SocketError>::of(&QWebSocket::error), this, &WebSocketInterface::onError);
|
||||
}
|
||||
|
||||
void WebSocketInterface::reset()
|
||||
{
|
||||
m_socket->close();
|
||||
m_hostname.clear();
|
||||
m_partyId = 0;
|
||||
m_partyName.clear();
|
||||
m_awss_state = AWSS_STATE::Unconnected;
|
||||
}
|
||||
|
||||
void WebSocketInterface::requestServicePortInformation()
|
||||
{
|
||||
emit statusMessage(tr("Start Service Information Request"));
|
||||
m_socket->sendTextMessage(QStringLiteral("{\"type\": \"servicePortsInformationRequest\",\"uuid\": \"%s\"}").arg(QUuid::createUuid().toString()));
|
||||
m_awss_state = AWSS_STATE::RequestServicePorts;
|
||||
|
||||
}
|
||||
|
||||
void WebSocketInterface::requestExcerciseInformation()
|
||||
{
|
||||
emit statusMessage(tr("Start Excercise Information Request"));
|
||||
m_awss_state = AWSS_STATE::RequestExerciseInformation;
|
||||
m_socket->sendTextMessage(QStringLiteral("{\"type\": \"exerciseInformationRequest\",\"uuid\": \"%1\"}").arg(QUuid::createUuid().toString()));
|
||||
|
||||
}
|
||||
|
||||
void WebSocketInterface::requestPartyInformation()
|
||||
{
|
||||
emit statusMessage(tr("Start Party Information Request"));
|
||||
m_awss_state = AWSS_STATE::RequestPartyInformation;
|
||||
m_socket->sendTextMessage(QStringLiteral("{\"type\": \"partyBaseData\",\"uuid\": \"%1\"}").arg(QUuid::createUuid().toString()));
|
||||
}
|
||||
|
||||
void WebSocketInterface::connectToServer(const QString servername, int port, int saaId)
|
||||
{
|
||||
emit statusMessage(tr("Connecting to ServiceManagement on %1 : %2 for SAA%3").arg(servername).arg(port, saaId));
|
||||
if (m_socket->state() != QAbstractSocket::UnconnectedState)
|
||||
m_socket->close();
|
||||
m_hostname = servername;
|
||||
m_port = port;
|
||||
m_saaId = saaId;
|
||||
QUrl url = QUrl(QLatin1String("ws://") + servername + QLatin1Char(':') + QString::number(port));
|
||||
m_socket->open(url);
|
||||
m_awss_state = AWSS_STATE::ConnectToServer;
|
||||
}
|
||||
|
||||
void WebSocketInterface::connectToExerciseManagement(int port)
|
||||
{
|
||||
emit statusMessage(tr("Connecting to ExcerciseManagement on %1 : %2 ").arg(m_hostname).arg(port));
|
||||
m_socket->close();
|
||||
m_port = port;
|
||||
QUrl url = QUrl(QLatin1String("ws://") + m_hostname + QLatin1Char(':') + QString::number(port));
|
||||
m_awss_state = AWSS_STATE::ConnectToExerciseManagement;
|
||||
|
||||
m_socket->open(url);
|
||||
}
|
||||
|
||||
void WebSocketInterface::connectToParticipantManagement(int port)
|
||||
{
|
||||
emit statusMessage(tr("Connecting to ParticimantManagement on %1 : %2 ").arg(m_hostname).arg(port));
|
||||
m_socket->close();
|
||||
m_port = port;
|
||||
QUrl url = QUrl(QLatin1String("ws://") + m_hostname + QLatin1Char(':') + QString::number(port));
|
||||
m_awss_state = AWSS_STATE::ConnectToParticipantManagement;
|
||||
|
||||
m_socket->open(url);
|
||||
}
|
||||
|
||||
void WebSocketInterface::connectToProxy(int port, int partyId, const QString &partyName)
|
||||
{
|
||||
emit statusMessage(tr("Connecting to Proxy on %1 : %2 for party: %3").arg(m_hostname).arg(port).arg(partyName));
|
||||
m_socket->close();
|
||||
m_port = port;
|
||||
m_partyId = partyId;
|
||||
m_partyName = partyName;
|
||||
QUrl url = QUrl(QLatin1String("ws://") + m_hostname + QLatin1Char(':') + QString::number(port));
|
||||
m_awss_state = AWSS_STATE::ConnectToProxy;
|
||||
m_socket->open(url);
|
||||
|
||||
}
|
||||
|
||||
void WebSocketInterface::sendToProxy(const QString &message)
|
||||
{
|
||||
if (m_socket->state() != QAbstractSocket::ConnectedState)
|
||||
return;
|
||||
m_socket->sendTextMessage(message);
|
||||
}
|
||||
|
||||
void WebSocketInterface::sendFlugbahndaten(QString uuid)
|
||||
{
|
||||
AdlerJson::ExFlugbahndaten req;
|
||||
NOTICE_LOG(m_logger) << "WebSocketInterface::sendFlugbahndaten uuid=" << uuid;
|
||||
GenerateTelegrams::addHeaderData(req, m_saaId);
|
||||
GenerateTelegrams::generateFlugbahndaten(req);
|
||||
req.referenceUuid = uuid;
|
||||
|
||||
QJsonObject messageObj =req.toJson();
|
||||
QString message = QString::fromUtf8(QJsonDocument(messageObj).toJson());
|
||||
sendToProxy(message);
|
||||
}
|
||||
|
||||
|
||||
void WebSocketInterface::onTextMessageRecived(const QString &message)
|
||||
{
|
||||
switch (m_awss_state)
|
||||
{
|
||||
case AWSS_STATE::RequestServicePorts:
|
||||
emit statusMessage(tr("Recieved Service Ports"));
|
||||
emit gotServiceData(message);
|
||||
break;
|
||||
case AWSS_STATE::RequestExerciseInformation:
|
||||
emit statusMessage(tr("Recieved Exercise Information"));
|
||||
emit gotExerciseData(message);
|
||||
break;
|
||||
case AWSS_STATE::RequestPartyInformation:
|
||||
emit statusMessage(tr("Recieved Party Information"));
|
||||
emit gotPartyData(message);
|
||||
break;
|
||||
case AWSS_STATE::ConnectedToProxy:
|
||||
emit statusMessage(tr("Recieved Message"));
|
||||
emit proxyMessage(message);
|
||||
//emit gotPartyData(message);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(message.toUtf8());
|
||||
const QJsonObject jsonObj = jsonDoc.object();
|
||||
if ( jsonObj.contains(QStringLiteral("type")))
|
||||
if ( jsonObj.value(QStringLiteral("type")) == QStringLiteral("EX-Flugbahnberechnung"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "type=" << jsonObj.value(QStringLiteral("type")).toString();
|
||||
DEBUG_LOG(m_logger) << "reciver=" << jsonObj.value(QStringLiteral("reciver")).toString();
|
||||
DEBUG_LOG(m_logger) << "sender=" << jsonObj.value(QStringLiteral("sender")).toString();
|
||||
DEBUG_LOG(m_logger) << "timestamp=" << jsonObj.value(QStringLiteral("timestamp")).toString();
|
||||
DEBUG_LOG(m_logger) << "uuid=" << jsonObj.value(QStringLiteral("uuid")).toString();
|
||||
|
||||
|
||||
DEBUG_LOG(m_logger) << "Sende Flugbahndaten";
|
||||
if ( !jsonObj.contains(QStringLiteral("uuid")))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "No uuid available"
|
||||
<< ", message=" << message;
|
||||
return;
|
||||
}
|
||||
QString uuid = jsonObj.value(QStringLiteral("uuid")).toString();
|
||||
sendFlugbahndaten(uuid);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Received Message from WebSocket: "
|
||||
<< ", port :" << m_port
|
||||
<< ", message : " << message;
|
||||
}
|
||||
|
||||
void WebSocketInterface::onConnected()
|
||||
{
|
||||
switch (m_awss_state)
|
||||
{
|
||||
case AWSS_STATE::ConnectToServer:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectedToServer;
|
||||
DEBUG_LOG(m_logger) << "ConnectedToServer";
|
||||
emit statusMessage(tr("Connected To ServiceManagement"));
|
||||
requestServicePortInformation();
|
||||
break;
|
||||
}
|
||||
case AWSS_STATE::ConnectToExerciseManagement:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectedToExerciseManagement;
|
||||
DEBUG_LOG(m_logger) << "ConnectedToExercise";
|
||||
emit statusMessage(tr("Connected To ExerciseManagement for Exercise"));
|
||||
requestExcerciseInformation();
|
||||
break;
|
||||
}
|
||||
case AWSS_STATE::ConnectToParticipantManagement:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectedToParticipantManagement;
|
||||
DEBUG_LOG(m_logger) << "ConnectedToParticipantManagement";
|
||||
emit statusMessage(tr("Connected To ParticipantManagement for Exercise"));
|
||||
requestPartyInformation();
|
||||
break;
|
||||
}
|
||||
case AWSS_STATE::ConnectToProxy:
|
||||
{
|
||||
emit statusMessage(tr("Connected To Exercise Proxy for party: %1").arg(m_partyName));
|
||||
m_awss_state = AWSS_STATE::ConnectedToProxy;
|
||||
DEBUG_LOG(m_logger) << "ConnectedToProxy";
|
||||
//TEST
|
||||
emit connectedToParty(m_partyId, m_partyName, m_saaId);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
emit statusMessage(tr("Connected during wrong connection State"));
|
||||
|
||||
DEBUG_LOG(m_logger) << "connected during wrong connection State";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WebSocketInterface::onReconnect()
|
||||
{
|
||||
|
||||
DEBUG_LOG(m_logger) << "Disconnected - current state: " << m_awss_state;
|
||||
|
||||
|
||||
switch (m_awss_state)
|
||||
{
|
||||
case AWSS_STATE::RequestServicePorts:
|
||||
case AWSS_STATE::ConnectedToServer:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectToServer;
|
||||
emit statusMessage(tr("Try Recconect to ServiceManagement"));
|
||||
connectToServer(m_hostname, m_port, m_saaId);
|
||||
break;
|
||||
}
|
||||
case AWSS_STATE::ConnectedToExerciseManagement:
|
||||
case AWSS_STATE::RequestExerciseInformation:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectToExerciseManagement;
|
||||
emit statusMessage(tr("Try Recconect to ExceriseManagement"));
|
||||
connectToExerciseManagement(m_port);
|
||||
break;
|
||||
}
|
||||
case AWSS_STATE::ConnectToParticipantManagement:
|
||||
case AWSS_STATE::RequestPartyInformation:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectToParticipantManagement;
|
||||
|
||||
emit statusMessage(tr("Try Recconect to ParticipantManagement"));
|
||||
connectToParticipantManagement(m_port);
|
||||
break;
|
||||
}
|
||||
case AWSS_STATE::ConnectToProxy:
|
||||
case AWSS_STATE::ConnectedToProxy:
|
||||
{
|
||||
m_awss_state = AWSS_STATE::ConnectToProxy;
|
||||
emit statusMessage(tr("Try Recconect to TrainingAreaBase Proxy for party:").arg(m_partyName));
|
||||
connectToProxy(m_port, m_partyId, m_partyName);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DEBUG_LOG(m_logger) << "Disconnected during wrong connection State";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WebSocketInterface::onDisconnected()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "On DisConnect: " ;
|
||||
emit statusMessage(tr("Discconected "));
|
||||
// QTimer::singleShot(10000,this, &WebSocketInterface::onReconnect);
|
||||
}
|
||||
|
||||
void WebSocketInterface::onError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "On Error: " << error;
|
||||
emit statusMessage(tr("got Socket Error: %1").arg(error));
|
||||
QTimer::singleShot(10000,this, &WebSocketInterface::onReconnect);
|
||||
//onReconnect();
|
||||
}
|
||||
|
||||
} //namespace AdlerWebSocketSimulator
|
||||
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Websocket interface for ADLER WebsocketSimulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QObject>
|
||||
#include <QtWebSockets/QtWebSockets>
|
||||
|
||||
#include "logger.h"
|
||||
#include <AdlerJson/generatetelegrams.h>
|
||||
|
||||
namespace AdlerWebSocketSimulator {
|
||||
|
||||
|
||||
enum AWSS_STATE {
|
||||
Unconnected,
|
||||
ConnectToServer,
|
||||
ConnectedToServer,
|
||||
RequestServicePorts,
|
||||
ConnectToParticipantManagement,
|
||||
ConnectedToParticipantManagement,
|
||||
RequestExerciseInformation,
|
||||
ConnectToExerciseManagement,
|
||||
ConnectedToExerciseManagement,
|
||||
RequestPartyInformation,
|
||||
ConnectToProxy,
|
||||
ConnectedToProxy,
|
||||
};
|
||||
|
||||
class WebSocketInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WebSocketInterface(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief disconnects and resets everyting to startuip.
|
||||
*
|
||||
*/
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void gotServiceData(const QString &message);
|
||||
void gotExerciseData(const QString &message);
|
||||
void gotPartyData(const QString &message);
|
||||
void connectedToExercise();
|
||||
void connectedToParty(int id, const QString &name, int saaId);
|
||||
|
||||
/**
|
||||
* @brief emits a Status Message during operations.
|
||||
*
|
||||
*/
|
||||
void statusMessage(const QString& message);
|
||||
/**
|
||||
* @brief emits a an incommin message from proxy.
|
||||
*
|
||||
*/
|
||||
void proxyMessage(const QString& message);
|
||||
|
||||
private:
|
||||
void requestServicePortInformation();
|
||||
void requestExcerciseInformation();
|
||||
void requestPartyInformation();
|
||||
void sendFlugbahndaten(QString uuid);
|
||||
|
||||
public slots:
|
||||
void connectToServer(const QString servername, int port, int saaId);
|
||||
void connectToExerciseManagement(int port);
|
||||
void connectToParticipantManagement(int port);
|
||||
void connectToProxy(int port, int partyId, const QString &partyName);
|
||||
void sendToProxy(const QString &message);
|
||||
|
||||
|
||||
|
||||
private slots:
|
||||
void onTextMessageRecived(const QString &message);
|
||||
void onConnected();
|
||||
void onReconnect();
|
||||
void onDisconnected();
|
||||
|
||||
void onError(QAbstractSocket::SocketError error);
|
||||
|
||||
private:
|
||||
QWebSocket *m_socket {nullptr};
|
||||
AWSS_STATE m_awss_state {AWSS_STATE::Unconnected};
|
||||
|
||||
QString m_hostname {QString()};
|
||||
int m_port {0};
|
||||
int m_saaId {0};
|
||||
int m_partyId {0};
|
||||
QString m_partyName {QString()};
|
||||
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
} // namespace AdlerWebSocketSimulator
|
||||
@@ -0,0 +1,92 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=INFO, file
|
||||
|
||||
# Service: ReportManagement
|
||||
###########################################################
|
||||
|
||||
#log4j.logger.REP=DEBUG
|
||||
#log4j.logger.REP.main=DEBUG
|
||||
#log4j.logger.REP.MainHandler=DEBUG
|
||||
#log4j.logger.REP.HandlerDynamicParticipantData=DEBUG
|
||||
#log4j.logger.REP.HandlerReportData=DEBUG
|
||||
#log4j.logger.REP.ObjectReportInfo=DEBUG
|
||||
#log4j.logger.REP.DbHandler=DEBUG
|
||||
#log4j.logger.REP.DdsHandler=DEBUG
|
||||
#log4j.logger.REP.Settings=INFO
|
||||
#log4j.logger.REP.Publisher=INFO
|
||||
#log4j.logger.REP.FtsImpl=INFO
|
||||
#log4j.logger.REP.FtcImpl=INFO
|
||||
#log4j.logger.REP.FtTest=DEBUG
|
||||
|
||||
|
||||
# Service: PresentationManagement
|
||||
###########################################################
|
||||
#log4j.logger.PRE=DEBUG
|
||||
|
||||
|
||||
# File
|
||||
###########################################################
|
||||
log4j.appender.file=Lts::RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for ADLER Websocket Simulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace AdlerWebSocketSimulator
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "ALM.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace AdlerWebSocketSimulator
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for ADLER Websocket Simulator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
namespace AdlerWebSocketSimulator
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace AdlerWebSocketSimulator
|
||||
Executable
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* @RDE_HEADER@
|
||||
* Main for AdlerSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Patric Karwat, ESZS, 2025-03-03
|
||||
*/
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QPointF>
|
||||
|
||||
#include <QSettings>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <nglapplication/nglloggerhandler.h>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltranslator/ngltranslator.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
|
||||
#include "awss_base_layout.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QCoreApplication::setApplicationName(QLatin1String("ADLER Websocket Simulator"));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("RME"));
|
||||
|
||||
NGLApplication app(argc, argv);
|
||||
QApplication::setQuitOnLastWindowClosed(true); // we are cool enough to handle it ourselves 8)
|
||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
QNetworkProxy::setApplicationProxy(QNetworkProxy()); // do NOT use proxies anywhere!
|
||||
|
||||
app.createLogger("awss", "log4cxx_adlerWebSocketSimulator.props");
|
||||
NGL::INGLLogger &logger = app.baseLogger();
|
||||
QScopedPointer<QSettings> settings(new QSettings(app.organizationName(), app.applicationName()));
|
||||
|
||||
ERROR_LOG(logger) << "Settings Directory: " << settings->fileName();
|
||||
|
||||
LtsCommandLineParser::LtsCommandLineParser options(LtsCommandLineParser::LtsCommandLineParser::CustomConfigFile);
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("p") << QLatin1String("port")
|
||||
, QLatin1String("port to connect to server")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("2300")
|
||||
});
|
||||
|
||||
options.addOption({ QStringList() << QLatin1String("s") << QLatin1String("server")
|
||||
, QLatin1String("hostname or Ip of the server")
|
||||
, QLatin1String("Default value")
|
||||
, QLatin1String("exctds01")
|
||||
});
|
||||
|
||||
if (!options.init())
|
||||
{
|
||||
options.showHelp();
|
||||
return -1;
|
||||
}
|
||||
QSettings serverSettings(app.applicationDirPath() + QLatin1String("/") + options.iniFile(), QSettings::IniFormat);
|
||||
|
||||
DEBUG_LOG(logger) << "Starting Server";
|
||||
AdlerWebSocketSimulator::BaseLayout *bl = new AdlerWebSocketSimulator::BaseLayout();
|
||||
bl->show();
|
||||
int ret = app.exec();
|
||||
|
||||
// delete s;
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in new issue
Block a user