Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Effector Firing Strategy for SMart
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Norbert Thoden, ESVG, 2026-05-20
|
||||
*/
|
||||
|
||||
#include "smart_firing_strategy.h"
|
||||
#include "object_effector.h"
|
||||
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <TrainingAreaBase/Plugins/AdlerJson/telegrams.h>
|
||||
#include <TrajectorySplitter/trajectory_splitter.h>
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace AreaEffectSimulation
|
||||
{
|
||||
|
||||
SmartFiringStrategy::SmartFiringStrategy(ObjectEffector *effector)
|
||||
: BaseClass(effector)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
DEBUG_LOG(m_logger) << "using SmartFiringStrategy";
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
SmartFiringStrategy::~SmartFiringStrategy()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
void SmartFiringStrategy::doFiring()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// by default, following is done
|
||||
// - calculateDispersionTrajectory
|
||||
// - calc new target
|
||||
// - calc matching trajectory
|
||||
// (intendendTrajectory -> m_transformedTrajectory)
|
||||
// - sendChargeEffect
|
||||
// - emit signalFired
|
||||
|
||||
// for SMArt, calculateDispersionTrajectory is not necessary
|
||||
// But we have to split the tow-in-one trajectory:
|
||||
|
||||
const qint64 trajectoryStartTime = getStartTime();
|
||||
|
||||
//
|
||||
// first check, if trajectory is a tow-in-one trajectory:
|
||||
//
|
||||
|
||||
// convert from intendendTrajectory (relativ) to TRAJECTORY_TYPE (absolute)
|
||||
// The TrajectorySplitter needs TRAJECTORY_TYPE
|
||||
// using TRAJECTORY_TYPE = std::vector<Core::GeoPositionRelativeTime>;
|
||||
const auto &intendendTrajectory = m_effector->intendendTrajectory();
|
||||
const auto &trajGeometry = buildTrajectoryGeometry(intendendTrajectory);
|
||||
|
||||
// split and avoid copying:
|
||||
const TrajectorySplitter<std::vector<Core::GeoPositionRelativeTime>> splitter(trajGeometry);
|
||||
const auto &trajGeo1 = splitter.getTrajectory1();
|
||||
const auto &trajGeo2 = splitter.getTrajectory2();
|
||||
|
||||
DEBUG_LOG(m_logger) << "splitter: " << " intendendTrajectory.size = " << intendendTrajectory.size();
|
||||
DEBUG_LOG(m_logger) << "splitter: " << " trajGeometry.size = " << trajGeometry.size();
|
||||
DEBUG_LOG(m_logger) << "splitter: " << " rawTrajectorySize = " << splitter.rawTrajectorySize();
|
||||
DEBUG_LOG(m_logger) << "splitter: " << " trajGeo1 = " << trajGeo1.size();
|
||||
DEBUG_LOG(m_logger) << "splitter: " << " trajGeo2 = " << trajGeo2.size();
|
||||
|
||||
//
|
||||
// and second, process both Trajectories/Impacts
|
||||
//
|
||||
|
||||
// ToDo: Check, how oftem signalFired should be fired?
|
||||
QVector<int> chargeEffectIds;
|
||||
if (trajGeo1.size() > 2)
|
||||
{
|
||||
const auto &trajTimeAware = buildTrajectoryTimeAware(trajGeo1, trajectoryStartTime, 0);
|
||||
const int chargeEffectId = sendChargeEffect(trajTimeAware);
|
||||
chargeEffectIds << chargeEffectId;
|
||||
DEBUG_LOG(m_logger) << "Trajectory1 - created ChargeEffectId: " << chargeEffectId;
|
||||
}
|
||||
if (trajGeo2.size() > 2)
|
||||
{
|
||||
const auto &trajTimeAware = buildTrajectoryTimeAware(trajGeo2, trajectoryStartTime, 1);
|
||||
const int chargeEffectId = sendChargeEffect(trajTimeAware);
|
||||
chargeEffectIds << chargeEffectId;
|
||||
DEBUG_LOG(m_logger) << "Trajectory2 - created ChargeEffectId: " << chargeEffectId;
|
||||
}
|
||||
if (chargeEffectIds.size())
|
||||
emit signalFired(m_effector->participantId(), m_effector->aesItemId(), chargeEffectIds);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
} // namespace AreaEffectSimulation
|
||||
Reference in new issue
Block a user