Files
qt5-legatus-legacy/Lts/Services/OcSituationClient/handler_oc_situation_data.h
T
2026-08-13 18:33:10 +02:00

132 lines
5.1 KiB
C++
Executable File

/**
* Handler for all oc situation data at the client
* $Id$
* $HeadURL$
* $Author$
* Created by Philipp Dassow, NLST, 01-03-2018
*/
#pragma once
#include <QHash>
#include <ParticipantManagement/ppm_dtc.h>
#include <ParticipantManagement/ppm_ftc.h>
#include <OcSituationServer/oc_situation.h>
#include <TrainingAreaBase/tab_dts.h>
#include <TrainingAreaBaseOC/taboc_dtc.h>
#include <TrainingAreaBaseOC/taboc_dts.h>
#include "dds_handler.h"
#include "logger.h"
namespace OcSituationClient
{
class HandlerOcSituationData : public QObject
, protected ParticipantManagement::Interface::Ftc::ModifyParticipantDataReplyHandler
{
Q_OBJECT
public:
explicit HandlerOcSituationData(const std::shared_ptr<DdsHandler> &dds,
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
const std::shared_ptr<ParticipantManagement::Interface::Ftc> &ppmFtc,
const std::shared_ptr<TrainingAreaBase::Interface::Dts> &tabDts,
const std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> &tabocDtc,
const std::shared_ptr<TrainingAreaBaseOC::Interface::Dts> &tabocDts,
QObject *parent);
~HandlerOcSituationData();
bool init();
void process(const QByteArray &data, bool bIsInitial);
void removeAllPositions();
void setInvalidPositionForParticipant(int participantId);
void onModifyParticipantDataReply(const Core::FunctionReplyObject &reply);
bool withCompression() const { return m_bWithCompression; }
void setWithCompression(bool bOn) { m_bWithCompression = bOn; }
bool withVBGTime() const { return m_bWithVBGTime; }
void setWithVBGTime(bool bOn) { m_bWithVBGTime = bOn; }
private:
bool decodeSituationData(const QByteArray &data);
void sendParticipantData(int requestId);
template <typename T>
void publishMap(QMap<int, T> &map);
void sendTrainingAreaBaseData();
bool getParticipantId(const QByteArray &buf,
size_t &pos,
int &participantId,
OcSituation::ModificationBits &modifiedFlags) const;
bool getPosition2D(const QByteArray &buf,
size_t &pos,
TrainingAreaBase::EquipmentPosition &position,
bool bAvailable) const;
bool getPosition3D(const QByteArray &buf,
size_t &pos,
TrainingAreaBase::EquipmentPosition &position,
bool bAvailable) const;
bool getVBG(const QByteArray &buf,
size_t &pos,
TrainingAreaBase::EquipmentState &equipmentState,
TrainingAreaBase::ParticipantSanitation &sanitation,
bool bAvailable) const;
bool getState(const QByteArray &buf,
size_t &pos,
TrainingAreaBase::SpecialSensorData &specialSensorData,
TrainingAreaBase::EquipmentOperationalState &equipmentOperationalState,
bool bAvailable) const;
bool getStructure(const QByteArray &buf,
size_t &pos,
ParticipantManagement::ParticipantData &participant,
bool bAvailable) const;
bool getDesignator(const QByteArray &buf,
size_t &pos,
ParticipantManagement::ParticipantData &participant,
bool bAvailable) const;
bool getSymbolSidc(const QByteArray &buf,
size_t &pos,
ParticipantManagement::ParticipantData &participant,
bool bAvailable) const;
void onPartyChanged(const ParticipantManagement::Party &party, DataModification mod);
void onParticipantChanged(const ParticipantManagement::Participant &participant, DataModification mod);
private:
// for partition time
std::shared_ptr<DdsHandler> m_dds;
// data publishing
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
std::shared_ptr<ParticipantManagement::Interface::Ftc> m_ppmFtc;
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
std::shared_ptr<TrainingAreaBaseOC::Interface::Dtc> m_tabocDtc;
std::shared_ptr<TrainingAreaBaseOC::Interface::Dts> m_tabocDts;
// internal participant data
// all paired to thier participantId
QMap<int, ParticipantManagement::ParticipantData> m_participantData;
QMap<int, TrainingAreaBase::EquipmentPosition> m_equipmentPositions;
QMap<int, TrainingAreaBase::EquipmentState> m_equipmentStates;
QMap<int, TrainingAreaBase::ParticipantSanitation> m_participantSanitations;
QMap<int, TrainingAreaBase::EquipmentOperationalState> m_equipmentOperationalStates;
QMap<int, TrainingAreaBase::SpecialSensorData> m_specialSensorData;
// internal management data
QHash<int, int> m_participantId2EqId;
QHash<int, ParticipantManagement::ModifyParticipantDataRequest *> m_modifiyRequests;
QSet<int> m_knownParties;
QHash<int, ParticipantManagement::Participant> m_participants;
int m_requestId = 1;
// options, must be in sync with oss
bool m_bWithCompression = true;
bool m_bWithVBGTime = true;
LOGGER_T &m_logger;
};
} // namespace OcSituationClient