Files
torstenandCopilot 7a6be7474e Qt6 migration: Fix BUILD_RTI=OFF build errors in TrainingAreaBase
- training_area_telegrams.cpp: Fixed QJsonObject initializer syntax (Qt6 requires {{}} not ({}))
- training_area_telegrams.cpp: Fixed fromJson() methods to access m_* members directly
- training_area_telegrams.cpp: Fixed brace mismatches in multiple toJson() methods
- training_area_telegrams.h: Changed Header struct to public members for consistency
- tx_mixin.cpp: Fixed getEquipmentNumber() template for direct member access
- lts_coordinate.cpp: Added missing #include <iomanip>
- MIGRATION_STATUS.md: Added migration progress tracking document

C++17 constraint enforced due to RTI Connext DDS 7.7.0 incompatibility with C++20+

Build status: BUILD_RTI=OFF successful (0 errors, warnings only)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-08-23 20:49:23 +02:00

200 lines
3.6 KiB
C++
Executable File

#pragma once
#include <NGLLogger/NGLLoggerBootstrap.h>
#include <QtCore/QXmlStreamReader>
#include <QtCore/QVector>
#include <QtCore/QUrl>
namespace BuildingControlUnit
{
class HandelEffect;
enum EffectType
{
ET_Unset = 0,
ET_Relay = 1,
ET_BackgroundSound = 2,
ET_BsmFlash = 3,
};
enum EffectOverride
{
EO_Auto = -1,
EO_Off = 0,
EO_On = 1,
};
enum ActionType
{
AT_Off = 0,
AT_On = 1,
AT_Infinite = 2,
AT_Flash = 3
};
enum ActionClass
{
AC_Unset,
AC_Standard,
AC_Repeat,
AC_Pause,
AC_Bsm
};
enum Category
{
CT_Default = 0,
CT_BGS_Bahnhof = 1,
CT_BGS_Personen = 2,
CT_BGS_Sonstige = 3,
CT_BGS_Stadt = 4,
CT_BGS_Testsounds = 5,
CT_BGS_Aircrafts = 6,
CT_BGS_Battlefields = 7,
CT_BGS_Boats = 8,
CT_BGS_Explosions = 9,
CT_BGS_Helicopter = 10,
CT_BGS_Motors_and_urban_traffic = 11,
CT_BGS_InsideBuildings = 12,
CT_BGS_Vehicles = 13
};
class Action
{
public:
Action(ActionClass ac = AC_Unset)
: aclass(ac)
{}
ActionClass aclass = AC_Unset;
ActionType atype = AT_Off;
QUrl url;
QString comment;
};
class RepeatAction : public Action
{
public:
RepeatAction()
: Action(AC_Repeat)
{}
int count = -1;
QVector<Action *> actions;
};
class PauseAction : public Action
{
public:
PauseAction()
: Action(AC_Pause)
{}
int pause = 0;
};
class BsmAction : public Action
{
public:
bool isNull() const { return (count == 0 && pause == 0 && pulses == 0); }
int count = 0;
int pause = 0;
int choplength = 0;
int pulses = 0;
int pulseduration = 0;
BsmAction() : Action(AC_Bsm) {}
};
class Range
{
public:
inline bool fits(int value) const { return (min <= value && value <= max); }
int min = 0;
int max = 100;
bool restartOnChange = false;
QVector<Action *> actions;
};
class Effect
{
public:
Range* getRangeByDamagePercent(int damagePercent) const;
EffectType effectType = ET_Unset;
Category category = CT_Default;
int id = 0;
QString name;
QVector<Range *> ranges;
HandelEffect *effectHandler = nullptr;
EffectOverride override = EO_Auto;
const QVector<Range *> constRanges() const { return ranges; }
};
struct XmlContents
{
QVector<Effect *> effects;
int hitSoundVolume = 50;
int bgSoundVolume = 50;
QString username;
QString password;
int port = 80;
int updateRelayState = 1000;
const QVector<Effect *> constEffects() const { return effects; }
QString toString() const
{
QString str(QStringLiteral("User: %1, Password: %2, Port: %3, BGSound Vol: %4, HitSound Vol: %5, No of Effects: %6"));
return str.arg(username, password).arg(port).arg(bgSoundVolume).arg(hitSoundVolume).arg(effects.count());
}
};
class XmlReader : public QObject
{
Q_OBJECT
public:
explicit XmlReader(QObject *parent = nullptr);
~XmlReader() = default;
static QUrl createPreparedUrl(const XmlContents &contents, const QString &hostname = QString());
bool init(const QString &effectConfigFile);
XmlContents contents() const { return m_contents; }
private:
NGL::INGLLogger &m_logger;
void createHttpRequests();
static QString categoryName(Category c);
Effect *parseEffect(QXmlStreamReader &xml);
Range *parseRange(QXmlStreamReader &xml);
Action *parseAction(QXmlStreamReader &xml);
PauseAction *parsePauseAction(QXmlStreamReader &xml);
RepeatAction *parseRepeatAction(QXmlStreamReader &xml);
BsmAction* parseBsmAction(QXmlStreamReader &xml);
Action *parseStandardAction(QXmlStreamReader &xml);
void generateUrls(const Effect *e, const QVector<Action *> &actions);
void generateUrl(const Effect *e, Action *a);
XmlContents m_contents;
};
}