1377 lines
40 KiB
C++
Executable File
1377 lines
40 KiB
C++
Executable File
/**
|
||
* @RDE_HEADER@
|
||
* ModuleTest
|
||
* $Id$
|
||
* $HeadURL$
|
||
* $Author$
|
||
*/
|
||
|
||
#include "limits_module_test.h"
|
||
#include "qtestcase.h"
|
||
#include <nglapplication/nglcoreapplication.h>
|
||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||
|
||
// AES
|
||
#include <AreaEffectSimulation/Utils/polygons.h>
|
||
#include <Core/function_reply_object.h>
|
||
#include <Core/core.hpp>
|
||
|
||
|
||
#include <QTimer>
|
||
#include <QDebug>
|
||
|
||
#include <iostream>
|
||
|
||
|
||
using namespace AreaEffectSimulation;
|
||
|
||
bool ModuleTestLimits::m_noDelete = false;
|
||
|
||
// must be in pdm.pdm_charge_type
|
||
static const int s_ChargeTypeId1 = 371;
|
||
static const int s_IgniterTypeId = 101;
|
||
|
||
static const int s_TraingAreaId_Altmark = 2;
|
||
static const int s_offset = 5;
|
||
static const int s_pauseTimeInSec = 5;
|
||
|
||
ModuleTestLimits::ModuleTestLimits(int domainId, int exerciseId)
|
||
: m_domainId(domainId)
|
||
, m_exerciseId(exerciseId)
|
||
, m_logger(getLogger("ModuleTestLimits"))
|
||
{
|
||
}
|
||
|
||
void ModuleTestLimits::onExplosionClusterModifyReply(const Core::FunctionReplyObject &replyObject)
|
||
{
|
||
Q_UNUSED(replyObject);
|
||
}
|
||
|
||
|
||
void ModuleTestLimits::testExplosionClusterCentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
const Core::GeoPosition2D &cornerBottomLeft = m_centralPoint;
|
||
auto explosionCluster = getEc(cornerBottomLeft);
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
for (int i = 0; i < m_maxExplosionsCentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_EC") + QStringLiteral("_CEN_") + QString::number(i);
|
||
explosionCluster.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->explosionClusterModifyRequest(explosionCluster, this);
|
||
if (i < m_maxExplosionsCentral)
|
||
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
|
||
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->explosionClusters();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == true)
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxExplosionsCentral, "Too many explosion clusters");
|
||
// if(!m_noDelete)
|
||
// QVERIFY2(counter == m_maxExplosionsCentral, "Too few explosion clusters");
|
||
}
|
||
|
||
void ModuleTestLimits::testExplosionClusterDecentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
const Core::GeoPosition2D &cornerBottomLeft = m_decentralPoint;
|
||
auto explosionCluster = getEc(cornerBottomLeft);
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
for (int i = 0; i < m_maxExplosionsDecentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_EC") + QStringLiteral("_DEC_") + QString::number(i);
|
||
explosionCluster.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->explosionClusterModifyRequest(explosionCluster, this);
|
||
if (i < m_maxExplosionsDecentral)
|
||
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->explosionClusters();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if ((item.effectStateId() == AesEffectState::EsPrepared) && (item.isCentral() == false))
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxExplosionsDecentral, "Too many explosion clusters");
|
||
// if(!m_noDelete)
|
||
// QVERIFY2(counter == m_maxExplosionsDecentral, "Too few explosion clusters");
|
||
}
|
||
|
||
void ModuleTestLimits::testAirSupports()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
QVERIFY2(m_pdmDtc, "ERROR, No Pdm Dtc available!!");
|
||
|
||
auto airSupport = getAs();
|
||
|
||
for (int i = 0; i < m_maxAirSupports + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_AS") + QStringLiteral("_CEN_") + QString::number(i);
|
||
airSupport.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->explosionClusterModifyRequest(airSupport, this);
|
||
if (i < m_maxAirSupports)
|
||
QVERIFY2(ret != 0, "ERROR, explosionClusterModifyRequest failed!!");
|
||
}
|
||
|
||
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->explosionClusters();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() && m_pdmDtc->gearClassFromChargeTypeId(item.chargeStruct().chargeTypeId()) == ProjectDataManagement::GearClass::AirSupport)
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxAirSupports, "Too many explosion clusters");
|
||
// if(!m_noDelete)
|
||
// QVERIFY2(counter == m_maxExplosionsCentral, "Too few explosion clusters");
|
||
}
|
||
|
||
void ModuleTestLimits::testMineAreaCentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto mineArea = getMa();
|
||
mineArea.segments(m_segmentsCentral);
|
||
for (int i = 0; i < m_maxMineAreasCentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_MA") + QStringLiteral("_CEN_") + QString::number(i);
|
||
mineArea.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->mineAreaModifyRequest(mineArea, this);
|
||
if (i < m_maxMineAreasCentral)
|
||
QVERIFY2(ret != 0, "ERROR, mineAreaModifyRequest failed!!");
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->mineAreas();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if ((item.effectStateId() == AesEffectState::EsPrepared) && (item.isCentral() == true))
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxMineAreasCentral, "Too many mine areas");
|
||
// if(!m_noDelete)
|
||
// QVERIFY2(counter == m_maxMineAreasCentral, "Too few mine areas");
|
||
}
|
||
|
||
void ModuleTestLimits::testMineAreaDecentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto mineArea = getMa();
|
||
mineArea.segments(m_segmentsDecentral);
|
||
for (int i = 0; i < m_maxMineAreasDecentral - m_maxSafePzAbwSafe + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_MA") + QStringLiteral("_DEC_") + QString::number(i);
|
||
mineArea.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->mineAreaModifyRequest(mineArea, this);
|
||
if (i < (m_maxMineAreasDecentral - m_maxSafePzAbwSafe))
|
||
QVERIFY2(ret != 0, "ERROR, mineAreaModifyRequest failed!!");
|
||
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->mineAreas();
|
||
for (const auto &curMineArea : qAsConst(items))
|
||
{
|
||
if ((curMineArea.effectStateId() == AesEffectState::EsPrepared) && (curMineArea.isCentral() == false))
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxMineAreasDecentral, "Too many mine areas");
|
||
// if(!m_noDelete)
|
||
// QVERIFY2(counter == m_maxMineAreasDecentral, "Too few mine areas");
|
||
|
||
|
||
mineArea.layingProcedureType(AreaEffectSimulation::AesMaLayingProcedureType_def::LptArtillery);
|
||
for (int i = 0; i < m_maxSafePzAbwSafe + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_MA_ART") + QStringLiteral("_DEC_") + QString::number(i);
|
||
mineArea.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->mineAreaModifyRequest(mineArea, this);
|
||
if (i < m_maxSafePzAbwSafe)
|
||
QVERIFY2(ret != 0, "ERROR, mineAreaModifyRequest failed!!");
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter2 = 0;
|
||
|
||
const auto &mineAreas = m_aesDtc->mineAreas();
|
||
for (const auto &item : qAsConst(mineAreas))
|
||
{
|
||
if ((item.effectStateId() == AesEffectState::EsPrepared) &&
|
||
!item.isCentral() &&
|
||
(item.layingProcedureType() == AreaEffectSimulation::AesMaLayingProcedureType_def::LptArtillery))
|
||
++counter2;
|
||
}
|
||
|
||
QVERIFY2(counter2 <= m_maxSafePzAbwSafe, "Too many mine areas artillery");
|
||
}
|
||
|
||
void ModuleTestLimits::testNBCCentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto nbContamination = getNBC();
|
||
nbContamination.impactPosition(m_centralPoint);
|
||
|
||
for (int i = 0; i < m_maxNBCCentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_NBC") + QStringLiteral("_CEN_") + QString::number(i);
|
||
nbContamination.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->nContaminationModifyRequest(nbContamination, this);
|
||
if (i < m_maxNBCCentral)
|
||
QVERIFY2(ret != 0, "ERROR, nContamination RModify Request failed!!");
|
||
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->nContaminations();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == true)
|
||
++counter;
|
||
}
|
||
|
||
|
||
QVERIFY2(counter <= m_maxNBCCentral, "Too many NBC");
|
||
|
||
}
|
||
|
||
void ModuleTestLimits::testNBCDecentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto nbContamination = getNBC();
|
||
nbContamination.impactPosition(m_decentralPoint);
|
||
|
||
for (int i = 0; i < m_maxNBCDecentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_NBC") + QStringLiteral("_DEC_") + QString::number(i);
|
||
nbContamination.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->nContaminationModifyRequest(nbContamination, this);
|
||
if (i < m_maxNBCDecentral)
|
||
QVERIFY2(ret != 0, "ERROR, nContamination RModify Request failed!!");
|
||
|
||
}
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->nContaminations();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == false)
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxNBCDecentral, "Too many NBC");
|
||
}
|
||
|
||
void ModuleTestLimits::testOffRouteMines()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto offRouteMine = getORM();
|
||
|
||
for (int i = 0; i < m_maxOffRouteMines + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_ORM") + QStringLiteral("_") + QString::number(i);
|
||
offRouteMine.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->offRouteMineModifyRequest(offRouteMine, this);
|
||
if (i < m_maxOffRouteMines)
|
||
QVERIFY2(ret != 0, "ERROR, Off Route Mine Modify Request failed!!");
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->offRouteMines();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == true)
|
||
++counter;
|
||
}
|
||
|
||
|
||
QVERIFY2(counter <= m_maxOffRouteMines, "Too many Off Route Mines");
|
||
}
|
||
|
||
void ModuleTestLimits::testBoobyTraps()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto boobyTrap = getBT();
|
||
|
||
for (int i = 0; i < m_maxBoobyTraps + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_BT") + QStringLiteral("_") + QString::number(i);
|
||
boobyTrap.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->boobyTrapModifyRequest(boobyTrap, this);
|
||
if (i < m_maxBoobyTraps)
|
||
QVERIFY2(ret != 0, "ERROR, Booby Trap Modify Request failed!!");
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->boobyTraps();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == true)
|
||
++counter;
|
||
}
|
||
|
||
|
||
QVERIFY2(counter <= m_maxBoobyTraps, "Too many Booby traps");
|
||
}
|
||
|
||
void ModuleTestLimits::testBCCCentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto bcContamination = getBCC();
|
||
bcContamination.impactPosition(m_centralPoint);
|
||
|
||
for (int i = 0; i < m_maxNBCCentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_BCC") + QStringLiteral("_CEN_") + QString::number(i);
|
||
bcContamination.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->bCContaminationModifyRequest(bcContamination, this);
|
||
if (i < m_maxNBCCentral)
|
||
QVERIFY2(ret != 0, "ERROR, nContamination RModify Request failed!!");
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->bCContaminations();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == true)
|
||
++counter;
|
||
}
|
||
|
||
|
||
QVERIFY2(counter <= m_maxNBCCentral, "Too many BCC central");
|
||
}
|
||
|
||
void ModuleTestLimits::testBCCDecentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto bcContamination = getBCC();
|
||
bcContamination.impactPosition(m_decentralPoint);
|
||
|
||
for (int i = 0; i < m_maxNBCDecentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_BCC") + QStringLiteral("_DEC_") + QString::number(i);
|
||
bcContamination.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->bCContaminationModifyRequest(bcContamination, this);
|
||
if (i < m_maxNBCDecentral)
|
||
QVERIFY2(ret != 0, "ERROR, bcContamination Modify Request failed!!");
|
||
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->bCContaminations();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == false)
|
||
++counter;
|
||
}
|
||
|
||
QVERIFY2(counter <= m_maxNBCDecentral, "Too many BCC");
|
||
|
||
}
|
||
|
||
void ModuleTestLimits::testFADecentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto functionArea = getFA();
|
||
functionArea.area().cornerBottomLeft(m_decentralPoint);
|
||
|
||
for (int i = 0; i < m_maxFunctionalAreaDec + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_FA") + QStringLiteral("_DEC_") + QString::number(i);
|
||
functionArea.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->functionalAreaModifyRequest(functionArea, this);
|
||
if (i < m_maxFunctionalAreaDec)
|
||
QVERIFY2(ret != 0, "ERROR, Functional Area Modify Request failed!!");
|
||
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->functionalAreas();
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == false)
|
||
++counter;
|
||
}
|
||
|
||
|
||
QVERIFY2(counter <= m_maxFunctionalAreaDec, "Too many Functional Areas");
|
||
|
||
}
|
||
|
||
void ModuleTestLimits::testFACentral()
|
||
{
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
QVERIFY2(m_aesFtc, "ERROR, No Aes Ftc available!!");
|
||
|
||
auto functionArea = getFA();
|
||
functionArea.area().cornerBottomLeft(m_centralPoint);
|
||
|
||
for (int i = 0; i < m_maxFunctionalAreaCentral + s_offset; ++i)
|
||
{
|
||
QString name = QStringLiteral("TEST_FA") + QStringLiteral("_CEN_") + QString::number(i);
|
||
functionArea.name(name.toStdString());
|
||
QTest::qWait(50);
|
||
int ret = m_aesFtc->functionalAreaModifyRequest(functionArea, this);
|
||
if (i < m_maxFunctionalAreaCentral)
|
||
QVERIFY2(ret != 0, "ERROR, Functional Area Modify Request failed!!");
|
||
|
||
}
|
||
|
||
QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
|
||
int counter = 0;
|
||
const auto &items = m_aesDtc->functionalAreas();
|
||
|
||
for (const auto &item : qAsConst(items))
|
||
{
|
||
if (item.effectStateId() == AesEffectState::EsPrepared && item.isCentral() == true)
|
||
++counter;
|
||
}
|
||
|
||
|
||
QVERIFY2(counter <= m_maxFunctionalAreaCentral, "Too many Functional Areas");
|
||
|
||
}
|
||
|
||
// void ModuleTestLimits::testTADecentral()
|
||
// {
|
||
// QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
// auto ta = getTA();
|
||
// ta.area().cornerBottomLeft(m_decentralPoint);
|
||
|
||
// QVERIFY2(m_aesFtc , "ERROR, No Aes Ftc available!!");
|
||
|
||
// for (int i = 0; i < m_maxTechnicalAreaDecentral + s_offset; ++i)
|
||
// {
|
||
// QString name = QStringLiteral("TEST_TA") + QStringLiteral("_DEC_") + QString::number(i);
|
||
// ta.name(name.toStdString());
|
||
// int ret = m_aesFtc->technicalAreaModifyRequest(ta, this);
|
||
// if(i < m_maxTechnicalAreaDecentral)
|
||
// QVERIFY2(ret != 0, "ERROR, Technical Area Modify Request failed!!");
|
||
|
||
// }
|
||
|
||
// QVERIFY2(waitForData([this]() {
|
||
// int counter = 0;
|
||
// for (const auto &ta : m_aesDtc->technicalAreas())
|
||
// {
|
||
// if (ta.effectStateId() == AesEffectState::EsPrepared && ta.isCentral() == false)
|
||
// ++counter;
|
||
// }
|
||
// return (counter <= m_maxTechnicalAreaDecentral);
|
||
|
||
// }, 5), "Too many Technical Areas");
|
||
// }
|
||
|
||
// void ModuleTestLimits::testTACentral()
|
||
// {
|
||
// QTest::qWait(s_pauseTimeInSec * 1000);
|
||
|
||
// auto ta = getTA();
|
||
// ta.area().cornerBottomLeft(m_centralPoint);
|
||
|
||
// QVERIFY2(m_aesFtc , "ERROR, No Aes Ftc available!!");
|
||
|
||
// for (int i = 0; i < m_maxTechnicalAreaCentral + s_offset; ++i)
|
||
// {
|
||
// QString name = QStringLiteral("TEST_TA") + QStringLiteral("_CEN_") + QString::number(i);
|
||
// ta.name(name.toStdString());
|
||
// int ret = m_aesFtc->technicalAreaModifyRequest(ta, this);
|
||
// if(i < m_maxTechnicalAreaCentral)
|
||
// QVERIFY2(ret != 0, "ERROR, Technical Area Modify Request failed!!");
|
||
|
||
// }
|
||
|
||
// QVERIFY2(waitForData([this]() {
|
||
// int counter = 0;
|
||
// for (const auto &ta : m_aesDtc->technicalAreas())
|
||
// {
|
||
// if (ta.effectStateId() == AesEffectState::EsPrepared && ta.isCentral() == true)
|
||
// ++counter;
|
||
// }
|
||
// return (counter <= m_maxTechnicalAreaCentral);
|
||
|
||
// }, 5), "Too many Technical Areas");
|
||
// }
|
||
|
||
bool ModuleTestLimits::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();
|
||
}
|
||
|
||
ExplosionClusterModifyRequest ModuleTestLimits::getEc(const Core::GeoPosition2D &cornerBottomLeft)
|
||
{
|
||
|
||
AreaEffectSimulation::ExplosionClusterModifyRequest eaReq;
|
||
eaReq.id(0);
|
||
|
||
eaReq.effectStart((time(nullptr) + 30) * 1000); // msec
|
||
|
||
QString name(QStringLiteral("Test_EC"));
|
||
eaReq.name(name.toStdString());
|
||
eaReq.effectDuration(100000); // 10 seconds
|
||
eaReq.effectStart(QDateTime::currentMSecsSinceEpoch() + 3000000000);
|
||
eaReq.chargeStruct().chargeTypeId(s_ChargeTypeId1);
|
||
eaReq.chargeStruct().igniterTypeId(s_IgniterTypeId);
|
||
|
||
eaReq.partyId(2);
|
||
eaReq.participantId(6);
|
||
|
||
eaReq.mhpCount(4);
|
||
eaReq.impactCount(4);
|
||
|
||
eaReq.peakHeight(500);
|
||
|
||
eaReq.firePurposeId(1); // 1=Blenden, 2=Blenden mit IR,
|
||
|
||
const double height = 10;
|
||
const double width = 20;
|
||
const double rot = 0;
|
||
|
||
// NOTICE_LOG(m_logger) << "getEc: default SpecicalArea Bottom Left" << m_specialArea.boundingBoxBottomLeft();
|
||
// eaReq.area().cornerBottomLeft(m_specialArea.boundingBoxBottomLeft());
|
||
eaReq.area().cornerBottomLeft(cornerBottomLeft);
|
||
eaReq.area().height(height);
|
||
eaReq.area().width(width);
|
||
eaReq.area().rotation(rot);
|
||
|
||
eaReq.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgArea);
|
||
eaReq.tla(0); // aka zog / ZielOrtungsGenauigkeit
|
||
|
||
eaReq.externalId(0);
|
||
|
||
return eaReq;
|
||
}
|
||
|
||
ExplosionClusterModifyRequest ModuleTestLimits::getAs()
|
||
{
|
||
AreaEffectSimulation::ExplosionClusterModifyRequest eaReq;
|
||
eaReq.id(0);
|
||
|
||
eaReq.effectStart((time(nullptr) + 30) * 1000); // msec
|
||
|
||
QString name(QStringLiteral("Test_EC"));
|
||
eaReq.name(name.toStdString());
|
||
eaReq.effectDuration(100000); // 10 seconds
|
||
eaReq.effectStart(QDateTime::currentMSecsSinceEpoch() + 3000000000);
|
||
eaReq.chargeStruct().chargeTypeId(450); //PGM GBU 31
|
||
eaReq.chargeStruct().igniterTypeId(s_IgniterTypeId);
|
||
|
||
eaReq.partyId(2);
|
||
eaReq.participantId(6);
|
||
|
||
eaReq.mhpCount(1);
|
||
eaReq.impactCount(1);
|
||
|
||
eaReq.peakHeight(500);
|
||
|
||
eaReq.firePurposeId(1); // 1=Blenden, 2=Blenden mit IR,
|
||
|
||
const double height = 10;
|
||
const double width = 20;
|
||
const double rot = 0;
|
||
|
||
// NOTICE_LOG(m_logger) << "getAs: Default is SpecialArea Bottom Left" << m_specialArea.boundingBoxBottomLeft();
|
||
// eaReq.area().cornerBottomLeft(m_specialArea.boundingBoxBottomLeft());
|
||
eaReq.area().cornerBottomLeft(m_centralPoint);
|
||
eaReq.area().height(height);
|
||
eaReq.area().width(width);
|
||
eaReq.area().rotation(rot);
|
||
|
||
eaReq.explosionGeometry(AreaEffectSimulation::AesExplosionGeometry_def::EgPoint); // AirSupport -> EgPoint
|
||
eaReq.tla(0); // aka zog / ZielOrtungsGenauigkeit
|
||
|
||
eaReq.externalId(0);
|
||
|
||
return eaReq;
|
||
}
|
||
|
||
ExplosionAreaModifyRequest ModuleTestLimits::getEa()
|
||
{
|
||
|
||
auto ea = ExplosionAreaModifyRequest();
|
||
ea.area(AreaEffectSimulation::Area(m_decentralPoint, 500, 600, 70));
|
||
ea.name(QStringLiteral("Test_AE__").toStdString());
|
||
ea.id(0);
|
||
ea.cannonCount(10);
|
||
ea.cannonRounds(10);
|
||
ea.chargeTypeId(s_ChargeTypeId1);
|
||
ea.effectDuration(400000);
|
||
ea.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000);
|
||
ea.partyId(2);
|
||
ea.externalId(2);
|
||
|
||
return ea;
|
||
}
|
||
|
||
ExplosionSingleModifyRequest ModuleTestLimits::getEs()
|
||
{
|
||
auto es = ExplosionSingleModifyRequest();
|
||
es.impactPosition(m_decentralPoint);
|
||
es.name(QStringLiteral("Test_AE__").toStdString());
|
||
es.id(0);
|
||
es.chargeTypeId(s_ChargeTypeId1);
|
||
es.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000);
|
||
es.partyId(2);
|
||
es.externalId(2);
|
||
|
||
return es;
|
||
}
|
||
|
||
MineAreaModifyRequest ModuleTestLimits::getMa()
|
||
{
|
||
|
||
auto ma = MineAreaModifyRequest();
|
||
ma.id(0);
|
||
ma.name(QStringLiteral("Test_MA_").toStdString());
|
||
ma.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000);
|
||
ma.effectDuration(400000);
|
||
ma.density(0.5);
|
||
ma.width(169.58);
|
||
ma.partyId(2);
|
||
ma.chargeStruct().chargeTypeId(216);
|
||
ma.isCenterLine(false);
|
||
ma.isLaidHidden(false);
|
||
ma.distance(500.0);
|
||
ma.layingProcedureType(AreaEffectSimulation::AesMaLayingProcedureType_def::LptPioneer);
|
||
return ma;
|
||
|
||
|
||
}
|
||
|
||
NContaminationModifyRequest ModuleTestLimits::getNBC()
|
||
{
|
||
auto nbc = NContaminationModifyRequest();
|
||
nbc.id(0);
|
||
nbc.name("Test_NBC_");
|
||
nbc.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000); // msec
|
||
nbc.effectDuration(10000); // 10 sec
|
||
nbc.chargeTypeId(321);
|
||
nbc.impactPosition(m_decentralPoint);
|
||
nbc.borderLengthInner(1000); // 1km
|
||
nbc.borderLengthOuter(2000); // 2km
|
||
nbc.impactRadius(500); // 500m
|
||
nbc.spanAngle(31);
|
||
nbc.rotationAngle(57);
|
||
nbc.detonationValue(1000); // kt, only cosmetical
|
||
nbc.partyId(2);
|
||
nbc.externalId(0);
|
||
return nbc;
|
||
|
||
}
|
||
|
||
OffRouteMineModifyRequest ModuleTestLimits::getORM()
|
||
{
|
||
auto orm = OffRouteMineModifyRequest();
|
||
orm.id(0);
|
||
orm.effectStart(QDateTime::currentMSecsSinceEpoch() + 300000000); // msec
|
||
orm.effectDuration(100000); // 10 sec
|
||
orm.chargeTypeId(253);
|
||
orm.name("Test_ORM_");
|
||
orm.area().cornerBottomLeft(m_decentralPoint);
|
||
orm.area().width(1000);//(20);
|
||
orm.area().height(200);//(15);
|
||
orm.area().rotation(0.0);//(20.5);
|
||
orm.impactRadius(100); // 100m
|
||
orm.partyId(2);
|
||
return orm;
|
||
}
|
||
|
||
BoobyTrapModifyRequest ModuleTestLimits::getBT()
|
||
{
|
||
auto bt = BoobyTrapModifyRequest();
|
||
bt.id(0);
|
||
bt.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000); // msec
|
||
bt.effectDuration(100000); // 10 sec
|
||
bt.chargeTypeId(251);
|
||
bt.name("Test_BT_");
|
||
bt.impactPosition(m_decentralPoint);
|
||
bt.centralAngle(90);
|
||
bt.rotationAngle(120);
|
||
bt.impactRadius(100); // 100m
|
||
bt.triggerRadius(200);
|
||
bt.partyId(2);
|
||
return bt;
|
||
}
|
||
|
||
BCContaminationModifyRequest ModuleTestLimits::getBCC()
|
||
{
|
||
auto bcc = BCContaminationModifyRequest();
|
||
bcc.id(0);
|
||
bcc.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000); // msec
|
||
bcc.effectDuration(100000); // 10 sec
|
||
bcc.impactRadius(100); // 100m
|
||
bcc.partyId(2);
|
||
bcc.upperOffset(6.0);
|
||
bcc.lowerOffset(-1000.0);
|
||
bcc.impactPosition(m_decentralPoint);
|
||
bcc.chargeTypeId(341);
|
||
bcc.weatherSource(AesWeatherSource::AwsStatic);
|
||
return bcc;
|
||
}
|
||
|
||
FunctionalAreaModifyRequest ModuleTestLimits::getFA()
|
||
{
|
||
auto fa = FunctionalAreaModifyRequest();
|
||
fa.id(0);
|
||
fa.effectStart(QDateTime::currentMSecsSinceEpoch() + 30000000);
|
||
fa.effectDuration(100000);
|
||
fa.area(AreaEffectSimulation::Area(m_decentralPoint, 500, 600, 70));
|
||
fa.chargeTypeId(311);
|
||
fa.partyId(2);
|
||
fa.deconMode(AreaEffectSimulation::AesOperatingMode::OmWaitingTime);
|
||
fa.deconTime(200000);
|
||
fa.maintMode(AreaEffectSimulation::AesOperatingMode::OmWaitingTime);
|
||
fa.maintTime(200000);
|
||
fa.medicMode(AreaEffectSimulation::AesOperatingMode::OmWaitingTime);
|
||
fa.medicTime(200000);
|
||
return fa;
|
||
|
||
}
|
||
|
||
TechnicalAreaModifyRequest ModuleTestLimits::getTA()
|
||
{
|
||
auto ta = TechnicalAreaModifyRequest();
|
||
ta.id(0);
|
||
ta.area(AreaEffectSimulation::Area(m_decentralPoint, 500, 600, 70));
|
||
ta.type(AreaEffectSimulation::AesTechnicalAreaType::TatRestingAreaVehicle);
|
||
return ta;
|
||
}
|
||
|
||
//
|
||
// context of textCases
|
||
//
|
||
void ModuleTestLimits::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!!");
|
||
|
||
//
|
||
// 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!!");
|
||
|
||
//
|
||
// ISM
|
||
//
|
||
m_ismDtc = InfrastructureManagement::Interface::Dtc::create(m_ddsConnector);
|
||
QVERIFY2(m_ismDtc, "ERROR, create m_ismDtc failed!!");
|
||
bRet = bRet && m_ismDtc->enableSpecialArea();
|
||
QVERIFY2(bRet, "ERROR, enableAll failed!!");
|
||
|
||
//
|
||
// PDM
|
||
//
|
||
m_pdmDtc = ProjectDataManagement::Interface::Dtc::create(m_ddsConnector);
|
||
QVERIFY2(m_pdmDtc, "ERROR, create m_pdmDtc failed!!");
|
||
bRet = bRet && m_pdmDtc->enableChargeType();
|
||
bRet = bRet && m_pdmDtc->enableGearTypeChargeType();
|
||
bRet = bRet && m_pdmDtc->enableGearType();
|
||
QVERIFY2(bRet, "ERROR, enableAll failed!!");
|
||
|
||
m_ismDtc->waitForHistoricalDataSpecialArea(1000);
|
||
|
||
|
||
if (m_exmDtc->exercise(m_exerciseId).trainingAreaId() == s_TraingAreaId_Altmark)
|
||
{
|
||
m_centralPoint = m_centralAltmark;
|
||
m_decentralPoint = m_decentralAltmark;
|
||
m_segmentsCentral = m_segmentsCentralAltmark;
|
||
m_segmentsDecentral = m_segmentsDecentralAltmark;
|
||
m_partPos = m_partPosAltmark;
|
||
}
|
||
else
|
||
{
|
||
m_centralPoint = m_centralBremen;
|
||
m_decentralPoint = m_decentralBremen;
|
||
m_segmentsCentral = m_segmentsCentralBremen;
|
||
m_segmentsDecentral = m_segmentsDecentralBremen;
|
||
m_partPos = m_partPosBremen;
|
||
}
|
||
|
||
|
||
setupParticipant();
|
||
setupCharges();
|
||
deleteAesAreas();
|
||
|
||
// spend some for the eventLoop to "consume" existing topics/samples:
|
||
for (int i = 0; i < 10; ++i)
|
||
QTest::qWait(1000);
|
||
|
||
|
||
QVERIFY2(!m_ismDtc->specialAreas().isEmpty(), "No special areas available");
|
||
if (!m_ismDtc->specialAreas().isEmpty())
|
||
m_specialArea = m_ismDtc->specialAreas().first();
|
||
}
|
||
|
||
void ModuleTestLimits::init()
|
||
{
|
||
if (ModuleTestLimits::m_noDelete)
|
||
return;
|
||
// init will be called before each test function is executed.
|
||
QTest::qWait(2500);
|
||
// if(m_exerciseId != 42)
|
||
// return;
|
||
m_counterDds.reset();
|
||
}
|
||
|
||
void ModuleTestLimits::cleanup()
|
||
{
|
||
// if(m_exerciseId != 42)
|
||
// return;
|
||
|
||
if (ModuleTestLimits::m_noDelete)
|
||
return;
|
||
|
||
deleteAesAreas();
|
||
|
||
|
||
// finish last (dds) calls:
|
||
waitForData([]() { return false; }, 10);
|
||
|
||
}
|
||
|
||
// void ModuleTestLimits::testExplosionAreaCentral()
|
||
// {
|
||
// QTest::qWait(s_pauseTimeInSec * 1000);
|
||
// auto ea = getEa();
|
||
// ea.area().cornerBottomLeft(m_centralPoint);
|
||
// QVERIFY2(m_aesFtc , "ERROR, No Aes Ftc available!!");
|
||
|
||
// for (int i = 0; i < m_maxExplosionsCentral + s_offset; ++i)
|
||
// {
|
||
// QString name = QStringLiteral("TEST_EA") + QStringLiteral("_CEN_") + QString::number(i);
|
||
// ea.name(name.toStdString());
|
||
// int ret = m_aesFtc->explosionAreaModifyRequest(ea, this);
|
||
// if(i < m_maxExplosionsCentral)
|
||
// QVERIFY2(ret != 0, "ERROR, explosionAreaModifyRequest failed!!");
|
||
|
||
// }
|
||
|
||
// QVERIFY2(waitForData([this]() {
|
||
// int counter = 0;
|
||
// for (const auto &ea : m_aesDtc->explosionAreas())
|
||
// {
|
||
// if (ea.effectStateId() == AesEffectState::EsPrepared && ea.isCentral() == true)
|
||
// ++counter;
|
||
// }
|
||
// return (counter <= m_maxExplosionsCentral);
|
||
|
||
// }, 5), "Too many explosion areas");
|
||
// }
|
||
|
||
// void ModuleTestLimits::testExplosionAreaDecentral()
|
||
// {
|
||
// QTest::qWait(s_pauseTimeInSec * 1000);
|
||
// auto ea = getEa();
|
||
// ea.area().cornerBottomLeft(m_decentralPoint);
|
||
// QVERIFY2(m_aesFtc , "ERROR, No Aes Ftc available!!");
|
||
|
||
// for (int i = 0; i < m_maxExplosionsDecentral + s_offset; ++i)
|
||
// {
|
||
// QString name = QStringLiteral("TEST_EA") + QStringLiteral("_DEC_") + QString::number(i);
|
||
// ea.name(name.toStdString());
|
||
// int ret = m_aesFtc->explosionAreaModifyRequest(ea, this);
|
||
// if(i < m_maxExplosionsDecentral)
|
||
// QVERIFY2(ret != 0, "ERROR, explosionAreaModifyRequest failed!!");
|
||
|
||
// }
|
||
|
||
// QVERIFY2(waitForData([this]() {
|
||
// int counter = 0;
|
||
// for (const auto &ea : m_aesDtc->explosionAreas())
|
||
// {
|
||
// if (ea.effectStateId() == AesEffectState::EsPrepared && ea.isCentral() == false)
|
||
// ++counter;
|
||
// }
|
||
// return (counter <= m_maxExplosionsDecentral);
|
||
|
||
// }, 5), "Too many explosion areas");
|
||
// }
|
||
|
||
// void ModuleTestLimits::testExplosionSingleCentral()
|
||
// {
|
||
// QTest::qWait(s_pauseTimeInSec * 1000);
|
||
// auto es = getEs();
|
||
// es.impactPosition(m_centralPoint);
|
||
// QVERIFY2(m_aesFtc , "ERROR, No Aes Ftc available!!");
|
||
|
||
// for (int i = 0; i < m_maxExplosionsCentral + s_offset; ++i)
|
||
// {
|
||
// QString name = QStringLiteral("TEST_ES") + QStringLiteral("_CEN_") + QString::number(i);
|
||
// es.name(name.toStdString());
|
||
// int ret = m_aesFtc->explosionSingleModifyRequest(es, this);
|
||
// if(i < m_maxExplosionsCentral)
|
||
// QVERIFY2(ret != 0, "ERROR, explosionSingleModifyRequest failed!!");
|
||
|
||
// }
|
||
|
||
// QVERIFY2(waitForData([this]() {
|
||
// int counter = 0;
|
||
// for (const auto &es : m_aesDtc->explosionSingles())
|
||
// {
|
||
// if (es.effectStateId() == AesEffectState::EsPrepared && es.isCentral() == true)
|
||
// ++counter;
|
||
// }
|
||
// return (counter <= m_maxExplosionsCentral);
|
||
|
||
// }, 5), "Too many explosion single");
|
||
// }
|
||
|
||
// void ModuleTestLimits::testExplosionSingleDecentral()
|
||
// {
|
||
// QTest::qWait(s_pauseTimeInSec * 1000);
|
||
// auto es = getEs();
|
||
// es.impactPosition(m_decentralPoint);
|
||
// QVERIFY2(m_aesFtc , "ERROR, No Aes Ftc available!!");
|
||
|
||
// for (int i = 0; i < m_maxExplosionsDecentral + s_offset; ++i)
|
||
// {
|
||
// QString name = QStringLiteral("TEST_ES") + QStringLiteral("DEC") + QString::number(i);
|
||
// es.name(name.toStdString());
|
||
// int ret = m_aesFtc->explosionSingleModifyRequest(es, this);
|
||
// if(i < m_maxExplosionsDecentral)
|
||
// QVERIFY2(ret != 0, "ERROR, explosionSingleModifyRequest failed!!");
|
||
|
||
// }
|
||
|
||
// QVERIFY2(waitForData([this]() {
|
||
// int counter = 0;
|
||
// for (const auto &es : m_aesDtc->explosionSingles())
|
||
// {
|
||
// if (es.effectStateId() == AesEffectState::EsPrepared && es.isCentral() == false)
|
||
// ++counter;
|
||
// }
|
||
// return (counter <= m_maxExplosionsDecentral);
|
||
|
||
// }, 5), "Too many explosion single");
|
||
// }
|
||
|
||
|
||
void ModuleTestLimits::cleanupTestCase()
|
||
{
|
||
// if(m_exerciseId != 42)
|
||
// return;
|
||
|
||
if (ModuleTestLimits::m_noDelete)
|
||
return;
|
||
deleteAesAreas();
|
||
|
||
|
||
// finish last (dds) calls:
|
||
waitForData([]() { return false; }, 10);
|
||
|
||
INFO_LOG(m_logger) << " ddsConnector destroy...";
|
||
m_ddsConnector.reset();
|
||
INFO_LOG(m_logger) << " ddsConnector destroy...DONE";
|
||
}
|
||
|
||
/*!
|
||
* \brief ModuleTestLimits::setupParticipant
|
||
* \details Set new simulated position for the participant that will used to fire the artillery/Steilfeuer
|
||
* The participant is available with test-db
|
||
* \author Niklas Schmidt
|
||
*/
|
||
void ModuleTestLimits::setupParticipant()
|
||
{
|
||
QVERIFY2(m_ppmFtc, "ERROR, no m_ppmFtc");
|
||
|
||
ParticipantManagement::SetSimulatedPosition req;
|
||
|
||
req.participantId(6); // according testDB
|
||
req.onlyOutdatedParticipants(false);
|
||
req.position(Core::GeoPosition(m_partPos.lon(), m_partPos.lat(), 0.0));
|
||
|
||
INFO_LOG(m_logger) << " setSimulatedPositionRequest ...";
|
||
m_replyError = true;
|
||
m_ppmFtc->setSimulatedPositionRequest(req, this);
|
||
|
||
// expected condition:
|
||
if (!waitForData([this]() { return !m_replyError; }))
|
||
{
|
||
ERROR_LOG(m_logger) << "Error on request";
|
||
}
|
||
|
||
QVERIFY2(m_replyError == false, "ERROR, setupParticipant failed");
|
||
}
|
||
|
||
/*!
|
||
* \brief ModuleTestLimits::setupCharges
|
||
* \details Add charges for the artillery/Steilfeuer
|
||
* \author Niklas Schmidt
|
||
*/
|
||
void ModuleTestLimits::setupCharges()
|
||
{
|
||
QVERIFY2(m_aesFtc, "ERROR, no m_aesFtc");
|
||
ChargeAdministrationModifyRequest req;
|
||
req.id(0);
|
||
req.chargeTypeId(371);
|
||
req.partyId(2);
|
||
req.amount(9999999);
|
||
m_aesFtc->chargeAdministrationModifyRequest(req, this);
|
||
|
||
}
|
||
|
||
/*!
|
||
* \brief ModuleTestLimits::deleteAesAreas
|
||
* \details Tries to delete all aes objects of all types
|
||
* \author Niklas Schmidt
|
||
*/
|
||
void ModuleTestLimits::deleteAesAreas()
|
||
{
|
||
if (!m_aesDtc)
|
||
return;
|
||
|
||
NOTICE_LOG(m_logger) << " removing most AesObject...";
|
||
|
||
const QVector<AesEffectState::type> sts = {AesEffectState::EsExpired, AesEffectState::EsRemoved, AesEffectState::EsActivated};
|
||
|
||
auto clusters = m_aesDtc->explosionClusters();
|
||
for (auto cluster : qAsConst(clusters))
|
||
{
|
||
if (!sts.contains(cluster.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(cluster.id());
|
||
m_aesFtc->explosionClusterRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto nbcs = m_aesDtc->nContaminations();
|
||
for (auto nbc : qAsConst(nbcs))
|
||
{
|
||
if (!sts.contains(nbc.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(nbc.id());
|
||
m_aesFtc->nContaminationRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto orms = m_aesDtc->offRouteMines();
|
||
for (auto orm : qAsConst(orms))
|
||
{
|
||
if (!sts.contains(orm.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(orm.id());
|
||
m_aesFtc->offRouteMineRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto bts = m_aesDtc->boobyTraps();
|
||
for (auto bt : qAsConst(bts))
|
||
{
|
||
if (!sts.contains(bt.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(bt.id());
|
||
m_aesFtc->boobyTrapRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto mas = m_aesDtc->mineAreas();
|
||
for (auto ma : qAsConst(mas))
|
||
{
|
||
if (!sts.contains(ma.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(ma.id());
|
||
m_aesFtc->mineAreaRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto bccs = m_aesDtc->bCContaminations();
|
||
for (auto bcc : qAsConst(bccs))
|
||
{
|
||
if (!sts.contains(bcc.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(bcc.id());
|
||
m_aesFtc->bCContaminationRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto fas = m_aesDtc->functionalAreas();
|
||
for (auto fa : qAsConst(fas))
|
||
{
|
||
if (!sts.contains(fa.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(fa.id());
|
||
m_aesFtc->functionalAreaRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
auto tas = m_aesDtc->technicalAreas();
|
||
for (auto ta : qAsConst(tas))
|
||
{
|
||
if (!sts.contains(ta.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(ta.id());
|
||
m_aesFtc->technicalAreaRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
|
||
auto eas = m_aesDtc->explosionAreas();
|
||
for (auto ea : qAsConst(eas))
|
||
{
|
||
if (!sts.contains(ea.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(ea.id());
|
||
m_aesFtc->explosionAreaRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
|
||
auto ess = m_aesDtc->explosionSingles();
|
||
for (auto es : qAsConst(ess))
|
||
{
|
||
if (!sts.contains(es.effectStateId().underlying()))
|
||
{
|
||
auto removeReq = Core::RemoveElementRequest();
|
||
removeReq.id(es.id());
|
||
m_aesFtc->explosionSingleRemoveRequest(removeReq, this);
|
||
}
|
||
}
|
||
NOTICE_LOG(m_logger) << " removing most AesObject...DONE";
|
||
}
|
||
|
||
// Aufrufe:
|
||
// ./bin/aesModuleTestLimits testAirSupports -e42
|
||
// ./bin/aesModuleTestLimits testAirSupports -e42
|
||
// ./bin/aesModuleTestLimits testOffRouteMines -e42
|
||
// ./bin/aesModuleTestLimits testBoobyTraps -e42
|
||
// ./bin/aesModuleTestLimits -e42
|
||
|
||
// Hinweise:
|
||
// Bei Programmstart werden alle AesWirkfelder gelöscht (via deleteAesAreas)
|
||
// funktioniert mit ex_42, die in die Altmark verschoben wurden (training_area = 2)
|
||
|
||
|
||
// Tips:
|
||
// - TlnId: 6
|
||
// - Darstellung der Zentrale-Bereiche einschalten (Lage|Symboldarstellung|Zentrale Wirksimulationsbereichen-Bereiche
|
||
// - Blick nach Salchau bzw Altmark richten
|
||
// - Geduld haben.
|
||
// - evtl. ddsview einschalten und samples und/oder functioncall verfolgen
|
||
|
||
// ToDo
|
||
// Wirkfelder zw. central und deCentral 'verschieben'
|
||
|
||
|
||
|
||
/*!
|
||
* \brief main
|
||
* \param argc
|
||
* \param argv
|
||
* \details You can start the test with './aesModuleTestLimits -e42 -n' (No spaces between params and value allowed)
|
||
* With the -n param the aes objects will not be deleted after executing, but just once before the test.
|
||
* The Test will create several aes objects of each type (BoobyTrap, MineArea...).
|
||
* If there a multiple limits for one type, e.g. decentral/central limit, the test will create objects for both limits.
|
||
* The test tries to create more objects than possible, then it will wait and count the amount on DDS.
|
||
* If the amount is lower or even maximum, the test is passed.
|
||
* \return
|
||
* \author Niklas Schmidt
|
||
*/
|
||
int main(int argc, char *argv[])
|
||
{
|
||
NGLCoreApplication app(argc, argv);
|
||
app.createLogger("ModuleTest_ExplosionCluster", "log4cxx_aes.props");
|
||
|
||
CmdLineParser options;
|
||
options.setUnitModuleTestMode(true);
|
||
QCommandLineOption deleteOption(QStringLiteral("n"), QCoreApplication::tr("If set the aes areas will not be deleted after test"));
|
||
options.addOption(deleteOption);
|
||
|
||
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:
|
||
if (options.isSet(deleteOption))
|
||
{
|
||
--argc;
|
||
ModuleTestLimits::m_noDelete = true;
|
||
}
|
||
std::cout << "No Delete:" << ModuleTestLimits::m_noDelete;
|
||
|
||
ModuleTestLimits tc(options.domainId(), options.exerciseId());
|
||
return QTest::qExec(&tc, argc, argv);
|
||
}
|