829 lines
29 KiB
C++
Executable File
829 lines
29 KiB
C++
Executable File
/**
|
||
* @RDE_HEADER@
|
||
* ModuleTest
|
||
* $Id$
|
||
* $HeadURL$
|
||
* $Author$
|
||
*/
|
||
|
||
#include "aes_others_module_test.h"
|
||
#include <nglapplication/nglcoreapplication.h>
|
||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||
|
||
|
||
// AES
|
||
#include <AreaEffectSimulation/aes_dtc.h>
|
||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||
|
||
|
||
#include <QTimer>
|
||
#include <QDebug>
|
||
|
||
#include <iostream>
|
||
|
||
using namespace AreaEffectSimulation;
|
||
using namespace LtsCoordTrans;
|
||
|
||
|
||
// must be in pdm.pdm_charge_type
|
||
static const int s_ChargeTypeId1 = 371;
|
||
static const int s_ChargeTypeId2 = 372;
|
||
|
||
|
||
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>();
|
||
}
|
||
|
||
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);
|
||
}
|
||
|
||
ModuleTestAesOthers::ModuleTestAesOthers(int domainId, int exerciseId)
|
||
: m_domainId(domainId)
|
||
, m_exerciseId(exerciseId)
|
||
, m_logger(getLogger("ModuleTestAesOthers"))
|
||
{
|
||
}
|
||
|
||
void ModuleTestAesOthers::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 ModuleTestAesOthers::onBoobyTrapModifyReply(const Core::FunctionReplyObject &replyObject)
|
||
{
|
||
m_replyError = replyObject.error();
|
||
DEBUG_LOG(m_logger) << " got reply - onBoobyTrapModifyReply : " << m_replyError;
|
||
if (!replyObject.str().empty())
|
||
ERROR_LOG(m_logger) << " got reply - onBoobyTrapModifyReply: " << replyObject.translated();
|
||
}
|
||
|
||
void ModuleTestAesOthers::onBoobyTrapRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||
{
|
||
DEBUG_LOG(m_logger) << " got reply - onBoobyTrapRemoveReply : " << m_replyError;
|
||
if (!replyObject.str().empty())
|
||
ERROR_LOG(m_logger) << " got reply - onBoobyTrapRemoveReply: " << replyObject.translated();
|
||
}
|
||
|
||
void ModuleTestAesOthers::onOffRouteMineModifyReply(const Core::FunctionReplyObject &replyObject)
|
||
{
|
||
m_replyError = replyObject.error();
|
||
DEBUG_LOG(m_logger) << " got reply - onOffRouteMineModifyReply : " << m_replyError;
|
||
if (!replyObject.str().empty())
|
||
ERROR_LOG(m_logger) << " got reply - onOffRouteMineModifyReply: " << replyObject.translated();
|
||
}
|
||
|
||
void ModuleTestAesOthers::onOffRouteMineRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||
{
|
||
DEBUG_LOG(m_logger) << " got reply - onOffRouteMineRemoveReply : " << m_replyError;
|
||
if (!replyObject.str().empty())
|
||
ERROR_LOG(m_logger) << " got reply - onOffRouteMineRemoveReply: " << replyObject.translated();
|
||
}
|
||
|
||
|
||
void ModuleTestAesOthers::boobyTrapChanged(const BoobyTrap &data, DataModification modType)
|
||
{
|
||
Q_UNUSED(modType);
|
||
if (data.id() == -1)
|
||
return;
|
||
|
||
++m_counterDds.cntBoobyTrap;
|
||
|
||
m_dataBoobyTrap = data;
|
||
qint64 startTimeMsec = -1;
|
||
if (m_dataBoobyTrap.effectStart().is_set())
|
||
startTimeMsec = m_dataBoobyTrap.effectStart().get();
|
||
|
||
DEBUG_LOG(m_logger) << " got changed - m_dataBoobyTrap: " << m_dataBoobyTrap.id() << ", state=" << m_dataBoobyTrap.effectStateId()
|
||
<< ", startTimeMsec=" << startTimeMsec
|
||
<< ", cntBoobyTrap=" << m_counterDds.cntBoobyTrap;
|
||
TRACE_LOG(m_logger) << " got changed - m_dataBoobyTrap: " << m_dataBoobyTrap;
|
||
}
|
||
|
||
void ModuleTestAesOthers::offRouteMineChanged(const OffRouteMine &data, DataModification modType)
|
||
{
|
||
Q_UNUSED(modType);
|
||
if (data.id() == -1)
|
||
return;
|
||
|
||
++m_counterDds.cntOffRouteMine;
|
||
|
||
m_dataOffRouteMine = data;
|
||
qint64 startTimeMsec = -1;
|
||
if (m_dataOffRouteMine.effectStart().is_set())
|
||
startTimeMsec = m_dataOffRouteMine.effectStart().get();
|
||
|
||
DEBUG_LOG(m_logger) << " got changed - m_dataOffRouteMine: " << m_dataOffRouteMine.id() << ", state=" << m_dataOffRouteMine.effectStateId()
|
||
<< ", startTimeMsec=" << startTimeMsec
|
||
<< ", cntOffRouteMine=" << m_counterDds.cntOffRouteMine;
|
||
TRACE_LOG(m_logger) << " got changed - m_dataOffRouteMine: " << m_dataOffRouteMine;
|
||
}
|
||
|
||
|
||
void ModuleTestAesOthers::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, aesType=" << aesType;
|
||
|
||
switch (aesType)
|
||
{
|
||
case AreaEffectSimulation::AesType_def::AtBoobyTrap:
|
||
case AreaEffectSimulation::AesType_def::AtBoobyTrapSecondary:
|
||
case AreaEffectSimulation::AesType_def::AtOffRouteMine:
|
||
case AreaEffectSimulation::AesType_def::AtOffRouteMineSecondary:
|
||
++m_counterDds.cntItemView;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
void ModuleTestAesOthers::dumpCnt()
|
||
{
|
||
NOTICE_LOG(m_logger) << LOGFUNCTION << " Counter: "
|
||
<< " cntBoobyTrap = " << m_counterDds.cntBoobyTrap
|
||
<< " cntOffRouteMine = " << m_counterDds.cntOffRouteMine
|
||
<< ", cntItemView = " << m_counterDds.cntItemView;
|
||
}
|
||
|
||
|
||
|
||
bool ModuleTestAesOthers::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)
|
||
{
|
||
DEBUG_LOG(m_logger) << " waitForData - i: " << i;
|
||
if (func())
|
||
return true;
|
||
QTest::qWait(100);
|
||
}
|
||
return func();
|
||
}
|
||
|
||
void ModuleTestAesOthers::waitForEffectStatesBT(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_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsPrepared;}, durPrep))
|
||
{
|
||
ERROR_LOG(m_logger) << "Timeout waiting for EsPrepared of m_dataBoobyTrap with id " << m_dataBoobyTrap.id()
|
||
<< ", lineNumber = " << lineNumber;
|
||
QVERIFY2(false, "ERROR, exit");
|
||
return;
|
||
}
|
||
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsActivated...";
|
||
if (!waitForData([this]() { return m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated;}, durAct))
|
||
{
|
||
ERROR_LOG(m_logger) << "Timeout waiting for EsActivated of m_dataBoobyTrapr with id " << m_dataBoobyTrap.id()
|
||
<< ", lineNumber = " << lineNumber;
|
||
QVERIFY2(false, "ERROR, exit");
|
||
return;
|
||
}
|
||
|
||
if (durExp > 0)
|
||
{
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsExpired...";
|
||
if (!waitForData([this]() { return m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired;}, durExp))
|
||
{
|
||
ERROR_LOG(m_logger) << "Timeout waiting for EsExpired of m_dataBoobyTrap with id " << m_dataBoobyTrap.id()
|
||
<< ", lineNumber = " << lineNumber;
|
||
QVERIFY2(false, "ERROR, exit");
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
|
||
void ModuleTestAesOthers::waitForEffectStatesORM(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_dataOffRouteMine.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsPrepared;}, durPrep))
|
||
{
|
||
ERROR_LOG(m_logger) << "Timeout waiting for EsPrepared of m_dataOffRouteMine with id " << m_dataOffRouteMine.id()
|
||
<< ", lineNumber = " << lineNumber;
|
||
QVERIFY2(false, "ERROR, exit");
|
||
return;
|
||
}
|
||
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsActivated...";
|
||
if (!waitForData([this]() { return m_dataOffRouteMine.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated;}, durAct))
|
||
{
|
||
ERROR_LOG(m_logger) << "Timeout waiting for EsActivated of m_dataOffRouteMine with id " << m_dataOffRouteMine.id()
|
||
<< ", lineNumber = " << lineNumber;
|
||
QVERIFY2(false, "ERROR, exit");
|
||
return;
|
||
}
|
||
|
||
if (durExp > 0)
|
||
{
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " waiting for EsExpired...";
|
||
if (!waitForData([this]() { return m_dataOffRouteMine.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired;}, durExp))
|
||
{
|
||
ERROR_LOG(m_logger) << "Timeout waiting for EsExpired of m_dataOffRouteMine with id " << m_dataOffRouteMine.id()
|
||
<< ", lineNumber = " << lineNumber;
|
||
QVERIFY2(false, "ERROR, exit");
|
||
return;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
void ModuleTestAesOthers::setupParticipants()
|
||
{
|
||
INFO_LOG(m_logger) << " setupParticipant ...";
|
||
|
||
QVERIFY2(m_ppmFtc, "ERROR, no m_ppmFtc");
|
||
|
||
{
|
||
ParticipantManagement::SetSimulatedPosition req;
|
||
|
||
{
|
||
req.participantId(18); // according testDB
|
||
req.onlyOutdatedParticipants(false);
|
||
|
||
const LtsCoordTrans::UtmCoordinate &utmPos =
|
||
LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UPD7690018100")); // 32U PD 76900 18100
|
||
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";
|
||
}
|
||
}
|
||
}
|
||
INFO_LOG(m_logger) << " setSimulatedPositionRequest ...DONE";
|
||
}
|
||
|
||
bool ModuleTestAesOthers::checkParticipant_18()
|
||
{
|
||
// soll: QStringLiteral("32UPD7690018000")); // 32U PD 76900 18000
|
||
const int partId = 18;
|
||
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 18100");
|
||
}
|
||
|
||
bool ModuleTestAesOthers::tryRemoveOldBoobyTraps()
|
||
{
|
||
m_aesDtc->waitForHistoricalDataBoobyTrap(5000);
|
||
|
||
const auto &btMap = m_aesDtc->boobyTraps();
|
||
|
||
for (const auto &bt : btMap)
|
||
{
|
||
qCritical() << " bt.name" << bt.name().c_str();
|
||
int ret = m_aesFtc->boobyTrapRemoveRequest(Core::RemoveElementRequest(bt.id()));
|
||
qCritical() << " bt.name -> " << ret;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
int ModuleTestAesOthers::doBoobyTrapModifyRequest(const BoobyTrap &btData)
|
||
{
|
||
BoobyTrapModifyRequest req(btData.id(),
|
||
btData.name(),
|
||
btData.effectDuration(),
|
||
btData.chargeStruct().chargeTypeId(),
|
||
btData.impactPosition(),
|
||
btData.impactRadius(),
|
||
btData.triggerRadius(),
|
||
btData.rotationAngle(),
|
||
btData.centralAngle(),
|
||
btData.effectStart(),
|
||
btData.partyId()
|
||
);
|
||
|
||
int ret = m_aesFtc->boobyTrapModifyRequest(req, this);
|
||
return ret;
|
||
}
|
||
|
||
int ModuleTestAesOthers::doOffRouteMineModifyRequest(const OffRouteMine &offRouteMine)
|
||
{
|
||
OffRouteMineModifyRequest req(offRouteMine.id(),
|
||
offRouteMine.name(),
|
||
offRouteMine.effectDuration(),
|
||
offRouteMine.chargeStruct().chargeTypeId(),
|
||
offRouteMine.area(),
|
||
offRouteMine.impactRadius(),
|
||
offRouteMine.effectStart(),
|
||
offRouteMine.partyId()
|
||
);
|
||
|
||
int ret = m_aesFtc->offRouteMineModifyRequest(req, this);
|
||
return ret;
|
||
}
|
||
|
||
int ModuleTestAesOthers::doMoveParticipant(int participantId, const QString &newPositionMGRS)
|
||
{
|
||
ParticipantManagement::SetSimulatedPosition req;
|
||
{
|
||
req.participantId(participantId); // according testDB
|
||
req.onlyOutdatedParticipants(false);
|
||
|
||
const LtsCoordTrans::UtmCoordinate &utmPos =
|
||
LtsCoordTrans::UtmCoordinate::fromMgrs(newPositionMGRS); // 32U PD 76900 18100
|
||
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";
|
||
}
|
||
}
|
||
INFO_LOG(m_logger) << " doMoveParticipant ...DONE";
|
||
return true;
|
||
}
|
||
|
||
//
|
||
// context of textCases
|
||
//
|
||
void ModuleTestAesOthers::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!!");
|
||
|
||
|
||
std::cout << " waitForHistoricalDataAesItemView... " << std::endl;
|
||
m_aesDtc->waitForHistoricalDataBoobyTrap(2000);
|
||
std::cout << " waitForHistoricalDataAesItemView... Done" << std::endl;
|
||
|
||
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;
|
||
|
||
//
|
||
// 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::boobyTrapChanged,
|
||
this, &ModuleTestAesOthers::boobyTrapChanged, Qt::UniqueConnection);
|
||
|
||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::offRouteMineChanged,
|
||
this, &ModuleTestAesOthers::offRouteMineChanged, Qt::UniqueConnection);
|
||
|
||
connect(m_aesDtc.get(), &AreaEffectSimulation::Interface::Dtc::aesItemViewChanged,
|
||
this, &ModuleTestAesOthers::onAesItemViewChanged, Qt::UniqueConnection);
|
||
|
||
// spend some for the eventLoop to "consume" existing topics/samples:
|
||
for (int i = 0; i < 10; ++i)
|
||
QTest::qWait(100);
|
||
}
|
||
|
||
void ModuleTestAesOthers::init()
|
||
{
|
||
// init will be called before each test function is executed.
|
||
m_counterDds.reset();
|
||
|
||
setupParticipants();
|
||
}
|
||
|
||
void ModuleTestAesOthers::test_justSetupParticipants()
|
||
{
|
||
NOTICE_LOG(m_logger) << LOGFUNCTION << " START";
|
||
setupParticipants();
|
||
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
|
||
}
|
||
|
||
//
|
||
// 1104
|
||
//
|
||
void ModuleTestAesOthers::test_boobyTrap_01()
|
||
{
|
||
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_18(), "ERROR, checkParticipant_5 failed!!");
|
||
|
||
AreaEffectSimulation::BoobyTrap bt;
|
||
bt.id(0);
|
||
bt.name(QString(QStringLiteral("ModuleTest_BoobyTrap01")).toStdString());
|
||
bt.chargeStruct().chargeTypeId(252);
|
||
bt.effectDuration(60000);
|
||
bt.partyId(2);
|
||
bt.impactRadius(10);
|
||
bt.triggerRadius(5);
|
||
|
||
// Type1 == SchAbwMi ohne rotationAngle, centralAngle
|
||
// Type2 == SchAbwRiMi mit rotationAngle, centralAngle
|
||
|
||
|
||
LtsCoordinate lts = LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77000 18100")), 0.0);
|
||
bt.impactPosition(lts.geoPosition2D());
|
||
|
||
bt.effectStart((time(nullptr) + 10) * 1000); // msec
|
||
|
||
m_replyError = true;
|
||
m_dataBoobyTrap = AreaEffectSimulation::BoobyTrap();
|
||
|
||
int ret = doBoobyTrapModifyRequest(bt);
|
||
QVERIFY2(ret != 0, "ERROR, doBoobyTrapModifyRequest failed!!");
|
||
|
||
waitForEffectStatesBT(__LINE__, 5, 15, 0); // do _not_ wait for expired!
|
||
QVERIFY2(m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated, "ERROR, effectStateId failed!!");
|
||
dumpCnt();
|
||
QVERIFY2(m_counterDds.cntBoobyTrap == 2, "ERROR, cnt failed!!"); // EsPrepared, EsActivated,
|
||
QVERIFY2(m_counterDds.cntItemView == 4, "ERROR, cnt failed!!"); //
|
||
|
||
// Move Participant to trigger area, maybe also 3D scene marker:
|
||
|
||
doMoveParticipant(18, QStringLiteral("32U PD 77002 18112"));
|
||
|
||
// wait...
|
||
waitForData([]() { return false; }, 2);
|
||
|
||
doMoveParticipant(18, QStringLiteral("32U PD 77002 18103"));
|
||
|
||
// wait until expired:
|
||
waitForData([this]() { return m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired; }, 60);
|
||
|
||
QVERIFY2(m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
|
||
|
||
// wait to let it disappear:
|
||
waitForData([]() { return false; }, 15);
|
||
|
||
NOTICE_LOG(m_logger) << LOGFUNCTION << " END";
|
||
}
|
||
|
||
|
||
void ModuleTestAesOthers::test_boobyTrap_02_IMPL(const QString &name,
|
||
const LtsCoordinate &impactCoord,
|
||
double rotationAngle,
|
||
const LtsCoordinate &particpantCoord)
|
||
{
|
||
if (m_traingAreaId != s_TraingAreaId_Altmark)
|
||
{
|
||
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
|
||
return;
|
||
}
|
||
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId
|
||
<< ", name =" << name << "'"
|
||
<< ", impactCoord= " << impactCoord.mgrs()
|
||
<< ", rotationAngle = " << rotationAngle
|
||
<< ", particpantCoord = " << particpantCoord.mgrs();
|
||
|
||
QVERIFY2(checkParticipant_18(), "ERROR, checkParticipant_5 failed!!");
|
||
|
||
AreaEffectSimulation::BoobyTrap bt;
|
||
bt.id(0);
|
||
bt.name(name.toStdString());
|
||
bt.chargeStruct().chargeTypeId(252);
|
||
bt.effectDuration(600000);
|
||
bt.partyId(2);
|
||
bt.impactRadius(10);
|
||
bt.triggerRadius(5);
|
||
|
||
bt.impactPosition(impactCoord.geoPosition());
|
||
|
||
// Type1 == SchAbwMi ohne rotationAngle, centralAngle
|
||
// Type2 == SchAbwRiMi mit rotationAngle, centralAngle
|
||
bt.rotationAngle(toOptional(rotationAngle)); // Q1: 30
|
||
bt.centralAngle(toOptional(90.0));
|
||
|
||
bt.effectStart((time(nullptr) + 10) * 1000); // msec
|
||
|
||
m_replyError = true;
|
||
m_dataBoobyTrap = AreaEffectSimulation::BoobyTrap();
|
||
|
||
int ret = doBoobyTrapModifyRequest(bt);
|
||
QVERIFY2(ret != 0, "ERROR, doBoobyTrapModifyRequest failed!!");
|
||
|
||
waitForEffectStatesBT(__LINE__, 5, 15, 0); // do _not_ wait for expired!
|
||
QVERIFY2(m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated, "ERROR, m_dataBoobyTrap effectStateId failed!!");
|
||
dumpCnt();
|
||
QVERIFY2(m_counterDds.cntBoobyTrap == 2, "ERROR, cnt failed!!"); // EsPrepared, EsActivated,
|
||
QVERIFY2(m_counterDds.cntItemView == 4, "ERROR, cnt failed!!"); //
|
||
|
||
// Move Participant to trigger area, maybe also 3D scene marker:
|
||
|
||
// 1. in the near of area:
|
||
doMoveParticipant(18, QStringLiteral("32U PD 77002 18112"));
|
||
|
||
// wait...
|
||
waitForData([]() { return false; }, 2);
|
||
|
||
// 2. move IN the area:
|
||
doMoveParticipant(18, particpantCoord.mgrs());
|
||
|
||
// wait until expired:
|
||
waitForData([this]() { return m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired; }, 60);
|
||
|
||
QVERIFY2(m_dataBoobyTrap.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, effectStateId failed!!");
|
||
|
||
// wait to let it disappear:
|
||
waitForData([]() { return false; }, 15);
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " END"
|
||
<< ", name =" << name << "'"
|
||
<< ", impactCoord= " << impactCoord.mgrs()
|
||
<< ", rotationAngle = " << rotationAngle
|
||
<< ", particpantCoord = " << particpantCoord.mgrs();
|
||
}
|
||
|
||
void ModuleTestAesOthers::test_boobyTrap_02_Q1()
|
||
{
|
||
test_boobyTrap_02_IMPL(QStringLiteral("ModuleTest_BoobyTrap02_Q1"),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77000 18100")), 0.0),
|
||
30+(0*90),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77002 18102")), 0.0));
|
||
}
|
||
|
||
void ModuleTestAesOthers::test_boobyTrap_02_Q2()
|
||
{
|
||
test_boobyTrap_02_IMPL(QStringLiteral("ModuleTest_BoobyTrap02_Q2"),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77000 18100")), 0.0),
|
||
30+(1*90),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77002 18098")), 0.0));
|
||
}
|
||
|
||
void ModuleTestAesOthers::test_boobyTrap_02_Q3()
|
||
{
|
||
test_boobyTrap_02_IMPL(QStringLiteral("test_boobyTrap_02_Q3"),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77000 18100")), 0.0),
|
||
30+(2*90),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 76998 18098")), 0.0));
|
||
}
|
||
|
||
void ModuleTestAesOthers::test_boobyTrap_02_Q4()
|
||
{
|
||
test_boobyTrap_02_IMPL(QStringLiteral("test_boobyTrap_02_Q4"),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77000 18100")), 0.0),
|
||
30+(3*90),
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 76998 18102")), 0.0));
|
||
}
|
||
|
||
void ModuleTestAesOthers::test_offRouteMine_02()
|
||
{
|
||
if (m_traingAreaId != s_TraingAreaId_Altmark)
|
||
{
|
||
NOTICE_LOG(m_logger) << LOGFUNCTION << " skip testcase due to m_traingAreaId = " << m_traingAreaId;
|
||
return;
|
||
}
|
||
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " START, m_traingAreaId = " << m_traingAreaId;
|
||
|
||
QVERIFY2(checkParticipant_18(), "ERROR, checkParticipant_5 failed!!");
|
||
|
||
// offRouteMine1 = 253; // OHNE impactRadius
|
||
// offRouteMine2 = 254; // MIT impactRadius
|
||
|
||
AreaEffectSimulation::OffRouteMine orm;
|
||
orm.id(0);
|
||
orm.name(QString(QStringLiteral("test_offRouteMine_02")).toStdString());
|
||
orm.chargeStruct().chargeTypeId(254);
|
||
orm.effectDuration(600000);
|
||
orm.partyId(2);
|
||
orm.impactRadius(10); // 254 -> MIT impactRadius -> mit 3DSphere/Kugel
|
||
|
||
const LtsCoordinate &coord =
|
||
LtsCoordinate::fromUtmCoordinate(UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77000 18100")), 0.0);
|
||
orm.area().cornerBottomLeft(coord.geoPosition());
|
||
orm.area().height(50);
|
||
orm.area().width(1);
|
||
orm.area().rotation(85);
|
||
|
||
orm.effectStart((time(nullptr) + 10) * 1000); // msec
|
||
|
||
m_replyError = true;
|
||
m_dataOffRouteMine = AreaEffectSimulation::OffRouteMine();
|
||
|
||
int ret = doOffRouteMineModifyRequest(orm);
|
||
QVERIFY2(ret != 0, "ERROR, doOffRouteMineModifyRequest failed!!");
|
||
|
||
waitForEffectStatesORM(__LINE__, 5, 15, 0); // do _not_ wait for expired!
|
||
QVERIFY2(m_dataOffRouteMine.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsActivated, "ERROR, effectStateId failed!!");
|
||
dumpCnt();
|
||
QVERIFY2(m_counterDds.cntOffRouteMine == 2, "ERROR, cnt failed!!"); // EsPrepared, EsActivated,
|
||
QVERIFY2(m_counterDds.cntItemView == 4, "ERROR, cnt failed!!"); //
|
||
|
||
// Move Participant to trigger area, maybe also 3D scene marker:
|
||
|
||
// 1. in the near of area:
|
||
doMoveParticipant(18, QStringLiteral("32U PD 77002 18112"));
|
||
|
||
// wait...
|
||
waitForData([]() { return false; }, 2);
|
||
|
||
// 2. move OVER the area:
|
||
doMoveParticipant(18, QStringLiteral("32U PD 77020 18095"));
|
||
|
||
// wait until expired:
|
||
waitForData([this]() { return m_dataOffRouteMine.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired; }, 60);
|
||
|
||
QVERIFY2(m_dataOffRouteMine.effectStateId() == AreaEffectSimulation::AesEffectState_def::EsExpired, "ERROR, m_dataOffRouteMine effectStateId failed!!");
|
||
|
||
// wait to let it disappear:
|
||
waitForData([]() { return false; }, 15);
|
||
INFO_LOG(m_logger) << LOGFUNCTION << " END" << ", name =" << orm.name() << "'";
|
||
}
|
||
|
||
void ModuleTestAesOthers::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");
|
||
|
||
// aesModuleTestAesOthers -v2 test_long -e42 -d139
|
||
// ^^^ ^^^^ // no space!!!
|
||
// aesModuleTestAesOthers -v2 test_long -e42
|
||
// aesModuleTestAesOthers -v2 test_long -e42
|
||
// aesModuleTestAesOthers test_long -e42
|
||
// aesModuleTestAesOthers -e42
|
||
|
||
CmdLineParser options;
|
||
options.setUnitModuleTestMode(true);
|
||
|
||
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:
|
||
// ModuleTestAesOthers::m_enable_create_bulk = slPositionalArgs.contains(QStringLiteral("test_create_bulk"));
|
||
// std::cout << " enable_create_bulk = " << ModuleTestAesOthers::m_enable_create_bulk << std::endl;
|
||
|
||
|
||
ModuleTestAesOthers tc(options.domainId(), options.exerciseId());
|
||
return QTest::qExec(&tc, argc, argv);
|
||
}
|
||
|
||
|
||
|