- 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>
194 lines
6.4 KiB
C++
Executable File
194 lines
6.4 KiB
C++
Executable File
|
|
|
|
|
|
#include "handler_participant.h"
|
|
#include <utility>
|
|
#include "handler_nasat_aircraft.h"
|
|
#include "handler_nasat_aircraft_participant.h"
|
|
#include "initialization.h"
|
|
#include "dds_handler.h"
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
|
|
#include <QTimer>
|
|
|
|
namespace GuezNasat
|
|
{
|
|
|
|
|
|
|
|
|
|
NasatAircraftParticipantEx::NasatAircraftParticipantEx()
|
|
: m_logger(getLogger("NasatAircraftParticipantEx"))
|
|
{
|
|
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
|
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
|
}
|
|
|
|
NasatAircraftParticipantEx::NasatAircraftParticipantEx(const NasatAircraftParticipant &nap, const std::shared_ptr<Participant2Dds> &publisher)
|
|
: m_nap(nap)
|
|
, m_publisher(publisher)
|
|
{
|
|
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
|
m_publisher->addParticipantToWatch(m_nap.participantId());
|
|
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
|
}
|
|
|
|
NasatAircraftParticipantEx::~NasatAircraftParticipantEx()
|
|
{
|
|
DEBUG_LOG() << Q_FUNC_INFO << " START";
|
|
m_publisher->removeParticipantToWatch(m_nap.participantId());
|
|
DEBUG_LOG() << Q_FUNC_INFO << " END";
|
|
}
|
|
|
|
int NasatAircraftParticipantEx::partyId() const
|
|
{
|
|
return m_publisher ? m_publisher->partyId(participantId()) : -1;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HandlerParticipant::HandlerParticipant(Initialization *mainHandler)
|
|
: m_mainHandler(mainHandler)
|
|
{}
|
|
|
|
HandlerParticipant::~HandlerParticipant()
|
|
{
|
|
for (const auto &ex : std::as_const(m_activePublisher))
|
|
qDeleteAll(ex);
|
|
}
|
|
|
|
QHash<ExerciseParticipantKey, NasatAircraftParticipantEx *> HandlerParticipant::participantsForNasatId(int nasatId) const
|
|
{
|
|
return m_activePublisher.value(nasatId);
|
|
}
|
|
|
|
void HandlerParticipant::onNasatAircraftParticipantCreated(const NasatAircraftParticipant &nap)
|
|
{
|
|
const int nasatId = m_mainHandler->nasatAircraft()->nasatIdFromNasatAircraftId(nap.nasatAircraftId());
|
|
auto it = m_activePublisher.find(nasatId);
|
|
if (it == m_activePublisher.end())
|
|
return createNasatAircraftParticipant(nap, nasatId);
|
|
|
|
auto itParticipants = it.value().find(ExerciseParticipantKey(nap.exerciseId(), nap.participantId()));
|
|
if (itParticipants == it.value().end())
|
|
return createNasatAircraftParticipant(nap, nasatId);
|
|
}
|
|
|
|
void HandlerParticipant::onNasatAircraftParticipantRemoved(const NasatAircraftParticipant &nap)
|
|
{
|
|
const int nasatId = m_mainHandler->nasatAircraft()->nasatIdFromNasatAircraftId(nap.nasatAircraftId());
|
|
auto it = m_activePublisher.find(nasatId);
|
|
if (it == m_activePublisher.end())
|
|
{
|
|
WARNING_LOG() << "No publisher for NasatAircraftParticipant " << nasatId << "(" << nap.nasatAircraftId() << ") found !?";
|
|
return;
|
|
}
|
|
auto itParticipants = it.value().find(ExerciseParticipantKey(nap.exerciseId(), nap.participantId()));
|
|
if (itParticipants == it.value().end())
|
|
{
|
|
WARNING_LOG() << "No participant entry for NasatAircraftParticipant " << nasatId << "("
|
|
<< nap.exerciseId() << "," << nap.participantId() << ") found !?";
|
|
return;
|
|
}
|
|
|
|
|
|
DEBUG_LOG() << " emit nasatAircraftParticipantRemoved, nap = " << nap;
|
|
emit nasatAircraftParticipantRemoved(nap);
|
|
|
|
|
|
DEBUG_LOG() << "Remove position publisher for " << nap;
|
|
|
|
|
|
NasatAircraftParticipantEx* napeCopy= itParticipants.value();
|
|
if (napeCopy && napeCopy->publisher())
|
|
{
|
|
|
|
napeCopy->publisher()->removeParticipantToWatch(napeCopy->participantId());
|
|
}
|
|
|
|
QTimer::singleShot(2000, this, [napeCopy]() {
|
|
delete napeCopy;
|
|
});
|
|
|
|
it.value().erase(itParticipants);
|
|
if (it.value().isEmpty())
|
|
m_activePublisher.erase(it);
|
|
}
|
|
|
|
Core::GeoPosition HandlerParticipant::nasatPosition(int nasatId) const
|
|
{
|
|
DEBUG_LOG() << Q_FUNC_INFO << " START, nasatId=" << nasatId;
|
|
auto it = m_lastNasatPositionsAsCoreGeoposition.find(nasatId);
|
|
if (it == m_lastNasatPositionsAsCoreGeoposition.end())
|
|
{
|
|
INFO_LOG() << "No NasatPosition for nasat id " << nasatId << " found";
|
|
return {};
|
|
}
|
|
return *it;
|
|
}
|
|
|
|
void HandlerParticipant::onNasatPosition(const NasatPosition &position)
|
|
{
|
|
DEBUG_LOG() << Q_FUNC_INFO << " START, position.aircraftId=" << position.aircraftId;
|
|
const Core::GeoPosition geoPos(position.position.lon * LtsCoordTrans::deg2rad(),
|
|
position.position.lat * LtsCoordTrans::deg2rad(),
|
|
position.position.height);
|
|
|
|
const qint64 tsMSec = position.timestamp <= 0 ? QDateTime::currentMSecsSinceEpoch() : qRound64(position.timestamp * 1000);
|
|
onNasatAircraftPosition(position.aircraftId, geoPos, tsMSec);
|
|
|
|
m_lastNasatPositionsAsCoreGeoposition[position.aircraftId] = geoPos;
|
|
}
|
|
|
|
void HandlerParticipant::onNasatAircraftPosition(int nasatId, const Core::GeoPosition &pos, qint64 ts)
|
|
{
|
|
DEBUG_LOG() << Q_FUNC_INFO << " START, nasatId=" << nasatId;
|
|
auto it = m_activePublisher.find(nasatId);
|
|
if (it == m_activePublisher.end())
|
|
{
|
|
INFO_LOG() << "No position publisher for nasat id " << nasatId << " found - ignoring " << m_activePublisher.size();
|
|
return;
|
|
}
|
|
|
|
const auto &h = it.value();
|
|
TrainingAreaBase::EquipmentPosition tabPos;
|
|
tabPos.position().position(pos);
|
|
tabPos.sampleTime(ts);
|
|
for (const NasatAircraftParticipantEx *napEx : h)
|
|
{
|
|
tabPos.equipmentNumber(-napEx->participantId());
|
|
int success = napEx->publisher()->publish(tabPos);
|
|
if (success)
|
|
DEBUG_LOG() << "Publishing positon: " << tabPos << " to exercise " << napEx->exerciseId()
|
|
<< ", napEx: " << napEx->participant()
|
|
<< " -> success = " << success;
|
|
else
|
|
ERROR_LOG() << "Error on Publishing positon: " << tabPos << " to exercise " << napEx->exerciseId()
|
|
<< ", napEx: " << napEx->participant()
|
|
<< " -> success = " << success;
|
|
|
|
}
|
|
}
|
|
|
|
void HandlerParticipant::onNasatIdChanged(int oldNasatId, int newNasatId)
|
|
{
|
|
m_activePublisher[newNasatId] = m_activePublisher[oldNasatId];
|
|
m_activePublisher.remove(oldNasatId);
|
|
}
|
|
|
|
void HandlerParticipant::createNasatAircraftParticipant(const NasatAircraftParticipant &nap, int nasatId)
|
|
{
|
|
DEBUG_LOG() << "Creating position publisher for " << nap
|
|
<< ", nasatId=" << nasatId;
|
|
auto *napEx = new NasatAircraftParticipantEx(nap,
|
|
m_mainHandler->dds()->ddsParticipant(nap.exerciseId()));
|
|
m_activePublisher[nasatId][ExerciseParticipantKey(nap.exerciseId(), nap.participantId())] = napEx;
|
|
connect(napEx->publisher().get(), &Participant2Dds::participantRemoved,
|
|
m_mainHandler->nasatAircraftParticipant().get(), &HandlerNasatAircraftParticipant::participantRemoved,
|
|
Qt::QueuedConnection);
|
|
}
|
|
|
|
}
|