735 lines
27 KiB
C++
Executable File
735 lines
27 KiB
C++
Executable File
/**
|
|
* AES Function Topic Client test executable
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "aes_test_mine_area.h"
|
|
#include "Utils/polygons.h"
|
|
#include "qjsonobject.h"
|
|
#include <QCoreApplication>
|
|
#include <QJsonDocument>
|
|
#include <QTest>
|
|
#include <QTimer>
|
|
#include <LtsCoordTrans/lts_coord_trans.h>
|
|
|
|
namespace AreaEffectSimulation
|
|
{
|
|
|
|
// must be in pdm.pdm_charge_type
|
|
static const int s_ChargeTypeId1 = 53; // Virtual AP
|
|
static const int s_ChargeTypeId2 = 40; // DUS AP
|
|
static const int s_ChargeTypeId3 = 213; // DUS-Mine
|
|
static const int s_ChargeTypeId4 = 240; // Concrete-Mine
|
|
|
|
TestMineArea::TestMineArea(QObject *parent)
|
|
: TestBase("Test.MineArea", parent)
|
|
{
|
|
}
|
|
|
|
bool TestMineArea::init(int domainId, int exerciseId, int testId)
|
|
{
|
|
if (!TestBase::init(domainId, exerciseId, testId))
|
|
return false;
|
|
|
|
m_dtc->waitForHistoricalDataMineArea();
|
|
m_maData.id(-1);
|
|
connect(m_dtc.get(), &AreaEffectSimulation::Interface::Dtc::mineAreaChanged, this, &TestMineArea::mineAreaChanged);
|
|
|
|
return true;
|
|
}
|
|
void TestMineArea::startTest()
|
|
{
|
|
setSegmentForTesMineData();
|
|
const auto effectClusterList = m_dtc->effectClusters();
|
|
m_referencedAesItemId = 0;
|
|
for (const auto &ec : effectClusterList)
|
|
{
|
|
m_referencedAesItemId = ec.id();
|
|
}
|
|
|
|
if (m_testId <= 0)
|
|
tryCreateMineArea();
|
|
else
|
|
{
|
|
m_currentMineId = 12;
|
|
// Dus Mine Test
|
|
if (m_testId == 10)
|
|
tryCreateMineArea2(s_ChargeTypeId3);
|
|
// Concrete Mine
|
|
if (m_testId == 11)
|
|
tryCreateMineArea2(s_ChargeTypeId4);
|
|
if (m_testId == 12)
|
|
tryCreateMineArea2(215, 0.109); // Virt. Mine
|
|
if (m_testId == 15)
|
|
testMineData_11(); // Virt. Mine
|
|
if (m_testId == 16)
|
|
testAddMineData_11(); // Virt. Mine
|
|
if (m_testId == 17)
|
|
testMineData_21(); // Virt. Mine
|
|
if (m_testId == 18)
|
|
testAddMineData_21(); // Virt. Mine
|
|
}
|
|
}
|
|
|
|
bool TestMineArea::checkBaseData(const AreaEffectSimulation::MineArea &a, const AreaEffectSimulation::MineArea &b) const
|
|
{
|
|
if (!checkAesItem(a, b))
|
|
return false;
|
|
|
|
for (size_t i = 0; i < a.segments().size() && i < b.segments().size(); ++i)
|
|
{
|
|
if (a.segments()[i] != b.segments()[i])
|
|
{
|
|
WARNING_LOG(m_logger) << "impactPosition does not match: " << a.segments()[i] << " - " << b.segments()[i];
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//
|
|
// MineArea
|
|
//
|
|
void TestMineArea::tryCreateMineArea()
|
|
{
|
|
ERROR_LOG(m_logger) << " >>>> create Mine Area...";
|
|
m_maData = AreaEffectSimulation::MineArea();
|
|
AreaEffectSimulation::MineArea esData;
|
|
esData.id(0);
|
|
esData.name("chris");
|
|
esData.effectStart((time(nullptr) + 4) * 1000); // msec
|
|
esData.chargeStruct().chargeTypeId(345863487); // Todo: Is this intended?
|
|
esData.effectDuration(400 * 1000);
|
|
esData.density(0.2);
|
|
esData.width(7.0);
|
|
esData.partyId(7);
|
|
esData.participantId(1234);
|
|
esData.layingProcedureType(AreaEffectSimulation::AesMaLayingProcedureType_def::LptArtillery);
|
|
esData.isLaidHidden(true);
|
|
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
segments.emplace_back(Core::GeoPosition2D(0.17001, 0.93001));
|
|
segments.emplace_back(Core::GeoPosition2D(0.17002, 0.93002));
|
|
segments.emplace_back(Core::GeoPosition2D(0.17003, 0.93003));
|
|
|
|
const double distance = 100.0;
|
|
INFO_LOG(m_logger) << "trying to send mineAreaCreateRequest()";
|
|
m_replyError = false;
|
|
m_bExpectedFailure = true;
|
|
m_bIsCreatedRequest = true;
|
|
if (!m_ftc->mineAreaModifyRequest(MineAreaModifyRequest(0,
|
|
esData.name(),
|
|
esData.effectStart(),
|
|
esData.effectDuration(),
|
|
esData.effectSourceId(),
|
|
esData.density(),
|
|
esData.width(),
|
|
{esData.chargeStruct().chargeTypeId(), 0, 0},
|
|
segments,
|
|
esData.partyId(),
|
|
esData.participantId(),
|
|
esData.layingProcedureType(),
|
|
esData.isLaidHidden(),
|
|
esData.effectMarkingInTa(),
|
|
true,
|
|
distance,
|
|
esData.externalId(),
|
|
true),
|
|
this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaCreateRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
// since the chargeTypeId is not valid, we should get an error
|
|
if (!waitForData([this]() { return m_replyError == true; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error creating mine area object (try with error)";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
// now with correct charge type
|
|
m_bExpectedFailure = false;
|
|
m_expectedAesId = -1;
|
|
m_bIsCreatedRequest = true;
|
|
esData.chargeStruct().chargeTypeId(s_ChargeTypeId1);
|
|
if (!m_ftc->mineAreaModifyRequest(MineAreaModifyRequest(esData.id(),
|
|
esData.name(),
|
|
esData.effectStart(),
|
|
esData.effectDuration(),
|
|
esData.effectSourceId(),
|
|
esData.density(),
|
|
esData.width(),
|
|
{esData.chargeStruct().chargeTypeId(), 0, 0},
|
|
segments,
|
|
esData.partyId(),
|
|
esData.participantId(),
|
|
esData.layingProcedureType(),
|
|
esData.isLaidHidden(),
|
|
esData.effectMarkingInTa(),
|
|
true,
|
|
distance,
|
|
esData.externalId(),
|
|
true),
|
|
this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaCreateRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
if (!waitForData([this]() { return m_maData.id() == m_expectedAesId; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error creating mine area object";
|
|
failExit();
|
|
return;
|
|
}
|
|
if (!checkBaseData(m_maData, esData))
|
|
{
|
|
ERROR_LOG(m_logger) << "Creation data does not match published data";
|
|
failExit();
|
|
return;
|
|
}
|
|
QTimer::singleShot(0, this, &TestMineArea::tryModifyMineArea);
|
|
INFO_LOG(m_logger) << "tryCreateMineArea successful";
|
|
}
|
|
// test Mine Data
|
|
void TestMineArea::testMineData_11()
|
|
{
|
|
if (m_referencedAesItemId == 0)
|
|
{
|
|
ERROR_LOG(m_logger) << " TESTING ADD MINE DATA WILL NOT BE POSSIBLE. CREATE A EFFECT CLUSTER BEFORE STARTING THIS TEST";
|
|
return;
|
|
}
|
|
|
|
if (!m_ftc->isMineAreaReferenceModifyEnabled())
|
|
{
|
|
if (!m_ftc->enableMineAreaReferenceModify())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error updating mine area object";
|
|
failExit();
|
|
return;
|
|
}
|
|
}
|
|
|
|
QVector<Database::AesMineAreaSegment> dbsegments;
|
|
int count = 0;
|
|
std::vector<Core::GeoPosition2D> addVec;
|
|
addVec.push_back({0.154111, 0.925984});
|
|
addVec.push_back({0.154111, 0.925937});
|
|
addVec.push_back({0.154137, 0.925984});
|
|
addVec.push_back({0.154137, 0.925937});
|
|
|
|
qCritical() << " ---> newSegments Pos count: " << addVec.size();
|
|
std::vector<MineData> mineData;
|
|
count = 60;
|
|
|
|
QDateTime date = QDateTime::currentDateTime().addDays(7);
|
|
for (const auto &pos : addVec)
|
|
{
|
|
MineData m;
|
|
// auto dt = QDateTime::fromMSecsSinceEpoch(date.toMSecsSinceEpoch());
|
|
m.appearenceTime(date.toMSecsSinceEpoch());
|
|
m.armingTime(date.addDays(count).toMSecsSinceEpoch());
|
|
m.position() = pos;
|
|
count += 6;
|
|
mineData.push_back(m);
|
|
}
|
|
|
|
qCritical() << " ---> final mineAreaReferenceModifyRequest ";
|
|
m_replyError = false;
|
|
m_bExpectedFailure = false;
|
|
m_bIsCreatedRequest = true;
|
|
if (!m_ftc->mineAreaReferenceModifyRequest(MineAreaReferenceModifyRequest(m_referencedAesItemId, 216, m_wirkzeitMsec, mineData)))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaReferenceModifyRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
if (!waitForData([this]() { return m_replyError == false; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error creating mine area from mine data with referenced Id: " << m_referencedAesItemId;
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
// QTimer::singleShot(3000, this, &TestMineArea::testAddMineData_11);
|
|
}
|
|
|
|
void TestMineArea::testAddMineData_11()
|
|
{
|
|
if (m_referencedAesItemId == 0)
|
|
{
|
|
ERROR_LOG(m_logger) << " TESTING ADD MINE DATA WILL NOT BE POSSIBLE. CREATE A EFFECT CLUSTER BEFORE STARTING THIS TEST";
|
|
return;
|
|
}
|
|
|
|
if (!m_ftc->enableMineAreaReferenceModify())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error updating mine area object";
|
|
failExit();
|
|
return;
|
|
}
|
|
QVector<Database::AesMineAreaSegment> dbsegments;
|
|
int count = 0;
|
|
std::vector<Core::GeoPosition2D> addVec;
|
|
addVec.push_back({0.154111, 0.925937});
|
|
addVec.push_back({0.154111, 0.925900});
|
|
addVec.push_back({0.154137, 0.925937});
|
|
addVec.push_back({0.154137, 0.925900});
|
|
|
|
qCritical() << " ---> newSegments Pos count: " << addVec.size();
|
|
std::vector<MineData> mineData;
|
|
count = 60;
|
|
|
|
QDateTime date = QDateTime::currentDateTime().addDays(7);
|
|
for (const auto &pos : addVec)
|
|
{
|
|
MineData m;
|
|
// auto dt = QDateTime::fromMSecsSinceEpoch(date.toMSecsSinceEpoch());
|
|
m.appearenceTime(date.toMSecsSinceEpoch());
|
|
m.armingTime(date.addDays(count).toMSecsSinceEpoch());
|
|
m.position() = pos;
|
|
count += 6;
|
|
mineData.push_back(m);
|
|
}
|
|
|
|
qCritical() << " ---> final mineAreaReferenceModifyRequest ";
|
|
if (!m_ftc->mineAreaReferenceModifyRequest(MineAreaReferenceModifyRequest(m_referencedAesItemId, 216, m_wirkzeitMsec, mineData)))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaReferenceModifyRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
}
|
|
|
|
void TestMineArea::testMineData_21()
|
|
{
|
|
if (m_referencedAesItemId == 0)
|
|
{
|
|
ERROR_LOG(m_logger) << " TESTING ADD MINE DATA WILL NOT BE POSSIBLE. CREATE A EFFECT CLUSTER BEFORE STARTING THIS TEST";
|
|
return;
|
|
}
|
|
|
|
if (!m_ftc->enableMineAreaReferenceModify())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error updating mine area object";
|
|
failExit();
|
|
return;
|
|
}
|
|
QVector<Database::AesMineAreaSegment> dbsegments;
|
|
int count = 0;
|
|
std::vector<Core::GeoPosition2D> addVec;
|
|
addVec.push_back({0.153900, 0.925950});
|
|
addVec.push_back({0.153825, 0.925905});
|
|
addVec.push_back({0.153850, 0.925890});
|
|
addVec.push_back({0.153929, 0.925937});
|
|
|
|
qCritical() << " ---> newSegments Pos count: " << addVec.size();
|
|
std::vector<MineData> mineData;
|
|
count = 60;
|
|
|
|
QDateTime date = QDateTime::currentDateTime().addDays(7);
|
|
for (const auto &pos : addVec)
|
|
{
|
|
MineData m;
|
|
// auto dt = QDateTime::fromMSecsSinceEpoch(date.toMSecsSinceEpoch());
|
|
m.appearenceTime(date.toMSecsSinceEpoch());
|
|
m.armingTime(date.addDays(count).toMSecsSinceEpoch());
|
|
m.position() = pos;
|
|
count += 6;
|
|
mineData.push_back(m);
|
|
}
|
|
|
|
qCritical() << " ---> final mineAreaReferenceModifyRequest ";
|
|
if (!m_ftc->mineAreaReferenceModifyRequest(MineAreaReferenceModifyRequest(m_referencedAesItemId, 216, m_wirkzeitMsec, mineData)))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaReferenceModifyRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
// QTimer::singleShot(3000, this, &TestMineArea::testAddMineData_21);
|
|
}
|
|
void TestMineArea::testAddMineData_21()
|
|
{
|
|
|
|
if (m_referencedAesItemId == 0)
|
|
{
|
|
ERROR_LOG(m_logger) << " TESTING ADD MINE DATA WILL NOT BE POSSIBLE. CREATE A EFFECT CLUSTER BEFORE STARTING THIS TEST";
|
|
return;
|
|
}
|
|
|
|
if (!m_ftc->enableMineAreaReferenceModify())
|
|
{
|
|
ERROR_LOG(m_logger) << "Error updating mine area object";
|
|
failExit();
|
|
return;
|
|
}
|
|
QVector<Database::AesMineAreaSegment> dbsegments;
|
|
int count = 0;
|
|
std::vector<Core::GeoPosition2D> addVec;
|
|
addVec.push_back({0.153900, 0.925937});
|
|
addVec.push_back({0.153955, 0.925937});
|
|
addVec.push_back({0.153955, 0.925920});
|
|
addVec.push_back({0.153900, 0.925920});
|
|
|
|
qCritical() << " ---> newSegments Pos count: " << addVec.size();
|
|
std::vector<MineData> mineData;
|
|
count = 60;
|
|
|
|
QDateTime date = QDateTime::currentDateTime().addDays(7);
|
|
for (const auto &pos : addVec)
|
|
{
|
|
MineData m;
|
|
// auto dt = QDateTime::fromMSecsSinceEpoch(date.toMSecsSinceEpoch());
|
|
m.appearenceTime(date.toMSecsSinceEpoch());
|
|
m.armingTime(date.addDays(count).toMSecsSinceEpoch());
|
|
m.position() = pos;
|
|
count += 6;
|
|
mineData.push_back(m);
|
|
}
|
|
|
|
qCritical() << " ---> final mineAreaReferenceModifyRequest ";
|
|
if (!m_ftc->mineAreaReferenceModifyRequest(MineAreaReferenceModifyRequest(m_referencedAesItemId, 216, m_wirkzeitMsec, mineData)))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaReferenceModifyRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
}
|
|
void TestMineArea::setSegmentForTesMineData()
|
|
{
|
|
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
|
|
// (form == 1)
|
|
{
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
segments.emplace_back(Core::GeoPosition2D(0.154136, 0.926118));
|
|
segments.emplace_back(Core::GeoPosition2D(0.154136, 0.926231));
|
|
m_mapSegmentForm.insert(1, segments);
|
|
}
|
|
// (form == 2)
|
|
{
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
segments.emplace_back(Core::GeoPosition2D(0.154215, 0.926000));
|
|
segments.emplace_back(Core::GeoPosition2D(0.15345, 0.926231));
|
|
m_mapSegmentForm.insert(1, segments);
|
|
}
|
|
// (form == 3)
|
|
{
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
segments.emplace_back(Core::GeoPosition2D(0.153581, 0.926173));
|
|
segments.emplace_back(Core::GeoPosition2D(0.154500, 0.926126));
|
|
m_mapSegmentForm.insert(3, segments);
|
|
}
|
|
}
|
|
void TestMineArea::tryModifyMineArea()
|
|
{
|
|
INFO_LOG(m_logger) << "trying to send modify request";
|
|
m_maData.name("chris2");
|
|
m_maData.effectStart(m_maData.effectStart().get() + 2000);
|
|
m_maData.chargeStruct().chargeTypeId(s_ChargeTypeId2);
|
|
m_maData.effectDuration(4 * 1000);
|
|
m_maData.density(0.2);
|
|
m_maData.width(7.0);
|
|
m_maData.partyId(8);
|
|
m_maData.participantId(1235);
|
|
m_maData.layingProcedureType(AreaEffectSimulation::AesMaLayingProcedureType_def::LptArtillery);
|
|
m_maData.isLaidHidden(false);
|
|
const AreaEffectSimulation::MineArea esData(m_maData);
|
|
m_maData = AreaEffectSimulation::MineArea();
|
|
m_maData.id(esData.id());
|
|
m_maData.effectMarkingInTa(true);
|
|
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
segments.emplace_back(Core::GeoPosition2D(0.17004, 0.93004));
|
|
segments.emplace_back(Core::GeoPosition2D(0.17004, 0.93005));
|
|
|
|
const double distance = 100.0;
|
|
|
|
m_bIsCreatedRequest = false;
|
|
if (!m_ftc->mineAreaModifyRequest(MineAreaModifyRequest(esData.id(),
|
|
esData.name(),
|
|
esData.effectStart(),
|
|
esData.effectDuration(),
|
|
esData.effectSourceId(),
|
|
esData.density(),
|
|
esData.width(),
|
|
{esData.chargeStruct().chargeTypeId(), 0, 0},
|
|
segments,
|
|
esData.partyId(),
|
|
esData.participantId(),
|
|
esData.layingProcedureType(),
|
|
esData.isLaidHidden(),
|
|
esData.effectMarkingInTa(),
|
|
true,
|
|
distance,
|
|
esData.externalId(),
|
|
true),
|
|
this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting modify data";
|
|
failExit();
|
|
return;
|
|
}
|
|
if (!waitForData([this]() { return m_maData.chargeStruct().chargeTypeId() == s_ChargeTypeId2; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error updating mine area object";
|
|
failExit();
|
|
return;
|
|
}
|
|
// No testing, segments won't match!
|
|
// if (!checkBaseData(m_maData, esData))
|
|
// {
|
|
// ERROR_LOG(m_logger) << "Modify data does not match published data";
|
|
// failExit();
|
|
// return;
|
|
// }
|
|
QTimer::singleShot(0, this, &TestMineArea::tryCreateAnotherMineArea);
|
|
INFO_LOG(m_logger) << "tryModifyMineArea successful";
|
|
}
|
|
|
|
//
|
|
// MineArea
|
|
//
|
|
void TestMineArea::tryCreateAnotherMineArea()
|
|
{
|
|
INFO_LOG(m_logger) << "trying to create another area request";
|
|
AreaEffectSimulation::MineArea esData;
|
|
esData.id(0);
|
|
esData.name("chris");
|
|
esData.effectStart((time(nullptr) + 4) * 1000); // msec
|
|
esData.chargeStruct().chargeTypeId(s_ChargeTypeId2);
|
|
esData.effectDuration(4 * 1000);
|
|
esData.density(0.2);
|
|
esData.width(7.0);
|
|
esData.partyId(7);
|
|
esData.participantId(1234);
|
|
esData.layingProcedureType(AreaEffectSimulation::AesMaLayingProcedureType_def::LptArtillery);
|
|
esData.isLaidHidden(false);
|
|
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
segments.emplace_back(Core::GeoPosition2D(0.17004, 0.93004));
|
|
segments.emplace_back(Core::GeoPosition2D(0.17005, 0.93004));
|
|
|
|
const double distance = 100.0;
|
|
|
|
INFO_LOG(m_logger) << "trying to send mineAreaCreateRequest()";
|
|
m_replyError = true;
|
|
m_bIsCreatedRequest = true;
|
|
if (!m_ftc->mineAreaModifyRequest(MineAreaModifyRequest(0,
|
|
esData.name(),
|
|
esData.effectStart(),
|
|
esData.effectDuration(),
|
|
esData.effectSourceId(),
|
|
esData.density(),
|
|
esData.width(),
|
|
{esData.chargeStruct().chargeTypeId(), 0, 0},
|
|
segments,
|
|
esData.partyId(),
|
|
esData.participantId(),
|
|
esData.layingProcedureType(),
|
|
esData.isLaidHidden(),
|
|
esData.effectMarkingInTa(),
|
|
true,
|
|
distance,
|
|
esData.externalId(),
|
|
true),
|
|
this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Modify data does not match published data";
|
|
failExit();
|
|
return;
|
|
}
|
|
if (!waitForData([this]() { return m_replyError == false; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error creating mine area object (try with error)";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
QTimer::singleShot(0, this, &TestMineArea::tryTriggerDusMineInBoth);
|
|
INFO_LOG(m_logger) << "tryCreateMineArea successful";
|
|
}
|
|
|
|
void TestMineArea::tryCreateMineArea2(int chargeTypeId, double density)
|
|
{
|
|
m_maData = AreaEffectSimulation::MineArea();
|
|
AreaEffectSimulation::MineArea esData;
|
|
esData.id(0);
|
|
esData.name("1337Test");
|
|
esData.effectStart((time(nullptr) + 4) * 1000); // msec
|
|
esData.chargeStruct().chargeTypeId(chargeTypeId);
|
|
esData.effectDuration(400 * 1000);
|
|
esData.density(density);
|
|
esData.width(7.0);
|
|
esData.partyId(7);
|
|
esData.participantId(1234);
|
|
esData.layingProcedureType(AreaEffectSimulation::AesMaLayingProcedureType_def::LptArtillery);
|
|
esData.isLaidHidden(false);
|
|
|
|
std::vector<Core::GeoPosition2D> segments;
|
|
/* Erzeugung der GeoKoordinaten fuer den guez-spezifischen zentralen Bereich (Sueden)
|
|
QPointF pos = LtsCoordTrans::geographicFromMgrs(QStringLiteral("32UPD 74600 14100"));
|
|
ERROR_LOG(m_logger) << "pos x: " << pos.x() << ", pos y: " << pos.y();
|
|
segments.emplace_back(Core::GeoPosition2D(pos.x(), pos.y()));
|
|
|
|
pos = LtsCoordTrans::geographicFromMgrs(QStringLiteral("32UPD 77500 14200"));
|
|
ERROR_LOG(m_logger) << "pos x: " << pos.x() << ", pos y: " << pos.y();
|
|
segments.emplace_back(Core::GeoPosition2D(pos.x(), pos.y()));
|
|
|
|
pos = LtsCoordTrans::geographicFromMgrs(QStringLiteral("32UPD 76100 09150"));
|
|
ERROR_LOG(m_logger) << "pos x: " << pos.x() << ", pos y: " << pos.y();
|
|
segments.emplace_back(Core::GeoPosition2D(pos.x(), pos.y()));
|
|
|
|
pos = LtsCoordTrans::geographicFromMgrs(QStringLiteral("32UPD 73550 09450"));
|
|
ERROR_LOG(m_logger) << "pos x: " << pos.x() << ", pos y: " << pos.y();
|
|
segments.emplace_back(Core::GeoPosition2D(pos.x(), pos.y()));
|
|
*/
|
|
|
|
segments.emplace_back(Core::GeoPosition2D(0.15401, 0.92501));
|
|
segments.emplace_back(Core::GeoPosition2D(0.15502, 0.92702));
|
|
segments.emplace_back(Core::GeoPosition2D(0.15603, 0.93003));
|
|
|
|
const double distance = 100.0;
|
|
INFO_LOG(m_logger) << "trying to send mineAreaCreateRequest()";
|
|
m_replyError = false;
|
|
m_bExpectedFailure = false;
|
|
m_bIsCreatedRequest = true;
|
|
if (!m_ftc->mineAreaModifyRequest(MineAreaModifyRequest(0,
|
|
esData.name(),
|
|
esData.effectStart(),
|
|
esData.effectDuration(),
|
|
esData.effectSourceId(),
|
|
esData.density(),
|
|
esData.width(),
|
|
{esData.chargeStruct().chargeTypeId(), 0, 0},
|
|
segments,
|
|
esData.partyId(),
|
|
esData.participantId(),
|
|
esData.layingProcedureType(),
|
|
esData.isLaidHidden(),
|
|
esData.effectMarkingInTa(),
|
|
true,
|
|
distance,
|
|
esData.externalId(),
|
|
true),
|
|
this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineAreaCreateRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
if (!waitForData([this]() { return m_replyError == false; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error creating mine area object with chargeTypeId " << chargeTypeId;
|
|
failExit();
|
|
return;
|
|
}
|
|
}
|
|
|
|
void TestMineArea::tryTriggerDusMineInBoth()
|
|
{
|
|
AreaEffectSimulation::MineTriggeredRequest mtr;
|
|
mtr.mineAreaId(0); // DUS does not send mine area ID!
|
|
mtr.mineId(123);
|
|
mtr.position(Core::GeoPosition2D(0.170041, 0.930041));
|
|
mtr.chargeTypeId(48);
|
|
|
|
INFO_LOG(m_logger) << "trying to send mineTriggeredRequest()";
|
|
m_replyError = true;
|
|
if (!m_ftc->mineTriggeredRequest(MineTriggeredRequest(mtr.mineAreaId(), mtr.mineId(), mtr.position().get(), mtr.chargeTypeId().get()), this))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error during mineTriggeredRequest()";
|
|
failExit();
|
|
return;
|
|
}
|
|
// since the chargeTypeId is not valid, we should get an error
|
|
if (!waitForData([this]() { return m_replyError == false; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error triggering mine (try with error)";
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
QTimer::singleShot(0, this, &TestMineArea::waitExpireMineArea);
|
|
INFO_LOG(m_logger) << "tryTriggerDusMineInBoth successful";
|
|
}
|
|
|
|
void TestMineArea::waitExpireMineArea()
|
|
{
|
|
INFO_LOG(m_logger) << "waiting until mine area expires";
|
|
|
|
if (!waitForData([this]() { return m_maData.effectStateId() == AreaEffectSimulation::AesEffectState::EsExpired; }))
|
|
{
|
|
ERROR_LOG(m_logger) << "Timeout waiting for expiry of mine area with id " << m_maData.id();
|
|
failExit();
|
|
return;
|
|
}
|
|
|
|
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
|
INFO_LOG(m_logger) << "waitExpireMineArea successful";
|
|
}
|
|
|
|
void TestMineArea::mineAreaChanged(const AreaEffectSimulation::MineArea &data, DataModification modType)
|
|
{
|
|
if (m_maData.id() == -1)
|
|
return;
|
|
onAesChanged(data, modType, m_maData);
|
|
}
|
|
|
|
void TestMineArea::onMineAreaModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
if (m_bIsCreatedRequest)
|
|
onAesCreateReply(replyObject);
|
|
else
|
|
onAesModifyReply(replyObject);
|
|
}
|
|
|
|
void TestMineArea::onMineAreaRemoveReply(const Core::FunctionReplyObject &replyObject) { onAesRemoveReply(replyObject); }
|
|
|
|
void TestMineArea::onMineResetReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Got mine reset with id " << replyObject.id() << " and errorString " << replyObject.translated();
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError)
|
|
{
|
|
ERROR_LOG(m_logger) << "Got mine reset reply error: " << replyObject();
|
|
}
|
|
}
|
|
|
|
void TestMineArea::onMineTriggeredReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Got mine triggered with id " << replyObject.id() << " and errorString " << replyObject.translated();
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError)
|
|
{
|
|
ERROR_LOG(m_logger) << "Got mine triggered reply error: " << replyObject();
|
|
}
|
|
}
|
|
|
|
void TestMineArea::onMineAreaReferenceModifyReply(const Core::FunctionReplyObject &replyObject)
|
|
{
|
|
INFO_LOG(m_logger) << "Modify Mine Area with reference replyObj.id: " << replyObject.id() << " and errorString " << replyObject.translated();
|
|
m_replyError = replyObject.error();
|
|
if (m_replyError)
|
|
{
|
|
ERROR_LOG(m_logger) << "Got mine modify reply error: " << replyObject();
|
|
}
|
|
}
|
|
|
|
} // namespace AreaEffectSimulation
|
|
|
|
// ------------------------------------------------------------------
|
|
int main(int argc, char **argv)
|
|
{
|
|
return AreaEffectSimulation::mainBase(argc, argv, []() { return new AreaEffectSimulation::TestMineArea; });
|
|
}
|