Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+87
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Effector Firing Strategy for GMLRS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Fritsche, ESZS, 2026-05-12
|
||||
*/
|
||||
|
||||
#include "gmlrs_firing_strategy.h"
|
||||
#include "object_effector.h"
|
||||
|
||||
#include <TrainingAreaBase/Plugins/AdlerJson/telegrams.h>
|
||||
#include <Trajectory/trajectory_transform.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
GmlrsFiringStrategy::GmlrsFiringStrategy(ObjectEffector *effector)
|
||||
: BaseClass(effector)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
init();
|
||||
DEBUG_LOG(m_logger) << "using GmlrsFiringStrategy";
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
GmlrsFiringStrategy::~GmlrsFiringStrategy()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void GmlrsFiringStrategy::doFiring()
|
||||
{
|
||||
m_transformedTrajectory = TrajectoryTransform::transformToNewTarget(m_effector->intendendTrajectory(), m_impactPoints.at(m_impactPointIndex++));
|
||||
|
||||
if (m_impactPointIndex >= m_impactPoints.size())
|
||||
m_impactPointIndex = 0;
|
||||
|
||||
const qint64 trajectoryStartTime = getStartTime();
|
||||
|
||||
const auto &geometry = buildTrajectoryGeometry(m_transformedTrajectory);
|
||||
const auto &trajTimeAware = buildTrajectoryTimeAware(geometry, trajectoryStartTime);
|
||||
|
||||
const int chargeEffectId = sendChargeEffect(trajTimeAware);
|
||||
|
||||
emit signalFired(m_effector->participantId(), m_effector->aesItemId(), {chargeEffectId});
|
||||
}
|
||||
|
||||
void GmlrsFiringStrategy::init()
|
||||
{
|
||||
using namespace AdlerJson;
|
||||
|
||||
m_impactPointIndex = 0;
|
||||
m_impactPoints.clear();
|
||||
|
||||
const QJsonObject &properties = QJsonDocument::fromJson(QByteArray::fromStdString(m_effector->effectorData().properties())).object();
|
||||
const Core::GeoPosition &geoStartPos = participantPosition(m_effector->participantId());
|
||||
const LtsCoordTrans::UtmCoordinate &utmStartPos = LtsCoordTrans::UtmCoordinate::fromGeographic(geoStartPos.lon(), geoStartPos.lat());
|
||||
|
||||
bool bOk = false;
|
||||
WirkmittelFeuerkommandoRakete wirkmittel;
|
||||
wirkmittelFeuerkommandoRaketeFromJson(properties, wirkmittel, bOk);
|
||||
|
||||
for (const Treffpunkt &treffpunkt : qAsConst(wirkmittel.treffpunkte))
|
||||
{
|
||||
const LtsCoordTrans::UtmCoordinate utmTreffpunkt =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(treffpunkt.koordinate.koordinate.longitude * LtsCoordTrans::deg2rad(),
|
||||
treffpunkt.koordinate.koordinate.latitude * LtsCoordTrans::deg2rad());
|
||||
const LtsUtils::QPoint3D relImpactPoint(utmTreffpunkt.x - utmStartPos.x,
|
||||
utmTreffpunkt.y - utmStartPos.y,
|
||||
treffpunkt.koordinate.hoehe);
|
||||
|
||||
for (int anzahlCounter = 1; anzahlCounter <= treffpunkt.anzahl; ++anzahlCounter)
|
||||
m_impactPoints.append(relImpactPoint);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "Got " << m_impactPoints.size() << " impact points";
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user