Files
qt5-legatus-legacy/Lts/Services/AreaEffectSimulation/ModuleTest_ExplosionCluster/explosion_cluster_module_test.cpp
T
2026-08-13 18:33:10 +02:00

2758 lines
110 KiB
C++
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @RDE_HEADER@
* ModuleTest
* $Id$
* $HeadURL$
* $Author$
*/
#include "explosion_cluster_module_test.h"
#include <nglapplication/nglcoreapplication.h>
#include <LtsCoordTrans/lts_coord_trans.h>
// AES
#include <AreaEffectSimulation/aes_dtc.h>
#include <AreaEffectSimulation/Utils/polygons.h>
// BLD
#include <Buildings/bld_ftc.h>
#include <QTimer>
#include <QDebug>
#include <iostream>
using namespace AreaEffectSimulation;
using namespace LtsCoordTrans;
bool ModuleTestExplosionCluster::m_enable_create_bulk = false;
// must be in pdm.pdm_charge_type
static const int s_ChargeTypeId1 = 371;
static const int s_ChargeTypeId2 = 372;
static const int s_IgniterTypeProximity = 101; // Proximity Generic
static const int s_IgniterTypeImpact = 102; // Impact Generic
static const int s_IgniterTypeDelay = 103; // Delay Generic
static const int s_ChargeTypeIdVulcano = 376;
static const int s_FirePurposeId = 3; // 3=Blenden mit Wirkung
static const int s_TraingAreaId_Altmark = 2;
static const int s_TraingAreaId_Bremen = 6;
//
// some helper functions
//
template<typename T>
dds::core::optional<T> toOptional(T inVal)
{
return inVal != T() ? dds::core::optional<T>(inVal) : dds::core::optional<T>();
}
template<typename T>
dds::core::optional<T> optional()
{
return dds::core::optional<T>();
}
// mathematical positive north -> mathematical negativ, east = 0°, 0,01 degree in 1/100° -> factor 100
static inline int compassToMathAngleForSfm(double compassDegree)
{
int ret = qRound((90.0 - compassDegree) * 100.0);
while (ret < 0)
ret += 36000;
while (ret > 36000)
ret -= 36000;
return ret;
}
double distanceMeter(const LtsCoordTrans::UtmCoordinate &utmCoord1, const LtsCoordTrans::UtmCoordinate &utmCoord2)
{
double dist = LtsCoordTrans::distance(utmCoord1, utmCoord2);
qCritical() << " dist" << dist;
return dist;
}
double distanceMeter(const Core::GeoPosition &geoPos , const LtsCoordTrans::UtmCoordinate &utmCoord)
{
const LtsCoordTrans::UtmCoordinate &utmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos.lon(), geoPos.lat());
return distanceMeter(utmPos, utmCoord);
}
double distanceMeter(const Core::GeoPosition2D &geoPos2D , const LtsCoordTrans::UtmCoordinate &utmCoord)
{
const LtsCoordTrans::UtmCoordinate &utmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(geoPos2D.lon(), geoPos2D.lat());
return distanceMeter(utmPos, utmCoord);
}
ModuleTestExplosionCluster::ModuleTestExplosionCluster(int domainId, int exerciseId)
: m_domainId(domainId)
, m_exerciseId(exerciseId)
, m_logger(getLogger("ModuleTestExplosionCluster"))
{
}
void ModuleTestExplosionCluster::onSetSimulatedPositionReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onSetSimulatedPositionReply : " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onExplosionClusterModifyReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onSetSimulatedParticipantFormationReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onSetSimulatedParticipantFormationReply : " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onSetSimulatedParticipantFormationReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onExplosionClusterModifyReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onExplosionClusterModifyReply: " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onExplosionClusterModifyReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onExplosionClusterSingleEffectOnlyModifyReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onExplosionClusterSingleEffectOnlyModifyReply: " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onExplosionClusterSingleEffectOnlyModifyReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onExplosionClusterOcModifyReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onExplosionClusterOcModifyReply: " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onExplosionClusterOcModifyReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onExplosionClusterPauseResumeReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onExplosionClusterPauseResumeReply: " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onExplosionClusterModifyReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onTargetPositionsModifyReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onTargetPositionsModifyReply: " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onTargetPositionsModifyReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onSetBuildingStatesReply(const Core::FunctionReplyObject &replyObject)
{
m_replyError = replyObject.error();
DEBUG_LOG(m_logger) << " got reply - onSetBuildingStatesReply: " << m_replyError;
if (!replyObject.str().empty())
ERROR_LOG(m_logger) << " got reply - onSetBuildingStatesReply: " << replyObject.translated();
}
void ModuleTestExplosionCluster::onExplosionClusterChanged(const ExplosionCluster &data, DataModification modType)
{
Q_UNUSED(modType);
if (data.id() == -1)
return;
++m_counterDds.cntExplosionCluster;
// handle remove?
if ((m_data.isObjectModifiable() == true) && (data.isObjectModifiable() == false))
{
long now = time(nullptr) * 1000;
long diff = now - m_objectRequestedTimePointMsec;
DEBUG_LOG(m_logger) << " got changed - m_data: " << m_data.id() << ", state=" << m_data.effectStateId()
<< ", OBJECT IS NOT Modifiable ANYMORE"
<< " ((diff = " << diff << ")";
}
m_data = data;
qint64 startTimeMsec = -1;
if (m_data.effectStart().is_set())
startTimeMsec = m_data.effectStart().get();
DEBUG_LOG(m_logger) << " got changed - m_data: " << m_data.id() << ", state=" << m_data.effectStateId()
<< ", startTimeMsec=" << startTimeMsec
<< ", cntExplosionCluster=" << m_counterDds.cntExplosionCluster;
TRACE_LOG(m_logger) << " got changed - m_data: " << m_data;
}
void ModuleTestExplosionCluster::onBuildingStateChanged(const Buildings::BuildingState &bldgState, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
// DEBUG_LOG(m_logger) << " got changed - BuildingState.id: " << bldgState.id() << ", data.damagePerc " << bldgState.damagePercent() << "m_bldgIdToFilter " << m_bldgIdToFilter;
if (m_bldgIdToFilter == bldgState.id())
m_buildingStateVec.push_back(bldgState);
}
void ModuleTestExplosionCluster::onAesItemViewChanged(const AesItemView &aesItemView, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
AreaEffectSimulation::AesType_def::type aesType = aesItemView.aesTypeId().underlying();
DEBUG_LOG(m_logger) << " got onAesItemViewChanged - m_data: " << m_data.id() << ", aesType=" << aesType;
switch (aesType) {
case AreaEffectSimulation::AesType_def::AtExplosionCluster:
++m_counterDds.cntAtExplosionCluster;
break;
case AreaEffectSimulation::AesType_def::AtExplosionClusterGunToTargetLine:
++m_counterDds.cntAtExplosionClusterGunToTargetLine;
break;
// case AreaEffectSimulation::AesType_def::AtExplosionClusterSingleExplosions:
// ++m_counterDds.cntAtExplosionClusterSingleExplosions;
// m_aesItemViewSingleExplosions = aesItemView;
// break;
default:
break;
}
}
void ModuleTestExplosionCluster::onEffectsChanged(const Effects &effects, DataModification modType)
{
if (modType == DataModification::eRemoved)
return;
AreaEffectSimulation::AesType_def::type aesType = effects.aesTypeId().underlying();
DEBUG_LOG(m_logger) << " got onEffectsChanged - m_data: " << m_data.id() << ", aesType=" << aesType;
++m_counterDds.cntExplosionClusterEffects;
m_effects = effects;
DEBUG_LOG(m_logger) << " got onEffectsChanged - m_effects: " << m_effects;
}
void ModuleTestExplosionCluster::onTrajectoryTimeAwareChanged(const TrajectoryTimeAware &data, DataModification modType)
{
Q_UNUSED(modType);
if (data.id() == -1)
return;
++m_counterDds.cntTrajectory;
DEBUG_LOG(m_logger) << " got TrajectoryTimeAwareChanged - data: " << data.id() << ", cntTrajectory=" << m_counterDds.cntTrajectory;
}
void ModuleTestExplosionCluster::dumpCnt()
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " Counter: "
<< " cntExplosionCluster = " << m_counterDds.cntExplosionCluster
<< ", cntAtExplosionCluster = " << m_counterDds.cntAtExplosionCluster
<< ", cntGunToTargetLine = " << m_counterDds.cntAtExplosionClusterGunToTargetLine
// << ", cntSingleExplosions = " << m_counterDds.cntAtExplosionClusterSingleExplosions
<< ", cntClusterEffects = " << m_counterDds.cntExplosionClusterEffects
<< ", cntTrajectory = " << m_counterDds.cntTrajectory;
}
void ModuleTestExplosionCluster::dumpBldgStates()
{
NOTICE_LOG(m_logger) << " m_buildingStateVec.size() = " << m_buildingStateVec.size();
for (const Buildings::BuildingState &bldgState : qAsConst(m_buildingStateVec))
NOTICE_LOG(m_logger) << " bldgState: "
<< ", id = " << bldgState.id()
<< ", damagePercent = " << bldgState.damagePercent()
<< ", vulnerabilityState = " << bldgState.vulnerabilityState();
}
bool ModuleTestExplosionCluster::setFilterForBldgState(const QString &bldgName)
{
m_bldgIdToFilter = -1;
const int bldgId = getBldgId(bldgName);
if (bldgId<=0)
{
ERROR_LOG(m_logger) << " getBldgId failed for '" << bldgName << "'";
return false;
}
m_bldgIdToFilter = bldgId;
INFO_LOG(m_logger) << " setFilterForBldgState for '" << bldgName << "' to " << m_bldgIdToFilter;
return true;
}
bool ModuleTestExplosionCluster::checkSingleEffects(uint idx, const LtsCoordTrans::LtsCoordinate &coord, const AreaEffectSimulation::AesZPlacement zPlace
, const QString &context, double maxDist3D)
{
//m_effects
// [id: 119024, sampleTime: 1731589251949, aesItemId: 119, aesTypeId: AesType::AtExplosionClusterSingleExplosions ,
// singleEffects: {
// [singleEffectState: AesSingleEffectState::SesTriggered , position: [[lon: 0.202618316049855, lat: 0.916077235166475]z: 96.499], zPlacement: AesZPlacement::ZpAbsolute , singleEffectTime: 1731589246950],
// [singleEffectState: AesSingleEffectState::SesTriggered , position: [[lon: 0.202617916282675, lat: 0.916076590531811]z: 94.127901927008], zPlacement: AesZPlacement::ZpAbsolute , singleEffectTime: 1731589249949],
// [singleEffectState: AesSingleEffectState::SesTriggered position: [[lon: 0.20261744391547, lat: 0.916075873952916]z: 93.7899755716979], zPlacement: AesZPlacement::ZpDraped , singleEffectTime: 1731589251949],
// [singleEffectState: AesSingleEffectState::SesScheduled , position: [[lon: 0.202616961210441, lat: 0.916075147176726]z: 93.86], zPlacement: AesZPlacement::ZpDraped , singleEffectTime: 0]}]
std::vector<AreaEffectSimulation::SingleEffect>& singleEffects = m_effects.singleEffects();
if (singleEffects.size() <= idx)
return false;
const SingleEffect &se = singleEffects[idx];
if (se.singleEffectTime() < 1000)
{
ERROR_LOG(m_logger) << " bldg: " << context << ", idx = " << idx << ": singleEffectTime failed, SingleEffect = " << se;
return false;
}
if (se.zPlacement() != zPlace)
{
ERROR_LOG(m_logger) << " bldg: " << context << ", idx = " << idx << ": zPlacement failed, SingleEffect = " << se;
return false;
}
LtsCoordinate ltsPos(se.position());
const double dist3D = ltsPos.distanceUtm3D(coord);
if (dist3D > maxDist3D)
{
ERROR_LOG(m_logger) << " bldg: " << context << ", idx = " << idx << ": position failed, dist3D = " << dist3D;
ERROR_LOG(m_logger) << " idx = " << idx << ", Impact IST = " << ltsPos;
ERROR_LOG(m_logger) << " idx = " << idx << ", Impact SHD = " << coord;
return false;
}
return true;
}
bool ModuleTestExplosionCluster::checkBldgStates(const QVector<int> &damagePercent, const QString &context)
{
QVector<int> damagePercentIst;
damagePercentIst.reserve(m_buildingStateVec.size());
for (const Buildings::BuildingState &bldgState : qAsConst(m_buildingStateVec))
damagePercentIst.append(bldgState.damagePercent());
bool same = damagePercentIst == damagePercent;
// if (!same)
{
qCritical() << " bldg: " << context << " damagePercent IST: " << damagePercentIst;
qCritical() << " bldg: " << context << " damagePercent SHD: " << damagePercent;
}
return same;
}
bool ModuleTestExplosionCluster::waitForData(const std::function<bool ()> &func, int retryCount)
{
// Maybe give QTRY_VERIFY2 or QTRY_VERIFY2_WITH_TIMEOUT a chance
// Or better QTRY_IMPL ??
// QTRY_IMPL(m_replyError == false, 1);
// wait for data
retryCount *= 10;
for (int i = 0; i < retryCount; ++i)
{
TRACE_LOG(m_logger) << " waitForData - i: " << i;
if (func())
return true;
QTest::qWait(100);
}
return func();
}
ExplosionCluster ModuleTestExplosionCluster::getEcForTneVerification(const QString &eaName, double rotation)
{
AreaEffectSimulation::ExplosionCluster eaData;
eaData.id(0);
eaData.effectSourceId(ProjectDataManagement::EffectSource::ES_Internal);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
QString name(eaName);
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.effectDuration(10000); // 10 seconds
eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.partyId(2);
eaData.participantId(7);
eaData.mhPoints({Core::GeoPosition2D(0.0, 0.0)});
eaData.impactCount(10);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(100);
eaData.flightCurve(toOptional(fc));
// siehe auch: GUEZE-2311 Verifikation des Algorithmus bzgl. MTPs zw. TNE und EXCON.
const double height = 100; // Y
const double width = 40; // X
const double rot = rotation;
// In Kontext GUEZE-2311 werden die MTPs unabhängig von eigentliche WirkfeldGeometrie an die TNE übermittelt.
// Um in der Zentrale den gewünschten MTP zu erhalten, muss das Wirkfeld entsprechend angelegt werden:
LtsCoordTrans::UtmCoordinate cp = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97000 78000"));
QPointF bottomLeft(Polygons::centerPoint2BottomLeft(cp.geographic(), width, height, rot));
qCritical() << " bottomLeft" << bottomLeft;
eaData.area().cornerBottomLeft(Core::GeoPosition(bottomLeft.x(), bottomLeft.y(), 0.0));
eaData.area().height(height);
eaData.area().width(width);
eaData.area().rotation(rot);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
eaData.tla(0); // aka zop
eaData.externalId(0);
return eaData;
}
ExplosionCluster ModuleTestExplosionCluster::getEcFor1104(const QString &eaName)
{
AreaEffectSimulation::ExplosionCluster eaData;
eaData.id(0);
eaData.effectSourceId(ProjectDataManagement::EffectSource::ES_Internal);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
QString name(eaName);
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.effectDuration(10000); // 10 seconds
eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.partyId(2);
eaData.participantId(5);
eaData.mhPoints({Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0)});
eaData.impactCount(4);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(100);
eaData.flightCurve(toOptional(fc));
eaData.firePurposeId(1); // 1=Blenden, 2=Blenden mit IR,
const double height = 11;
const double width = 25;
const double rot = 0;
// 0.202561460978929 0.916110427477059 == 32U PD 76937 18655
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.202561460978929, 0.916110427477059));
eaData.area().height(height);
eaData.area().width(width);
eaData.area().rotation(rot);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
eaData.tla(0); // aka zog
eaData.externalId(0);
return eaData;
}
ExplosionCluster ModuleTestExplosionCluster::getEcFor1106(const QString &eaName)
{
AreaEffectSimulation::ExplosionCluster eaData;
eaData.id(0);
eaData.effectSourceId(ProjectDataManagement::EffectSource::ES_Internal);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
QString name(eaName);
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.effectDuration(10000); // 10 seconds
eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.partyId(2);
eaData.participantId(6);
eaData.mhPoints({Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0)});
eaData.impactCount(4);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(500);
eaData.flightCurve(toOptional(fc));
eaData.firePurposeId(1); // 1=Blenden, 2=Blenden mit IR,
const double height = 10;
const double width = 20;
const double rot = 100;
// 0.202561460978929 0.916110427477059 == 32U PD 76937 18655
const LtsCoordTrans::UtmCoordinate &utmPos =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7696018588")); //
QPointF pos = utmPos.geographic();
eaData.area().cornerBottomLeft(Core::GeoPosition2D(pos.x(), pos.y()));
eaData.area().height(height);
eaData.area().width(width);
eaData.area().rotation(rot);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
eaData.tla(0); // aka zog
eaData.externalId(0);
return eaData;
}
ExplosionCluster ModuleTestExplosionCluster::getEcForUBAHN(const QString &eaName)
{
AreaEffectSimulation::ExplosionCluster eaData;
eaData.id(0);
eaData.effectSourceId(ProjectDataManagement::EffectSource::ES_Internal);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
QString name(eaName);
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.effectDuration(10000); // 10 seconds
eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.partyId(2);
eaData.participantId(5);
eaData.mhPoints({Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0)});
eaData.impactCount(4);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(500);
eaData.flightCurve(toOptional(fc));
eaData.firePurposeId(1); // 1=Blenden, 2=Blenden mit IR,
const double height = 10;
const double width = 20;
const double rot = 110;
const LtsCoordTrans::UtmCoordinate &utmPos =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77154 18454")); // 32 U PD 77154 18454
QPointF pos = utmPos.geographic();
eaData.area().cornerBottomLeft(Core::GeoPosition2D(pos.x(), pos.y()));
eaData.area().height(height);
eaData.area().width(width);
eaData.area().rotation(rot);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
eaData.tla(0); // aka zog
eaData.externalId(0);
return eaData;
}
ExplosionCluster ModuleTestExplosionCluster::getEcFor3101(const QString &eaName)
{
AreaEffectSimulation::ExplosionCluster eaData;
eaData.id(0);
eaData.effectSourceId(ProjectDataManagement::EffectSource::ES_Internal);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
QString name(eaName);
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.effectDuration(10000); // 10 seconds
eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.partyId(2);
eaData.participantId(89);
eaData.mhPoints({Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0),
Core::GeoPosition2D(0.0, 0.0)});
eaData.impactCount(4);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(1000);
eaData.flightCurve(toOptional(fc));
eaData.firePurposeId(1); // 1=Blenden, 2=Blenden mit IR,
const double height = 20;
const double width = 20;
const double rot = 45;
const LtsCoordTrans::UtmCoordinate &utmPos =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7722018559")); // 32 U PD 77220 18559
QPointF pos = utmPos.geographic();
eaData.area().cornerBottomLeft(Core::GeoPosition2D(pos.x(), pos.y()));
eaData.area().height(height);
eaData.area().width(width);
eaData.area().rotation(rot);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
eaData.tla(0); // aka zog
eaData.externalId(0);
return eaData;
}
int ModuleTestExplosionCluster::doExplosionClusterModifyRequest(const ExplosionCluster &eaData)
{
if (eaData.effectStart().is_set())
INFO_LOG(m_logger) << " explosionClusterModifyRequest with effectStart: " << QDateTime::fromMSecsSinceEpoch(eaData.effectStart().get()).toString();
else
INFO_LOG(m_logger) << " explosionClusterModifyRequest with effectStart: not set ";
FlightCurve fc;
if (eaData.flightCurve().is_set())
fc = eaData.flightCurve().get();
const std::string properties = "{}";
int ret = m_aesFtc->explosionClusterModifyRequest(
ExplosionClusterModifyRequest(
eaData.id(),
eaData.name(),
eaData.element(),
eaData.effectStart(),
eaData.effectDuration(),
eaData.effectSourceId(),
eaData.area(),
eaData.explosionGeometry(), // AimPoint, Radial, Area, Line, Point
eaData.tla(), // ZielOrtungsGenauigkeit
eaData.mhPoints().size(), // mhpCount;
optional<double>(), // mhpRotation for ExplosionClusterOcModify only
eaData.impactCount(), // impactCount
{ eaData.chargeStruct().chargeTypeId(),
eaData.chargeStruct().igniterTypeId(),
eaData.chargeStruct().igniterFunctionId()},
eaData.firePurposeId(), // FirePurpose: blenden, niederhalten, vernichten
fc.requestedRelativePeakHeight(), // peakHeight,
fc.requestedFlightDuration(), // flightDuration [msec],
eaData.partyId(),
eaData.participantId(),
{}, // esmParticipantIds
eaData.externalId(),
-1, // eaData.launchVelocity(),
-1, // eaData.launchAngleDeg(),
45, // eaData.dropAngle(),
8, // eaData.tapTime(), // msec, timepoint
-1, // eaData.lcAttack(), // fka lcPrf
-1, // eaData.lcTermination(),
std::numeric_limits<int>::min(), // eaData.cloudBase(), // Wolkenuntergrenze
eaData.effectMarkingInTa(),
properties),
this);
return ret;
}
int ModuleTestExplosionCluster::doExplosionClusterSingleEffectOnlyModifyRequest(const ExplosionClusterSingleEffectOnlyRequest &request)
{
if (request.effectStart().is_set())
INFO_LOG(m_logger) << " explosionClusterModifyRequest with effectStart: " << QDateTime::fromMSecsSinceEpoch(request.effectStart().get()).toString();
else
INFO_LOG(m_logger) << " explosionClusterModifyRequest with effectStart: not set ";
int ret = m_aesFtc->explosionClusterSingleEffectOnlyModifyRequest(request, this);
return ret;
}
int ModuleTestExplosionCluster::doExplosionClusterOcModifyRequest(const ExplosionClusterOcModifyRequest &request)
{
int ret = m_aesFtc->explosionClusterOcModifyRequest(request, this);
return ret;
}
int ModuleTestExplosionCluster::doExplosionClusterTargetPositionsModify(const TargetPositionsModifyRequest &request)
{
int ret = m_aesFtc->targetPositionsModifyRequest(request, this);
return ret;
}
void ModuleTestExplosionCluster::waitForEffectStates(int lineNumber, int durPrep, int durAct, int durExp)
{
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }, 1))
{
ERROR_LOG(m_logger) << "Error on request" << ", lineNumber = " << lineNumber;
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsPrepared...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsPrepared;}, durPrep))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsPrepared of explosion cluster with id " << m_data.id()
<< ", lineNumber = " << lineNumber;
QVERIFY2(false, "ERROR, exit");
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsActivated...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated;}, durAct))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsActivated of explosion cluster with id " << m_data.id()
<< ", lineNumber = " << lineNumber;
QVERIFY2(false, "ERROR, exit");
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsExpired...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired;}, durExp))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsExpired of explosion cluster with id " << m_data.id()
<< ", lineNumber = " << lineNumber;
QVERIFY2(false, "ERROR, exit");
return;
}
}
void ModuleTestExplosionCluster::setupParticipants()
{
std::cout << " initTestCase_data1 ..."<< std::endl;
QVERIFY2(m_ppmFtc, "ERROR, no m_ppmFtc");
{
ParticipantManagement::SetSimulatedPosition req;
{
req.participantId(5); // according testDB
req.onlyOutdatedParticipants(false);
const LtsCoordTrans::UtmCoordinate &utmPos =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7690018000")); // 32U PD 76900 18000
QPointF pos = utmPos.geographic();
req.position(Core::GeoPosition(pos.x(), pos.y(), 0.0));
INFO_LOG(m_logger) << " setSimulatedPositionRequest ...";
m_replyError = true;
m_ppmFtc->setSimulatedPositionRequest(req, this);
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }))
{
ERROR_LOG(m_logger) << "Error on request";
}
}
{
req.participantId(6); // according testDB
req.onlyOutdatedParticipants(false);
const LtsCoordTrans::UtmCoordinate &utmPos =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7600019000")); // 32U PD 76000 19000
QPointF pos = utmPos.geographic();
req.position(Core::GeoPosition(pos.x(), pos.y(), 0.0));
INFO_LOG(m_logger) << " setSimulatedPositionRequest ...";
m_replyError = true;
m_ppmFtc->setSimulatedPositionRequest(req, this);
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }))
{
ERROR_LOG(m_logger) << "Error on request";
}
}
}
{
ParticipantManagement::SetSimulatedParticipantFormation req_SSPF;
req_SSPF.participantId(89);
const LtsCoordTrans::UtmCoordinate &utmPos =
// LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7500018000")); // 32U PD 75000 18000
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD5000018000")); // 32U PD 50000 18000
QPointF pos = utmPos.geographic();
req_SSPF.position(Core::GeoPosition(pos.x(), pos.y(), 0.0));
QString prop = QString(QStringLiteral("{\"angle\":0,\"distance\":25,\"distanceSets\":{\"Aufgelockert\":50,\"Geschlossen\":25},\"geometry\":\"line\"}"));
req_SSPF.formation( prop.toStdString() );
INFO_LOG(m_logger) << " SetSimulatedParticipantFormation ... req = " << req_SSPF ;
m_replyError = true;
m_ppmFtc->setSimulatedParticipantFormationRequest(req_SSPF, this);
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }))
{
ERROR_LOG(m_logger) << "Error on request";
}
}
{
ParticipantManagement::SetSimulatedParticipantFormation req_SSPF;
req_SSPF.participantId(99);
const LtsCoordTrans::UtmCoordinate &utmPos =
// LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7500018000")); // 32U PD 75000 18000
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD0100018000")); // 32U PD 01000 18000
QPointF pos = utmPos.geographic();
req_SSPF.position(Core::GeoPosition(pos.x(), pos.y(), 0.0));
QString prop = QString(QStringLiteral("{\"angle\":0,\"distance\":25,\"distanceSets\":{\"Aufgelockert\":50,\"Geschlossen\":25},\"geometry\":\"line\"}"));
req_SSPF.formation( prop.toStdString() );
INFO_LOG(m_logger) << " SetSimulatedParticipantFormation ... req = " << req_SSPF ;
m_replyError = true;
m_ppmFtc->setSimulatedParticipantFormationRequest(req_SSPF, this);
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }))
{
ERROR_LOG(m_logger) << "Error on request";
}
}
INFO_LOG(m_logger) << " setSimulatedPositionRequest ...DONE";
}
bool ModuleTestExplosionCluster::checkParticipant_5()
{
// soll: QStringLiteral("32UPD7690018000")); // 32U PD 76900 18000
const int partId = 5;
const ParticipantManagement::ParticipantPosition &pos = m_ppmDtc->participantPosition(partId);
QString mgrsStr = LtsCoordTrans::mgrsFromGeographic(pos.pos().lon(), pos.pos().lat());
INFO_LOG(m_logger) << " for partId = '" << partId << "', we got position: " << mgrsStr;
return mgrsStr == QStringLiteral("32U PD 76900 18000");
}
bool ModuleTestExplosionCluster::checkParticipant_6()
{
// soll: QStringLiteral("32UPD7600019000")); // 32 U PD 76000 19000
const int partId = 6;
const ParticipantManagement::ParticipantPosition &pos = m_ppmDtc->participantPosition(partId);
QString mgrsStr = LtsCoordTrans::mgrsFromGeographic(pos.pos().lon(), pos.pos().lat());
INFO_LOG(m_logger) << " for partId = '" << partId << "', we got position: " << mgrsStr;
return mgrsStr == QStringLiteral("32U PD 76000 19000");
}
bool ModuleTestExplosionCluster::checkParticipant_89()
{
// soll: QStringLiteral("32UPD 50000 18000")); // 32 U PD 50000 18000
const int partId = 89;
std::vector<Core::GeoPosition> singlePositionsOut_unused;
const LtsUtils::QPoint3D &centerCoordGeo = Polygons::calculateFiringUnitCenterNonRecursive(m_ppmDtc, partId, singlePositionsOut_unused, m_logger);
if (centerCoordGeo.isNull() || std::isnan(centerCoordGeo.x()))
{
WARNING_LOG(m_logger) << LOGFUNCTION << " calculateFiringUnitCenterNonRecursive failed, partId = " << partId;
return false;
}
QString mgrsStr = LtsCoordTrans::mgrsFromGeographic(centerCoordGeo.x(), centerCoordGeo.y());
INFO_LOG(m_logger) << " for unit with partId = '" << partId << "', we got position: " << mgrsStr;
return mgrsStr == QStringLiteral("32U PD 50000 18000");
}
bool ModuleTestExplosionCluster::checkParticipant_99()
{
// soll: QStringLiteral("32UPD010018000")); // 32 U PD 01000 18000
const int partId = 99;
std::vector<Core::GeoPosition> singlePositionsOut_unused;
const LtsUtils::QPoint3D &centerCoordGeo = Polygons::calculateFiringUnitCenterNonRecursive(m_ppmDtc, partId, singlePositionsOut_unused, m_logger);
if (centerCoordGeo.isNull() || std::isnan(centerCoordGeo.x()))
{
WARNING_LOG(m_logger) << LOGFUNCTION << " calculateFiringUnitCenterNonRecursive failed, partId = " << partId;
return false;
}
QString mgrsStr = LtsCoordTrans::mgrsFromGeographic(centerCoordGeo.x(), centerCoordGeo.y());
INFO_LOG(m_logger) << " for unit with partId = '" << partId << "', we got position: " << mgrsStr;
return mgrsStr == QStringLiteral("32U PD 01000 18000");
}
void ModuleTestExplosionCluster::resetBldgs()
{
const QStringList bldgNames = {QStringLiteral("bldg_1104"),
QStringLiteral("bldg_1106"),
QStringLiteral("bldg_U_Bahn"),
QStringLiteral("bldg_BN_Kanaele"),
QStringLiteral("bldg_3101")
};
m_bldgIdToName.clear();
m_ismDtc->waitForHistoricalDataMainStructureElement(5000);
m_ismDtc->mainStructureElements([this, bldgNames](const InfrastructureManagement::MainStructureElement &mse)
{
if (mse.structureElementTypeId().underlying() != InfrastructureManagement::StructureElementType_def::Building)
return;
if (!bldgNames.contains(QString::fromStdString(mse.name()), Qt::CaseInsensitive))
return;
if (!m_ismDtc->isElementAssignedToExercise(mse, m_exerciseId))
return;
m_bldgIdToName.insert(mse.id(), QString::fromStdString(mse.name()));
});
qCritical() << " m_bldgIdToName" << m_bldgIdToName;
std::vector<Buildings::Building> buildingsVec;
buildingsVec.reserve(m_bldgIdToName.size());
auto bldgIds = m_bldgIdToName.keys();
for (int bldgId : qAsConst(bldgIds))
buildingsVec.push_back( Buildings::Building(bldgId, {}) );
Buildings::SetBuildingStatesRequest requestData;
requestData.buildings(buildingsVec);
requestData.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CombatReady);
requestData.resetContamination(true);
m_bldFtc->setBuildingStatesRequest(requestData, this);
// wait some seconds:
// spend some for the eventLoop to "consume" existing topics/samples:
for (int i = 0; i<20; ++i)
QTest::qWait(100);
// check states:
for (int bldgId : qAsConst(bldgIds))
{
const ProjectDataManagement::VulnerabilityState& bldgState = m_bldDtc->buildingState(bldgId).vulnerabilityState();
INFO_LOG(m_logger) << "resetBldgs: bldgId " << bldgId
<< ", state= " << bldgState
<< ", bldgName= " << m_bldgIdToName[bldgId];
QVERIFY2(bldgState.underlying()==ProjectDataManagement::VulnerabilityState_def::CombatReady, "ERROR, bldgState failed!!");
}
m_buildingStateVec.clear();
}
bool ModuleTestExplosionCluster::isKanaeleAssigned()
{
const QStringList bldgName(QStringLiteral("bldg_BN_Kanaele"));
m_ismDtc->waitForHistoricalDataMainStructureElement(5000);
bool bIsAssigned = false;
m_ismDtc->mainStructureElements([this, bldgName, &bIsAssigned](const InfrastructureManagement::MainStructureElement &mse)
{
if (mse.structureElementTypeId().underlying() != InfrastructureManagement::StructureElementType_def::Building)
return;
if (!bldgName.contains(QString::fromStdString(mse.name()), Qt::CaseInsensitive))
return;
if (!m_ismDtc->isElementAssignedToExercise(mse, m_exerciseId))
return;
bIsAssigned = true;
});
// qCritical() << " bIsAssigned" << bIsAssigned;
return bIsAssigned;
}
int ModuleTestExplosionCluster::getBldgId(const QString &bldgName) const
{
QMapIterator<int, QString> it (m_bldgIdToName);
while (it.hasNext())
{
it.next();
if (it.value().compare(bldgName, Qt::CaseInsensitive) == 0) // !!! '== 0' !!!
return it.key();
}
return -1;
}
//
// context of textCases
//
void ModuleTestExplosionCluster::initTestCase()
{
//
// DdsConnector
//
NOTICE_LOG(m_logger) << "DDSConnector: m_domainId " << m_domainId << ", m_exerciseId " << m_exerciseId;
// cmd
m_ddsConnector.reset(new DDSConnector::DdsConnector(m_domainId, IDL::PartitionType::Exercise, m_exerciseId));
bool bInit = m_ddsConnector->init();
QVERIFY2(bInit, "ERROR, ddsConnector.init failed!!");
if (!bInit)
{
ERROR_LOG(m_logger) << " ERROR, ddsConnector.init failed!!";
return;
}
INFO_LOG(m_logger) << " ddsConnector.init successfull";
// cmd
m_ddsConnector->initPublisherSubscriber();
INFO_LOG(m_logger) << " ddsConnector.initPublisherSubscriber done";
//
// Aes
//
// cmd
m_aesFtc = AreaEffectSimulation::Interface::Ftc::create(m_ddsConnector);
QVERIFY2(m_aesFtc, "ERROR, create m_aesFtc failed!!");
bool bRet = m_aesFtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
// cmd
m_aesDtc = AreaEffectSimulation::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_aesDtc, "ERROR, create m_aesDtc failed!!");
bRet = bRet && m_aesDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
m_aesDtc->enableAesItemView();
std::cout << " waitForHistoricalDataAesItemView... "<< std::endl;
m_aesDtc->waitForHistoricalDataAesItemView(2000);
std::cout << " waitForHistoricalDataAesItemView... Done"<< std::endl;
QMap<qint32, AreaEffectSimulation::AesItemView> aesItemViewsCont = m_aesDtc->aesItemViews();
std::cout << " aesItemViewsCont.size() " << aesItemViewsCont.size() << std::endl;
//
// PDM
//
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_pdmDtc, "ERROR, create m_pdmDtc failed!!");
bRet = bRet && m_pdmDtc->enableBuildingChargeEffect();
QVERIFY2(bRet, "ERROR, enableBuildingChargeEffect failed!!");
m_pdmDtc->waitForHistoricalDataBuildingChargeEffect(2000);
std::cout << " waitForHistoricalDataBuildingChargeEffect... Done" << std::endl;
ProjectDataManagement::BuildingChargeEffect bceInOut;
const int usedChargeTypeId = 371;
#ifdef Q_OS_WIN
const auto cb = [usedChargeTypeId, &bceInOut](const ProjectDataManagement::BuildingChargeEffect& data) -> bool
#else
const auto cb = [&bceInOut](const ProjectDataManagement::BuildingChargeEffect& data) -> bool
#endif
{
if (data.chargeTypeId() == usedChargeTypeId)
{
bceInOut = data;
return true; // break loop
}
return false;
};
// sonst kann sich der compiler nicht zwischen bool und void entscheiden... !?
std::function<bool(const ProjectDataManagement::BuildingChargeEffect &data)> cb1 = cb;
m_pdmDtc->buildingChargeEffects(cb1);
std::cout << " BuildingChargeEffect for usedChargeTypeId = " << usedChargeTypeId
<< ", BuildingChargeEffect = " << bceInOut << std::endl;
QVERIFY2(bceInOut.chargeTypeId() == usedChargeTypeId, "ERROR, buildingChargeEffects failed!!");
QVERIFY2(bceInOut.destructiveFactor() == 100, "ERROR, buildingChargeEffects.destructiveFactor failed!!");
QVERIFY2(bceInOut.penetrationFactor() == 150, "ERROR, buildingChargeEffects.penetrationFactor failed!!");
//
// BLD
//
m_bldDtc = Buildings::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_bldDtc, "ERROR, create m_bldDtc failed!!");
bRet = bRet && m_bldDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
m_bldFtc = Buildings::Interface::Ftc::create(m_ddsConnector);
QVERIFY2(m_bldFtc, "ERROR, create m_bldFtc failed!!");
bRet = bRet && m_bldFtc->enableAll();
m_bldFtc->enableSetBuildingStates();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
connect(m_bldDtc.get(), &Buildings::Interface::Dtc::buildingStateChanged,
this, &ModuleTestExplosionCluster::onBuildingStateChanged, Qt::UniqueConnection);
//
// ISM
//
m_ismDtc = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_ismDtc, "ERROR, create m_ismDtc failed!!");
bRet = bRet && m_ismDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
//
// EXM ExerciseManagement
//
m_exmDtc = ExerciseManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_exmDtc, "ERROR, create m_exmDtc failed!!");
bRet = bRet && m_exmDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
m_exmDtc->waitForHistoricalDataExercise(2000);
std::cout << " waitForHistoricalDataExercise... Done" << std::endl;
const ExerciseManagement::Exercise &exercise = m_exmDtc->exercise(m_exerciseId);
QVERIFY2(exercise.id() == m_exerciseId, "ERROR, exercise failed!!");
m_traingAreaId = exercise.trainingAreaId();
std::cout << " ExerciseManagement"
<< ", m_traingAreaId = " << m_traingAreaId << std::endl;
//
// PPM ParticipantManagement
//
//
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsConnector);
QVERIFY2(m_ppmDtc, "ERROR, create m_ppmDtc failed!!");
bRet = bRet && m_ppmDtc->enableAll();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
m_ppmFtc = ParticipantManagement::Interface::Ftc::create(m_ddsConnector);
QVERIFY2(m_ppmFtc, "ERROR, create m_ppmFtc failed!!");
bRet = bRet && m_ppmFtc->enableAll();
m_ppmFtc->enableSetSimulatedPosition();
QVERIFY2(bRet, "ERROR, enableAll failed!!");
// Geschuetz
setupParticipants();
// connect at the end to skip unwanted
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::explosionClusterChanged,
this, &ModuleTestExplosionCluster::onExplosionClusterChanged, Qt::UniqueConnection);
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::aesItemViewChanged,
this, &ModuleTestExplosionCluster::onAesItemViewChanged, Qt::UniqueConnection);
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::trajectoryTimeAwareChanged,
this, &ModuleTestExplosionCluster::onTrajectoryTimeAwareChanged, Qt::UniqueConnection);
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::effectsChanged,
this, &ModuleTestExplosionCluster::onEffectsChanged, Qt::UniqueConnection);
// spend some for the eventLoop to "consume" existing topics/samples:
for (int i = 0; i<10; ++i)
QTest::qWait(100);
}
void ModuleTestExplosionCluster::init()
{
// init will be called before each test function is executed.
m_counterDds.reset();
resetBldgs();
}
void ModuleTestExplosionCluster::test_justSetupParticipants()
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " START";
setupParticipants();
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_TneVerificationBremen_00()
{
if (m_traingAreaId != s_TraingAreaId_Bremen)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
// AXXX Zentrale/DDS ToSFM (compassDegree + 90.0)
// Zentrale/DDS ToSFM (tele.rotation + 90.0)
// Die '+90' ergeben sich wohl, weil in der Zentrale die Y-Achse (Tiefe) herangezogen wird,
// während die TNE die X-Achse (Breite) heranzieht.
// 'compass' 'math'
//
// A000 0 [deg] 0
// ___
// | |
// | |
// | |
// | |
// ___
//
// A030 30 [deg] 330 (-30)
// ___
// / /
// / /
// / /
// / /
// / /
// ___
double rot = 0;
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " rot " << rot << ", rotSfmOrg " << compassToMathAngleForSfm(rot) << ", rotSfmPlus90 " << compassToMathAngleForSfm(rot+90);
rot = 1;
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " rot " << rot << ", rotSfmOrg " << compassToMathAngleForSfm(rot) << ", rotSfmPlus90 " << compassToMathAngleForSfm(rot+90);
rot = 30;
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " rot " << rot << ", rotSfmOrg " << compassToMathAngleForSfm(rot) << ", rotSfmPlus90 " << compassToMathAngleForSfm(rot+90);
rot = 60;
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " rot " << rot << ", rotSfmOrg " << compassToMathAngleForSfm(rot) << ", rotSfmPlus90 " << compassToMathAngleForSfm(rot+90);
rot = -30;
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " rot " << rot << ", rotSfmOrg " << compassToMathAngleForSfm(rot) << ", rotSfmPlus90 " << compassToMathAngleForSfm(rot+90);
}
void ModuleTestExplosionCluster::test_TneVerificationBremen_01()
{
if (m_traingAreaId != s_TraingAreaId_Bremen)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
//
// !!!!! ModuleTest_TneVerification -> randomNumber = 32767; !!!!!!!!!!!
//
const int ausrichtung = 0; // Entsprechend dem Dateinamen von Mötje
const int rotation = ausrichtung;
AreaEffectSimulation::ExplosionCluster eaData = getEcForTneVerification(QStringLiteral("ModuleTest_TneVerificationBremen_01__"), rotation);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
// Check MHP:
const std::vector<Core::GeoPosition2D>& mhPointsRef = m_data.mhPoints();
QVERIFY2(mhPointsRef.size() == 1, "ERROR, mhPoints().size() failed!!");
const LtsCoordTrans::UtmCoordinate &mhpUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(mhPointsRef.front().lon(), mhPointsRef.front().lat());
DEBUG_LOG(m_logger) << " TNE VERIFICATION: mhpUtm = " << mhpUtm.mgrs();
QVERIFY2(distanceMeter(mhPointsRef.front(), LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97000 78000"))) < 1, "ERROR, mhPointsRef failed!!");
//
// get AesItemView:
//
// m_data should contain the id bc onExplosionClusterChanged:
const int simId = m_data.id();
AreaEffectSimulation::AesItemView itemView;
DEBUG_LOG(m_logger) << " TNE VERIFICATION: simId = " << simId;
const bool bFound = m_aesDtc->aesItemViewFromEntityId(simId, AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions, itemView);
QVERIFY2(bFound, "ERROR,aesItemViewFromEntityId failed!!");
QVERIFY2(itemView.aesItemId() == simId, "ERROR,aesItemViewFromEntityId failed!!");
INFO_LOG(m_logger) << " ddsConnector.initPublisherSubscriber done";
const double rot = m_data.area().rotation();
const double rotSfmOrg = compassToMathAngleForSfm(rot);
const double rotSfmPlus90 = compassToMathAngleForSfm(rot+90);
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:"
<< " randomNumber = ????????"
<< ", width=" << m_data.area().width()
<< ", height=" << m_data.area().height()
<< ", ausrichtung=" << ausrichtung
<< ", rot=" << rot
<< ", rotSfmOrg=" << rotSfmOrg
<< ", rotSfmPlus90=" << rotSfmPlus90
<< ", m_data.mhPoints().size()=" << m_data.mhPoints().size();
const std::vector<Core::GeoPosition> &formRef = itemView.form();
for (const Core::GeoPosition &geoCoord : qAsConst(formRef))
{
const LtsCoordTrans::UtmCoordinate &utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoCoord.lon(), geoCoord.lat());
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " utm: " << utm.mgrs() << ", item=" << geoCoord;
}
size_t i = 0;
// see GUEZE-2311: file MTP_97000E_78000N_B40_T100_A000.txt
// Nr=1 Mtp=0 Oost=97003[m] Nord=77996[m]
// Nr=2 Mtp=0 Oost=96994[m] Nord=78019[m]
// Nr=3 Mtp=0 Oost=97001[m] Nord=77991[m]
// Nr=4 Mtp=0 Oost=97005[m] Nord=78019[m]
// Nr=5 Mtp=0 Oost=96999[m] Nord=78006[m]
// Nr=6 Mtp=0 Oost=97005[m] Nord=78011[m]
// Nr=7 Mtp=0 Oost=96995[m] Nord=77965[m]
// Nr=8 Mtp=0 Oost=96999[m] Nord=77986[m]
// Nr=9 Mtp=0 Oost=97005[m] Nord=78024[m]
// Nr=10 Mtp=0 Oost=97002[m] Nord=78004[m]
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97003 77996"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96994 78019"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97001 77991"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97005 78019"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96999 78006"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97005 78011"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96995 77965"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96999 77986"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97005 78024"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97002 78004"))) < 1, "ERROR, distanceMeter failed!!");
dumpCnt();
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_TneVerificationBremen_02()
{
if (m_traingAreaId != s_TraingAreaId_Bremen)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
//
// !!!!! ModuleTest_TneVerification -> randomNumber = 32767; !!!!!!!!!!!
//
const int ausrichtung = 30; // Entsprechend dem Dateinamen von Mötje
const int rotation = ausrichtung;
AreaEffectSimulation::ExplosionCluster eaData = getEcForTneVerification(QStringLiteral("ModuleTest_TneVerificationBremen_02__"), rotation);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
// Check MHP:
const std::vector<Core::GeoPosition2D>& mhPointsRef = m_data.mhPoints();
QVERIFY2(mhPointsRef.size() == 1, "ERROR, mhPoints().size() failed!!");
const LtsCoordTrans::UtmCoordinate &mhpUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(mhPointsRef.front().lon(), mhPointsRef.front().lat());
DEBUG_LOG(m_logger) << " TNE VERIFICATION: mhpUtm = " << mhpUtm.mgrs();
QVERIFY2(distanceMeter(mhPointsRef.front(), LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97000 78000"))) < 1, "ERROR, mhPointsRef failed!!");
//
// get AesItemView:
//
// m_data should contain the id bc onExplosionClusterChanged:
const int simId = m_data.id();
AreaEffectSimulation::AesItemView itemView;
DEBUG_LOG(m_logger) << " TNE VERIFICATION: simId = " << simId;
const bool bFound = m_aesDtc->aesItemViewFromEntityId(simId, AreaEffectSimulation::AesType::AtExplosionClusterSingleExplosions, itemView);
QVERIFY2(bFound, "ERROR,aesItemViewFromEntityId failed!!");
QVERIFY2(itemView.aesItemId() == simId, "ERROR,aesItemViewFromEntityId failed!!");
INFO_LOG(m_logger) << " ddsConnector.initPublisherSubscriber done";
const double rot = m_data.area().rotation();
const double rotSfmOrg = compassToMathAngleForSfm(rot);
const double rotSfmPlus90 = compassToMathAngleForSfm(rot+90);
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:"
<< " randomNumber = ????????"
<< ", width=" << m_data.area().width()
<< ", height=" << m_data.area().height()
<< ", ausrichtung=" << ausrichtung
<< ", rot=" << rot
<< ", rotSfmOrg=" << rotSfmOrg
<< ", rotSfmPlus90=" << rotSfmPlus90
<< ", m_data.mhPoints().size()=" << m_data.mhPoints().size();
const std::vector<Core::GeoPosition> &formRef = itemView.form();
for (const Core::GeoPosition &geoCoord : qAsConst(formRef))
{
const LtsCoordTrans::UtmCoordinate &utm = LtsCoordTrans::UtmCoordinate::fromGeographic(geoCoord.lon(), geoCoord.lat());
INFO_LOG(m_logger) << " TNE VERIFICATION: CHECK:" << " utm: " << utm.mgrs() << ", item=" << geoCoord;
}
size_t i = 0;
// see GUEZE-2311: MTP_97000E_78000N_B40_T100_A030.txt
// Nr=1 Mtp=0 Oost=97001[m] Nord=77995[m]
// Nr=2 Mtp=0 Oost=97004[m] Nord=78019[m]
// Nr=3 Mtp=0 Oost=96996[m] Nord=77992[m]
// Nr=4 Mtp=0 Oost=97014[m] Nord=78014[m]
// Nr=5 Mtp=0 Oost=97002[m] Nord=78006[m]
// Nr=6 Mtp=0 Oost=97010[m] Nord=78007[m]
// Nr=7 Mtp=0 Oost=96978[m] Nord=77972[m]
// Nr=8 Mtp=0 Oost=96992[m] Nord=77988[m]
// Nr=9 Mtp=0 Oost=97016[m] Nord=78018[m]
// Nr=10 Mtp=0 Oost=97004[m] Nord=78002[m]
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97001 77995"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97004 78019"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96996 77992"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97014 78014"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97002 78006"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97010 78007"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96978 77972"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 96992 77988"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97016 78018"))) < 1, "ERROR, distanceMeter failed!!");
QVERIFY2(distanceMeter(formRef[i++], LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 97004 78002"))) < 1, "ERROR, distanceMeter failed!!");
}
//
// 1104
//
void ModuleTestExplosionCluster::test_bldg_1104_Proximity()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
// !!! assume ONE elevationMap: Altmark_dt1.tif !!!
// !!! assume ONE elevationMap: Altmark_dt1.tif !!!
// !!! assume ONE elevationMap: Altmark_dt1.tif !!!
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_1104_Proximity_ec__"));
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
// // eaData.impactCount(120);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(m_counterDds.cntExplosionCluster == 4, "ERROR, cnt failed!!"); // EsPrepared, EsActivated, isObjectModifiable==false, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionCluster == 3, "ERROR, cnt failed!!"); // EsPrepared, EsActivated, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionClusterGunToTargetLine == 1, "ERROR, cnt failed!!"); // one for eAdded, eRemoved is skipped
// cnt..Effects == 4, weil es zu Schnittpunkten mit dem Bldg kommt und der ideale Einschlag daher "verschoben" werden muss:
// In der Zwischenzeit scheint CES so schnell zu sein, das aufgrund von timing teilweise nur weniger cntAt..SingleExplosion sind:
const bool bOkCntEffects = (m_counterDds.cntExplosionClusterEffects == 4);
QVERIFY2(bOkCntEffects, "ERROR, bOkCntEffects failed!!");
QVERIFY2(m_counterDds.cntTrajectory == 4, "ERROR, cnt failed!!"); // 4 impacts -> 4 trajectory
// 25.11.2024
QVERIFY2(checkSingleEffects(0, LtsCoordinate(0.202561540523851, 0.916109327069519, 97.36), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(1, LtsCoordinate(0.202563069434816, 0.916108822522219, 99.37), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(2, LtsCoordinate(0.202564591566166, 0.916108475073837, 100.66), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(3, LtsCoordinate(0.202566139016178, 0.916108284016931, 101.21), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
// UNABHÄNGIG von [GUEZE-2766] Zünderarten Freifläche:
// mal Raum 2209 -> {9, 18, 27, 36}
// mal Raum 2308 -> {9, 18, 27, 40}
bool bOk = checkBldgStates({9, 18, 27, 36}, QString::fromStdString(eaData.name())) ||
checkBldgStates({9, 18, 27, 40}, QString::fromStdString(eaData.name()));
QVERIFY2(bOk, "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_1104_Impact()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_1104_Impact_ec__"));
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// 25.11.2024
QVERIFY2(checkSingleEffects(0, LtsCoordinate(0.202561627985573, 0.916110065124748, 94.75), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(1, LtsCoordinate(0.202563154670975, 0.916109519058226, 96.80), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(2, LtsCoordinate(0.202564693697330, 0.916109157164788, 98.10), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(3, LtsCoordinate(0.202566253464458, 0.916108977469463, 98.68), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
// UNABHÄNGIG von [GUEZE-2766] Zünderarten Freifläche:
QVERIFY2(checkBldgStates({14, 32, 49, 63}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_1104_Delay()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_1104_Delay_ec__"));
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// 25.11.2024
QVERIFY2(checkSingleEffects(0, LtsCoordinate(0.202561720250798, 0.916110735664395, 92.15), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(1, LtsCoordinate(0.202563249164409, 0.916110231116934, 94.22), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(2, LtsCoordinate(0.202564803395849, 0.916109882960961, 95.55), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
QVERIFY2(checkSingleEffects(3, LtsCoordinate(0.202566382946022, 0.916109691196411, 96.15), AesZPlacement_def::ZpAbsolute, bldgName), "ERROR, checkSingleEffects failed!!");
// Vor Anpassung der MTP-Flächenausdehung: 30, 47, 68, 87
// Nach Anpassung der MTP-Flächenausdehung: 30, 56, 74, 90
// UNABHÄNGIG von [GUEZE-2766] Zünderarten Freifläche:
QVERIFY2(checkBldgStates({30, 56, 74, 90}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
//
// 1106
//
void ModuleTestExplosionCluster::test_bldg_1106_Proximity()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1106"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_6(), "ERROR, checkParticipant_6 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1106(QStringLiteral("ModuleTest_1106_Proximity_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// Maybe Kanaele cover bldg_1106 from impact due to very simple algorithm:
// CES/Plugins/Buildings/handler_aes_data.cpp:674 / findBuildingsBetween(impactPos, footprint)
const bool bIsKanaeleAssigned = isKanaeleAssigned();
NOTICE_LOG(m_logger) << LOGFUNCTION << " bIsKanaeleAssigned = " << bIsKanaeleAssigned;
if (bIsKanaeleAssigned)
// QVERIFY2(checkBldgStates({14, 22, 29, 37}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
// since 13.11.2024 ; [GUEZE-2766] Zünderarten Freifläche:
QVERIFY2(checkBldgStates({15, 23, 30, 38}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
else
QVERIFY2(checkBldgStates({14, 30, 45, 61}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_1106_Impact()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1106"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_6(), "ERROR, checkParticipant_6 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1106(QStringLiteral("ModuleTest_1106_Impact_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// Maybe Kanaele cover bldg_1106 from impact due to very simple algorithm:
// CES/Plugins/Buildings/handler_aes_data.cpp:674 / findBuildingsBetween(impactPos, footprint)
const bool bIsKanaeleAssigned = isKanaeleAssigned();
NOTICE_LOG(m_logger) << LOGFUNCTION << " bIsKanaeleAssigned = " << bIsKanaeleAssigned;
if (bIsKanaeleAssigned)
QVERIFY2(checkBldgStates({14, 28, 41, 56}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
else
QVERIFY2(checkBldgStates({14, 41, 68, 88}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_1106_Delay()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1106"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_6(), "ERROR, checkParticipant_6 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1106(QStringLiteral("ModuleTest_1106_Delay_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeDelay);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// Maybe Kanaele cover bldg_1106 from impact due to very simple algorithm:
// CES/Plugins/Buildings/handler_aes_data.cpp:674 / findBuildingsBetween(impactPos, footprint)
const bool bIsKanaeleAssigned = isKanaeleAssigned();
NOTICE_LOG(m_logger) << LOGFUNCTION << " bIsKanaeleAssigned = " << bIsKanaeleAssigned;
if (bIsKanaeleAssigned)
QVERIFY2(checkBldgStates({14, 43, 72, 86 }, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
else
QVERIFY2(checkBldgStates({14, 71, 90, 99}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_UBAHN_Proximity()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_U_Bahn"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcForUBAHN(QStringLiteral("ModuleTest_UBAHN_Proximity_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// QVERIFY2(checkBldgStates({2, 4, 6, 6}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
// since 13.11.2024 ; [GUEZE-2766] Zünderarten Freifläche:
QVERIFY2(checkBldgStates({2, 4, 7, 7}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
// participantId(5)
// Schuss 1: nearestWall.roomId = 2303
// Schuss 2: nearestWall.roomId = 2303
// Schuss 3: nearestWall.roomId = 2303
// Schuss 4: nearestWall.roomId=2303, hitPos.distance=3.89286
// Damage: 8%
}
void ModuleTestExplosionCluster::test_bldg_UBAHN_Impact()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_U_Bahn"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcForUBAHN(QStringLiteral("ModuleTest_UBAHN_Impact_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// NT, Nov 2024: Durch irgendwelche Anpassungen scheint es sich verändert zu haben: {4, 8, 9, 10} -> {4, 5, 9, 8}
// NT, Feb 2025: Nun doch wieder das alte? damagePercent IST: QVector(4, 8, 9, 10)
bool bCheckBldgOk = checkBldgStates({4, 8, 9, 10}, QString::fromStdString(eaData.name())) ||
checkBldgStates({4, 5, 7, 8}, QString::fromStdString(eaData.name()));
QVERIFY2(bCheckBldgOk, "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
// participantId(5)
// Schuss 1: nearestWall.roomId = 2303
// Schuss 2: nearestWall.roomId = 2232
// Schuss 3: nearestWall.roomId = 2303
// Schuss 4: nearestWall.roomId=2303, hitPos.distance=3.89286
// Damage: 10%
}
void ModuleTestExplosionCluster::test_bldg_UBAHN_Delay()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_U_Bahn"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcForUBAHN(QStringLiteral("ModuleTest_UBAHN_Delay_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeDelay);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(checkBldgStates({8, 11, 13, 13}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
// participantId(5)
// Schuss 1: nearestWall.roomId = 2132
// Schuss 2: found several rooms, choose first: 2132
// Schuss 3: found several rooms, choose first: 2132
// Schuss 4: nearestWall.roomId=2303, hitPos.distance=3.89286
// Damage: 9%
}
void ModuleTestExplosionCluster::test_bldg_3101_Proximity()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_3101"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_89(), "ERROR, checkParticipant_89 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor3101(QStringLiteral("ModuleTest_3101_Proximity_ec__"));
eaData.effectStart((time(nullptr) + 50) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// QVERIFY2(checkBldgStates({7, 13, 20, 27}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
// since 13.11.2024 ; [GUEZE-2766] Zünderarten Freifläche:
QVERIFY2(checkBldgStates({7, 14, 21, 28}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
// participantId(89)
// Schuss 1:
// Schuss 2:
// Schuss 3:
// Schuss 4:
// Damage: 37%
}
void ModuleTestExplosionCluster::test_bldg_3101_Impact()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_3101"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_89(), "ERROR, checkParticipant_89 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor3101(QStringLiteral("ModuleTest_3101_Impact_ec__"));
eaData.effectStart((time(nullptr) + 50) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(checkBldgStates({7, 13, 25, 36}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
// participantId(89)
// Schuss 1:
// Schuss 2:
// Schuss 3:
// Schuss 4:
// Damage: 53%
}
void ModuleTestExplosionCluster::test_bldg_3101_Delay()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_3101"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_89(), "ERROR, checkParticipant_89 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor3101(QStringLiteral("ModuleTest_3101_Delay_ec__"));
eaData.effectStart((time(nullptr) + 50) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeDelay);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(checkBldgStates({7, 13, 37, 58}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
// participantId(89)
// Schuss 1:
// Schuss 2:
// Schuss 3:
// Schuss 4:
// Damage: 69%
}
void ModuleTestExplosionCluster::test_remove_effect_start()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_RemoveEffectStart_ec__"));
eaData.effectStart((time(nullptr) + 40) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
// SubStruct FlightCurve
FlightCurve fc;
fc.requestedRelativePeakHeight(-1);
fc.requestedFlightDuration(10 * 1000);
eaData.flightCurve(toOptional(fc));
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
m_objectRequestedTimePointMsec = time(nullptr) * 1000;
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
// expected condition:
if (!waitForData([this]() { return m_replyError == false; }, 1))
{
ERROR_LOG(m_logger) << "Error on request";
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsPrepared...";
if (!waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsPrepared;}, 2))
{
ERROR_LOG(m_logger) << "Timeout waiting for EsPrepared of explosion cluster with id " << m_data.id();
return;
}
{
// calculatedFlightDurationMsec = ((FlightDuration + 2sec) => 12sec
// estimatedMaxFlightDurationMSec = ((FlightDuration + 2sec) * 1.1) + 10sec => 23,2sec
long waitSec = 10;
QTimer::singleShot(waitSec*1000, this, [this, eaData]
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " ACTION: prepared back to created ... ";
AreaEffectSimulation::ExplosionCluster copy = eaData;
copy.id(m_data.id());
copy.effectStart().reset(); // 'remove' -> prepared back to created
int ret = doExplosionClusterModifyRequest(copy);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " ACTION: prepared back to created ... DONE";
});
}
INFO_LOG(m_logger) << LOGFUNCTION << " waiting to make sure, that next step is never reached:";
if (waitForData([this]() { return m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated;}, 60))
{
ERROR_LOG(m_logger) << "Next step is accidentically reached of explosion cluster with id " << m_data.id();
QVERIFY2(false, "ERROR, exit");
return;
}
INFO_LOG(m_logger) << LOGFUNCTION << " object effectState: " << m_data.effectStateId();
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsCreated, "ERROR, ExplosionCluster in wrong state");
dumpCnt();
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_create_bulk()
{
if (!ModuleTestExplosionCluster::m_enable_create_bulk)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase, has to be call explicitly called by user";
return;
}
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_89(), "ERROR, checkParticipant_89 failed!!");
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
for (int i = 0; i < 50; ++i)
{
QString name = QString(QStringLiteral("ModTst_Proximity_ec_%1")).arg(i);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(name);
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
eaData.effectDuration(60 * 1000); // 60 seconds
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
eaData.impactCount(60);
eaData.area().cornerBottomLeft().lon() = 0.20128 + (i*0.00001);
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
QTest::qWait(100);
} // for
waitForEffectStates(__LINE__, 5, 60, 60);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_point_geometry_bldg_1104()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_Point_1104_Impact_ec__"));
eaData.effectStart((time(nullptr) + 45) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
eaData.chargeStruct().chargeTypeId(371); // radius == 25, diameter == 50m
QVERIFY2(eaData.flightCurve().is_set(), "ERROR, flightCurve() not set !!");
eaData.flightCurve().get().requestedRelativePeakHeight(500);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint);
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.20256382834808495, 0.9161105453111705)); // !!bottomLeft!! should be interpreted at center of impact
// LtsCoordTrans::UtmCoordinate newTargetPosUtm_Hill = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77457 17613")); // 32U PD 77438 17632
// auto newPnt = newTargetPosUtm_Hill.geographic();
// eaData.area().cornerBottomLeft(Core::GeoPosition2D(newPnt.x(), newPnt.y())); // !!bottomLeft!! should be interpreted at center of impact
eaData.area().width(0);
eaData.area().height(0);
eaData.area().rotation(0);
eaData.mhPoints().resize(1);
eaData.impactCount(1);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(checkBldgStates({29}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_point_geometry_bldg_1104_SMArt_Proximity()
{
// NT, Jan 2025: since SMArt seems to be 'not implememented yet', test case fails
// NT, Jan 2025: since SMArt seems to be 'not implememented yet', test case fails
// NT, Jan 2025: since SMArt seems to be 'not implememented yet', test case fails
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104_SMArt"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_Point_1104_SMArt_Impact_ec__"));
eaData.effectStart((time(nullptr) + 45) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
eaData.chargeStruct().chargeTypeId(374); // 374: isSMArt=true ; radius == 25, diameter == 50m
NOTICE_LOG(m_logger) << LOGFUNCTION << "Vor eaData.flightCurve().is_set()";
QVERIFY2(eaData.flightCurve().is_set(), "ERROR, flightCurve() not set !!");
NOTICE_LOG(m_logger) << LOGFUNCTION << "Nach eaData.flightCurve().is_set()";
eaData.flightCurve().get().requestedRelativePeakHeight(500);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint);
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.20256382834808495, 0.9161105453111705)); // !!bottomLeft!! should be interpreted at center of impact
// LtsCoordTrans::UtmCoordinate newTargetPosUtm_Hill = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77457 17613")); // 32U PD 77438 17632
// auto newPnt = newTargetPosUtm_Hill.geographic();
// eaData.area().cornerBottomLeft(Core::GeoPosition2D(newPnt.x(), newPnt.y())); // !!bottomLeft!! should be interpreted at center of impact
eaData.area().width(0);
eaData.area().height(0);
eaData.area().rotation(0);
eaData.mhPoints().resize(1);
eaData.impactCount(1);
m_replyError = true;
NOTICE_LOG(m_logger) << "vor m_data = AreaEffectSimulation::ExplosionCluster(); " << m_data;
m_data = AreaEffectSimulation::ExplosionCluster();
NOTICE_LOG(m_logger) << "vor doExplosionClusterModifyRequest";
int ret = doExplosionClusterModifyRequest(eaData);
NOTICE_LOG(m_logger) << "nach doExplosionClusterModifyRequest";
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(checkBldgStates({29}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_1104_OC()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
// QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
// setFilterForBldgState(bldgName);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
AreaEffectSimulation::ExplosionClusterOcModifyRequest requestOC;
requestOC.id(0);
requestOC.effectStart((time(nullptr) + 30) * 1000); // msec
requestOC.effectDuration(5000); // msec
QString name(QStringLiteral("ModuleTest_test_bldg_1104_OC"));
name += QString::number(requestOC.effectStart());
requestOC.name(name.toStdString());
requestOC.area().cornerBottomLeft(Core::GeoPosition2D(0.2025, 0.91611)); // !!bottomLeft!!
requestOC.area().width(20);
requestOC.area().height(30);
requestOC.area().rotation(17);
requestOC.mhpCount(2);
requestOC.mhpRotation(17);
requestOC.impactCount(3);
requestOC.chargeStruct().chargeTypeId(371);
requestOC.partyId(2);
int ret = doExplosionClusterOcModifyRequest(requestOC);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
// light -> no curve
void ModuleTestExplosionCluster::test_point_geometry_bldg_1104_light()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData;
eaData.effectStart((time(nullptr) + 45) * 1000); // msec
eaData.effectDuration(5000); // 5 seconds
QString name(QStringLiteral("ModuleTest_Point_1104_Light__"));
name += QString::number(eaData.effectStart().get());
eaData.name(name.toStdString());
eaData.id(0);
eaData.externalId(815);
eaData.partyId(4);
eaData.participantId(-1); // <--------------- no participantId provided -> no curve/trajectory!?!!
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
eaData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint);
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.20256382834808495, 0.9161105453111705)); // !!bottomLeft!!
eaData.area().width(10);
eaData.area().height(10);
eaData.area().rotation(0);
eaData.mhPoints().resize(1);
eaData.impactCount(1);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
// QVERIFY2(checkBldgStates({29}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster:: test_point_geometry_bldg_1104_single_effect_only()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
// // QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
AreaEffectSimulation::ExplosionClusterSingleEffectOnlyRequest request;
request.id(0);
request.effectStart((time(nullptr) + 45) * 1000); // msec
QString name(QStringLiteral("ModuleTest_PointGeometery_bldg_1104_effect_only"));
name += QString::number(request.effectStart().get());
request.name(name.toStdString());
request.element(request.name());
const QPointF impactPointF(0.20256382834808495, 0.9161105453111705);
request.impactPosition(Core::GeoPosition2D(impactPointF.x(), impactPointF.y()));
INFO_LOG(m_logger) << LOGFUNCTION << " requested impact position = " << LtsCoordTrans::UtmCoordinate::fromGeographic(impactPointF).mgrs();
request.chargeTypeId(371);
request.externalId(815);
int ret = doExplosionClusterSingleEffectOnlyModifyRequest(request);
QVERIFY2(ret != 0, "ERROR, doExplosionClusterSingleEffectOnlyModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 60, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(checkBldgStates({29}, QString::fromStdString(request.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_bldg_1104_effects_only()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
// QVERIFY2(checkParticipant_5(), "ERROR, checkParticipant_5 failed!!");
setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_1104_effects_only__"));
eaData.effectStart((time(nullptr) + 30) * 1000); // msec
eaData.chargeStruct().igniterTypeId(s_IgniterTypeProximity);
//
// avoid trajectory :
//
// // eaData.partyId().reset(); ??
eaData.participantId().reset();
//
// : avoid trajectory
//
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 150, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(m_counterDds.cntExplosionCluster == 3, "ERROR, cnt failed!!"); // EsPrepared, isObjectModifiable==false, EsActivated, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionCluster == 3, "ERROR, cnt failed!!"); // EsPrepared, EsActivated, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionClusterGunToTargetLine == 0, "ERROR, cnt failed!!"); // no participantId, no trajectory
// cnt..Effects == 4, weil es zu Schnittpunkten mit dem Bldg kommt und der ideale Einschlag daher "verschoben" werden muss:
// In der Zwischenzeit scheint CES so schnell zu sein, das aufgrund von timing teilweise nur weniger cntAt..SingleExplosion sind:
const bool bOkCntEffects = (m_counterDds.cntExplosionClusterEffects == 4);
QVERIFY2(bOkCntEffects, "ERROR, bOkCntEffects failed!!");
QVERIFY2(m_counterDds.cntTrajectory == 0, "ERROR, cnt failed!!"); // 4 impacts -> 4 trajectory
std::vector<AreaEffectSimulation::SingleEffect>&singleEffects = m_effects.singleEffects();
for (const AreaEffectSimulation::SingleEffect &se : qAsConst(singleEffects))
{
// Since there is no trajectory, no intersection is calculated.
// Therefore the impacts are on the ground.
QVERIFY2(se.singleEffectState() == AreaEffectSimulation::AesSingleEffectState_def::SesTriggered, "ERROR, wrong singleEffectState");
QVERIFY2(se.zPlacement() == AreaEffectSimulation::AesZPlacement_def::ZpDraped, "ERROR, wrong zPlacement");
QVERIFY2(se.position().z() > 90, "ERROR, wrong z-Value 1");
QVERIFY2(se.position().z() < 95, "ERROR, wrong z-Value 2");
}
QVERIFY2(checkBldgStates({29, 59, 82, 94}, QString::fromStdString(eaData.name())), "ERROR, checkBldgStates failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_vulcano_bldg_1104()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104_VULCANO"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_99(), "ERROR, checkParticipant_99 failed!!");
// setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_Point_1104_Impact_VULCANO__"));
eaData.effectStart((time(nullptr) + 130) * 1000); // msec
eaData.participantId(99);
eaData.partyId(3);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
eaData.chargeStruct().chargeTypeId(s_ChargeTypeIdVulcano); // s_ChargeTypeIdVulcano == 376
QVERIFY2(eaData.flightCurve().is_set(), "ERROR, flightCurve() not set !!");
eaData.flightCurve().get().requestedRelativePeakHeight(11100); // == 53deg bei 500 m/s -> apo: x: 12211 y/z= 8190
eaData.flightCurve().get().launchVelocity(500);
eaData.flightCurve().get().launchAngle(0); // calculated ; parameter is prepared for ADLER
eaData.flightCurve().get().dropAngle(45);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint);
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.20256382834808495, 0.9161105453111705)); // !!bottomLeft!!
eaData.area().width(25);
eaData.area().height(25);
eaData.area().rotation(0);
eaData.mhPoints().resize(1);
eaData.impactCount(1);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
waitForEffectStates(__LINE__, 5, 150, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(m_counterDds.cntExplosionCluster == 4, "ERROR, cnt failed!!"); // EsPrepared, EsActivated, isObjectModifiable==false, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionCluster == 3, "ERROR, cnt failed!!");
QVERIFY2(m_counterDds.cntAtExplosionClusterGunToTargetLine == 1, "ERROR, cnt failed!!");
QVERIFY2(m_counterDds.cntExplosionClusterEffects == 1, "ERROR, cnt failed!!");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_vulcano_bldg_1104_withTargetModify()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104_VULCANO"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_99(), "ERROR, checkParticipant_99 failed!!");
// setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_Point_1104_Impact_VULCANO__"));
eaData.effectStart((time(nullptr) + 130) * 1000); // msec
eaData.participantId(99);
eaData.partyId(3);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
eaData.chargeStruct().chargeTypeId(s_ChargeTypeIdVulcano); // s_ChargeTypeIdVulcano == 376
QVERIFY2(eaData.flightCurve().is_set(), "ERROR, flightCurve() not set !!");
eaData.flightCurve().get().requestedRelativePeakHeight(11100); // == 53deg bei 500 m/s -> apo: x: 12211 y/z= 8190
eaData.flightCurve().get().launchVelocity(500);
eaData.flightCurve().get().launchAngle(0); // calculated ; parameter is prepared for ADLER
eaData.flightCurve().get().dropAngle(45);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint);
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.20256382834808495, 0.9161105453111705)); // !!bottomLeft!!
eaData.area().width(25);
eaData.area().height(25);
eaData.area().rotation(0);
eaData.mhPoints().resize(1);
eaData.impactCount(1);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
static LtsCoordTrans::UtmCoordinate s_newTargetPosUtm_1 =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77438 17632")); // 32U PD 77438 17632
QTimer::singleShot(2000, this, [this] () { // local static is captured implicit by gcc and for MSVS
qint64 startTimeMsec = -1;
if (m_data.effectStart().is_set())
startTimeMsec = m_data.effectStart().get();
const qint64 nowMsec = QDateTime::currentMSecsSinceEpoch();
const qint64 distMsec = startTimeMsec - nowMsec;
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 1 "
<< ", effectStart (impactTime) = " << startTimeMsec
<< ", nowMsec = " << nowMsec
<< ", distMsec = " << distMsec;
int delayMsec = 5000; // distMsec - 5000;
QTimer::singleShot(distMsec - delayMsec, this, [this] () { // local static is captured implicit by gcc and for MSVS
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 2 ";
QPointF newTargetPosGeo = s_newTargetPosUtm_1.geographic();
TargetPositionsModifyRequest request;
request.aesItemId(m_data.id());
request.positions().emplace_back(Core::GeoPosition(newTargetPosGeo.x(), newTargetPosGeo.y(), 123));
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 2, doExplosionClusterTargetPositionsModify ...";
doExplosionClusterTargetPositionsModify(request);
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 2, doExplosionClusterTargetPositionsModify ... DONE";
});
});
waitForEffectStates(__LINE__, 5, 150, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
dumpCnt();
QVERIFY2(m_counterDds.cntExplosionCluster == 4, "ERROR, cnt failed!!"); // EsPrepared, EsActivated, isObjectModifiable==false, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionCluster == 3, "ERROR, cnt failed!!");
QVERIFY2(m_counterDds.cntAtExplosionClusterGunToTargetLine == 1, "ERROR, cnt failed!!");
QVERIFY2(m_counterDds.cntExplosionClusterEffects == 1, "ERROR, cnt failed!!");
QVERIFY2(m_effects.aesItemId() == m_data.id(), "ERROR, id mismatch");
if (!m_effects.singleEffects().empty())
{
const AreaEffectSimulation::SingleEffect &se = m_effects.singleEffects().front();
const Core::GeoPosition &seGeoPos = se.position();
const LtsCoordTrans::UtmCoordinate &seUtmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(seGeoPos.lon(), seGeoPos.lat());
int dist = LtsCoordTrans::distance(s_newTargetPosUtm_1, seUtmPos);
NOTICE_LOG(m_logger) << LOGFUNCTION << " dist = " << dist;
}
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::test_vulcano_bldg_1104_withTargetModify2()
{
if (m_traingAreaId != s_TraingAreaId_Altmark)
{
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
return;
}
const QString bldgName(QStringLiteral("bldg_1104_VULCANO"));
NOTICE_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
QVERIFY2(checkParticipant_99(), "ERROR, checkParticipant_99 failed!!");
// setFilterForBldgState(bldgName);
AreaEffectSimulation::ExplosionCluster eaData = getEcFor1104(QStringLiteral("ModuleTest_Point_1104_Impact_VULCANO__"));
eaData.effectStart((time(nullptr) + 130) * 1000); // msec
eaData.participantId(99);
eaData.partyId(3);
eaData.chargeStruct().igniterTypeId(s_IgniterTypeImpact);
eaData.chargeStruct().chargeTypeId(s_ChargeTypeIdVulcano); // s_ChargeTypeIdVulcano == 376
QVERIFY2(eaData.flightCurve().is_set(), "ERROR, flightCurve() not set !!");
eaData.flightCurve().get().requestedRelativePeakHeight(11100); // == 53deg bei 500 m/s -> apo: x: 12211 y/z= 8190
eaData.flightCurve().get().launchVelocity(500);
eaData.flightCurve().get().launchAngle(0); // calculated ; parameter is prepared for ADLER
eaData.flightCurve().get().dropAngle(45);
eaData.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint);
eaData.area().cornerBottomLeft(Core::GeoPosition2D(0.20256382834808495, 0.9161105453111705)); // !!bottomLeft!!
eaData.area().width(25);
eaData.area().height(25);
eaData.area().rotation(0);
eaData.mhPoints().resize(1);
eaData.impactCount(1);
m_replyError = true;
m_data = AreaEffectSimulation::ExplosionCluster();
int ret = doExplosionClusterModifyRequest(eaData);
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
static LtsCoordTrans::UtmCoordinate s_newTargetPosUtm_1 =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77438 17632")); // 32U PD 77438 17632
static LtsCoordTrans::UtmCoordinate s_newTargetPosUtm_2 =
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77296 19400")); // 32U PD 77296 19400
QTimer::singleShot(2000, this, [this] () { // local static is captured implicit by gcc and for MSVS
qint64 startTimeMsec = -1;
if (m_data.effectStart().is_set())
startTimeMsec = m_data.effectStart().get();
const qint64 nowMsec = QDateTime::currentMSecsSinceEpoch();
const qint64 distMsec = startTimeMsec - nowMsec;
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 1 "
<< ", effectStart (impactTime) = " << startTimeMsec
<< ", nowMsec = " << nowMsec
<< ", distMsec = " << distMsec;
const int offset = 5000;
// Timer _BEFORE_ EffectStart
const int delayMsec_1 = distMsec - offset;
QTimer::singleShot(delayMsec_1, this, [this] () { // local static is captured implicit by gcc and for MSVS
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 2 ";
QPointF newTargetPosGeo = s_newTargetPosUtm_1.geographic();
// ^
TargetPositionsModifyRequest request;
request.aesItemId(m_data.id());
request.positions().emplace_back(Core::GeoPosition(newTargetPosGeo.x(), newTargetPosGeo.y(), 123));
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 2, doExplosionClusterTargetPositionsModify ...";
doExplosionClusterTargetPositionsModify(request);
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 2, doExplosionClusterTargetPositionsModify ... DONE";
});
// Timer _AFTER_ EffectStart
const int delayMsec_2 = distMsec + offset;
QTimer::singleShot(delayMsec_2, this, [this] () { // local static is captured implicit by gcc and for MSVS
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 3 ";
QPointF newTargetPosGeo = s_newTargetPosUtm_2.geographic();
// ^
TargetPositionsModifyRequest request;
request.aesItemId(m_data.id());
request.positions().emplace_back(Core::GeoPosition(newTargetPosGeo.x(), newTargetPosGeo.y(), 124));
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 3, doExplosionClusterTargetPositionsModify ...";
doExplosionClusterTargetPositionsModify(request);
NOTICE_LOG(m_logger) << LOGFUNCTION << " TIMER 3, doExplosionClusterTargetPositionsModify ... DONE";
});
});
waitForEffectStates(__LINE__, 5, 150, 30);
QVERIFY2(m_data.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
QTest::qWait(500);
QTest::qWait(500);
QTest::qWait(500);
QTest::qWait(600);
dumpCnt();
QVERIFY2(m_counterDds.cntExplosionCluster == 4, "ERROR, cnt failed!!"); // EsPrepared, EsActivated, isObjectModifiable==false, EsExpired
QVERIFY2(m_counterDds.cntAtExplosionCluster == 3, "ERROR, cnt failed!!");
QVERIFY2(m_counterDds.cntAtExplosionClusterGunToTargetLine == 1, "ERROR, cnt failed!!");
QVERIFY2(m_counterDds.cntExplosionClusterEffects == 1, "ERROR, cnt failed!!");
QVERIFY2(m_effects.aesItemId() == m_data.id(), "ERROR, id mismatch");
QVERIFY2(m_effects.singleEffects().size() == 1, "ERROR, m_effects.singleEffects().size() failed");
if (!m_effects.singleEffects().empty())
{
const AreaEffectSimulation::SingleEffect &se = m_effects.singleEffects().front();
const Core::GeoPosition &seGeoPos = se.position();
const LtsCoordTrans::UtmCoordinate &seUtmPos = LtsCoordTrans::UtmCoordinate::fromGeographic(seGeoPos.lon(), seGeoPos.lat());
// compare with s_newTargetPosUtm_1, not s_newTargetPosUtm_2:
int dist = LtsCoordTrans::distance(s_newTargetPosUtm_1, seUtmPos);
NOTICE_LOG(m_logger) << LOGFUNCTION << " dist = " << dist;
QVERIFY2(dist < 100, "ERROR, m_effects failed");
}
//
// check AesItemView to verify circle:
//
// 1st AesItemView for boundary:
AreaEffectSimulation::AesItemView itemViewBoundary;
const bool found = m_aesDtc->aesItemViewFromEntityId(m_data.id(), AreaEffectSimulation::AesType::AtExplosionCluster, itemViewBoundary);
QVERIFY2(found, "ERROR, aesItemViewFromEntityId failed!!");
const Core::GeoPosition2D &bottomLeftGeo = itemViewBoundary.boundingBoxBottomLeft();
const LtsCoordTrans::UtmCoordinate &bottomLeftUtm = LtsCoordTrans::UtmCoordinate::fromGeographic(bottomLeftGeo.lon(), bottomLeftGeo.lat());
const int distBL = LtsCoordTrans::distance(s_newTargetPosUtm_1, bottomLeftUtm);
NOTICE_LOG(m_logger) << LOGFUNCTION << " itemViewBoundary.dist = " << distBL;
QVERIFY2(distBL < 100, "ERROR, itemViewBoundary failed");
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
}
void ModuleTestExplosionCluster::cleanupTestCase()
{
// finish last (dds) calls:
waitForData([]() { return false; }, 10);
INFO_LOG(m_logger) << " ddsConnector destroy...";
m_ddsConnector.reset();
INFO_LOG(m_logger) << " ddsConnector destroy...DONE";
}
int main(int argc, char *argv[])
{
NGLCoreApplication app(argc, argv);
app.createLogger("ModuleTest_ExplosionCluster", "log4cxx_aes.props");
// aesModuleTestExplosionCluster -v2 test_long -e42 -d139
// ^^^ ^^^^ // no space!!!
// aesModuleTestExplosionCluster -v2 test_long -e42
// aesModuleTestExplosionCluster -v2 test_long -e42
// aesModuleTestExplosionCluster test_long -e42
// aesModuleTestExplosionCluster -e42
CmdLineParser options;
options.setUnitModuleTestMode(true);
std::cout << " consider 'aesModuleTestExplosionCluster test_bldg_1104_Proximity -e42' " << std::endl;
std::cout << " 'aesModuleTestExplosionCluster test_bldg_1104_Proximity test_bldg_1104_Impact -e42' " << std::endl;
if (!options.init(true)) // showHelp , exitOnBadOption
return -1;
if (options.exerciseId() <= 0)
{
fprintf(stderr, "ExerciseId not set!\n");
return -2;
}
std::cout << " DomainId = " << options.domainId() << " - ExerciseId = " << options.exerciseId() << std::endl;
if (options.isSet(QStringLiteral("exerciseid")))
--argc;
if (options.isSet(QStringLiteral("domainid")))
--argc;
const QStringList &slPositionalArgs = options.positionalArguments();
for (const QString &item : qAsConst(slPositionalArgs))
std::cout << " item = " << item << std::endl;
// enable_create_bulk only if it´s explicitly called by user:
ModuleTestExplosionCluster::m_enable_create_bulk = slPositionalArgs.contains(QStringLiteral("test_create_bulk"));
std::cout << " enable_create_bulk = " << ModuleTestExplosionCluster::m_enable_create_bulk << std::endl;
ModuleTestExplosionCluster tc(options.domainId(), options.exerciseId());
return QTest::qExec(&tc, argc, argv);
}