- 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>
200 lines
5.4 KiB
C++
Executable File
200 lines
5.4 KiB
C++
Executable File
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <QByteArray>
|
|
#include <QObject>
|
|
#include <QQueue>
|
|
#include <QStringBuilder>
|
|
#include <QTimer>
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include <TrainingAreaBase/training_area_telegrams.h>
|
|
|
|
#include "logger.h"
|
|
#include "settings.h"
|
|
|
|
inline Q_CONSTEXPR double pi() { return M_PI; }
|
|
inline Q_CONSTEXPR double deg2rad() { return pi() / 180.; }
|
|
|
|
namespace WirelessLocationSystem
|
|
{
|
|
class Acknowledge_rx;
|
|
class SfmMsgTetra_rx;
|
|
class SfmMsgTetra_tx;
|
|
|
|
class WlsParticipant : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
static int calcWlsZone(int wlsAreaId, int wlsBuildingId, int wlsRoomNumber)
|
|
{
|
|
if (wlsAreaId == 0 && wlsBuildingId == 0 && wlsRoomNumber == 0)
|
|
return 3;
|
|
if (wlsAreaId != 0 && wlsBuildingId == 1002 && wlsRoomNumber == 1001)
|
|
return 4;
|
|
if (wlsAreaId != 0 && wlsBuildingId == 0 && wlsRoomNumber == 0)
|
|
return 5;
|
|
|
|
return 6;
|
|
}
|
|
static bool mustSendGpsOn(int wlsZoneOld, int wlsZoneNew)
|
|
{
|
|
|
|
if (wlsZoneOld == -1)
|
|
return wlsZoneNew <= 4;
|
|
|
|
return (wlsZoneOld >= 4 && wlsZoneNew <= 3);
|
|
}
|
|
static bool mustSendGpsOff(int wlsZoneOld, int wlsZoneNew)
|
|
{
|
|
|
|
if (wlsZoneOld == -1)
|
|
return wlsZoneNew >= 5;
|
|
|
|
return (wlsZoneOld <= 4 && wlsZoneNew >= 5);
|
|
}
|
|
|
|
enum class GpsMode : char
|
|
{
|
|
Off,
|
|
On
|
|
};
|
|
enum class DataCommunication : char
|
|
{
|
|
Unknown,
|
|
Off,
|
|
On
|
|
};
|
|
|
|
struct RelativePosition
|
|
{
|
|
double x = 0;
|
|
double y = 0;
|
|
double z = 0;
|
|
int wlsAreaId = 0;
|
|
int wlsBuildingId = 0;
|
|
int wlsRoomNumber = 0;
|
|
int playerOrientation = 0;
|
|
int weaponOrientation = 0;
|
|
bool isValid = false;
|
|
|
|
} ;
|
|
|
|
static bool comparePos (const RelativePosition &rhs, const RelativePosition &lhs )
|
|
{
|
|
double dx = ((lhs.x/deg2rad())-(rhs.x/deg2rad()));
|
|
double dy = ((lhs.y/deg2rad())-rhs.y/deg2rad());
|
|
double dz = (lhs.z-rhs.z);
|
|
double dist = dx*dx + dy*dy + dz*dz;
|
|
|
|
|
|
bool ret = dist < Settings::wlsSquareDistanceMax()
|
|
&& lhs.wlsAreaId == rhs.wlsAreaId
|
|
&& lhs.wlsBuildingId == rhs.wlsBuildingId
|
|
&& lhs.wlsRoomNumber == rhs.wlsRoomNumber;
|
|
|
|
|
|
|
|
return ret;
|
|
}
|
|
protected:
|
|
explicit WlsParticipant(QObject *parent = nullptr);
|
|
public:
|
|
void setPosition(const RelativePosition &newPosition, qint64 tsCurrentPos);
|
|
bool positionIsValid() const { return m_relativePosition.isValid; }
|
|
qint64 positionTimestamp() const { return m_lastValidPosition; }
|
|
RelativePosition position() const { return m_relativePosition; }
|
|
bool isGpsMode() const { return m_gpsMode == WlsParticipant::GpsMode::On; }
|
|
|
|
void checkGpsOnOffTimeoutTimer(qint64 tNow);
|
|
void setLastSeenWlsTelegramTime(qint64 ts);
|
|
qint64 lastSeenWlsTelegramTime() const { return m_lastSeenDataCommunication; }
|
|
|
|
void setWlsZone(int newWlsZone);
|
|
int wlsZone() const { return m_wlsZone; }
|
|
|
|
QByteArray getPlayerIdStr() const;
|
|
|
|
const QByteArray &tagId() const { return m_tagId; }
|
|
void setEquipmentNumber(int newEquipmentNumber);
|
|
int equipmentNumber() const { return m_equipmentNumber; }
|
|
int exerciseId() const { return m_exerciseId; }
|
|
void setExerciseId(int exerciseId) { m_exerciseId = exerciseId; }
|
|
bool isDataCommunicationPossible() const { return m_dataCommunication == DataCommunication::On; }
|
|
DataCommunication dataCommunication() const { return m_dataCommunication; }
|
|
GpsMode gpsMode() const { return m_gpsMode; }
|
|
|
|
bool handleSfmRxData(const SfmMsgTetra_rx *sfmTele);
|
|
bool isSfmRxDataAvailable() const { return m_bSfmPayloadReady; }
|
|
uint8_t nextSfmRxDataFragmentCounter() const { return m_sfmRxPayloadFragmentNumber; }
|
|
const QByteArray &sfmRxData() const { return m_sfmRxPayloadData; }
|
|
|
|
static bool calcChunkCountAndLen(const QByteArray &data, int &chunkCount, int &chunkLen);
|
|
void sendBinarySfmData(const std::vector<unsigned char> &data);
|
|
void handleWlsAck(const Acknowledge_rx *ack);
|
|
|
|
TrainingAreaBase::TetraIcd::WlsParticipantState wlsParticipantState() const;
|
|
|
|
|
|
double voltage = 0;
|
|
qint64 lastEquipmentNumberRequest = 0;
|
|
|
|
Q_SIGNALS:
|
|
void positionChanged(WlsParticipant *p);
|
|
void gpsOnOffChanged(WlsParticipant *p);
|
|
void wlsBinarySfmDataComplete(WlsParticipant *p);
|
|
void dataCommunicationStateChanged(WlsParticipant *p);
|
|
void dataForWls(WlsParticipant *p, const SfmMsgTetra_tx &data);
|
|
private Q_SLOTS:
|
|
void checkSendTele();
|
|
void sendNextWlsTelegram(bool bIsResend);
|
|
void onWlsTeleTimeout();
|
|
private:
|
|
uint8_t getNextSendCounter(bool bIsResend);
|
|
bool isRecvCounterCorrect(uint8_t recvCounter);
|
|
private:
|
|
struct WlsPayloadData
|
|
{
|
|
QByteArray payload;
|
|
uint8_t retryCount = 0;
|
|
uint8_t fragmentCount = 0;
|
|
uint8_t fragmentNumber = 0;
|
|
};
|
|
|
|
friend class WlsParticipantHandler;
|
|
QByteArray m_tagId;
|
|
QByteArray m_sfmRxPayloadData;
|
|
QQueue<WlsPayloadData> m_currentFragmentedTeleQueue;
|
|
QQueue<WlsPayloadData> m_wlsQueue;
|
|
|
|
uint8_t m_sfmRxPayloadFragmentNumber = 0;
|
|
bool m_bSfmPayloadReady = false;
|
|
|
|
int m_equipmentNumber = 0;
|
|
int m_exerciseId = 0;
|
|
|
|
int m_wlsZone = -1;
|
|
|
|
RelativePosition m_relativePosition;
|
|
GpsMode m_gpsMode = GpsMode::On;
|
|
DataCommunication m_dataCommunication = DataCommunication::Unknown;
|
|
qint64 m_lastSeenDataCommunication = 0;
|
|
qint64 m_lastValidPosition = 0;
|
|
qint64 m_lastSeenPosition = 0;
|
|
|
|
QTimer *m_wlsTeleTimeoutTimer = nullptr;
|
|
int m_wlsTeleTimeoutCounter = 0;
|
|
uint8_t m_nextSendCounter = 0;
|
|
uint8_t m_lastRecvCounter = 0;
|
|
};
|
|
|
|
std::ostream &operator<<(std::ostream &stream, WlsParticipant::GpsMode gm);
|
|
std::ostream &operator<<(std::ostream &stream, WlsParticipant::DataCommunication dc);
|
|
|
|
}
|
|
|