Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+97
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Handle the mapping real aircraft <-> nasat configuration
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Ehrlicher, NLSE, 2018-08-16
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <GuezNasat/gna.hpp>
|
||||
#include <ParticipantManagement/ppm_dtc_types.h>
|
||||
#include "guez_nasat_telegrams.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace GuezNasat
|
||||
{
|
||||
class Initialization;
|
||||
class Participant2Dds;
|
||||
|
||||
struct NasatAircraftParticipantEx final
|
||||
{
|
||||
NasatAircraftParticipantEx();
|
||||
explicit NasatAircraftParticipantEx(const NasatAircraftParticipant &nap,
|
||||
const std::shared_ptr<Participant2Dds> &publisher);
|
||||
~NasatAircraftParticipantEx();
|
||||
|
||||
std::shared_ptr<Participant2Dds> publisher() const { return m_publisher; }
|
||||
|
||||
int exerciseId() const { return m_nap.exerciseId(); }
|
||||
int partyId() const;
|
||||
int participantId() const { return m_nap.participantId(); }
|
||||
const NasatAircraftParticipant &participant() const { return m_nap; }
|
||||
|
||||
Q_DISABLE_COPY(NasatAircraftParticipantEx)
|
||||
private:
|
||||
NasatAircraftParticipant m_nap;
|
||||
std::shared_ptr<Participant2Dds> m_publisher;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
struct ExerciseParticipantKey
|
||||
{
|
||||
int exerciseId = 0;
|
||||
int participantId = 0;
|
||||
ExerciseParticipantKey() = default;
|
||||
ExerciseParticipantKey(int e, int p)
|
||||
: exerciseId(e), participantId(p) {}
|
||||
bool operator ==(const ExerciseParticipantKey &o) const
|
||||
{
|
||||
return exerciseId == o.exerciseId && participantId == o.participantId;
|
||||
}
|
||||
};
|
||||
inline uint qHash(ExerciseParticipantKey key, uint seed = 0)
|
||||
{
|
||||
return ::qHash((key.exerciseId << 16) + key.participantId, seed);
|
||||
}
|
||||
|
||||
class HandlerParticipant : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit HandlerParticipant(Initialization *mainHandler);
|
||||
~HandlerParticipant();
|
||||
|
||||
bool init() const { return true; }
|
||||
|
||||
// QHash<ExerciseParticipantKey, NasatAircraftParticipantEx>
|
||||
QHash<ExerciseParticipantKey, NasatAircraftParticipantEx*> participantsForNasatId(int nasatId) const;
|
||||
|
||||
void onNasatAircraftParticipantCreated(const NasatAircraftParticipant &nap);
|
||||
void onNasatAircraftParticipantRemoved(const NasatAircraftParticipant &nap);
|
||||
|
||||
Core::GeoPosition nasatPosition(int nasatId) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void nasatAircraftParticipantRemoved(const NasatAircraftParticipant &nap);
|
||||
|
||||
public Q_SLOTS:
|
||||
void onNasatPosition(const NasatPosition &position);
|
||||
void onNasatAircraftPosition(int nasatId, const Core::GeoPosition &pos, qint64 ts);
|
||||
void onNasatIdChanged(int oldNasatId, int newNasatId);
|
||||
|
||||
private:
|
||||
void createNasatAircraftParticipant(const NasatAircraftParticipant &nap, int nasatId);
|
||||
|
||||
// QHash<nasatId, QHash<ExerciseParticipantKey, NasatAircraftParticipantEx>>
|
||||
QHash<int, QHash<ExerciseParticipantKey, NasatAircraftParticipantEx*>> m_activePublisher;
|
||||
|
||||
// NasatId/AircraftId , GeoPosition
|
||||
QHash<int, Core::GeoPosition> m_lastNasatPositionsAsCoreGeoposition;
|
||||
Initialization *m_mainHandler;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
} // namespace GuezNasat
|
||||
Reference in new issue
Block a user