Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+304
@@ -0,0 +1,304 @@
|
||||
/**
|
||||
* Connect to ngs / hla and provide the basic interface
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, SLSE, 2017-04-07
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Common/participantposition.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointF>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
#include <QTransform>
|
||||
|
||||
#include <WorldLocationStruct.h>
|
||||
#include <EntityTypeStruct.h>
|
||||
|
||||
#include <ProjectDataManagement/pdm_enums.hpp>
|
||||
|
||||
#include <IObserver.h>
|
||||
#include <IPlayerBaseEntityObjInstance.h>
|
||||
|
||||
#include <IObserverObjectInstance.h>
|
||||
#include <IObserverEmbeddedSystemObjInstance.h>
|
||||
|
||||
#include <ForceIdentifierEnum8.h>
|
||||
#include <DamageStatusEnum32.h>
|
||||
#include <DesignatorCodeEnum16.h>
|
||||
#include <DetonationResultCodeEnum8.h>
|
||||
#include <SensorFieldEnum32.h>
|
||||
#include <ClockTimeStruct.h>
|
||||
#include <ArrayOfWorldLocationStructDynamicHLAlengthlessVarArray.h>
|
||||
#include <ArrayOfHLAoctetN_slsh_AperfectalwaysN_slsh_ADynamicHLApaddingTo32Array.h>
|
||||
#include <Core/core.hpp>
|
||||
// For LaserDesignation
|
||||
#include <TrainingAreaBase/tab.hpp>
|
||||
|
||||
namespace ngs
|
||||
{
|
||||
class ISimulatedWorldAdmin;
|
||||
class IFederationMaster;
|
||||
}
|
||||
|
||||
namespace rpr2
|
||||
{
|
||||
class IPlayerSOM;
|
||||
class MarkingStruct;
|
||||
class IPlayerPhysicalEntityObjInstance;
|
||||
class IPlayerEnvironmentObjectObjInstance;
|
||||
class OMT13string;
|
||||
class EventIdentifierStruct;
|
||||
|
||||
class IObserverEngagementReplyIntInstance;
|
||||
class IObserverEventReportIntInstance;
|
||||
class IObserverMunitionDetonationIntInstance;
|
||||
class IObserverWeaponFireIntInstance;
|
||||
class IObserverDesignatorObjInstance;
|
||||
}
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace AreaEffectSimulation {
|
||||
class AirSupportImpactModifyRequest;
|
||||
}
|
||||
namespace TrainingAreaBase
|
||||
{
|
||||
class EquipmentGearEvent;
|
||||
class EquipmentGearChargeState;
|
||||
class EquipmentGearAssignment;
|
||||
class EquipmentState;
|
||||
class SendCesHitInformation;
|
||||
class SpecialSensorData;
|
||||
}
|
||||
|
||||
namespace ParticipantManagement
|
||||
{
|
||||
class ParticipantGearEvent;
|
||||
class StateInformation;
|
||||
}
|
||||
|
||||
namespace LtsCoordTrans
|
||||
{
|
||||
struct UtmCoordinate;
|
||||
}
|
||||
|
||||
class ObserverHumanCBNotifier;
|
||||
class ObserverGroundVehicleCBNotifier;
|
||||
class ObserverLongBowApacheCBNotifier;
|
||||
class ObserverDesignatorCBNotifier;
|
||||
|
||||
class ObserverObjectCB;
|
||||
class ObserverBaseEntityObjectCB;
|
||||
class ObserverPhysicalEntityObjectCB;
|
||||
class ObserverPlatformObjectCB;
|
||||
class ObserverGroundVehicleObjectCB;
|
||||
class ObserverLifeformObjectCB;
|
||||
class ObserverHumanObjectCB;
|
||||
class ObserverAircraftObjectCB;
|
||||
class ObserverLongBowApacheObjectCB;
|
||||
|
||||
class ObserverEmbeddedSystemObjectCB;
|
||||
class ObserverDesignatorObjectCB;
|
||||
|
||||
class ObserverEngagementReplyCBNotifier;
|
||||
class ObserverEventReportCBNotifier;
|
||||
class ObserverMunitionDetonationCBNotifier;
|
||||
class ObserverWeaponFireCBNotifier;
|
||||
|
||||
class QTimer;
|
||||
|
||||
struct GuezHitStruct
|
||||
{
|
||||
qint32 targetId = 0;
|
||||
qint64 sampleTime = 0;
|
||||
ProjectDataManagement::VulnerabilityState vulnerabilityState = ProjectDataManagement::VulnerabilityState_def::get_default();
|
||||
qint32 vulnerabilityKind = 0;
|
||||
qint32 vulnerabilityBits = 0;
|
||||
Core::GeoPosition position = Core::GeoPosition(0, 0, 0);
|
||||
qint32 originatorId = 0;
|
||||
ProjectDataManagement::StateChangeOriginator originatorType = ProjectDataManagement::StateChangeOriginator_def::get_default();
|
||||
QString originatorChargeTypeEtsString;
|
||||
};
|
||||
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
class NgsHandler;
|
||||
class PlayerCallback;
|
||||
class DamageModel;
|
||||
class IdentifierStruct;
|
||||
class TypeStruct;
|
||||
struct ParticipantInformation;
|
||||
|
||||
class NgsConnector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
void connectObserverObjectSignals(ObserverObjectCB *entity);
|
||||
void connectObserverBaseEntityObjectSignals(ObserverBaseEntityObjectCB *entity);
|
||||
void connectObserverPhysicalEntityObjectSignals(ObserverPhysicalEntityObjectCB *entity);
|
||||
void connectObserverPlatformObjectSignals(ObserverPlatformObjectCB *entity);
|
||||
void connectObserverGroundVehicleObjectSignals(ObserverGroundVehicleObjectCB *entity);
|
||||
void connectObserverLifeformObjectSignals(ObserverLifeformObjectCB *entity);
|
||||
void connectObserverHumanObjectSignals(ObserverHumanObjectCB *entity);
|
||||
void connectObserverAircraftObjectSignals(ObserverAircraftObjectCB *entity);
|
||||
void connectObserverLongBowApacheObjectSignals(ObserverLongBowApacheObjectCB *entity);
|
||||
void connectObserverEmbeddedSystemObjectSignals(ObserverEmbeddedSystemObjectCB *entity);
|
||||
void connectObserverDesignatorObjectSignals(ObserverDesignatorObjectCB *entity);
|
||||
|
||||
void addObserverObjectInstance(const ngs::IObserverObjectInstance &obj);
|
||||
void removeObserverObjectInstance(const ngs::IObserverObjectInstance &obj);
|
||||
|
||||
void ensureDamageModelExists(const IdentifierStruct &is);
|
||||
|
||||
bool addBaseEntity(rpr2::IPlayerBaseEntityObjInstance *playerInstance, const ParticipantInformation &participantData);
|
||||
bool addPhysicalEntity(rpr2::IPlayerPhysicalEntityObjInstance *playerInstance, const ParticipantInformation &playerData);
|
||||
|
||||
static rpr2::MarkingStruct toMarkingStruct(const QString &designator);
|
||||
static rpr2::ClockTimeStruct getClockTimeStruct(qint64 msecsSinceEpoch);
|
||||
static qint64 getMSecsSinceEpoch(const rpr2::ClockTimeStruct &cts);
|
||||
rpr2::EntityTypeStruct getEtsCharge(int chargeType) const;
|
||||
|
||||
template<typename T>
|
||||
static rpr2::ArrayOfWorldLocationStructDynamicHLAlengthlessVarArray positionArray(const T &data);
|
||||
|
||||
static inline QTransform fromRotation(double rot) { return QTransform().rotate(rot); }
|
||||
|
||||
static QPolygonF utmToGeogrphic(const QPolygonF &polyUtm, const LtsCoordTrans::UtmCoordinate &base);
|
||||
|
||||
rpr2::EventIdentifierStruct getEventIdentifierStruct();
|
||||
bool setVulnerabilityState(int eqNo, const ParticipantManagement::StateInformation &state);
|
||||
static ProjectDataManagement::VulnerabilityState getVulnerabilityStateFromState(const ParticipantManagement::StateInformation &state);
|
||||
|
||||
int getEquipmentNoByRTIObjectId(const std::string &sender) const;
|
||||
|
||||
static ngs::SimTime getSimTime(qint64 msecsSinceEpoch = 0);
|
||||
static ngs::SimTime getSimTime(const QDateTime &dateTime);
|
||||
IdentifierStruct getIdentifierStructByEquipmentNo(const int eqId) const;
|
||||
rpr2::OMT13string getObjectIdentifierByEquipmentNo(const int eqId) const;
|
||||
|
||||
TrainingAreaBase::LaserDesignation getLaserDesignation(const IdentifierStruct &is, const rpr2::IObserverDesignatorObjInstance *instance, qint64 simTimeMSecs) const;
|
||||
|
||||
public:
|
||||
NgsConnector(const QString &fedName, NgsHandler *ngsHandler);
|
||||
~NgsConnector();
|
||||
|
||||
bool initialize(ngs::IObserver::ProtocolType protocol, const QString &playerName, const QString &appDirPath);
|
||||
void uninitialize();
|
||||
|
||||
bool canPublishData() const { return m_bCanPublishData; }
|
||||
|
||||
bool addHuman(const ParticipantInformation &participantData, const ProjectDataManagement::VulnerabilityState &state);
|
||||
bool addGroundVehicle(const ParticipantInformation &participantData, const ProjectDataManagement::VulnerabilityState &state);
|
||||
bool addLongBowApache(const ParticipantInformation &participantData, const ProjectDataManagement::VulnerabilityState &state);
|
||||
bool removeBaseEntity(int eqNo);
|
||||
|
||||
bool setParticipantName(int eqNo, const QString &designator);
|
||||
bool setParticipantHit(int eqNo, const ParticipantManagement::StateInformation &state,
|
||||
const ParticipantPosition &partPos, int chargeType,
|
||||
ProjectDataManagement::StateChangeOriginator originatorType, int originatorEqNo = 0);
|
||||
|
||||
bool setWorldLocation(int eqNo, const ParticipantPosition &pos);
|
||||
void sendMunitionDetonation(int targetEqId,
|
||||
ProjectDataManagement::ChargeType ct,
|
||||
int sourceEqId,
|
||||
rpr2::DetonationResultCodeEnum8::ET drc,
|
||||
qint64 timestamp);
|
||||
void sendParticipantInitRequest(int eqNo, bool resetManipulation, bool resetVulnerabilityState, bool restockCharges, qint64 simTimeMSecs);
|
||||
bool sendData(int eqNo, const QByteArray &data, int requestIdentifier);
|
||||
|
||||
protected slots:
|
||||
void go();
|
||||
void onFirstTickFinished();
|
||||
|
||||
signals:
|
||||
void spatialChanged(int eqId, const ParticipantPosition &pos, qint64 simTimeMSecs);
|
||||
void markingChanged(int eqId, const QString &marking, qint64 simTimeMSecs);
|
||||
void virtualParticipantDeleted(int eqId);
|
||||
void virtualEmbeddedSystemDeleted(int eqIdHost);
|
||||
void firstTickFinished();
|
||||
|
||||
void airSupportImpact(AreaEffectSimulation::AirSupportImpactModifyRequest &asi, int equipmentNumber);
|
||||
|
||||
void weaponFire(const TrainingAreaBase::EquipmentGearEvent &event);
|
||||
void gearAssignment(const TrainingAreaBase::EquipmentGearAssignment &event);
|
||||
void gearChargeState(const TrainingAreaBase::EquipmentGearChargeState &event);
|
||||
void exconEngagement(int eqNo, const ProjectDataManagement::VulnerabilityState &state);
|
||||
void equipmentState(const TrainingAreaBase::EquipmentState &event);
|
||||
void sensorChanged(const TrainingAreaBase::SpecialSensorData &event);
|
||||
void cesHitInformation(const TrainingAreaBase::SendCesHitInformation &event);
|
||||
void eventCountOverflow();
|
||||
void laserDesignation(const TrainingAreaBase::LaserDesignation &event);
|
||||
|
||||
protected:
|
||||
void subscribeAtNgs();
|
||||
void unsubscribeFromNgs();
|
||||
|
||||
int m_enitityNumberCounter;
|
||||
int m_eventCount;
|
||||
|
||||
NgsHandler *m_ngsHandler;
|
||||
const QString m_fedName;
|
||||
ngs::ISimulatedWorldAdmin *m_swadmin;
|
||||
ngs::IFederationMaster *m_master;
|
||||
rpr2::IPlayerSOM *m_somPlayer;
|
||||
PlayerCallback *m_playerCallback;
|
||||
|
||||
// Callbacks:
|
||||
ObserverHumanCBNotifier *m_humanCallback;
|
||||
ObserverGroundVehicleCBNotifier *m_groundVehicleCallback;
|
||||
ObserverLongBowApacheCBNotifier *m_longBowApacheCallback;
|
||||
ObserverDesignatorCBNotifier *m_designatorCallback;
|
||||
|
||||
ObserverEngagementReplyCBNotifier *m_iaEngagementReplyCallback;
|
||||
ObserverEventReportCBNotifier *m_iaEventReportCallback;
|
||||
ObserverMunitionDetonationCBNotifier *m_iaMunitionDetonationCallback;
|
||||
ObserverWeaponFireCBNotifier *m_iaWeaponFireCallback;
|
||||
|
||||
QMap<int, rpr2::IPlayerBaseEntityObjInstance *> m_playerMap; // Key: EqNo // All Players, WE handle
|
||||
QMap<int, const ngs::IObserverObjectInstance *> m_observerBaseEntityInstances; // Key: EqNo // All of THEIR Base Entities on the bus.
|
||||
QMap<int, const ngs::IObserverObjectInstance *> m_observerEmbeddedSystemInstances; // Key: EqNo // All of THEIR Players on the bus.
|
||||
QMap<int, ParticipantPosition> m_observerPositions; // Key: EqNo
|
||||
QMap<int, DamageModel *> m_damageModelMap; // Key: EqNo
|
||||
QSet<const ngs::IObserverObjectInstance *> m_newBaseEntitesWithoutParticipantIdSetIdSet;
|
||||
QSet<const ngs::IObserverObjectInstance *> m_newEmbeddedSystemsWithoutParticipantIdSet;
|
||||
|
||||
bool m_bInitialized;
|
||||
bool m_bCanPublishData;
|
||||
|
||||
QTimer *m_timer; // Todo: Start with 1 ms occurs! Needed?
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
static quint16 s_ownSiteId;
|
||||
static quint16 s_ownApplicationId;
|
||||
|
||||
static const int STATUS_WAIT_INTERVAL = 500; // Wartezeit auf Statusänderung
|
||||
static const int ACTIVATION_LEAD_TIME = 5000; // Vorlaufzeit beim Aktivieren von Wirkfeldern.
|
||||
|
||||
private slots:
|
||||
void onBaseEntityEntityIdentifierChanged(const rpr2::EntityIdentifierStruct &eis, const rpr2::IObserverBaseEntityObjInstance *obj, qint64 simTimeMSecs);
|
||||
void onEmbeddedSystemEntityIdentifierChanged(const rpr2::EntityIdentifierStruct &eis, const rpr2::IObserverEmbeddedSystemObjInstance *obj, qint64 simTimeMSecs);
|
||||
bool onSpatialChanged(const rpr2::EntityIdentifierStruct &eis, const rpr2::WorldLocationStruct &wl, qint64 simTimeMSecs);
|
||||
void onEntityTypeChanged(const rpr2::EntityIdentifierStruct &eis, const rpr2::EntityTypeStruct &ets, qint64 simTimeMSecs);
|
||||
bool onMarkingChanged(const rpr2::EntityIdentifierStruct &eis, const rpr2::MarkingStruct &marking, qint64 simTimeMSecs);
|
||||
bool onForceIdentifierChanged(const rpr2::EntityIdentifierStruct &eis, rpr2::ForceIdentifierEnum8::ET identifier, qint64 simTimeMSecs);
|
||||
bool onDamageStateChanged(const rpr2::EntityIdentifierStruct &eis, rpr2::DamageStatusEnum32::ET status, qint64 simTimeMSecs);
|
||||
bool onSensorChanged(const rpr2::EntityIdentifierStruct &eis, rpr2::SensorFieldEnum32::ET value, qint64 simTimeMSecs);
|
||||
bool onDesignatorCodeChanged(const rpr2::EntityIdentifierStruct &eis, rpr2::DesignatorCodeEnum16::ET value, qint64 simTimeMSecs);
|
||||
bool onDesignatorOutputPowerChanged(const rpr2::EntityIdentifierStruct &eis, ngs::FLOAT32 value, qint64 simTimeMSecs);
|
||||
bool onDesignatorSpotLocationChanged(const rpr2::EntityIdentifierStruct &eis, const rpr2::WorldLocationStruct &value, qint64 simTimeMSecs);
|
||||
|
||||
void onNewEngagementReply(const rpr2::IObserverEngagementReplyIntInstance &interaction);
|
||||
void onNewEventReport(const rpr2::IObserverEventReportIntInstance &interaction);
|
||||
void onNewMunitionDetonation(const rpr2::IObserverMunitionDetonationIntInstance &interaction);
|
||||
void onNewWeaponFire(const rpr2::IObserverWeaponFireIntInstance &interaction);
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
Reference in new issue
Block a user