467 lines
13 KiB
C++
Executable File
467 lines
13 KiB
C++
Executable File
/**
|
|
* Msg Function Topic Module Test
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
*/
|
|
|
|
#include "ces_tests_geo_pairing_bsp.h"
|
|
|
|
#include "CentralEffectSimulation/ces_dtc.h"
|
|
#include "CentralEffectSimulation/ces_ftc.h"
|
|
#include <nglapplication/nglcoreapplication.h>
|
|
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
|
#include <QTimer>
|
|
#include <QDateTime>
|
|
#include <QPolygonF>
|
|
|
|
/* ----------------------------------------------------------------------------------
|
|
* HOW TO RUN THE TESTS (example)
|
|
* ----------------------------------------------------------------------------------
|
|
* 0. Preconditions:
|
|
* load BT56 (BUILD)
|
|
* make db
|
|
* Start services: (SV)
|
|
* ./svcCentralEffectSimulation -e 42
|
|
* ./cesTestsGeopairing -t 1 -e 42 // Moerser
|
|
* ./cesTestsGeopairing -t 2 -e 42 // IGLA
|
|
* ./cesTestsGeopairing -t 3 -e 42 // IGLA Target Fire
|
|
* ./cesTestsGeopairing -t 4 -e 42 // MK19 Area Fire
|
|
*/
|
|
|
|
namespace CentralEffectSimulation
|
|
{
|
|
|
|
CesTestsGeopairing::CesTestsGeopairing(QObject *parent)
|
|
: QObject(parent)
|
|
, m_bTestsSuccessful(true)
|
|
, m_housePos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
|
|
, m_logger(getLogger("CesTestsGeopairing"))
|
|
, m_testId(0)
|
|
{}
|
|
|
|
CesTestsGeopairing::~CesTestsGeopairing()
|
|
{}
|
|
|
|
bool CesTestsGeopairing::init(int domainId, int exerciseId, int testId)
|
|
{
|
|
bool bRet = true;
|
|
INFO_LOG(m_logger) << "init begin";
|
|
|
|
m_testId = testId;
|
|
|
|
m_ddsConnector42 = std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId);
|
|
m_ddsConnector42->init();
|
|
m_ddsConnector42->initPublisherSubscriber();
|
|
|
|
|
|
m_ppmDts = ParticipantManagement::Interface::Dts::create(m_ddsConnector42);
|
|
bRet &= m_ppmDts->enableParticipantPosition();
|
|
bRet &= m_ppmDts->enableParticipant();
|
|
bRet &= m_ppmDts->enableDynamicParticipantData();
|
|
|
|
m_mdmDts = MeteoDataManagement::Interface::Dts::create(m_ddsConnector42);
|
|
bRet &= m_mdmDts->enableAll();
|
|
|
|
m_tabDts = TrainingAreaBase::Interface::Dts::create(m_ddsConnector42);
|
|
bRet &= m_tabDts->enableGeopairingData();
|
|
|
|
m_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
|
|
bRet &= m_cesDtc->enableAll();
|
|
|
|
m_cesFtc = CentralEffectSimulation::Interface::Ftc::create(m_ddsConnector42);
|
|
bRet &= m_cesFtc->enableAll();
|
|
|
|
m_aesDtc = AreaEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
|
|
bRet &= m_aesDtc->enableAll();
|
|
|
|
|
|
return bRet;
|
|
}
|
|
|
|
void CesTestsGeopairing::startTest()
|
|
{
|
|
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
|
|
switch (m_testId)
|
|
{
|
|
case 1: // Geopairing Mortar
|
|
{
|
|
QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateGeopairingData);
|
|
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
|
|
break;
|
|
}
|
|
case 2: // IGLA Target Detection
|
|
{
|
|
INFO_LOG(m_logger) << "Geopairing IGLA";
|
|
//QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateAircraftPosition);
|
|
QTimer::singleShot(750, this, &CesTestsGeopairing::tryCreateGeopairingDataIGLA);
|
|
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
|
|
break;
|
|
}
|
|
case 3: // IGLA Target Fire
|
|
{
|
|
INFO_LOG(m_logger) << "Geopairing IGLA Target Fire";
|
|
QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateAircraftPosition);
|
|
QTimer::singleShot(750, this, &CesTestsGeopairing::tryCreateGeopairingDataIGLATarget);
|
|
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
|
|
break;
|
|
}
|
|
case 4: // MK 19
|
|
{
|
|
INFO_LOG(m_logger) << "Geopairing MK 19";
|
|
QTimer::singleShot(750, this, &CesTestsGeopairing::tryCreateGeopairingDataMK19);
|
|
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
|
|
failExit();
|
|
}
|
|
}
|
|
QTimer::singleShot(6000, this, &CesTestsGeopairing::failExit);
|
|
}
|
|
|
|
// /////////////////////////////////////////////////////
|
|
/// \brief CesTestsGeopairing::tryCreateParticipantPosition
|
|
///
|
|
void CesTestsGeopairing::tryCreateSoldierPosition()
|
|
{
|
|
ParticipantManagement::ParticipantPosition pp;
|
|
const qint64 time = QDateTime::currentMSecsSinceEpoch();
|
|
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
|
|
double lon = 0.15530400;
|
|
double lat = 0.92601500;
|
|
pp.participantId(5);
|
|
pp.participantTypeId(55);
|
|
pp.pos().lon(lon);
|
|
pp.pos().lat(lat);
|
|
pp.partyId(2);
|
|
pp.roomId(0);
|
|
pp.sampleTime(posTime);
|
|
|
|
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
|
|
if (!m_ppmDts->publish(pp))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
|
|
failExit();
|
|
}
|
|
}
|
|
// /////////////////////////////////////////////////////
|
|
/// \brief CesTestsGeopairing::tryCreateAircraftPosition
|
|
///
|
|
void CesTestsGeopairing::tryCreateAircraftPosition()
|
|
{
|
|
ParticipantManagement::ParticipantPosition pp;
|
|
const qint64 time = QDateTime::currentMSecsSinceEpoch();
|
|
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
|
|
double lon = 0.15488;
|
|
double lat = 0.925742;
|
|
pp.participantId(61);
|
|
pp.participantTypeId(130);
|
|
pp.pos().lon(lon);
|
|
pp.pos().lat(lat);
|
|
pp.partyId(2);
|
|
pp.roomId(0);
|
|
pp.sampleTime(posTime);
|
|
|
|
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
|
|
if (!m_ppmDts->publish(pp))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
|
|
failExit();
|
|
}
|
|
}
|
|
// /////////////////////////////////////////////////////
|
|
/// \brief CesTestsGeopairing::tryCreateGeopairingData
|
|
///
|
|
void CesTestsGeopairing::tryCreateGeopairingData()
|
|
{
|
|
TrainingAreaBase::GeopairingData gd;
|
|
const qint64 time = QDateTime::currentMSecsSinceEpoch();
|
|
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
|
|
gd.payload().resize(18);
|
|
|
|
gd.payload()[0] = 227;
|
|
gd.payload()[1] = 1;
|
|
gd.payload()[2] = 28;
|
|
gd.payload()[3] = 230;
|
|
gd.payload()[4] = 4;
|
|
gd.payload()[5] = 159;
|
|
gd.payload()[6] = 2;
|
|
gd.payload()[7] = 0;
|
|
gd.payload()[8] = 0;
|
|
gd.payload()[9] = 29;
|
|
gd.payload()[10] = 3;
|
|
gd.payload()[11] = 0;
|
|
gd.payload()[12] = 0;
|
|
gd.payload()[13] = 25;
|
|
gd.payload()[14] = 0;
|
|
gd.payload()[15] = 0;
|
|
gd.payload()[16] = 0;
|
|
gd.payload()[17] = 7;
|
|
|
|
//Utm Nordwert: 76400
|
|
//Utm Ostwert : 92000
|
|
|
|
gd.sampleTime(posTime);
|
|
gd.equipmentNumber(1001);
|
|
// lon: 0.154997430779329, lat: 0.925671430121431]
|
|
double lon = 0.154997430779329;
|
|
double lat = 0.925671430121431;
|
|
gd.position().lon(lon);
|
|
gd.position().lat(lat);
|
|
|
|
DEBUG_LOG(m_logger) << "Publishing GeopairingData";
|
|
if (!m_tabDts->publish(gd))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create GeopairingData";
|
|
failExit();
|
|
}
|
|
|
|
}
|
|
|
|
// /////////////////////////////////////////////////////
|
|
/// \brief CesTestsGeopairing::tryCreateGeopairingDataIGLA
|
|
///
|
|
void CesTestsGeopairing::tryCreateGeopairingDataIGLA()
|
|
{
|
|
TrainingAreaBase::GeopairingData gd;
|
|
const qint64 time = QDateTime::currentMSecsSinceEpoch();
|
|
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
|
|
gd.payload().resize(18);
|
|
|
|
// Original aus UAE LogViewer Script
|
|
|
|
gd.payload()[0] = 227;
|
|
gd.payload()[1] = 2;
|
|
gd.payload()[2] = 28;
|
|
gd.payload()[3] = 230;
|
|
gd.payload()[4] = 4;
|
|
gd.payload()[5] = 159;
|
|
gd.payload()[6] = 2;
|
|
gd.payload()[7] = 0;
|
|
gd.payload()[8] = 0;
|
|
gd.payload()[9] = 29;
|
|
gd.payload()[10] = 3;
|
|
gd.payload()[11] = 0;
|
|
gd.payload()[12] = 0;
|
|
gd.payload()[13] = 25;
|
|
gd.payload()[14] = 0;
|
|
gd.payload()[15] = 0;
|
|
gd.payload()[16] = 5;
|
|
gd.payload()[17] = 7;
|
|
|
|
gd.sampleTime(posTime);
|
|
gd.equipmentNumber(1001);
|
|
double lon = 0.15530364;
|
|
double lat = 0.92601523;
|
|
gd.position().lon(lon);
|
|
gd.position().lat(lat);
|
|
|
|
DEBUG_LOG(m_logger) << "Publishing GeopairingData";
|
|
if (!m_tabDts->publish(gd))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create GeopairingData";
|
|
failExit();
|
|
}
|
|
|
|
}
|
|
// /////////////////////////////////////////////////////
|
|
/// \brief CesTestsGeopairing::tryCreateGeopairingDataIGLA
|
|
///
|
|
void CesTestsGeopairing::tryCreateGeopairingDataIGLATarget()
|
|
{
|
|
TrainingAreaBase::GeopairingData gd;
|
|
const qint64 time = QDateTime::currentMSecsSinceEpoch();
|
|
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
|
|
gd.payload().resize(18);
|
|
|
|
// Original aus UAE LogViewer Script
|
|
|
|
gd.payload()[0] = 227;
|
|
gd.payload()[1] = 3;
|
|
gd.payload()[2] = 28;
|
|
gd.payload()[3] = 230;
|
|
gd.payload()[4] = 4;
|
|
gd.payload()[5] = 159;
|
|
gd.payload()[6] = 2;
|
|
gd.payload()[7] = 0;
|
|
gd.payload()[8] = 0;
|
|
gd.payload()[9] = 29;
|
|
gd.payload()[10] = 3;
|
|
gd.payload()[11] = 0;
|
|
gd.payload()[12] = 0;
|
|
gd.payload()[13] = 25;
|
|
gd.payload()[14] = 0;
|
|
gd.payload()[15] = 0;
|
|
gd.payload()[16] = 5;
|
|
gd.payload()[17] = 7;
|
|
|
|
gd.sampleTime(posTime);
|
|
gd.equipmentNumber(1001);
|
|
double lon = 0.15530364;
|
|
double lat = 0.92601523;
|
|
gd.position().lon(lon);
|
|
gd.position().lat(lat);
|
|
|
|
DEBUG_LOG(m_logger) << "Publishing GeopairingData";
|
|
if (!m_tabDts->publish(gd))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create GeopairingData";
|
|
failExit();
|
|
}
|
|
|
|
}
|
|
|
|
// /////////////////////////////////////////////////////
|
|
/// \brief CesTestsGeopairing::tryCreateGeopairingDataIGLA
|
|
///
|
|
void CesTestsGeopairing::tryCreateGeopairingDataMK19()
|
|
{
|
|
TrainingAreaBase::GeopairingData gd;
|
|
const qint64 time = QDateTime::currentMSecsSinceEpoch();
|
|
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
|
|
gd.payload().resize(18);
|
|
|
|
gd.payload()[0] = 227;
|
|
gd.payload()[1] = 5;
|
|
gd.payload()[2] = 28;
|
|
gd.payload()[3] = 230;
|
|
gd.payload()[4] = 4;
|
|
gd.payload()[5] = 159;
|
|
gd.payload()[6] = 2;
|
|
gd.payload()[7] = 0;
|
|
gd.payload()[8] = 0;
|
|
gd.payload()[9] = 29;
|
|
gd.payload()[10] = 3;
|
|
gd.payload()[11] = 0;
|
|
gd.payload()[12] = 0;
|
|
gd.payload()[13] = 25;
|
|
gd.payload()[14] = 0;
|
|
gd.payload()[15] = 0;
|
|
gd.payload()[16] = 5;
|
|
gd.payload()[17] = 7;
|
|
|
|
gd.sampleTime(posTime);
|
|
gd.equipmentNumber(1001);
|
|
double lon = 0.15488;
|
|
double lat = 0.925742;
|
|
|
|
gd.position().lon(lon);
|
|
gd.position().lat(lat);
|
|
|
|
DEBUG_LOG(m_logger) << "Publishing GeopairingData";
|
|
if (!m_tabDts->publish(gd))
|
|
{
|
|
ERROR_LOG(m_logger) << "Error requesting create GeopairingData";
|
|
failExit();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
void CesTestsGeopairing::checkGeopairing()
|
|
{
|
|
INFO_LOG(m_logger) << "checkMessageOnDds";
|
|
|
|
switch (m_testId)
|
|
{
|
|
case 1:
|
|
{
|
|
m_aesDtc->waitForHistoricalDataExplosionSingle();
|
|
QMap < int ,AreaEffectSimulation::ExplosionSingle> explosionSingles = m_aesDtc->explosionSingles();
|
|
INFO_LOG(m_logger) << "explosionSingles.size()" << explosionSingles.size();
|
|
AreaEffectSimulation::ExplosionSingle explosionSingle = explosionSingles.last();
|
|
DEBUG_LOG(m_logger) << "explosionSingle.lat=" << explosionSingle.impactPosition().lat()
|
|
<< " lon=" << explosionSingle.impactPosition().lon();
|
|
if ( (explosionSingle.impactPosition().lat() > 0.9 && explosionSingle.impactPosition().lat() < 1.0)
|
|
&& (explosionSingle.impactPosition().lon() > 0.1 && explosionSingle.impactPosition().lon() < 0.2))
|
|
{
|
|
ExitSuccess();
|
|
return;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
ExitSuccess();
|
|
} // end switch
|
|
|
|
failExit();
|
|
}
|
|
|
|
void CesTestsGeopairing::failExit()
|
|
{
|
|
DEBUG_LOG(m_logger) << "FailExit";
|
|
m_bTestsSuccessful = false;
|
|
QTimer::singleShot(50, qApp, &QCoreApplication::quit);
|
|
}
|
|
|
|
void CesTestsGeopairing::ExitSuccess()
|
|
{
|
|
DEBUG_LOG(m_logger) << "ExitSuccess";
|
|
m_bTestsSuccessful = true;
|
|
QTimer::singleShot(50, qApp, &QCoreApplication::quit);
|
|
}
|
|
|
|
}
|
|
|
|
// ------------------------------------------------------------------
|
|
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
|
{
|
|
public:
|
|
CmdLineParser()
|
|
: LtsCommandLineParser()
|
|
{
|
|
addOption({ QStringList() << QLatin1String("t") << QLatin1String("testId")
|
|
, QLatin1String("TestId.")
|
|
, QLatin1String("Default: 0 (all tests)")
|
|
, QLatin1String("0")
|
|
});
|
|
|
|
addOption({ QStringList() << QLatin1String("a") << QLatin1String("trainingAreaId")
|
|
, QLatin1String("TrainingAreaId.")
|
|
, QLatin1String("Default: 0 (Unknown)")
|
|
, QLatin1String("0")
|
|
});
|
|
}
|
|
|
|
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; }
|
|
int trainingAreaId() const { return isSet(QLatin1String("a")) ? value(QLatin1String("a")).toInt() : -1; }
|
|
};
|
|
|
|
// ------------------------------------------------------------------
|
|
int main(int argc, char **argv)
|
|
{
|
|
NGLCoreApplication app(argc, argv);
|
|
app.createLogger("CES", "log4cxx_ces.props");
|
|
|
|
CmdLineParser options;
|
|
if (!options.init())
|
|
return -1;
|
|
|
|
int iRet = -1;
|
|
{
|
|
std::unique_ptr<CentralEffectSimulation::CesTestsGeopairing> cesTests(new CentralEffectSimulation::CesTestsGeopairing);
|
|
|
|
if (!cesTests->init(options.domainId(), options.exerciseId(), options.testId()))
|
|
return iRet;
|
|
|
|
cesTests->startTest();
|
|
|
|
STARTUP_LOG(app.baseLogger());
|
|
|
|
app.exec();
|
|
|
|
iRet = cesTests->testsSuccessful() ? 0 : 1;
|
|
fprintf(stderr, "%d\n", iRet);
|
|
|
|
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
|
|
|
SHUTDOWN_LOG(app.baseLogger());
|
|
}
|
|
|
|
return iRet;
|
|
}
|
|
|