Initial commit

This commit is contained in:
torsten committed 2026-08-13 18:33:10 +02:00
commit b7d90b9afe
16245 files changed
+3396666

No files matched your search

@@ -0,0 +1,425 @@
#
# $Id$
# $HeadURL$
# $Author$
#
IF(BUILD_TESTING AND BUILD_SV)
####################################
# CES Test
####################################
SET(SRCS_TEST_CES
ces_tests.cpp
ces_tests.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTests
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTests ${SRCS_TEST_CES})
TARGET_LINK_LIBRARIES(cesTests
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcPpmCommon
svcPpmClient
svcBldServer
svcTabServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS cesTests DESTINATION bin/test)
NGL_INSTALL(AAR SV FILES ../log4cxx_ces.props DESTINATION bin/test)
ENDIF()
####################################
# CES Test Ownership
####################################
SET(SRCS_TEST_CES_OWNERSHIP
ces_tests_ownership.cpp
ces_tests_ownership.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsOwnership
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsOwnership ${SRCS_TEST_CES_OWNERSHIP})
TARGET_LINK_LIBRARIES(cesTestsOwnership
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS cesTestsOwnership DESTINATION bin/test)
NGL_INSTALL(AAR SV FILES ../log4cxx_ces.props DESTINATION bin/test)
ENDIF()
####################################
# CES Test Blocked Areas
####################################
SET(SRCS_TEST_CES_OWNERSHIP
ces_tests_blocked_areas.cpp
ces_tests_blocked_areas.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsBlockedAreas
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsBlockedAreas ${SRCS_TEST_CES_OWNERSHIP})
TARGET_LINK_LIBRARIES(cesTestsBlockedAreas
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS cesTestsBlockedAreas DESTINATION bin/test)
NGL_INSTALL(AAR SV FILES ../log4cxx_ces.props DESTINATION bin/test)
ENDIF()
####################################
# CES Test Smart
####################################
SET(SRCS_TEST_CES_SMART
ces_tests_smart.cpp
ces_tests_smart.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsSmart
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsSmart ${SRCS_TEST_CES_SMART})
TARGET_LINK_LIBRARIES(cesTestsSmart
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS cesTestsSmart DESTINATION bin/test)
NGL_INSTALL(AAR SV FILES ../log4cxx_ces.props DESTINATION bin/test)
ENDIF()
####################################
# CES Test Simulated Movement
####################################
SET(SRCS_TEST_CES_SIMULATED_MOVEMENT
ces_tests_simulated_movement.cpp
ces_tests_simulated_movement.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsSimulatedMovement
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsSimulatedMovement ${SRCS_TEST_CES_SIMULATED_MOVEMENT})
TARGET_LINK_LIBRARIES(cesTestsSimulatedMovement
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
IF(NOT BUILD_RPM)
NGL_INSTALL(AAR SV TARGETS cesTestsSimulatedMovement DESTINATION bin/test)
NGL_INSTALL(AAR SV FILES ../log4cxx_ces.props DESTINATION bin/test)
ENDIF()
####################################
# CES Test Geopairing
####################################
SET(SRCS_TEST_CES_GEO_PAIRING
ces_tests_geo_pairing.cpp
ces_tests_geo_pairing.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsGeopairing
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsGeopairing ${SRCS_TEST_CES_GEO_PAIRING})
TARGET_LINK_LIBRARIES(cesTestsGeopairing
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcMdmServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
####################################
# CES Test Geopairing Bsp von UAE ( streams_Mortar_IGLA_MK19.txt )
####################################
SET(SRCS_TEST_CES_GEO_PAIRING_BSP
ces_tests_geo_pairing_bsp.cpp
ces_tests_geo_pairing_bsp.h
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsGeopairingBsp
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsGeopairingBsp ${SRCS_TEST_CES_GEO_PAIRING_BSP})
TARGET_LINK_LIBRARIES(cesTestsGeopairingBsp
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcMdmServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
####################################
# CES Test GasPipe
####################################
SET(SRCS_TEST_CES_GAS_PIPE
ces_tests_gas_pipe.cpp
ces_tests_gas_pipe.cpp
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesTestsGasPipe
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsGasPipe ${SRCS_TEST_CES_GAS_PIPE})
TARGET_LINK_LIBRARIES(cesTestsGasPipe
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcMdmServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
####################################
# CES Test BoobyTrap
####################################
SET(SRCS_TEST_CES_BOOBY_TRAP
ces_tests_booby_trap.h
ces_tests_booby_trap.cpp
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesBoobyTrap
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsBoobyTrap ${SRCS_TEST_CES_BOOBY_TRAP})
TARGET_LINK_LIBRARIES(cesTestsBoobyTrap
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcMdmServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
####################################
# CES Test Mine Areas
####################################
SET(SRCS_TEST_CES_MINE_AREAS
ces_tests_mine_areas.h
ces_tests_mine_areas.cpp
)
NGL_TARGET_INCLUDE_DIRECTORIES(cesMineAreas
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}/../
)
# Testing FunctionTopic Functionality (FTC)
ADD_EXECUTABLE(cesTestsMineAreas ${SRCS_TEST_CES_MINE_AREAS})
TARGET_LINK_LIBRARIES(cesTestsMineAreas
Qt5::Core
Qt5::Test
RTI::nddscpp2
svcAesCommon
svcAesClient
svcCesClient
svcAesServer
svcIsmServer
svcPdmServer
svcPpmServer
svcBldServer
svcTabServer
svcMdmServer
svcCoreClient
LtsCommandLineParser
LtsCoordTrans
ddsconnector
nglcoreapplication
)
ENDIF()
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,134 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <AreaEffectSimulation/aes_dtc.h>
#include <AreaEffectSimulation/aes_ftc.h>
#include <AreaEffectSimulation/aes_dts.h>
#include <CentralEffectSimulation/logger.h>
#include <InfrastructureManagement/ism_dts.h>
#include <ProjectDataManagement/pdm_dts.h>
#include <CentralEffectSimulation/ces_dtc.h>
#include <ParticipantManagement/ppm_dts.h>
#include <Buildings/bld_dts.h>
#include <Buildings/bld_fts.h>
#include <TrainingAreaBase/tab_fts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QHash>
#include <QPointF>
namespace CentralEffectSimulation
{
class CesTests : public QObject
, protected Buildings::Interface::Fts::SendCesHitOnBuildingRequestHandler
, protected TrainingAreaBase::Interface::Fts::SendCesHitRequestHandler
{
Q_OBJECT
public:
explicit CesTests(QObject *parent = nullptr);
bool init(int domainId, int exerciseId, int testId, int roomId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
protected Q_SLOTS:
void tryCreateTriggeredExplosion();
void tryCreateExplosionArea();
void tryCreateExplosionSinglePrepared();
void tryCreateExplosionSingle();
void tryCreateAesItemView();
void tryCreateAesItemViewSingleExplosions();
void tryCreateMainStructureElement();
void tryCreateMainFootprint();
void tryCreateChargeType();
void tryCreateAesItemViewBC(AreaEffectSimulation::AesEffectState desiredState = AreaEffectSimulation::AesEffectState_def::EsActivated);
void tryCreateAesItemViewSM();
void tryCreateAesItemViewMA();
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPosition();
void tryCreateBuildingState();
void tryCreateParticipant();
void tryCreateDynamicParticipantData();
// ////////////////////////
// Borderline
// ////////////////////////
void tryCreateBorderline();
void failExit(const char *reason);
inline void failExit(const QString &reason) { failExit(qPrintable(reason)); }
void testTimeout() { failExit("Test timeout"); }
void ExitSuccess();
private:
void onSendCesHitOnBuildingRequest(const rti::core::SampleIdentity &cookie,
const Buildings::SendCesHitOnBuildingRequest &request) override;
void onSendCesHitRequest(const rti::core::SampleIdentity &cookie,
const TrainingAreaBase::SendCesHitRequest &request) override;
void checkParticipantEvent();
private: // structs
struct Participant
{
int participantId;
int equipmentNumber;
int relX;
int relY;
};
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<AreaEffectSimulation::Interface::Dts> m_aesDts;
std::shared_ptr<InfrastructureManagement::Interface::Dts> m_ismDts;
std::shared_ptr<ProjectDataManagement::Interface::Dts> m_pdmDts;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<Buildings::Interface::Dts> m_bldDts;
std::shared_ptr<Buildings::Interface::Fts> m_bldFts;
std::shared_ptr<TrainingAreaBase::Interface::Fts> m_tabFts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_buildingId;
int m_roomId;
int m_moutObjectId;
int m_chargeTypeId;
int m_participantIndex;
QVector<Participant> m_participants;
int m_originatorParticipantId;
int m_countHitOnBuildingReply;
int m_aesItemId;
AreaEffectSimulation::AesType m_aesType;
InfrastructureManagement::MainStructureElement m_mse;
AreaEffectSimulation::AesItemView m_aiv;
AreaEffectSimulation::ExplosionSingle m_es;
QHash<int, Core::GeoPosition2D> m_expectedPosition;
QPointF m_explosionSingle;
int m_replyEnterFunctionalArea;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,369 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_blocked_areas.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)
* ./bin/svcCentralEffectSimulation -e 42 &
* ./CesTestsBlockedAreas -t 1 -e 42 // 1 Participant in Bldg 56
* ./CesTestsBlockedAreas -t 2 -e 42 // Participants
* ./CesTestsBlockedAreas -t 3 -e 42 // Participants with vulnarability kill are not count
* ./CesTestsBlockedAreas -t 4 -e 42 // Participants in Bldg 56
* ./CesTestsBlockedAreas -t 5 -e 42 // reset Ownership
*/
namespace CentralEffectSimulation
{
CesTestsBlockedAreas::CesTestsBlockedAreas(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_housePos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("CesTestsBlockedAreas"))
, m_testId(0)
, m_participantIndex(0)
, m_DynamicParticipantIndex(0)
{}
CesTestsBlockedAreas::~CesTestsBlockedAreas()
{}
bool CesTestsBlockedAreas::init(int domainId, int exerciseId, int testId)
{
bool bRet = true;
INFO_LOG(m_logger) << "init begin";
m_testId = testId;
m_buildingId = 7; // ism_main_structure_element:id
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_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_cesDtc->enableAll();
m_bldDts = Buildings::Interface::Dts::create(m_ddsConnector42);
bRet &= m_bldDts->enableBuildingState();
m_participants.resize(1);
m_participants[0].participantId = 5;
m_participants[0].equipmentNumber = 1001;
m_participants[0].relX = -1;
m_participants[0].relY = -1;
m_participants[0].partyId = 2;
m_participants[0].buildingId = 301;
m_participants[0].roomId = 41;
return bRet;
}
void CesTestsBlockedAreas::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 Participant in BT56
{
QTimer::singleShot(0, this, &CesTestsBlockedAreas::tryCreateParticipantPositionOutside);
QTimer::singleShot(200, this, &CesTestsBlockedAreas::tryCreateBuildingState);
QTimer::singleShot(400, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(600, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(800, this, &CesTestsBlockedAreas::tryCreateParticipantPositionOutside);
QTimer::singleShot(1000, this, &CesTestsBlockedAreas::tryCreateParticipantPositionOutside);
}
else if (m_testId <= 2) // Participants with vulnarability kill are not count
{
QTimer::singleShot(0, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsBlockedAreas::checkBuildingOwnership);
}
else if (m_testId <= 3) // Participants with vulnarability kill are not count
{
// 1 participant with party=1 combatReady for use and
// 2 participants with party=2 killed in the same room
m_participants[0].roomId = 32;
m_participants[1].roomId = 32;
m_participants[2].roomId = 32;
QTimer::singleShot(0, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsBlockedAreas::tryCreateDynamicParticipantData); // Kill for Participant 0 (participantId = 20)
QTimer::singleShot(1700, this, &CesTestsBlockedAreas::tryCreateDynamicParticipantData); // Kill for Participant 1 (participantId = 21)
QTimer::singleShot(2500, this, &CesTestsBlockedAreas::checkBuildingOwnership);
}
else if (m_testId <= 4) // Participants in BT56
{
QTimer::singleShot(0, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(2500, this, &CesTestsBlockedAreas::checkBuildingOwnership);
}
else if (m_testId <= 5) // reset ownership
{
QTimer::singleShot(0, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsBlockedAreas::tryCreateParticipantPosition);
QTimer::singleShot(3000, this, &CesTestsBlockedAreas::checkBuildingOwnership);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(6000, this, &CesTestsBlockedAreas::failExit);
}
// /////////////////////////////////////////////////////
/// \brief CesTestsBlockedAreas::tryCreateDynamicParticipantData
///
void CesTestsBlockedAreas::tryCreateDynamicParticipantData()
{
ParticipantManagement::DynamicParticipantData dp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
ParticipantManagement::StateInformation si;
si.stateTime(esTime);
si.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill);
dp.participantId(m_participants[m_DynamicParticipantIndex].participantId);
dp.stateHistory().push_back(si);
dp.sampleTime(esTime);
m_DynamicParticipantIndex++;
DEBUG_LOG(m_logger) << "Publishing DynamicParticipantData";
if (!m_ppmDts->publish(dp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsBlockedAreas::tryCreateParticipantPositionOutside
///
void CesTestsBlockedAreas::tryCreateParticipantPositionOutside()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
const Core::GeoPosition pos(0.15527934, 0.92597385, 1.0);
pp.buildingId(0);
pp.participantId(5);
pp.partyId(2);
pp.roomId(0);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsBlockedAreas::tryCreateParticipantPosition
///
void CesTestsBlockedAreas::tryCreateParticipantPosition()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
const Core::GeoPosition pos(0.15527550, 0.92597466, 1.0);
pp.buildingId(301);
pp.participantId(5);
pp.partyId(2);
pp.roomId(41);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsBlockedAreas::tryCreateParticipant
///
void CesTestsBlockedAreas::tryCreateParticipant()
{
ParticipantManagement::Participant pt;
pt.id(m_participants[m_participantIndex].participantId);
pt.equipmentNumber(m_participants[m_participantIndex].equipmentNumber);
DEBUG_LOG(m_logger) << "Publishing Participant";
if (!m_ppmDts->publish(pt))
{
ERROR_LOG(m_logger) << "Error requesting create Participant";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTests::tryCreateBuildingState
///
void CesTestsBlockedAreas::tryCreateBuildingStateInit()
{
Buildings::BuildingState bs;
bs.id(301); // BuildingId
bs.structureElementId(26);
bs.aesId(100);
bs.aesId(0);
bs.originatorParticipantId(2000);
bs.chargeTypeId(4);
bs.damagePercent(0);
bs.damagePercentOld(0);
bs.vulnerabilityState(ProjectDataManagement::VulnerabilityState::CombatReady);
bs.sampleTime(QDateTime::currentMSecsSinceEpoch());
DEBUG_LOG(m_logger) << "Publishing BuildingState";
if (!m_bldDts->publish(bs))
{
ERROR_LOG(m_logger) << "Error requesting create BuildingState";
failExit();
}
}
void CesTestsBlockedAreas::tryCreateBuildingState()
{
Buildings::BuildingState bs;
Buildings::RoomState rs;
bs.id(301); // BuildingId
bs.structureElementId(26);
bs.aesId(100);
bs.aesId(0);
bs.originatorParticipantId(2000);
bs.chargeTypeId(4);
bs.damagePercent(60);
bs.damagePercentOld(0);
bs.vulnerabilityState(ProjectDataManagement::VulnerabilityState::CombatReady);
bs.roomStates().resize(1);
rs.id(41); // RoomId
rs.damagePercent(90);
rs.remainingEffectPercent(90);
bs.roomStates()[0] = rs;
bs.sampleTime(QDateTime::currentMSecsSinceEpoch());
DEBUG_LOG(m_logger) << "Publishing BuildingState";
if (!m_bldDts->publish(bs))
{
ERROR_LOG(m_logger) << "Error requesting create BuildingState";
failExit();
}
}
void CesTestsBlockedAreas::checkBuildingOwnership()
{
INFO_LOG(m_logger) << "checkBuildingOwnership";
ExitSuccess();
}
void CesTestsBlockedAreas::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void CesTestsBlockedAreas::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::CesTestsBlockedAreas> cesTests(new CentralEffectSimulation::CesTestsBlockedAreas);
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;
}
@@ -0,0 +1,89 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/logger.h>
#include <ParticipantManagement/ppm_dts.h>
#include <Buildings/bld_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace CentralEffectSimulation
{
class CesTestsBlockedAreas : public QObject
{
Q_OBJECT
public:
explicit CesTestsBlockedAreas(QObject *parent = nullptr);
~CesTestsBlockedAreas();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
protected Q_SLOTS:
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPositionOutside();
void tryCreateParticipantPosition();
void tryCreateParticipant();
void tryCreateDynamicParticipantData();
void tryCreateBuildingStateInit();
void tryCreateBuildingState();
void failExit();
void ExitSuccess();
private: // methods
void checkParicipantEvent();
private: // structs
struct Participant
{
int participantId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<Buildings::Interface::Dts> m_bldDts;
void checkBuildingOwnership();
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_participantIndex;
int m_DynamicParticipantIndex;
QVector<Participant> m_participants;
int m_buildingId;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,396 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_booby_trap.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>
#include <QDateTime>
/* ----------------------------------------------------------------------------------
* HOW TO RUN THE TESTS (example)
* ----------------------------------------------------------------------------------
* 0. Preconditions:
* make test-db
* Start services: (SV)
* ./svcCentralEffectSimulation -e 42 &
* ./cesTestsBoobyTrap -t 1 -e 42 // Anstarten des Modul-Tests
*/
namespace CentralEffectSimulation
{
CesTestsBoobyTrap::CesTestsBoobyTrap(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
//, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD9387781202")))
, m_logger(getLogger("CesTest"))
, m_testId(0)
, m_participantIndex(0)
, m_id(20)
, m_equipmentNumber(60)
, m_DynamicParticipantIndex(0)
, m_aesItemId(5)
, m_chargeTypeId(252) // Verdeckte Ladung
, m_countEventBoobyTrap(0)
{}
CesTestsBoobyTrap::~CesTestsBoobyTrap()
{}
bool CesTestsBoobyTrap::init(int domainId, int exerciseId, int testId)
{
bool bRet = true;
int equipmentTypeIdVehicle = 27;
int equipmentTypeIdSoldier = 55; // dds-Topic Participant-Management::Type
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_pdmDts = ProjectDataManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_pdmDts->enableChargeType();
m_ppmDts = ParticipantManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_ppmDts->enableParticipantPosition();
bRet &= m_ppmDts->enableParticipant();
bRet &= m_ppmDts->enableDynamicParticipantData();
bRet &= m_ppmDts->enableType();
m_aesDts = AreaEffectSimulation::Interface::Dts::create(m_ddsConnector42);
bRet &= m_aesDts->enableBoobyTrap();
bRet &= m_aesDts->enableAesItemView();
m_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_cesDtc->enableAll();
bRet &= m_cesDtc->enableParticipantEvent();
m_cesFtc = CentralEffectSimulation::Interface::Ftc::create(m_ddsConnector42);
bRet &= m_cesFtc->enableAll();
connect(m_cesDtc.get(), &CentralEffectSimulation::Interface::Dtc::participantEventChanged,
this, &CesTestsBoobyTrap::onEventChanged);
m_participants.resize(3);
m_participants[0].participantId = 126; // Secondary
m_participants[0].participantTypeId = equipmentTypeIdSoldier;
m_participants[0].equipmentNumber = 1002;
m_participants[0].relX = 3;
m_participants[0].relY = -6;
m_participants[0].partyId = 4;
m_participants[0].buildingId = 0;
m_participants[0].roomId = 0;
m_participants[1].participantId = 125; // inside Building
m_participants[1].participantTypeId = equipmentTypeIdSoldier;
m_participants[1].equipmentNumber = 1001;
m_participants[1].relX = 0;
m_participants[1].relY = 0;
m_participants[1].partyId = 4;
m_participants[1].buildingId = 301;
m_participants[1].roomId = 126;
m_participants[2].participantId = 24; // inside BoobyTrap
m_participants[2].participantTypeId = equipmentTypeIdVehicle;
m_participants[2].equipmentNumber = 3803;
m_participants[2].relX = 3;
m_participants[2].relY = -6;
m_participants[2].partyId = 2;
m_participants[2].buildingId = 0;
m_participants[2].roomId = 0;
return bRet;
}
void CesTestsBoobyTrap::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 SMART
{
m_explosionSingle = m_refPos.geographic(5, 5);
QTimer::singleShot(250, this, &CesTestsBoobyTrap::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsBoobyTrap::tryCreateParticipantPosition);
QTimer::singleShot(4500, this, &CesTestsBoobyTrap::tryCreateAesBoobyTrap);
QTimer::singleShot(4500, this, &CesTestsBoobyTrap::tryCreateAesItemViewBoobyTrap);
QTimer::singleShot(6000, this, &CesTestsBoobyTrap::tryCreateParticipantPosition);
QTimer::singleShot(7500, this, &CesTestsBoobyTrap::tryCreateAesItemViewBoobyTrapSecondary);
QTimer::singleShot(8000, this, &CesTestsBoobyTrap::checkParticipantEvent);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(8000, this, &CesTestsBoobyTrap::failExit);
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipantPosition
///
void CesTestsBoobyTrap::tryCreateParticipantPosition()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
QPointF posF = m_refPos.geographic(m_participants[m_participantIndex].relX,
m_participants[m_participantIndex].relY);
const Core::GeoPosition pos(Core::GeoPosition(posF.x(), posF.y(), 0));
pp.buildingId(m_participants[m_participantIndex].buildingId);
pp.participantId(m_participants[m_participantIndex].participantId);
pp.participantTypeId(m_participants[m_participantIndex].participantTypeId);
pp.partyId(m_participants[m_participantIndex].partyId);
pp.roomId(m_participants[m_participantIndex].roomId);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition[" << m_participantIndex << "]"
<< " pos=" << posF.x() << "/" << posF.y();
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
void CesTestsBoobyTrap::checkParticipantEvent()
{
INFO_LOG(m_logger) << "checkParicipantEvent";
m_cesDtc->waitForHistoricalDataParticipantEvent();
switch (m_testId)
{
case 1:
if ( m_countEventBoobyTrap == 2)
{
INFO_LOG(m_logger) << "ExitSuccess";
ExitSuccess();
}
break;
default:
// nothing
failExit();
break;
}
}
static void setPos(std::vector<Core::GeoPosition> &cont, const QPointF &pos)
{
cont.emplace_back(Core::GeoPosition(pos.x(), pos.y(), 0.0));
}
void CesTestsBoobyTrap::tryCreateAesItemViewBoobyTrap()
{
INFO_LOG(m_logger) << "trying to send AesItemView tryCreateAesItemViewBoobyTrap";
AreaEffectSimulation::AesItemView iv;
iv.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
iv.aesItemId(m_aesItemId);
iv.id(m_aesItemId);
iv.aesTypeId(AreaEffectSimulation::AesType::AtBoobyTrap);
iv.partyId(5);
QPointF bl = m_refPos.geographic(-10, -10);
QPointF tr = m_refPos.geographic(30, 30);
iv.boundingBoxBottomLeft(Core::GeoPosition2D(bl.x(), bl.y()));
iv.boundingBoxTopRight(Core::GeoPosition2D(tr.x(), tr.y()));
iv.chargeStruct().chargeTypeId(m_chargeTypeId);
iv.sampleTime(QDateTime::currentMSecsSinceEpoch());
iv.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
setPos(iv.form(), m_refPos.geographic(-10, -10));
setPos(iv.form(), m_refPos.geographic(-10, 30));
setPos(iv.form(), m_refPos.geographic( 10, 30));
setPos(iv.form(), m_refPos.geographic( 10, -10));
DEBUG_LOG(m_logger) << "Publishing AesItemView";
if (!m_aesDts->publish(iv))
{
ERROR_LOG(m_logger) << "Error requesting create tryCreateAesItemViewBoobyTrap";
failExit();
}
}
void CesTestsBoobyTrap::tryCreateAesBoobyTrap()
{
INFO_LOG(m_logger) << "trying to send AesItemView tryCreateAesBoobyTrap";
AreaEffectSimulation::BoobyTrap iv;
iv.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
iv.id(m_aesItemId);
iv.partyId(5);
QPointF bl = m_refPos.geographic(10, 10);
iv.impactPosition(Core::GeoPosition2D(bl.x(), bl.y()));
iv.chargeStruct().chargeTypeId(m_chargeTypeId);
iv.sampleTime(QDateTime::currentMSecsSinceEpoch());
iv.isCentral(true);
iv.impactRadius(10.0);
iv.triggerRadius(2.0);
iv.centralAngle(90.0);
iv.effectDuration(3600000);
iv.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
DEBUG_LOG(m_logger) << "Publishing AesItemView";
if (!m_aesDts->publish(iv))
{
ERROR_LOG(m_logger) << "Error requesting create tryCreateBoobyTrap";
failExit();
}
}
void CesTestsBoobyTrap::tryCreateAesItemViewBoobyTrapSecondary()
{
INFO_LOG(m_logger) << "trying to send AesItemView tryCreateAesItemViewBoobyTrapSecondary";
AreaEffectSimulation::AesItemView iv;
iv.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
iv.aesItemId(m_aesItemId);
iv.id(m_aesItemId+1);
iv.aesTypeId(AreaEffectSimulation::AesType::AtBoobyTrapSecondary);
iv.partyId(5);
QPointF bl = m_refPos.geographic(-20, -20);
QPointF tr = m_refPos.geographic(40, 40);
iv.boundingBoxBottomLeft(Core::GeoPosition2D(bl.x(), bl.y()));
iv.boundingBoxTopRight(Core::GeoPosition2D(tr.x(), tr.y()));
iv.chargeStruct().chargeTypeId(m_chargeTypeId);
iv.sampleTime(QDateTime::currentMSecsSinceEpoch());
iv.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
setPos(iv.form(), m_refPos.geographic(-20, -20));
setPos(iv.form(), m_refPos.geographic(-20, 20));
setPos(iv.form(), m_refPos.geographic( 50, 50));
setPos(iv.form(), m_refPos.geographic( 50, -20));
DEBUG_LOG(m_logger) << "Publishing AesItemView";
if (!m_aesDts->publish(iv))
{
ERROR_LOG(m_logger) << "Error requesting create AesItemViewBoobyTrapSecondary";
failExit();
}
}
void CesTestsBoobyTrap::onEventChanged(const CentralEffectSimulation::ParticipantEvent &eventData, DataModification modType)
{
DEBUG_LOG(m_logger) << "onParticipantEventChanged participantId=" << eventData.participantId()
<< " eventType=" << eventData.eventTypeId()
<< " aesItemId=" << eventData.aesItemId();
if (modType == DataModification::eRemoved ||
modType == DataModification::eModified)
return;
if (eventData.eventTypeId() == ProjectDataManagement::EventType_def::HitMine)
{
m_countEventBoobyTrap ++;
DEBUG_LOG(m_logger) << "m_countEventBoobyTrap=" << m_countEventBoobyTrap
<< " eventData.aesItemId()=" << eventData.aesItemId()
<< " eventData.participantId()=" << eventData.participantId();
}
}
Core::FunctionReplyObject CesTestsBoobyTrap::fillFro(int participantId, bool bSuccess) const
{
if (bSuccess)
return Core::FunctionReplyObject(participantId);
return Core::FunctionReplyObject(participantId, tr_lts("dds", "Error sending telegram to tetra"));
}
void CesTestsBoobyTrap::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(200, qApp, QCoreApplication::quit);
}
void CesTestsBoobyTrap::ExitSuccess()
{
DEBUG_LOG(m_logger) << "ExitSuccess";
m_bTestsSuccessful = true;
QTimer::singleShot(200, 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::CesTestsBoobyTrap> cesTests(new CentralEffectSimulation::CesTestsBoobyTrap);
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;
}
@@ -0,0 +1,104 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <AreaEffectSimulation/aes_dts.h>
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ProjectDataManagement/pdm_dts.h>
#include <ParticipantManagement/ppm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QPointF>
namespace CentralEffectSimulation
{
class CesTestsBoobyTrap : public QObject
{
Q_OBJECT
public:
explicit CesTestsBoobyTrap(QObject *parent = nullptr);
~CesTestsBoobyTrap();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
void onEventChanged(const CentralEffectSimulation::ParticipantEvent &eventData, DataModification modType);
protected Q_SLOTS:
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPosition();
void tryCreateAesBoobyTrap();
void tryCreateAesItemViewBoobyTrap();
void tryCreateAesItemViewBoobyTrapSecondary();
void failExit();
void ExitSuccess();
protected:
private: // methods
void checkParticipantEvent();
private: // structs
struct Participant
{
int participantId;
int participantTypeId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
Core::FunctionReplyObject fillFro(int participantId, bool bSuccess) const;
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<AreaEffectSimulation::Interface::Dts> m_aesDts;
std::shared_ptr<ProjectDataManagement::Interface::Dts> m_pdmDts;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_refPos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_participantIndex;
int m_id;
int m_equipmentNumber;
int m_DynamicParticipantIndex;
int m_aesItemId;
QVector<Participant> m_participants;
AreaEffectSimulation::AesType m_aesType;
QPointF m_explosionSingle;
int m_chargeTypeId;
int m_countEventBoobyTrap;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,451 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_gas_pipe.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>
#include <QDateTime>
/* ----------------------------------------------------------------------------------
* HOW TO RUN THE TESTS (example)
* ----------------------------------------------------------------------------------
* 0. Preconditions:
* make test-db
* Start services: (SV)
* ./svcCentralEffectSimulation -e 42 &
* ./cesTestsGasPipe -t 1 -e 42 // Gas Pipe explosion
*/
namespace CentralEffectSimulation
{
CesTestsGasPipe::CesTestsGasPipe(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("CesTestGasPipe"))
, m_testId(0)
, m_participantIndex(0)
, m_id(20)
, m_equipmentNumber(60)
, m_DynamicParticipantIndex(0)
, m_aesItemId(5)
, m_chargeTypeId(374) // SMART
, m_countEventGasPipe(0)
{}
CesTestsGasPipe::~CesTestsGasPipe()
{}
bool CesTestsGasPipe::init(int domainId, int exerciseId, int testId)
{
bool bRet = true;
int equipmentTypeIdVehicle = 35;
int equipmentTypeIdSoldier = 30; // dds-Topic Participant-Management::Type
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_pdmDts = ProjectDataManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_pdmDts->enableChargeType();
m_ppmDts = ParticipantManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_ppmDts->enableParticipantPosition();
bRet &= m_ppmDts->enableParticipant();
bRet &= m_ppmDts->enableDynamicParticipantData();
bRet &= m_ppmDts->enableType();
m_aesDts = AreaEffectSimulation::Interface::Dts::create(m_ddsConnector42);
bRet &= m_aesDts->enableExplosionSingle();
bRet &= m_aesDts->enableAesItemView();
bRet &= m_aesDts->enableTriggeredImpacts();
m_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_cesDtc->enableAll();
m_cesFtc = CentralEffectSimulation::Interface::Ftc::create(m_ddsConnector42);
bRet &= m_cesFtc->enableAll();
connect(m_cesDtc.get(), &CentralEffectSimulation::Interface::Dtc::participantEventChanged,
this, &CesTestsGasPipe::onEventChanged);
m_participants.resize(6);
m_participants[0].participantId = 20; // inside
m_participants[0].participantTypeId = equipmentTypeIdVehicle;
m_participants[0].equipmentNumber = 60;
m_participants[0].relX = -10;
m_participants[0].relY = -10;
m_participants[0].partyId = 2;
m_participants[0].buildingId = 0;
m_participants[0].roomId = 0;
m_participants[1].participantId = 21; // inside
m_participants[1].participantTypeId = equipmentTypeIdVehicle;
m_participants[1].equipmentNumber = 61;
m_participants[1].relX = 10;
m_participants[1].relY = 10;
m_participants[1].partyId = 2;
m_participants[1].buildingId = 0;
m_participants[1].roomId = 0;
m_participants[2].participantId = 22; // inside
m_participants[2].participantTypeId = equipmentTypeIdSoldier;
m_participants[2].equipmentNumber = 62;
m_participants[2].relX = -10;
m_participants[2].relY = -30;
m_participants[2].partyId = 3;
m_participants[2].buildingId = 0;
m_participants[2].roomId = 0;
m_participants[3].participantId = 23; // inside
m_participants[3].participantTypeId = equipmentTypeIdSoldier;
m_participants[3].equipmentNumber = 63;
m_participants[3].relX = -10;
m_participants[3].relY = -1;
m_participants[3].partyId = 3;
m_participants[3].buildingId = 0;
m_participants[3].roomId = 0;
m_participants[4].participantId = 24; // outside
m_participants[4].participantTypeId = equipmentTypeIdVehicle;
m_participants[4].equipmentNumber = 64;
m_participants[4].relX = 30;
m_participants[4].relY = 30;
m_participants[4].partyId = 2;
m_participants[4].buildingId = 0;
m_participants[4].roomId = 0;
m_participants[5].participantId = 25; // outside
m_participants[5].participantTypeId = equipmentTypeIdVehicle;
m_participants[5].equipmentNumber = 65;
m_participants[5].relX = -30;
m_participants[5].relY = -30;
m_participants[5].partyId = 2;
m_participants[5].buildingId = 0;
m_participants[5].roomId = 0;
return bRet;
}
void CesTestsGasPipe::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 SMART
{
m_explosionSingle = m_refPos.geographic(5, 5);
QTimer::singleShot(0, this, &CesTestsGasPipe::tryCreateParticipant);
QTimer::singleShot(20, this, &CesTestsGasPipe::tryCreateParticipant);
QTimer::singleShot(40, this, &CesTestsGasPipe::tryCreateParticipant);
QTimer::singleShot(60, this, &CesTestsGasPipe::tryCreateParticipant);
QTimer::singleShot(80, this, &CesTestsGasPipe::tryCreateParticipant);
QTimer::singleShot(100, this, &CesTestsGasPipe::tryCreateParticipant);
QTimer::singleShot(250, this, &CesTestsGasPipe::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsGasPipe::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsGasPipe::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsGasPipe::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsGasPipe::tryCreateParticipantPosition);
QTimer::singleShot(2500, this, &CesTestsGasPipe::tryCreateParticipantPosition);
QTimer::singleShot(3000, this, &CesTestsGasPipe::tryCreateTypeVehicle);
QTimer::singleShot(3500, this, &CesTestsGasPipe::tryCreateTypeSoldier);
QTimer::singleShot(4000, this, &CesTestsGasPipe::tryCreateChargeType);
QTimer::singleShot(4500, this, &CesTestsGasPipe::tryCreateAesItemViewGasPipe);
QTimer::singleShot(6000, this, &CesTestsGasPipe::checkParticipantEvent);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(8000, this, &CesTestsGasPipe::failExit);
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateDynamicParticipantData
///
void CesTestsGasPipe::tryCreateDynamicParticipantData()
{
ParticipantManagement::DynamicParticipantData dp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
ParticipantManagement::StateInformation si;
si.stateTime(esTime);
si.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill);
dp.participantId(m_participants[m_DynamicParticipantIndex].participantId);
dp.stateHistory().push_back(si);
dp.sampleTime(esTime);
m_DynamicParticipantIndex++;
DEBUG_LOG(m_logger) << "Publishing DynamicParticipantData";
if (!m_ppmDts->publish(dp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipantPosition
///
void CesTestsGasPipe::tryCreateParticipantPosition()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
QPointF posF = m_refPos.geographic(m_participants[m_participantIndex].relX,
m_participants[m_participantIndex].relY);
const Core::GeoPosition pos(Core::GeoPosition(posF.x(), posF.y(), 0));
pp.buildingId(m_participants[m_participantIndex].buildingId);
pp.participantId(m_participants[m_participantIndex].participantId);
pp.participantTypeId(m_participants[m_participantIndex].participantTypeId);
pp.partyId(m_participants[m_participantIndex].partyId);
pp.roomId(m_participants[m_participantIndex].roomId);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipant
///
void CesTestsGasPipe::tryCreateParticipant()
{
ParticipantManagement::Participant pt;
pt.id(m_id);
pt.equipmentNumber(m_equipmentNumber);
DEBUG_LOG(m_logger) << "Publishing Participant";
if (!m_ppmDts->publish(pt))
{
ERROR_LOG(m_logger) << "Error requesting create Participant";
failExit();
}
m_id++;
m_equipmentNumber++;
}
void CesTestsGasPipe::checkParticipantEvent()
{
INFO_LOG(m_logger) << "checkParicipantEvent";
m_cesDtc->waitForHistoricalDataParticipantEvent();
switch (m_testId)
{
case 1:
if ( m_countEventGasPipe == 2)
{
ExitSuccess();
}
break;
default:
// nothing
failExit();
break;
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateTypeVehicle
///
void CesTestsGasPipe::tryCreateTypeVehicle()
{
ParticipantManagement::Type ty;
ty.id(35);
ty.typeClass(ParticipantManagement::TypeClass::inner_enum::GroundVehicle);
ty.equipmentTypeId(35);
ty.symbol("1001");
ty.name("HMMWV Utility");
DEBUG_LOG(m_logger) << "Publishing Type";
if (!m_ppmDts->publish(ty))
{
ERROR_LOG(m_logger) << "Error requesting create Type";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateType
///
void CesTestsGasPipe::tryCreateTypeSoldier()
{
ParticipantManagement::Type ty;
ty.id(11);
ty.typeClass(ParticipantManagement::TypeClass::inner_enum::Human);
ty.equipmentTypeId(30);
ty.symbol("1001");
ty.name("Soldier");
DEBUG_LOG(m_logger) << "Publishing Type";
if (!m_ppmDts->publish(ty))
{
ERROR_LOG(m_logger) << "Error requesting create Type";
failExit();
}
}
static void setPos(std::vector<Core::GeoPosition> &cont, const QPointF &pos)
{
cont.emplace_back(Core::GeoPosition(pos.x(), pos.y(), 0.0));
}
void CesTestsGasPipe::tryCreateAesItemViewGasPipe()
{
INFO_LOG(m_logger) << "trying to send AesItemView AtExplosionAreaSingleExplosions";
AreaEffectSimulation::AesItemView iv;
iv.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
iv.aesItemId(m_aesItemId);
iv.id(m_aesItemId);
iv.aesTypeId(AreaEffectSimulation::AesType::AtGasPipe);
iv.partyId(5);
QPointF bl = m_refPos.geographic(-10, -10);
QPointF tr = m_refPos.geographic(30, 30);
iv.boundingBoxBottomLeft(Core::GeoPosition2D(bl.x(), bl.y()));
iv.boundingBoxTopRight(Core::GeoPosition2D(tr.x(), tr.y()));
iv.chargeStruct().chargeTypeId(m_chargeTypeId);
iv.sampleTime(QDateTime::currentMSecsSinceEpoch());
iv.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
setPos(iv.form(), m_refPos.geographic(-10, -10));
setPos(iv.form(), m_refPos.geographic(-10, 30));
setPos(iv.form(), m_refPos.geographic( 10, 30));
setPos(iv.form(), m_refPos.geographic( 10, -10));
DEBUG_LOG(m_logger) << "Publishing AesItemView";
if (!m_aesDts->publish(iv))
{
ERROR_LOG(m_logger) << "Error requesting create AesItemViewSingleExplosions";
failExit();
}
}
void CesTestsGasPipe::tryCreateChargeType()
{
DEBUG_LOG(m_logger) << "Publishing ChargeType";
ProjectDataManagement::ChargeType ct;
ct.id(m_chargeTypeId);
ct.properties("{\"impactRadius\":25,\"impactEdgeLength\":50,\"isSmart\":true,\"searchRadius\":150}");
if (!m_pdmDts->publish(ct))
{
ERROR_LOG(m_logger) << "Error publish ChargeType";
failExit();
}
}
void CesTestsGasPipe::onEventChanged(const CentralEffectSimulation::ParticipantEvent &eventData, DataModification modType)
{
DEBUG_LOG(m_logger) << "onParticipantEventChanged participantId=" << eventData.participantId()
<< " eventType=" << eventData.eventTypeId();
if (modType == DataModification::eRemoved ||
modType == DataModification::eModified)
return;
if (eventData.eventTypeId() == ProjectDataManagement::EventType_def::HitGasPipe)
{
m_countEventGasPipe ++;
DEBUG_LOG(m_logger) << "m_countEventGasPipe=" << m_countEventGasPipe;
}
}
Core::FunctionReplyObject CesTestsGasPipe::fillFro(int participantId, bool bSuccess) const
{
if (bSuccess)
return Core::FunctionReplyObject(participantId);
return Core::FunctionReplyObject(participantId, tr_lts("dds", "Error sending telegram to tetra"));
}
void CesTestsGasPipe::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void CesTestsGasPipe::ExitSuccess()
{
DEBUG_LOG(m_logger) << "ExitSuccess";
m_bTestsSuccessful = true;
QTimer::singleShot(200, 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::CesTestsGasPipe> cesTests(new CentralEffectSimulation::CesTestsGasPipe);
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;
}
@@ -0,0 +1,107 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <AreaEffectSimulation/aes_dts.h>
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ProjectDataManagement/pdm_dts.h>
#include <ParticipantManagement/ppm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QPointF>
namespace CentralEffectSimulation
{
class CesTestsGasPipe : public QObject
{
Q_OBJECT
public:
explicit CesTestsGasPipe(QObject *parent = nullptr);
~CesTestsGasPipe();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
void onEventChanged(const CentralEffectSimulation::ParticipantEvent &eventData, DataModification modType);
protected Q_SLOTS:
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPosition();
void tryCreateParticipant();
void tryCreateDynamicParticipantData();
void tryCreateTypeVehicle();
void tryCreateTypeSoldier();
void tryCreateAesItemViewGasPipe();
void tryCreateChargeType();
void failExit();
void ExitSuccess();
protected:
private: // methods
void checkParticipantEvent();
private: // structs
struct Participant
{
int participantId;
int participantTypeId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
Core::FunctionReplyObject fillFro(int participantId, bool bSuccess) const;
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<AreaEffectSimulation::Interface::Dts> m_aesDts;
std::shared_ptr<ProjectDataManagement::Interface::Dts> m_pdmDts;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_refPos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_participantIndex;
int m_id;
int m_equipmentNumber;
int m_DynamicParticipantIndex;
int m_aesItemId;
QVector<Participant> m_participants;
AreaEffectSimulation::AesType m_aesType;
QPointF m_explosionSingle;
int m_chargeTypeId;
int m_countEventGasPipe;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,503 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_geo_pairing.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 // Mortar
* ./cesTestsGeopairing -t 2 -e 42 // IGLA
* ./cesTestsGeopairing -t 3 -e 42 // IGLA Damage States
* ./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:
{
QTimer::singleShot(0, this, &CesTestsGeopairing::tryCreateMeteoData);
QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateGeopairingData);
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
break;
}
case 2:
{
INFO_LOG(m_logger) << "Geopairing IGLA";
QTimer::singleShot(0, this, &CesTestsGeopairing::tryCreateMeteoData);
QTimer::singleShot(250, this, &CesTestsGeopairing::tryCreateSoldierPosition);
QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateAircraftPosition);
QTimer::singleShot(750, this, &CesTestsGeopairing::tryCreateGeopairingDataIGLA);
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
break;
}
case 3:
{
INFO_LOG(m_logger) << "Geopairing IGLA Damage States";
QTimer::singleShot(0, this, &CesTestsGeopairing::tryCreateMeteoData);
QTimer::singleShot(250, this, &CesTestsGeopairing::tryCreateSoldierPosition);
QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateAircraftPosition);
QTimer::singleShot(750, this, &CesTestsGeopairing::tryCreateGeopairingDataIGLA);
QTimer::singleShot(1000, this, &CesTestsGeopairing::checkGeopairing);
break;
}
case 4: // MK 19
{
INFO_LOG(m_logger) << "Geopairing MK 19";
QTimer::singleShot(0, this, &CesTestsGeopairing::tryCreateMeteoData);
QTimer::singleShot(250, this, &CesTestsGeopairing::tryCreateSoldierPosition);
QTimer::singleShot(500, this, &CesTestsGeopairing::tryCreateAircraftPosition);
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::tryCreateGeopairingData
///
void CesTestsGeopairing::tryCreateMeteoData()
{
MeteoDataManagement::MeteoData md;
md.id(1);
md.windSpeed(0.0);
md.windDirection(0.0);
md.temperature(20.0);
md.pressure(1013);
DEBUG_LOG(m_logger) << "Publishing MeteoData";
if (!m_mdmDts->publish(md))
{
ERROR_LOG(m_logger) << "Error requesting create MeteoData";
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);
// Fire_Report: TimerTick=58908 AmmuniationType=4 Azimut=79,7 Elevation=67,1 Temperatur=25 RoundsAmm1=0 RoundsAmm2=7
// E3 01 1C E6 04 9F 02 00 00 1D 03 00 00 19 00 00 00 07
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*gd.payload()[0] = 0xE3;
gd.payload()[1] = 0x01; // GeoPairing Mortar
gd.payload()[2] = 0x1C; // Time
gd.payload()[3] = 0xE6; // Time
gd.payload()[4] = 0x04; // Ammunition
gd.payload()[5] = 0x9F; // Elevation
gd.payload()[6] = 0x02; // Elevation
gd.payload()[7] = 0x00; // Elevation
gd.payload()[8] = 0x00; // Elevation
gd.payload()[9] = 0x1D; // Azimuth
gd.payload()[10] = 0x03; // Azimuth
gd.payload()[11] = 0x00; // Azimuth
gd.payload()[12] = 0x00; // Azimuth
gd.payload()[13] = 0x19; // Temperature
gd.payload()[14] = 0x00; // Time To Detonation
gd.payload()[15] = 0x00; // Time To Detonation
gd.payload()[16] = 0x00; // Weapon secific
gd.payload()[17] = 0x07; // */
gd.payload()[0] = 0xE3;
gd.payload()[1] = 0x01;
gd.payload()[2] = 0xe5;
gd.payload()[3] = 0x96;
gd.payload()[4] = 0x12;
gd.payload()[5] = 0x75;
gd.payload()[6] = 0x03;
gd.payload()[7] = 0x00;
gd.payload()[8] = 0x00;
gd.payload()[9] = 0x0e;
gd.payload()[10] = 0x0d;
gd.payload()[11] = 0x00;
gd.payload()[12] = 0x00;
gd.payload()[13] = 0x24;
gd.payload()[14] = 0x00;
gd.payload()[15] = 0x00;
gd.payload()[16] = 0x00;
gd.payload()[17] = 0x00;
gd.sampleTime(posTime);
gd.equipmentNumber(1001);
QPointF posF = m_housePos.geographic(10,10);
const Core::GeoPosition pos(Core::GeoPosition(posF.x(), posF.y(), 0));
gd.position(pos);
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] = 0xE3;
gd.payload()[1] = 0x03; // IGLA
gd.payload()[2] = 0x1c;
gd.payload()[3] = 0xe6;
gd.payload()[4] = 0x04;
gd.payload()[5] = 0x32;
gd.payload()[6] = 0x00;
gd.payload()[7] = 0x00;
gd.payload()[8] = 0x00;
gd.payload()[9] = 0x5a;
gd.payload()[10] = 0x01;
gd.payload()[11] = 0x00;
gd.payload()[12] = 0x00;
gd.payload()[13] = 0x19;
gd.payload()[14] = 0x00;
gd.payload()[15] = 0x00;
gd.payload()[16] = 0x00;
gd.payload()[17] = 0x00;*/
// Daten, wie bei Test1. Sollte ja dann im Zielbereich liegen.
/*
gd.payload()[0] = 0xE3;
gd.payload()[1] = 0x03; // IGLA
gd.payload()[2] = 0xe5;
gd.payload()[3] = 0x96;
gd.payload()[4] = 0x12;
gd.payload()[5] = 0x75;
gd.payload()[6] = 0x03;
gd.payload()[7] = 0x00;
gd.payload()[8] = 0x00;
gd.payload()[9] = 0x0e;
gd.payload()[10] = 0x0d;
gd.payload()[11] = 0x00;
gd.payload()[12] = 0x00;
gd.payload()[13] = 0x24;
gd.payload()[14] = 0x00;
gd.payload()[15] = 0x00;
gd.payload()[16] = 0x00;
gd.payload()[17] = 0x00;
*/
// Daten, wie bei Test1. Sollte ja dann im Zielbereich liegen.
gd.payload()[0] = 0xE3;
gd.payload()[1] = 0x03; // IGLA
gd.payload()[2] = 0x1c;
gd.payload()[3] = 0xe6;
gd.payload()[4] = 0x04;
gd.payload()[5] = 0x32;
gd.payload()[6] = 0x00;
gd.payload()[7] = 0x00;
gd.payload()[8] = 0x00;
gd.payload()[9] = 0x00;
gd.payload()[10] = 0x00;
gd.payload()[11] = 0x00;
gd.payload()[12] = 0x00;
gd.payload()[13] = 0x19;
gd.payload()[14] = 0x00;
gd.payload()[15] = 0x00;
gd.payload()[16] = 0x02; // Button Change over point pressed
gd.payload()[17] = 0x00;
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] = 0xE3;
gd.payload()[1] = 0x05; // MK 19
gd.payload()[2] = 0x1c;
gd.payload()[3] = 0xe6;
gd.payload()[4] = 0x04;
gd.payload()[5] = 0x32;
gd.payload()[6] = 0x00;
gd.payload()[7] = 0x00;
gd.payload()[8] = 0x00;
gd.payload()[9] = 0x00;
gd.payload()[10] = 0x00;
gd.payload()[11] = 0x00;
gd.payload()[12] = 0x00;
gd.payload()[13] = 0x19;
gd.payload()[14] = 0x00;
gd.payload()[15] = 0x00;
gd.payload()[16] = 0x02; // Button Change over point pressed
gd.payload()[17] = 0x00;
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();
}
}
void CesTestsGeopairing::checkGeopairing()
{
INFO_LOG(m_logger) << "checkMessageOnDds";
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();
switch (m_testId)
{
case 1:
{
if ( (explosionSingle.impactPosition().lat() > 0.9 && explosionSingle.impactPosition().lat() < 1.0)
&& (explosionSingle.impactPosition().lon() > 0.1 && explosionSingle.impactPosition().lon() < 0.2))
{
ExitSuccess();
return;
}
break;
}
} // 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;
}
@@ -0,0 +1,75 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ParticipantManagement/ppm_dts.h>
#include <AreaEffectSimulation/aes_dtc.h>
#include <TrainingAreaBase/tab_dts.h>
#include <MeteoDataManagement/mdm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace CentralEffectSimulation
{
class CesTestsGeopairing : public QObject
{
Q_OBJECT
public:
explicit CesTestsGeopairing(QObject *parent = nullptr);
~CesTestsGeopairing();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
void checkGeopairing();
protected Q_SLOTS:
void tryCreateMeteoData();
void tryCreateGeopairingData();
void tryCreateGeopairingDataIGLA();
void tryCreateGeopairingDataMK19();
void tryCreateSoldierPosition();
void tryCreateAircraftPosition();
void failExit();
void ExitSuccess();
private: // methods
void checkParicipantEvent();
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<MeteoDataManagement::Interface::Dts> m_mdmDts;
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,466 @@
/**
* 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;
}
@@ -0,0 +1,75 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ParticipantManagement/ppm_dts.h>
#include <AreaEffectSimulation/aes_dtc.h>
#include <TrainingAreaBase/tab_dts.h>
#include <MeteoDataManagement/mdm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace CentralEffectSimulation
{
class CesTestsGeopairing : public QObject
{
Q_OBJECT
public:
explicit CesTestsGeopairing(QObject *parent = nullptr);
~CesTestsGeopairing();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
void checkGeopairing();
protected Q_SLOTS:
void tryCreateGeopairingData();
void tryCreateGeopairingDataIGLA();
void tryCreateGeopairingDataIGLATarget();
void tryCreateGeopairingDataMK19();
void tryCreateSoldierPosition();
void tryCreateAircraftPosition();
void failExit();
void ExitSuccess();
private: // methods
void checkParicipantEvent();
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<MeteoDataManagement::Interface::Dts> m_mdmDts;
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
std::shared_ptr<AreaEffectSimulation::Interface::Dtc> m_aesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,490 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_mine_areas.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>
#include <QDateTime>
/* ----------------------------------------------------------------------------------
* HOW TO RUN THE TESTS (example)
* ----------------------------------------------------------------------------------
* 0. Preconditions:
* make test-db
* Start services: (SV)
* ./svcCentralEffectSimulation -e 42 &
* ./CesTestsMineAreas -t 1 -e 42 // Mine Area Tests
*
* Was soll getestet werden?
* - 1) Betreten einer Minensperre und auslösen einer Mine
* Teilnehmer geht in das Minensperre und betritt oder überquert mindestens eine Mine
* Reaktion: - Ausloesen einer Mine mit MineTriggerRequest und Anzeige auf der Karte
* - Event betreten Minensperre
* - CES-Hit ueber TAB den Teilnehmer
* - 2) Bewegung innerhalb einer Minensperre
* Teilnehmer ist im Minensperre und liefert eine neue Position innerhalb der Minensperre auf einer andern Mine
* Reaktion: - Ausloesen einer Mine mit MineTriggerRequest und Anzeige auf der Karte
* - CES-Hit ueber TAB den Teilnehmer
* - 3) Teilnehmer verlässt die Minensperre mit ueberquerung einer scharfen Mine
* Reaktion: - Ausloesen einer Mine mit MineTriggerRequest und Anzeige auf der Karte
* - Event verlassen Minensperre
* - CES-Hit ueber TAB den Teilnehmer
* - 4) Teilnehmer springt über eine Minensperre
* Reaktion: - Ausloesen einer Mine mit MineTriggerRequest und Anzeige auf der Karte
* - Event betreten Minensperre
* - Event verlassen Minensperre
* - CES-Hit ueber TAB den Teilnehmer
* - 5) Teilnehmer liefert neue Position außerhalb der Minensperre und hat noch Minen in der gespeicherten Liste
* Reaktion: - Ausloesen einer Mine mit MineTriggerRequest und Anzeige auf der Karte
* - CES-Hit ueber TAB den Teilnehmer
* - 6) Teilnehmer liefert neue Position außerhalb der Minensperre und hat noch Minen in der gespeicherten Liste
* ist aber im Zustand Catastorphic Kill
* Reaktion: - keine
* - 7) Teilnehmer liefert neue Position innerhalb der Minensperre und hat noch Minen in der gespeicherten Liste
* ist aber im Zustand Catastorphic Kill
* Reaktion: - keine
* - 8) Teilnehmer liefert neue Position außerhalb der Minensperre und hat noch Minen in der gespeicherten Liste,
* die outdated sind (siehe settings CES_MINE_AREAS/PeriodStoredMinesOutdated)
* Reaktion: - keine
* - 9) Minengasse: Verlegen einer Minengasse
* Teilnehmer überquert Minensperre ueber eine Minengasse
* Reaktion: - Event betreten Minensperre
* - Event verlassen Minensperre
*
*/
namespace CentralEffectSimulation
{
CesTestsMineAreas::CesTestsMineAreas(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_refPos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("CesTestMineAreas"))
, m_testId(0)
, m_participantIndex(0)
, m_id(20)
, m_equipmentNumber(60)
, m_DynamicParticipantIndex(0)
, m_aesItemId(5)
, m_chargeTypeId(374) // SMART
, m_countEventMineAreas(0)
{}
CesTestsMineAreas::~CesTestsMineAreas()
{}
bool CesTestsMineAreas::init(int domainId, int exerciseId, int testId)
{
bool bRet = true;
int equipmentTypeIdVehicle = 35;
int equipmentTypeIdSoldier = 30; // dds-Topic Participant-Management::Type
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_pdmDts = ProjectDataManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_pdmDts->enableChargeType();
m_ppmDts = ParticipantManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_ppmDts->enableParticipantPosition();
bRet &= m_ppmDts->enableParticipant();
bRet &= m_ppmDts->enableDynamicParticipantData();
bRet &= m_ppmDts->enableType();
m_aesDts = AreaEffectSimulation::Interface::Dts::create(m_ddsConnector42);
bRet &= m_aesDts->enableExplosionSingle();
bRet &= m_aesDts->enableAesItemView();
bRet &= m_aesDts->enableTriggeredImpacts();
m_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_cesDtc->enableAll();
m_cesFtc = CentralEffectSimulation::Interface::Ftc::create(m_ddsConnector42);
bRet &= m_cesFtc->enableAll();
connect(m_cesDtc.get(), &CentralEffectSimulation::Interface::Dtc::participantEventChanged,
this, &CesTestsMineAreas::onEventChanged);
m_participants.resize(6);
m_participants[0].participantId = 20; // inside
m_participants[0].participantTypeId = equipmentTypeIdVehicle;
m_participants[0].equipmentNumber = 60;
m_participants[0].relX = -10;
m_participants[0].relY = -10;
m_participants[0].partyId = 2;
m_participants[0].buildingId = 0;
m_participants[0].roomId = 0;
m_participants[1].participantId = 21; // inside
m_participants[1].participantTypeId = equipmentTypeIdVehicle;
m_participants[1].equipmentNumber = 61;
m_participants[1].relX = 10;
m_participants[1].relY = 10;
m_participants[1].partyId = 2;
m_participants[1].buildingId = 0;
m_participants[1].roomId = 0;
m_participants[2].participantId = 22; // inside
m_participants[2].participantTypeId = equipmentTypeIdSoldier;
m_participants[2].equipmentNumber = 62;
m_participants[2].relX = -10;
m_participants[2].relY = -30;
m_participants[2].partyId = 3;
m_participants[2].buildingId = 0;
m_participants[2].roomId = 0;
m_participants[3].participantId = 23; // inside
m_participants[3].participantTypeId = equipmentTypeIdSoldier;
m_participants[3].equipmentNumber = 63;
m_participants[3].relX = -10;
m_participants[3].relY = -1;
m_participants[3].partyId = 3;
m_participants[3].buildingId = 0;
m_participants[3].roomId = 0;
m_participants[4].participantId = 24; // outside
m_participants[4].participantTypeId = equipmentTypeIdVehicle;
m_participants[4].equipmentNumber = 64;
m_participants[4].relX = 30;
m_participants[4].relY = 30;
m_participants[4].partyId = 2;
m_participants[4].buildingId = 0;
m_participants[4].roomId = 0;
m_participants[5].participantId = 25; // outside
m_participants[5].participantTypeId = equipmentTypeIdVehicle;
m_participants[5].equipmentNumber = 65;
m_participants[5].relX = -30;
m_participants[5].relY = -30;
m_participants[5].partyId = 2;
m_participants[5].buildingId = 0;
m_participants[5].roomId = 0;
return bRet;
}
void CesTestsMineAreas::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 SMART
{
m_explosionSingle = m_refPos.geographic(5, 5);
QTimer::singleShot(0, this, &CesTestsMineAreas::tryCreateParticipant);
QTimer::singleShot(20, this, &CesTestsMineAreas::tryCreateParticipant);
QTimer::singleShot(40, this, &CesTestsMineAreas::tryCreateParticipant);
QTimer::singleShot(60, this, &CesTestsMineAreas::tryCreateParticipant);
QTimer::singleShot(80, this, &CesTestsMineAreas::tryCreateParticipant);
QTimer::singleShot(100, this, &CesTestsMineAreas::tryCreateParticipant);
QTimer::singleShot(250, this, &CesTestsMineAreas::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsMineAreas::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsMineAreas::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsMineAreas::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsMineAreas::tryCreateParticipantPosition);
QTimer::singleShot(2500, this, &CesTestsMineAreas::tryCreateParticipantPosition);
QTimer::singleShot(3000, this, &CesTestsMineAreas::tryCreateTypeVehicle);
QTimer::singleShot(3500, this, &CesTestsMineAreas::tryCreateTypeSoldier);
QTimer::singleShot(4000, this, &CesTestsMineAreas::tryCreateChargeType);
QTimer::singleShot(4500, this, &CesTestsMineAreas::tryCreateAesItemViewMineArea);
QTimer::singleShot(6000, this, &CesTestsMineAreas::checkParticipantEvent);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(8000, this, &CesTestsMineAreas::failExit);
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateDynamicParticipantData
///
void CesTestsMineAreas::tryCreateDynamicParticipantData()
{
ParticipantManagement::DynamicParticipantData dp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
ParticipantManagement::StateInformation si;
si.stateTime(esTime);
si.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill);
dp.participantId(m_participants[m_DynamicParticipantIndex].participantId);
dp.stateHistory().push_back(si);
dp.sampleTime(esTime);
m_DynamicParticipantIndex++;
DEBUG_LOG(m_logger) << "Publishing DynamicParticipantData";
if (!m_ppmDts->publish(dp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipantPosition
///
void CesTestsMineAreas::tryCreateParticipantPosition()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
QPointF posF = m_refPos.geographic(m_participants[m_participantIndex].relX,
m_participants[m_participantIndex].relY);
const Core::GeoPosition pos(Core::GeoPosition(posF.x(), posF.y(), 0));
pp.buildingId(m_participants[m_participantIndex].buildingId);
pp.participantId(m_participants[m_participantIndex].participantId);
pp.participantTypeId(m_participants[m_participantIndex].participantTypeId);
pp.partyId(m_participants[m_participantIndex].partyId);
pp.roomId(m_participants[m_participantIndex].roomId);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipant
///
void CesTestsMineAreas::tryCreateParticipant()
{
ParticipantManagement::Participant pt;
pt.id(m_id);
pt.equipmentNumber(m_equipmentNumber);
DEBUG_LOG(m_logger) << "Publishing Participant";
if (!m_ppmDts->publish(pt))
{
ERROR_LOG(m_logger) << "Error requesting create Participant";
failExit();
}
m_id++;
m_equipmentNumber++;
}
void CesTestsMineAreas::checkParticipantEvent()
{
INFO_LOG(m_logger) << "checkParicipantEvent";
m_cesDtc->waitForHistoricalDataParticipantEvent();
switch (m_testId)
{
case 1:
if ( m_countEventMineAreas == 2)
{
ExitSuccess();
}
break;
default:
// nothing
failExit();
break;
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateTypeVehicle
///
void CesTestsMineAreas::tryCreateTypeVehicle()
{
ParticipantManagement::Type ty;
ty.id(35);
ty.typeClass(ParticipantManagement::TypeClass::inner_enum::GroundVehicle);
ty.equipmentTypeId(35);
ty.symbol("1001");
ty.name("HMMWV Utility");
DEBUG_LOG(m_logger) << "Publishing Type";
if (!m_ppmDts->publish(ty))
{
ERROR_LOG(m_logger) << "Error requesting create Type";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateType
///
void CesTestsMineAreas::tryCreateTypeSoldier()
{
ParticipantManagement::Type ty;
ty.id(11);
ty.typeClass(ParticipantManagement::TypeClass::inner_enum::Human);
ty.equipmentTypeId(30);
ty.symbol("1001");
ty.name("Soldier");
DEBUG_LOG(m_logger) << "Publishing Type";
if (!m_ppmDts->publish(ty))
{
ERROR_LOG(m_logger) << "Error requesting create Type";
failExit();
}
}
static void setPos(std::vector<Core::GeoPosition> &cont, const QPointF &pos)
{
cont.emplace_back(Core::GeoPosition(pos.x(), pos.y(), 0.0));
}
void CesTestsMineAreas::tryCreateAesItemViewMineArea()
{
INFO_LOG(m_logger) << "trying to send AesItemView AtExplosionAreaSingleExplosions";
AreaEffectSimulation::AesItemView iv;
iv.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
iv.aesItemId(m_aesItemId);
iv.id(m_aesItemId);
iv.aesTypeId(AreaEffectSimulation::AesType::AtMineArea);
iv.partyId(5);
QPointF bl = m_refPos.geographic(-10, -10);
QPointF tr = m_refPos.geographic(30, 30);
iv.boundingBoxBottomLeft(Core::GeoPosition2D(bl.x(), bl.y()));
iv.boundingBoxTopRight(Core::GeoPosition2D(tr.x(), tr.y()));
iv.chargeStruct().chargeTypeId(m_chargeTypeId);
iv.sampleTime(QDateTime::currentMSecsSinceEpoch());
iv.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
setPos(iv.form(), m_refPos.geographic(-10, -10));
setPos(iv.form(), m_refPos.geographic(-10, 30));
setPos(iv.form(), m_refPos.geographic( 10, 30));
setPos(iv.form(), m_refPos.geographic( 10, -10));
DEBUG_LOG(m_logger) << "Publishing AesItemView";
if (!m_aesDts->publish(iv))
{
ERROR_LOG(m_logger) << "Error requesting create AesItemViewSingleExplosions";
failExit();
}
}
void CesTestsMineAreas::tryCreateChargeType()
{
DEBUG_LOG(m_logger) << "Publishing ChargeType";
ProjectDataManagement::ChargeType ct;
ct.id(m_chargeTypeId);
ct.properties("{\"impactRadius\":25,\"impactEdgeLength\":50,\"isSmart\":true,\"searchRadius\":150}");
if (!m_pdmDts->publish(ct))
{
ERROR_LOG(m_logger) << "Error publish ChargeType";
failExit();
}
}
void CesTestsMineAreas::onEventChanged(const CentralEffectSimulation::ParticipantEvent &eventData, DataModification modType)
{
DEBUG_LOG(m_logger) << "onParticipantEventChanged participantId=" << eventData.participantId()
<< " eventType=" << eventData.eventTypeId();
if (modType == DataModification::eRemoved ||
modType == DataModification::eModified)
return;
if (eventData.eventTypeId() == ProjectDataManagement::EventType_def::HitGasPipe)
{
m_countEventMineAreas ++;
DEBUG_LOG(m_logger) << "m_countEventMineAreas=" << m_countEventMineAreas;
}
}
Core::FunctionReplyObject CesTestsMineAreas::fillFro(int participantId, bool bSuccess) const
{
if (bSuccess)
return Core::FunctionReplyObject(participantId);
return Core::FunctionReplyObject(participantId, tr_lts("dds", "Error sending telegram to tetra"));
}
void CesTestsMineAreas::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void CesTestsMineAreas::ExitSuccess()
{
DEBUG_LOG(m_logger) << "ExitSuccess";
m_bTestsSuccessful = true;
QTimer::singleShot(200, 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::CesTestsMineAreas> cesTests(new CentralEffectSimulation::CesTestsMineAreas);
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;
}
@@ -0,0 +1,107 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <AreaEffectSimulation/aes_dts.h>
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ProjectDataManagement/pdm_dts.h>
#include <ParticipantManagement/ppm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QPointF>
namespace CentralEffectSimulation
{
class CesTestsMineAreas : public QObject
{
Q_OBJECT
public:
explicit CesTestsMineAreas(QObject *parent = nullptr);
~CesTestsMineAreas();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
void onEventChanged(const CentralEffectSimulation::ParticipantEvent &eventData, DataModification modType);
protected Q_SLOTS:
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPosition();
void tryCreateParticipant();
void tryCreateDynamicParticipantData();
void tryCreateTypeVehicle();
void tryCreateTypeSoldier();
void tryCreateAesItemViewMineArea();
void tryCreateChargeType();
void failExit();
void ExitSuccess();
protected:
private: // methods
void checkParticipantEvent();
private: // structs
struct Participant
{
int participantId;
int participantTypeId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
Core::FunctionReplyObject fillFro(int participantId, bool bSuccess) const;
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<AreaEffectSimulation::Interface::Dts> m_aesDts;
std::shared_ptr<ProjectDataManagement::Interface::Dts> m_pdmDts;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_refPos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_participantIndex;
int m_id;
int m_equipmentNumber;
int m_DynamicParticipantIndex;
int m_aesItemId;
QVector<Participant> m_participants;
AreaEffectSimulation::AesType m_aesType;
QPointF m_explosionSingle;
int m_chargeTypeId;
int m_countEventMineAreas;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,413 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_ownership.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)
* ./bin/svcCentralEffectSimulation -e 42 &
* ./cesTestsOwnership -t 1 -e 42 // 1 Participant in Bldg 56
* ./cesTestsOwnership -t 2 -e 42 // Participants
* ./cesTestsOwnership -t 3 -e 42 // Participants with vulnarability kill are not count
* ./cesTestsOwnership -t 4 -e 42 // Participants in Bldg 56
* ./cesTestsOwnership -t 5 -e 42 // reset Ownership
*/
namespace CentralEffectSimulation
{
CesTestsOwnership::CesTestsOwnership(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_housePos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("CesTestsOwnership"))
, m_testId(0)
, m_participantIndex(0)
, m_DynamicParticipantIndex(0)
{}
CesTestsOwnership::~CesTestsOwnership()
{}
bool CesTestsOwnership::init(int domainId, int exerciseId, int testId)
{
bool bRet = true;
INFO_LOG(m_logger) << "init begin";
m_testId = testId;
m_buildingId = 7; // ism_main_structure_element:id
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_cesDtc = CentralEffectSimulation::Interface::Dtc::create(m_ddsConnector42);
bRet &= m_cesDtc->enableAll();
m_cesFtc = CentralEffectSimulation::Interface::Ftc::create(m_ddsConnector42);
bRet &= m_cesFtc->enableAll();
m_participants.resize(5);
m_participants[0].participantId = 20;
m_participants[0].equipmentNumber = 60;
m_participants[0].relX = -1;
m_participants[0].relY = -1;
m_participants[0].partyId = 2;
m_participants[0].buildingId = m_buildingId;
m_participants[0].roomId = 58;
m_participants[1].participantId = 21;
m_participants[1].equipmentNumber = 61;
m_participants[1].relX = -10;
m_participants[1].relY = -1;
m_participants[1].partyId = 2;
m_participants[1].buildingId = m_buildingId;
m_participants[1].roomId = 32;
m_participants[2].participantId = 22;
m_participants[2].equipmentNumber = 62;
m_participants[2].relX = -10;
m_participants[2].relY = -1;
m_participants[2].partyId = 3;
m_participants[2].buildingId = m_buildingId;
m_participants[2].roomId = 32;
m_participants[3].participantId = 23;
m_participants[3].equipmentNumber = 63;
m_participants[3].relX = -10;
m_participants[3].relY = -1;
m_participants[3].partyId = 3;
m_participants[3].buildingId = m_buildingId;
m_participants[3].roomId = 32;
m_participants[4].participantId = 24;
m_participants[4].equipmentNumber = 64;
m_participants[4].relX = -10;
m_participants[4].relY = -1;
m_participants[4].partyId = 2;
m_participants[4].buildingId = m_buildingId;
m_participants[4].roomId = 58;
return bRet;
}
void CesTestsOwnership::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 Participant in BT56
{
QTimer::singleShot(0, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsOwnership::checkBuildingOwnership);
}
else if (m_testId <= 2) // Participants with vulnarability kill are not count
{
// 1 participant with party=1 combatReady for use and
// 2 participants with party=2
m_participants[0].roomId = 32;
m_participants[1].roomId = 32;
m_participants[2].roomId = 32;
QTimer::singleShot(0, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsOwnership::checkBuildingOwnership);
}
else if (m_testId <= 3) // Participants with vulnarability kill are not count
{
// 1 participant with party=1 combatReady for use and
// 2 participants with party=2 killed in the same room
m_participants[0].roomId = 32;
m_participants[1].roomId = 32;
m_participants[2].roomId = 32;
QTimer::singleShot(0, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsOwnership::tryCreateDynamicParticipantData); // Kill for Participant 0 (participantId = 20)
QTimer::singleShot(1700, this, &CesTestsOwnership::tryCreateDynamicParticipantData); // Kill for Participant 1 (participantId = 21)
QTimer::singleShot(2500, this, &CesTestsOwnership::checkBuildingOwnership);
}
else if (m_testId <= 4) // Participants in BT56
{
QTimer::singleShot(0, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(2500, this, &CesTestsOwnership::checkBuildingOwnership);
}
else if (m_testId <= 5) // reset ownership
{
QTimer::singleShot(0, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsOwnership::tryCreateParticipantPosition);
QTimer::singleShot(2500, this, &CesTestsOwnership::trySetOwnershipRequest);
QTimer::singleShot(3000, this, &CesTestsOwnership::checkBuildingOwnership);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(6000, this, &CesTestsOwnership::failExit);
}
// /////////////////////////////////////////////////////
/// \brief CesTestsOwnership::tryCreateDynamicParticipantData
///
void CesTestsOwnership::tryCreateDynamicParticipantData()
{
ParticipantManagement::DynamicParticipantData dp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
ParticipantManagement::StateInformation si;
si.stateTime(esTime);
si.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill);
dp.participantId(m_participants[m_DynamicParticipantIndex].participantId);
dp.stateHistory().push_back(si);
dp.sampleTime(esTime);
m_DynamicParticipantIndex++;
DEBUG_LOG(m_logger) << "Publishing DynamicParticipantData";
if (!m_ppmDts->publish(dp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsOwnership::tryCreateParticipantPosition
///
void CesTestsOwnership::tryCreateParticipantPosition()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
QPointF posF = m_housePos.geographic(m_participants[m_participantIndex].relX,
m_participants[m_participantIndex].relY);
const Core::GeoPosition pos(Core::GeoPosition(posF.x(), posF.y(), 0));
pp.buildingId(m_participants[m_participantIndex].buildingId);
pp.participantId(m_participants[m_participantIndex].participantId);
pp.partyId(m_participants[m_participantIndex].partyId);
pp.roomId(m_participants[m_participantIndex].roomId);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsOwnership::tryCreateParticipant
///
void CesTestsOwnership::tryCreateParticipant()
{
ParticipantManagement::Participant pt;
pt.id(m_participants[m_participantIndex].participantId);
pt.equipmentNumber(m_participants[m_participantIndex].equipmentNumber);
DEBUG_LOG(m_logger) << "Publishing Participant";
if (!m_ppmDts->publish(pt))
{
ERROR_LOG(m_logger) << "Error requesting create Participant";
failExit();
}
}
void CesTestsOwnership::trySetOwnershipRequest()
{
int32_t partyId = 0;
DEBUG_LOG(m_logger) << " request.buildingId() = " << m_buildingId
<< " request.partyId() = " << m_buildingId;
if (!m_cesFtc->setOwnershipRequest(SetOwnershipRequest(m_buildingId, partyId), this))
{
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
}
void CesTestsOwnership::onSetOwnershipReply(const Core::FunctionReplyObject &replyObject)
{
INFO_LOG(m_logger) << "onSetOwnershipReply() replyObject.id=" << replyObject.id();
}
void CesTestsOwnership::checkBuildingOwnership()
{
INFO_LOG(m_logger) << "checkBuildingOwnership";
/*
m_cesDtc->waitForHistoricalDataBuildingOwnership();
QMap < int ,CentralEffectSimulation::BuildingOwnership> buildingOwnership = m_cesDtc->buildingOwnerships();
INFO_LOG(m_logger) << "Recived ParicipantEvent BuildingOwnership:"<<buildingOwnership.buildingId();
for (unsigned int i = 0; i < buildingOwnership.ownerships().size(); i++)
{
CentralEffectSimulation::Ownership ownership = buildingOwnership.ownerships().at(i);
INFO_LOG(m_logger) << "ownership["<<i<<"].floorId="<< ownership.floorId()
<< " ownership["<<i<<"].partyId="<< ownership.partyId();
}
switch (m_testId)
{
case 1:
{
if ( buildingOwnership.ownerships().size() == 1
&& buildingOwnership.ownerships().at(0).floorId() == 57
&& buildingOwnership.ownerships().at(0).partyId() == 2)
{
ExitSuccess();
}
break;
}
case 2:
{
if ( buildingOwnership.ownerships().size() == 1
&& buildingOwnership.ownerships().at(0).floorId() == 24
&& buildingOwnership.ownerships().at(0).partyId() == 2)
{
ExitSuccess();
}
break;
}
case 3:
{
if ( buildingOwnership.ownerships().size() == 1
&& buildingOwnership.ownerships().at(0).floorId() == 24
&& buildingOwnership.ownerships().at(0).partyId() == 3)
{
ExitSuccess();
}
break;
}
case 4:
{
if ( buildingOwnership.ownerships().size() == 2
&& buildingOwnership.ownerships().at(0).floorId() == 57
&& buildingOwnership.ownerships().at(0).partyId() == 2
&& buildingOwnership.ownerships().at(1).floorId() == 24
&& buildingOwnership.ownerships().at(1).partyId() == 3)
{
ExitSuccess();
}
break;
}
case 5:
{
if ( buildingOwnership.ownerships().size() == 3
&& buildingOwnership.ownerships().at(0).floorId() == 57
&& buildingOwnership.ownerships().at(0).partyId() == 0
&& buildingOwnership.ownerships().at(1).floorId() == 24
&& buildingOwnership.ownerships().at(1).partyId() == 0
&& buildingOwnership.ownerships().at(2).floorId() == 89
&& buildingOwnership.ownerships().at(2).partyId() == 0)
{
ExitSuccess();
}
break;
}
} // end switch
*/
ExitSuccess();
}
void CesTestsOwnership::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void CesTestsOwnership::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::CesTestsOwnership> cesTests(new CentralEffectSimulation::CesTestsOwnership);
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;
}
@@ -0,0 +1,92 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ParticipantManagement/ppm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace CentralEffectSimulation
{
class CesTestsOwnership : public QObject
, protected CentralEffectSimulation::Interface::Ftc::SetOwnershipReplyHandler
{
Q_OBJECT
public:
explicit CesTestsOwnership(QObject *parent = nullptr);
~CesTestsOwnership();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
protected Q_SLOTS:
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPosition();
void tryCreateParticipant();
void tryCreateDynamicParticipantData();
void trySetOwnershipRequest();
void failExit();
void ExitSuccess();
protected:
void onSetOwnershipReply(const Core::FunctionReplyObject &replyObject) override final;
private: // methods
void checkParicipantEvent();
private: // structs
struct Participant
{
int participantId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
void checkBuildingOwnership();
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_participantIndex;
int m_DynamicParticipantIndex;
QVector<Participant> m_participants;
int m_buildingId;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,308 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_simulated_movement.h"
#include "CentralEffectSimulation/ces_dtc.h"
#include "CentralEffectSimulation/ces_ftc.h"
#include <TrainingAreaBase/tab_fts.h>
#include <nglapplication/nglcoreapplication.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QTimer>
#include <QDateTime>
#include <QPolygonF>
#include <QTest>
/* ----------------------------------------------------------------------------------
* HOW TO RUN THE TESTS (example)
* ----------------------------------------------------------------------------------
* 0. Preconditions:
* make db
* Start services: (SV)
* ./svcCentralEffectSimulation -e 42 &
* ./cesTestsSimulatedMovement -t 1 -e 42 // Simulated Movement no Repeat
* ./cesTestsSimulatedMovement -t 2 -e 42 // Simulated Movement Repeat
*/
namespace CentralEffectSimulation
{
cesTestsSimulatedMovement::cesTestsSimulatedMovement(QObject *parent)
: QObject(parent)
, m_bTestsSuccessful(true)
, m_participantId(20)
, m_repeat(false)
, m_housePos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("cesTestsSimulatedMovement"))
, m_testId(0)
{}
cesTestsSimulatedMovement::~cesTestsSimulatedMovement()
{}
bool cesTestsSimulatedMovement::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->enableParticipant();
m_cesFtc = CentralEffectSimulation::Interface::Ftc::create(m_ddsConnector42);
bRet &= m_cesFtc->enableAll();
return bRet;
}
void cesTestsSimulatedMovement::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 SMART
{
QTimer::singleShot(0, this, &cesTestsSimulatedMovement::tryCreateParticipant);
QTimer::singleShot(250, this, &cesTestsSimulatedMovement::trySimulatedMovementModifyRequest);
//QTimer::singleShot(500, this, &cesTestsSimulatedMovement::trySimulatedMovementModifyRequest);
//QTimer::singleShot(750, this, &cesTestsSimulatedMovement::trySimulatedMovementRemoveRequest);
//QTimer::singleShot(6000, this, &cesTestsSimulatedMovement::checkParticipantEvent);
}
else if (m_testId <= 2) // 1 SMART
{
m_repeat = true;
QTimer::singleShot(0, this, &cesTestsSimulatedMovement::tryCreateParticipant);
QTimer::singleShot(250, this, &cesTestsSimulatedMovement::trySimulatedMovementModifyRequest);
//QTimer::singleShot(500, this, &cesTestsSimulatedMovement::trySimulatedMovementModifyRequest);
//QTimer::singleShot(750, this, &cesTestsSimulatedMovement::trySimulatedMovementRemoveRequest);
//QTimer::singleShot(6000, this, &cesTestsSimulatedMovement::checkParticipantEvent);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(8000, this, &cesTestsSimulatedMovement::failExit);
}
void cesTestsSimulatedMovement::checkParticipantEvent()
{
INFO_LOG(m_logger) << "checkParticipantEvent";
m_cesDtc->waitForHistoricalDataParticipantEvent();
CentralEffectSimulation::ParticipantEvent participantEvent0 = m_cesDtc->participantEvent(0);
CentralEffectSimulation::ParticipantEvent participantEvent1 = m_cesDtc->participantEvent(1);
INFO_LOG(m_logger) << "Recived ParicipantEvent equipmentNumber:" << participantEvent0.equipmentNumber()
<< " eventType=" << participantEvent0.eventTypeId();
INFO_LOG(m_logger) << "Recived ParicipantEvent equipmentNumber:" << participantEvent1.equipmentNumber()
<< " eventType=" << participantEvent1.eventTypeId();
switch (m_testId)
{
case 1:
case 2:
if (participantEvent0.eventTypeId() == ProjectDataManagement::EventType::HitEffectSimulation
&& participantEvent1.eventTypeId() == ProjectDataManagement::EventType::HitEffectSimulation)
ExitSuccess();
break;
default:
// nothing
failExit();
break;
}
}
Core::FunctionReplyObject cesTestsSimulatedMovement::fillFro(int participantId, bool bSuccess) const
{
if (bSuccess)
return Core::FunctionReplyObject(participantId);
return Core::FunctionReplyObject(participantId, tr_lts("dds", "Error sending telegram to tetra"));
}
void cesTestsSimulatedMovement::trySimulatedMovementModifyRequest()
{
int32_t id = 0; // create
std::string name = "Name";
bool jumpToStart = false;
bool repeat = m_repeat;
int nextPoint = -1;
rti::core::int64 startTime = QDateTime::currentMSecsSinceEpoch()+2000;
int32_t participantId = m_participantId++;
CentralEffectSimulation::SimulatedMovementSegment seg0;
QPointF posF0 = m_housePos.geographic(5, 5);
const Core::GeoPosition2D pos0(Core::GeoPosition2D(posF0.x(), posF0.y()));
QPointF posF1 = m_housePos.geographic(10, 10);
const Core::GeoPosition2D pos1(Core::GeoPosition2D(posF1.x(), posF1.y()));
QPointF posF2 = m_housePos.geographic(5, 5);
const Core::GeoPosition2D pos2(Core::GeoPosition2D(posF2.x(), posF2.y()));
seg0.delay(5);
seg0.name("seg0");
seg0.speed(1.1);
//m_speed += 1.0;
seg0.position(pos0);
CentralEffectSimulation::SimulatedMovementSegment seg1;
seg1.delay(5);
seg1.name("seg1");
seg1.speed(1.2);
//m_speed += 1.0;
seg1.position(pos1);
CentralEffectSimulation::SimulatedMovementSegment seg2;
seg2.delay(6);
seg2.name("seg2");
seg2.speed(1.3);
//m_speed += 1.0;
seg2.position(pos2);
std::vector<CentralEffectSimulation::SimulatedMovementSegment> segments;
segments.push_back(seg0);
segments.push_back(seg1);
//segments[2] = seg2;
SimulatedMovementModifyRequest req;
req.id(id);
req.name(name);
req.startTime(startTime);
req.participantId(participantId);
req.segments(segments);
req.repeat(repeat);
req.jumpToStart(jumpToStart);
req.nextPoint(nextPoint);
if (!m_cesFtc->simulatedMovementModifyRequest(req, this))
{
ERROR_LOG(m_logger) << "Error requesting create data";
failExit();
}
QTest::qWait(2000);
}
void cesTestsSimulatedMovement::trySimulatedMovementRemoveRequest()
{
int32_t id = 1; // remove
if (!m_cesFtc->simulatedMovementRemoveRequest(SimulatedMovementRemoveRequest(id), this))
{
ERROR_LOG(m_logger) << "Error requesting remove data";
failExit();
}
QTest::qWait(2000);
}
// /////////////////////////////////////////////////////
/// \brief cesTestsSimulatedMovement::tryCreateParticipant
///
void cesTestsSimulatedMovement::tryCreateParticipant()
{
ParticipantManagement::Participant pt;
pt.id(m_participantId);
pt.partyId(5);
DEBUG_LOG(m_logger) << "Publishing Participant";
if (!m_ppmDts->publish(pt))
{
ERROR_LOG(m_logger) << "Error requesting create Participant";
failExit();
}
QTest::qWait(2000);
}
void cesTestsSimulatedMovement::onSimulatedMovementModifyReply(const Core::FunctionReplyObject &replyObject)
{
Q_UNUSED(replyObject);
INFO_LOG(m_logger) << "onSimulatedMovementModifyReply()";
}
void cesTestsSimulatedMovement::onSimulatedMovementRemoveReply(const Core::FunctionReplyObject &replyObject)
{
Q_UNUSED(replyObject);
INFO_LOG(m_logger) << "onSimulatedMovementRemoveReply()";
}
void cesTestsSimulatedMovement::failExit()
{
ERROR_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void cesTestsSimulatedMovement::ExitSuccess()
{
INFO_LOG(m_logger) << "ExitSuccess";
m_bTestsSuccessful = true;
QTimer::singleShot(200, 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::cesTestsSimulatedMovement> cesTests(new CentralEffectSimulation::cesTestsSimulatedMovement);
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;
}
@@ -0,0 +1,79 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ParticipantManagement/ppm_dts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
namespace CentralEffectSimulation
{
class cesTestsSimulatedMovement : public QObject
, protected CentralEffectSimulation::Interface::Ftc::SimulatedMovementModifyReplyHandler
, protected CentralEffectSimulation::Interface::Ftc::SimulatedMovementRemoveReplyHandler
{
Q_OBJECT
public:
explicit cesTestsSimulatedMovement(QObject *parent = nullptr);
~cesTestsSimulatedMovement();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
protected Q_SLOTS:
void trySimulatedMovementModifyRequest();
void trySimulatedMovementRemoveRequest();
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipant();
void failExit();
void ExitSuccess();
protected:
private: // methods
void checkParticipantEvent();
void onSimulatedMovementModifyReply(const Core::FunctionReplyObject &replyObject) override final;
void onSimulatedMovementRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
private:
Core::FunctionReplyObject fillFro(int participantId, bool bSuccess) const;
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
bool m_bTestsSuccessful;
int m_participantId;
bool m_repeat;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,523 @@
/**
* Msg Function Topic Module Test
* $Id$
* $HeadURL$
* $Author$
*/
#include "ces_tests_smart.h"
#include "CentralEffectSimulation/ces_dtc.h"
#include "CentralEffectSimulation/ces_ftc.h"
#include <TrainingAreaBase/tab_fts.h>
#include <nglapplication/nglcoreapplication.h>
#include <LtsCommandLineParser/LtsCommandLineParser.h>
#include <QTimer>
#include <QDateTime>
#include <QPolygonF>
#include <QDateTime>
/* ----------------------------------------------------------------------------------
* HOW TO RUN THE TESTS (example)
* ----------------------------------------------------------------------------------
* 0. Preconditions:
* make db
* Start services: (SV)
* ./svcCentralEffectSimulation -e 42 &
* ./cesTestsSmart -t 1 -e 42 // Smart Single Explosion
*/
namespace CentralEffectSimulation
{
CesTestsSmart::CesTestsSmart(QObject *parent)
: QObject(parent)
, TrainingAreaBase::Interface::Fts::SendCesHitRequestHandler(nullptr)
, m_bTestsSuccessful(true)
, m_housePos(LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32UMD8000090000")))
, m_logger(getLogger("CesTestsSmart"))
, m_testId(0)
, m_participantIndex(0)
, m_DynamicParticipantIndex(0)
, m_originatorParticipantId(30)
, m_aesItemId(5)
, m_buildingId(0)
, m_roomId(0)
, m_chargeTypeId(374) // SMART
{}
CesTestsSmart::~CesTestsSmart()
{}
bool CesTestsSmart::init(int domainId, int exerciseId, int testId)
{
bool bRet = true;
int equipmentTypeIdVehicle = 35;
int equipmentTypeIdSoldier = 30; // dds-Topic Participant-Management::Type
INFO_LOG(m_logger) << "init begin";
m_testId = testId;
m_buildingId = 0; // ism_main_structure_element:id
m_ddsConnector42 = std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId);
m_ddsConnector42->init();
m_ddsConnector42->initPublisherSubscriber();
m_pdmDts = ProjectDataManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_pdmDts->enableChargeType();
m_ppmDts = ParticipantManagement::Interface::Dts::create(m_ddsConnector42);
bRet &= m_ppmDts->enableParticipantPosition();
bRet &= m_ppmDts->enableParticipant();
bRet &= m_ppmDts->enableDynamicParticipantData();
bRet &= m_ppmDts->enableType();
m_aesDts = AreaEffectSimulation::Interface::Dts::create(m_ddsConnector42);
bRet &= m_aesDts->enableExplosionSingle();
bRet &= m_aesDts->enableAesItemView();
bRet &= m_aesDts->enableTriggeredImpacts();
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_tabFts = TrainingAreaBase::Interface::Fts::create(m_ddsConnector42);
m_tabFts->enableAll();
m_participants.resize(6);
m_participants[0].participantId = 20;
m_participants[0].participantTypeId = equipmentTypeIdVehicle;
m_participants[0].equipmentNumber = 60;
m_participants[0].relX = -10;
m_participants[0].relY = -10;
m_participants[0].partyId = 2;
m_participants[0].buildingId = m_buildingId;
m_participants[0].roomId = m_roomId;
m_participants[1].participantId = 21;
m_participants[1].participantTypeId = equipmentTypeIdVehicle;
m_participants[1].equipmentNumber = 61;
m_participants[1].relX = 10;
m_participants[1].relY = 10;
m_participants[1].partyId = 2;
m_participants[1].buildingId = m_buildingId;
m_participants[1].roomId = m_roomId;
m_participants[2].participantId = 22;
m_participants[2].participantTypeId = equipmentTypeIdSoldier;
m_participants[2].equipmentNumber = 62;
m_participants[2].relX = -10;
m_participants[2].relY = -30;
m_participants[2].partyId = 3;
m_participants[2].buildingId = m_buildingId;
m_participants[2].roomId = m_roomId;
m_participants[3].participantId = 23;
m_participants[3].participantTypeId = equipmentTypeIdSoldier;
m_participants[3].equipmentNumber = 63;
m_participants[3].relX = -10;
m_participants[3].relY = -1;
m_participants[3].partyId = 3;
m_participants[3].buildingId = m_buildingId;
m_participants[3].roomId = m_roomId;
m_participants[4].participantId = 24;
m_participants[4].participantTypeId = equipmentTypeIdVehicle;
m_participants[4].equipmentNumber = 64;
m_participants[4].relX = 10;
m_participants[4].relY = 30;
m_participants[4].partyId = 2;
m_participants[4].buildingId = m_buildingId;
m_participants[4].roomId = m_roomId;
m_participants[5].participantId = 25;
m_participants[5].participantTypeId = equipmentTypeIdVehicle;
m_participants[5].equipmentNumber = 65;
m_participants[5].relX = 1;
m_participants[5].relY = 3;
m_participants[5].partyId = 2;
m_participants[5].buildingId = m_buildingId;
m_participants[5].roomId = m_roomId;
return bRet;
}
void CesTestsSmart::startTest()
{
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
if (m_testId <= 1) // 1 SMART
{
m_explosionSingle = m_housePos.geographic(5, 5);
QTimer::singleShot(0, this, &CesTestsSmart::tryCreateParticipant);
QTimer::singleShot(250, this, &CesTestsSmart::tryCreateParticipantPosition);
QTimer::singleShot(500, this, &CesTestsSmart::tryCreateParticipantPosition);
QTimer::singleShot(1000, this, &CesTestsSmart::tryCreateParticipantPosition);
QTimer::singleShot(1500, this, &CesTestsSmart::tryCreateParticipantPosition);
QTimer::singleShot(2000, this, &CesTestsSmart::tryCreateParticipantPosition);
QTimer::singleShot(2500, this, &CesTestsSmart::tryCreateParticipantPosition);
QTimer::singleShot(3000, this, &CesTestsSmart::tryCreateTypeVehicle);
QTimer::singleShot(3500, this, &CesTestsSmart::tryCreateTypeSoldier);
QTimer::singleShot(4000, this, &CesTestsSmart::tryCreateChargeType);
QTimer::singleShot(4500, this, &CesTestsSmart::tryCreateAesItemViewSingleExplosion);
QTimer::singleShot(5000, this, &CesTestsSmart::tryCreatePrepareExplosionSingle);
QTimer::singleShot(5500, this, &CesTestsSmart::tryCreateExplosionSingle);
QTimer::singleShot(6000, this, &CesTestsSmart::checkParticipantEvent);
}
else
{
ERROR_LOG(m_logger) << "Unknown test id = " << m_testId;
failExit();
}
QTimer::singleShot(8000, this, &CesTestsSmart::failExit);
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateDynamicParticipantData
///
void CesTestsSmart::tryCreateDynamicParticipantData()
{
ParticipantManagement::DynamicParticipantData dp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
ParticipantManagement::StateInformation si;
si.stateTime(esTime);
si.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CatastrophicKill);
dp.participantId(m_participants[m_DynamicParticipantIndex].participantId);
dp.stateHistory().push_back(si);
dp.sampleTime(esTime);
m_DynamicParticipantIndex++;
DEBUG_LOG(m_logger) << "Publishing DynamicParticipantData";
if (!m_ppmDts->publish(dp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipantPosition
///
void CesTestsSmart::tryCreateParticipantPosition()
{
ParticipantManagement::ParticipantPosition pp;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 posTime = static_cast<rti::core::int64>(time);
QPointF posF = m_housePos.geographic(m_participants[m_participantIndex].relX,
m_participants[m_participantIndex].relY);
const Core::GeoPosition pos(Core::GeoPosition(posF.x(), posF.y(), 0));
pp.buildingId(m_participants[m_participantIndex].buildingId);
pp.participantId(m_participants[m_participantIndex].participantId);
pp.participantTypeId(m_participants[m_participantIndex].participantTypeId);
pp.partyId(m_participants[m_participantIndex].partyId);
pp.roomId(m_participants[m_participantIndex].roomId);
m_participantIndex++;
pp.sampleTime(posTime);
pp.pos(pos);
DEBUG_LOG(m_logger) << "Publishing ParticipantPosition";
if (!m_ppmDts->publish(pp))
{
ERROR_LOG(m_logger) << "Error requesting create ParticipantPosition";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateParticipant
///
void CesTestsSmart::tryCreateParticipant()
{
ParticipantManagement::Participant pt;
pt.id(21);
pt.equipmentNumber(61);
DEBUG_LOG(m_logger) << "Publishing Participant";
if (!m_ppmDts->publish(pt))
{
ERROR_LOG(m_logger) << "Error requesting create Participant";
failExit();
}
}
void CesTestsSmart::checkParticipantEvent()
{
INFO_LOG(m_logger) << "checkParicipantEvent m_cesDtc->participantEvents().size() =" << m_cesDtc->participantEvents().size();
m_cesDtc->waitForHistoricalDataParticipantEvent();
CentralEffectSimulation::ParticipantEvent participantEvent0 = m_cesDtc->participantEvent(0);
CentralEffectSimulation::ParticipantEvent participantEvent1 = m_cesDtc->participantEvent(1);
for ( int i = 0; i < m_cesDtc->participantEvents().size(); i++)
{
CentralEffectSimulation::ParticipantEvent participantEvent = m_cesDtc->participantEvent(i);
INFO_LOG(m_logger) << "Recived ParicipantEvent equipmentNumber:"<<participantEvent.equipmentNumber()
<< " eventType="<<participantEvent.eventTypeId();
}
switch (m_testId)
{
case 1:
if ( participantEvent0.eventTypeId()==ProjectDataManagement::EventType::HitEffectSimulation
&& participantEvent1.eventTypeId()==ProjectDataManagement::EventType::HitEffectSimulation)
{
ExitSuccess();
}
break;
default:
// nothing
ERROR_LOG(m_logger) << "Error checkParticipantEvent";
failExit();
break;
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateTypeVehicle
///
void CesTestsSmart::tryCreateTypeVehicle()
{
ParticipantManagement::Type ty;
ty.id(35);
ty.typeClass(ParticipantManagement::TypeClass::inner_enum::GroundVehicle);
ty.equipmentTypeId(35);
ty.symbol("1001");
ty.name("HMMWV Utility");
DEBUG_LOG(m_logger) << "Publishing Type";
if (!m_ppmDts->publish(ty))
{
ERROR_LOG(m_logger) << "Error requesting create Type";
failExit();
}
}
// /////////////////////////////////////////////////////
/// \brief CesTestsSmart::tryCreateType
///
void CesTestsSmart::tryCreateTypeSoldier()
{
ParticipantManagement::Type ty;
ty.id(11);
ty.typeClass(ParticipantManagement::TypeClass::inner_enum::Human);
ty.equipmentTypeId(30);
ty.symbol("1001");
ty.name("Soldier");
DEBUG_LOG(m_logger) << "Publishing Type";
if (!m_ppmDts->publish(ty))
{
ERROR_LOG(m_logger) << "Error requesting create Type";
failExit();
}
}
static void setPos(std::vector<Core::GeoPosition> &cont, const QPointF &pos)
{
cont.emplace_back(Core::GeoPosition(pos.x(), pos.y(), 0.0));
}
void CesTestsSmart::tryCreateAesItemViewSingleExplosion()
{
INFO_LOG(m_logger) << "trying to send AesItemView AtExplosionAreaSingleExplosions";
AreaEffectSimulation::AesItemView iv;
iv.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
iv.aesItemId(m_aesItemId);
iv.id(m_aesItemId);
iv.aesTypeId(AreaEffectSimulation::AesType::AtExplosionAreaSingleExplosions);
iv.partyId(5);
QPointF bl = m_housePos.geographic(-10, -10);
QPointF tr = m_housePos.geographic(30, 30);
iv.boundingBoxBottomLeft(Core::GeoPosition2D(bl.x(), bl.y()));
iv.boundingBoxTopRight(Core::GeoPosition2D(tr.x(), tr.y()));
iv.chargeStruct().chargeTypeId(m_chargeTypeId);
iv.sampleTime(QDateTime::currentMSecsSinceEpoch());
iv.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
setPos(iv.form(), m_housePos.geographic(-10, -10));
setPos(iv.form(), m_housePos.geographic(0, 0));
setPos(iv.form(), m_housePos.geographic(5, 5));
setPos(iv.form(), m_housePos.geographic(-10, 10));
setPos(iv.form(), m_housePos.geographic(-10, 20));
setPos(iv.form(), m_housePos.geographic(-10, 30));
DEBUG_LOG(m_logger) << "Publishing AesItemView";
if (!m_aesDts->publish(iv))
{
ERROR_LOG(m_logger) << "Error requesting create AesItemViewSingleExplosions";
failExit();
}
}
void CesTestsSmart::tryCreateChargeType()
{
DEBUG_LOG(m_logger) << "Publishing ChargeType";
ProjectDataManagement::ChargeType ct;
ct.id(m_chargeTypeId);
ct.properties("{\"impactRadius\":25,\"impactEdgeLength\":50,\"isSmart\":true,\"searchRadius\":150}");
if (!m_pdmDts->publish(ct))
{
ERROR_LOG(m_logger) << "Error publish ChargeType";
failExit();
}
}
void CesTestsSmart::tryCreatePrepareExplosionSingle()
{
INFO_LOG(m_logger) << "trying to send ExplosionSingle";
AreaEffectSimulation::ExplosionSingle es;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
es.id(m_aesItemId);
es.participantId(m_originatorParticipantId); // In ddsview <not set>
es.effectStateId(AreaEffectSimulation::AesEffectState_def::EsPrepared);
es.name("Smart tryCreatePrepareExplosionSingle");
es.impactPosition(Core::GeoPosition2D(m_explosionSingle.x(), m_explosionSingle.y()));
es.sampleTime(esTime);
es.chargeStruct().chargeTypeId(m_chargeTypeId);
es.isCentral(true);
es.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
DEBUG_LOG(m_logger) << "Publishing ExplosionSingle";
if (!m_aesDts->publish(es))
{
ERROR_LOG(m_logger) << "Error publish ExplosionArea";
failExit();
}
}
void CesTestsSmart::tryCreateExplosionSingle()
{
INFO_LOG(m_logger) << "trying to send ExplosionSingle";
AreaEffectSimulation::ExplosionSingle es;
const qint64 time = QDateTime::currentMSecsSinceEpoch();
const rti::core::int64 esTime = static_cast<rti::core::int64>(time);
es.id(m_aesItemId);
es.name("Smart tryCreateExplosionSingle");
es.participantId(m_originatorParticipantId); // In ddsview <not set>
es.effectStateId(AreaEffectSimulation::AesEffectState_def::EsActivated);
es.effectStart ( QDateTime::currentMSecsSinceEpoch() + 2000);
es.isCentral(true);
es.impactPosition(Core::GeoPosition2D(m_explosionSingle.x(), m_explosionSingle.y()));
es.sampleTime(esTime);
es.chargeStruct().chargeTypeId(m_chargeTypeId);
DEBUG_LOG(m_logger) << "Publishing ExplosionSingle";
if (!m_aesDts->publish(es))
{
ERROR_LOG(m_logger) << "Error publish ExplosionArea";
failExit();
}
}
Core::FunctionReplyObject CesTestsSmart::fillFro(int participantId, bool bSuccess) const
{
if (bSuccess)
return Core::FunctionReplyObject(participantId);
return Core::FunctionReplyObject(participantId, tr_lts("dds", "Error sending telegram to tetra"));
}
void CesTestsSmart::onSendCesHitRequest(const rti::core::SampleIdentity &cookie,
const TrainingAreaBase::SendCesHitRequest &request)
{
// debug und co
qint64 msecs = (qint64) request.effectTime();
QDateTime dateTime;
dateTime.setMSecsSinceEpoch(msecs);
DEBUG_LOG(m_logger) << "onSendCesHitRequest" << "\n"
<< " request.aesId() = " << request.aesId() << "\n"
<< " request.chargeTypeId() = " << request.chargeTypeId() << "\n"
<< " request.equipmentNumber() = " << request.equipmentNumber() << "\n"
<< " request.originatorEquipmentNumber() = " << request.originatorEquipmentNumber() << "\n"
<< " request.originatorPosition() = " << request.position() << "\n"
<< " request.effectTime()= " << request.effectTime() << " "
<< dateTime.toString(QStringLiteral("dd.MM.yy - hh:mm:ss.zzz")) << "\n"
<< " request.remainEffectPercent() = " << request.remainEffectPercent();
m_tabFts->sendCesHitReply(cookie, Core::FunctionReplyObject(request.equipmentNumber()));
ExitSuccess();
}
void CesTestsSmart::failExit()
{
DEBUG_LOG(m_logger) << "FailExit";
m_bTestsSuccessful = false;
QTimer::singleShot(50, qApp, QCoreApplication::quit);
}
void CesTestsSmart::ExitSuccess()
{
DEBUG_LOG(m_logger) << "ExitSuccess";
m_bTestsSuccessful = true;
QTimer::singleShot(200, 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::CesTestsSmart> cesTests(new CentralEffectSimulation::CesTestsSmart);
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;
}
@@ -0,0 +1,113 @@
/**
* ModuleTests for Msg
* $Id$
* $HeadURL$
* $Author$
*/
#pragma once
#include <AreaEffectSimulation/aes_dts.h>
#include <CentralEffectSimulation/ces_dtc.h>
#include <CentralEffectSimulation/ces_ftc.h>
#include <CentralEffectSimulation/ces_ftc_types.h>
#include <CentralEffectSimulation/logger.h>
#include <ProjectDataManagement/pdm_dts.h>
#include <ParticipantManagement/ppm_dts.h>
#include <TrainingAreaBase/tab_fts.h>
#include <DDS/DDSConnector/dds_connector.h>
#include <LtsCoordTrans/lts_coord_trans.h>
#include <QPointF>
namespace CentralEffectSimulation
{
class CesTestsSmart : public QObject
, protected TrainingAreaBase::Interface::Fts::SendCesHitRequestHandler
{
Q_OBJECT
public:
explicit CesTestsSmart(QObject *parent = nullptr);
~CesTestsSmart();
bool init(int domainId, int exerciseId, int testId);
bool testsSuccessful() const
{
return m_bTestsSuccessful;
}
public Q_SLOTS:
void startTest();
protected Q_SLOTS:
// ////////////////////////
// Participants
// ////////////////////////
void tryCreateParticipantPosition();
void tryCreateParticipant();
void tryCreateDynamicParticipantData();
void tryCreateTypeVehicle();
void tryCreateTypeSoldier();
void tryCreateAesItemViewSingleExplosion();
void tryCreateChargeType();
void tryCreatePrepareExplosionSingle();
void tryCreateExplosionSingle();
void failExit();
void ExitSuccess();
protected:
private: // methods
void checkParticipantEvent();
void onSendCesHitRequest(const rti::core::SampleIdentity &cookie,
const TrainingAreaBase::SendCesHitRequest &request) override;
private: // structs
struct Participant
{
int participantId;
int participantTypeId;
int equipmentNumber;
int partyId;
int buildingId;
int roomId;
int relX;
int relY;
};
private:
Core::FunctionReplyObject fillFro(int participantId, bool bSuccess) const;
private:
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector42;
std::shared_ptr<AreaEffectSimulation::Interface::Dts> m_aesDts;
std::shared_ptr<ProjectDataManagement::Interface::Dts> m_pdmDts;
std::shared_ptr<ParticipantManagement::Interface::Dts> m_ppmDts;
std::shared_ptr<CentralEffectSimulation::Interface::Dtc> m_cesDtc;
std::shared_ptr<CentralEffectSimulation::Interface::Ftc> m_cesFtc;
std::shared_ptr<TrainingAreaBase::Interface::Fts> m_tabFts;
bool m_bTestsSuccessful;
LtsCoordTrans::UtmCoordinate m_housePos;
NGL::INGLLogger &m_logger;
int m_testId;
int m_participantIndex;
int m_DynamicParticipantIndex;
int m_originatorParticipantId;
int m_aesItemId;
QVector<Participant> m_participants;
int m_buildingId;
int m_roomId;
AreaEffectSimulation::AesType m_aesType;
QPointF m_explosionSingle;
int m_chargeTypeId;
};
} // namespace CentralEffectSimulation
@@ -0,0 +1,2 @@
// Fire_Report: TimerTick=58908 AmmuniationType=4 Azimut=79,7 Elevation=67,1 Temperatur=25 RoundsAmm1=0 RoundsAmm2=7
E3 01 1C E6 04 9F 02 00 00 1D 03 00 00 19 00 00 00 07