Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+173
@@ -0,0 +1,173 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
INCLUDE(MacroRTIDDSGen)
|
||||
INCLUDE(MacroCodeGenIdl)
|
||||
|
||||
SET(xml_FILE tgt_service.xml)
|
||||
|
||||
#
|
||||
# --- Library svcTgtCommon --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_common
|
||||
tgt_export.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
# Generate tgt_enums.idl / tgt.idl
|
||||
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
|
||||
# Generate tgt_db_impl.cpp/.h, tgt_db.h
|
||||
CODEGEN_DATABASE(SRCS_common ${xml_FILE})
|
||||
|
||||
# Generate *.cpp/*.hpp from idl
|
||||
RTIDDSGEN(SRCS_common tgt_enums.idl)
|
||||
RTIDDSGEN(SRCS_common tgt.idl)
|
||||
|
||||
# Generate tgt_dt[s,c]_types.h, tgt_ft[s,c]_types.h
|
||||
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
|
||||
# Generate tgt_[d|f]tc.h
|
||||
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcTgtCommon SHARED ${SRCS_common})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcTgtCommon
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
NGL_TARGET_LINK_LIBRARIES(svcTgtCommon
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
ddscore
|
||||
NGLLogger
|
||||
ngldb
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcTgtCommon)
|
||||
|
||||
#
|
||||
# --- Library svcTgtClient --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_client
|
||||
tgt_export.h
|
||||
)
|
||||
# generate tgt_[d|f]tc.h, tgt_[d|f]tc_impl.[cpp|h]
|
||||
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcTgtClient SHARED ${SRCS_client})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcTgtClient
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcTgtClient
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
PUBLIC
|
||||
svcTgtCommon
|
||||
ddsftc
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcTgtClient)
|
||||
|
||||
#
|
||||
# --- Library svcTgtServer --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_server
|
||||
tgt_export.h
|
||||
)
|
||||
|
||||
# generate tgt_[d|f]ts.h, tgt_[d|f]ts_impl.[cpp|h]
|
||||
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV svcTgtServer SHARED ${SRCS_server})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcTgtServer
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcTgtServer
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
ddsfts
|
||||
ngldb
|
||||
PUBLIC
|
||||
svcTgtCommon
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcTgtServer)
|
||||
|
||||
#
|
||||
# --- Topic Type Plugin --------------------------------------------------------------
|
||||
#
|
||||
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
|
||||
|
||||
#
|
||||
# --- Executable svcTargetManagement (sTGT) -------------------------------------------------
|
||||
#
|
||||
SET(SRCS_exe
|
||||
main.cpp
|
||||
main_handler.cpp
|
||||
main_handler.h
|
||||
dds_handler.cpp
|
||||
dds_handler.h
|
||||
handler_target_config.cpp
|
||||
handler_target_config.h
|
||||
handler_shootback_area.cpp
|
||||
handler_shootback_area.h
|
||||
handler_shootback_target.cpp
|
||||
handler_shootback_target.h
|
||||
handler_target_area_assignment.cpp
|
||||
handler_target_area_assignment.h
|
||||
object_shootback_area.cpp
|
||||
object_shootback_area.h
|
||||
object_shootback_target.cpp
|
||||
object_shootback_target.h
|
||||
object_target_area_assignment.cpp
|
||||
object_target_area_assignment.h
|
||||
shootback_controller.cpp
|
||||
shootback_controller.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
${xml_FILE}
|
||||
)
|
||||
|
||||
# Generate tgt.sql, tgt.xml
|
||||
CODEGEN_SQL(SRCS_exe ${xml_FILE})
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV svcTargetManagement ${SRCS_exe})
|
||||
NGL_TARGET_LINK_LIBRARIES(svcTargetManagement
|
||||
Qt5::Core
|
||||
ddsconnector
|
||||
ddsQoS
|
||||
svcTgtCommon
|
||||
svcTgtServer
|
||||
svcTabClient
|
||||
svcPpmClient
|
||||
situationMapElevationMap
|
||||
ddsconnector
|
||||
nglsettings
|
||||
ProjectConfig
|
||||
LtsCommandLineParser
|
||||
LtsUtilsCore
|
||||
LtsCoordTrans
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
svcCoreClient
|
||||
ngltools
|
||||
ngldb
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcTargetManagement)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_tgt.props DESTINATION bin)
|
||||
NGL_ADD_TARGET_LINK(svcTargetManagement sTGT)
|
||||
|
||||
# Uncomment if necessary
|
||||
ADD_SUBDIRECTORY(UnitTests)
|
||||
ADD_SUBDIRECTORY(ModuleTests)
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
IF(TARGET svcTgtClient AND TARGET svcTgtServer)
|
||||
|
||||
####################################
|
||||
# Target Test
|
||||
####################################
|
||||
|
||||
SET(SRCS_TEST_TGT
|
||||
tgt_tests.cpp
|
||||
)
|
||||
SET(HDRS_TEST_TGT
|
||||
tgt_tests.h
|
||||
)
|
||||
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(tgtTests
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
# Testing FunctionTopic Functionality (FTC)
|
||||
ADD_EXECUTABLE(tgtTests ${SRCS_TEST_TGT} ${HDRS_TEST_TGT})
|
||||
TARGET_LINK_LIBRARIES(tgtTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcTgtClient
|
||||
svcCoreClient
|
||||
svcEemServer
|
||||
svcPpmServer
|
||||
svcTabServer
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS tgtTests DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
+415
@@ -0,0 +1,415 @@
|
||||
/**
|
||||
* Msg Function Topic Module Test
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "tgt_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
#include <QDateTime>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonDocument>
|
||||
/* ----------------------------------------------------------------------------------
|
||||
* Ablauf:
|
||||
* ----------------------------------------------------------------------------------
|
||||
* Anzeigen der Konfiguration am Arbeitsplatz
|
||||
- Teilnehmerfenster eines Targets enthält Bedienfeld zum Konfigurieren der Targets
|
||||
- Bei der Anwahl des Fensters wird die aktuelle Konfiguration vom Target abgefragt.
|
||||
- Das Bedienfenster sendet den Request configureTargetRequest
|
||||
- Der Service TargetManager empfaengt den Request und sendet ans TAB SendTargetDataRequest.
|
||||
- TAB sendet den Response an das Target Management.
|
||||
- TAB sendet die Konfigurationsdaten an das TargetManagement. (TAB::TargetData)
|
||||
- Das TargetManagement sendet sie an das Plugin weiter. (TGT::TargetConfig)
|
||||
- Das Plugin zeigt die Konfiguration an und gibt nun die Auswahl von Waffe und Mode frei
|
||||
- Fuer den Mode und die Waffe werden je ein Request vom Plugin an das TargetManagement geschickt.
|
||||
- Das TargetManagement leitet es an TAB weiter.
|
||||
|
||||
- TAB leitet es weiter und im Gutfall kommt die Antwort vom Target TrainingAreaBase::TargetData
|
||||
- Der Service Target Management empfaengt es und sendet an den Arbeitsplatz den Data-Topic
|
||||
TargetManagement::Target Config
|
||||
- Der Arbeitsplatz zeigt die Konfiguration an.
|
||||
|
||||
*
|
||||
*/
|
||||
/* ----------------------------------------------------------------------------------
|
||||
* HOW TO RUN THE TESTS
|
||||
* ----------------------------------------------------------------------------------
|
||||
*
|
||||
* Preconditions: Nothing
|
||||
*
|
||||
* Start services: (SV)
|
||||
* ./svcTargetManagement -e 42
|
||||
* ./tgtTests -t 1 -e 42 // Configure Target RequestTechnicalState
|
||||
* ./tgtTests -t 2 -e 42 -o 14 // Add ShootbackArea
|
||||
* ./tgtTests -t 3 -e 42 -s 1 -o 14 // Update ShootbackArea with id 1
|
||||
* ./tgtTests -t 4 -e 42 -s 1 -o 14 // Remove ShootbackArea with id 1
|
||||
*/
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
namespace TargetManagement
|
||||
{
|
||||
TgtTests::TgtTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_logger(getLogger("TgtTests"))
|
||||
{}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
bool TgtTests::init(int domainId, int testId, int operatorId, int shootbackAreaId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init begin";
|
||||
|
||||
m_testId = testId;
|
||||
m_operatorId = operatorId;
|
||||
m_participantIndex = 0;
|
||||
m_shootbackAreaId = shootbackAreaId;
|
||||
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Any));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
m_ftcTgt = TargetManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
bool bRet = m_ftcTgt->enableAll();
|
||||
|
||||
m_dtcTgt = TargetManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_dtcTgt->enableAll();
|
||||
|
||||
m_dtsPpm = ParticipantManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsPpm->enableAll();
|
||||
|
||||
m_dtsTab = TrainingAreaBase::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsTab->enableAll();
|
||||
|
||||
return bRet;
|
||||
} // init
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest m_testId=" << m_testId;
|
||||
if (m_testId == 1) // Send FTC ConfigureAlarms and EEM Event
|
||||
{
|
||||
QTimer::singleShot(0, this, &TgtTests::tryCreateParticipant);
|
||||
QTimer::singleShot(100, this, &TgtTests::tryRequestTechnicalState);
|
||||
QTimer::singleShot(200, this, &TgtTests::tryConfigureTargetMode);
|
||||
QTimer::singleShot(400, this, &TgtTests::tryConfigureTargetWeapon);
|
||||
|
||||
QTimer::singleShot(600, this, &TgtTests::tryCreateTargetData);
|
||||
QTimer::singleShot(800, this, &TgtTests::checkAlarm);
|
||||
}
|
||||
else if (m_testId == 2) // Create ShootbackArea
|
||||
{
|
||||
QTimer::singleShot(0, this, &TgtTests::tryCreateShootbackArea);
|
||||
}
|
||||
else if (m_testId == 3) // Update ShootbackArea
|
||||
{
|
||||
QTimer::singleShot(0, this, &TgtTests::tryUpdateShootbackArea);
|
||||
}
|
||||
else if (m_testId == 4) // Remove ShootbackArea
|
||||
{
|
||||
QTimer::singleShot(0, this, &TgtTests::tryRemoveShootbackArea);
|
||||
}
|
||||
QTimer::singleShot(5000, this, &TgtTests::failExit);
|
||||
} // startTest
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryCreateShootbackArea()
|
||||
{
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(0); // force create
|
||||
request.name("Test ShootbackArea");
|
||||
double lon = 0.15530364;
|
||||
double lat = 0.92601523;
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
request.width(100);
|
||||
request.height(100);
|
||||
|
||||
if (!m_ftcTgt->shootbackAreaModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create Shootback Area";
|
||||
failExit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryUpdateShootbackArea()
|
||||
{
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(m_shootbackAreaId); // update specific id
|
||||
request.name("Test ShootbackArea Updated");
|
||||
|
||||
if (!m_ftcTgt->shootbackAreaModifyRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting modify Shootback Area";
|
||||
failExit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryRemoveShootbackArea()
|
||||
{
|
||||
ShootbackAreaRemoveRequest request;
|
||||
|
||||
request.id(m_shootbackAreaId); // remove specific id
|
||||
|
||||
if (!m_ftcTgt->shootbackAreaRemoveRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting remove Shootback Area";
|
||||
failExit();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryRequestTechnicalState()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send createRequest Operator Message";
|
||||
|
||||
ConfigureTargetRequest request;
|
||||
|
||||
request.id(0);
|
||||
request.participantId(5);
|
||||
request.tgtCommand(TargetManagement::TgtCommand_def::RequestTechnicalState);
|
||||
|
||||
if (!m_ftcTgt->configureTargetRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
} // tryRequestTechnicalState
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryConfigureTargetMode()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send createRequest Operator Message";
|
||||
|
||||
ConfigureTargetRequest request;
|
||||
|
||||
request.id(0);
|
||||
request.participantId(5);
|
||||
TargetManagement::Mode mode = TargetManagement::Mode_def::ShootBack;
|
||||
request.tgtCommand(TargetManagement::TgtCommand_def::SetMode);
|
||||
request.mode(mode);
|
||||
|
||||
|
||||
if (!m_ftcTgt->configureTargetRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
} // tryConfigureTargetMode
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryConfigureTargetWeapon()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send createRequest Operator Message";
|
||||
|
||||
ConfigureTargetRequest request;
|
||||
|
||||
request.id(0);
|
||||
request.participantId(5);
|
||||
request.tgtCommand(TargetManagement::TgtCommand_def::SetWeapon);
|
||||
request.weapon(1); // AK47
|
||||
|
||||
if (!m_ftcTgt->configureTargetRequest(request, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting create data";
|
||||
failExit();
|
||||
}
|
||||
} // tryConfigureTargetWeapon
|
||||
|
||||
|
||||
// Response from Target
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryCreateTargetData()
|
||||
{
|
||||
TrainingAreaBase::TargetData targetData;
|
||||
|
||||
targetData.equipmentNumber(1001);
|
||||
|
||||
// Shoot Back - AK 47
|
||||
targetData.payload() = {0x65, 0x01, 0x01, 0xae, 0xff, 0x00 };
|
||||
|
||||
if (!m_dtsTab->publish(targetData))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error publish targetData";
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::tryCreateParticipant()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to create Participant index = " << m_participantIndex;
|
||||
ParticipantManagement::Participant participant;
|
||||
participant.id(5);
|
||||
participant.superiorId(0);
|
||||
participant.inferiorIds().resize(2);
|
||||
participant.inferiorIds().at(0) = 2;
|
||||
participant.inferiorIds().at(1) = 3;
|
||||
participant.partyId(5);
|
||||
participant.equipmentNumber(1001);
|
||||
DEBUG_LOG(m_logger) << "Publishing Participant";
|
||||
if (!m_dtsPpm->publish(participant))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error publish Participant";
|
||||
failExit();
|
||||
}
|
||||
m_participantIndex++;
|
||||
} // tryCreateParticipant
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::onShootbackAreaModifyReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onShootbackAreaModifyReply on id " << replyObject.id()
|
||||
<< " and error = " << replyObject.error();
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShoobackAreaModifyReply - aborting";
|
||||
failExit();
|
||||
}
|
||||
|
||||
ExitSuccess();
|
||||
|
||||
} // onShoobackAreaModifyReply
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::onShootbackAreaRemoveReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onShootbackAreaModifyReply on id " << replyObject.id()
|
||||
<< " and error = " << replyObject.error();
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting";
|
||||
failExit();
|
||||
}
|
||||
|
||||
ExitSuccess();
|
||||
} // onShootbackAreaRemoveReply
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::onConfigureTargetReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onConfigureTargetReply, error = " << replyObject.error();
|
||||
if (replyObject.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error ConfigureTargets - aborting";
|
||||
failExit();
|
||||
}
|
||||
} // onConfigureTargetReply
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::checkAlarm()
|
||||
{
|
||||
INFO_LOG(m_logger) << "checkAlarm";
|
||||
m_dtcTgt->waitForHistoricalDataTargetConfig();
|
||||
//qint32 id = 0;
|
||||
/*TargetManagement::Notification notification = m_dtcTgt->notification(id);
|
||||
INFO_LOG(m_logger) << "Recived TargetManagement::Notification: " << notification
|
||||
<< " testId: " << m_testId;
|
||||
|
||||
switch (m_testId)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
INFO_LOG(m_logger) << "ExitSuccess";
|
||||
ExitSuccess();
|
||||
break;
|
||||
default:
|
||||
// nothing
|
||||
INFO_LOG(m_logger) << "failExit";
|
||||
failExit();
|
||||
break;
|
||||
}*/
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
} // failExit
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
void TgtTests::ExitSuccess()
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "SUCCESS";
|
||||
m_bTestsSuccessful = true;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
} // ExitSuccess
|
||||
|
||||
} // namespace
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
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("o") << QLatin1String("operatorId")
|
||||
, QLatin1String("OperatorId")
|
||||
, QLatin1String("Default: 10")
|
||||
, QLatin1String("10")
|
||||
});
|
||||
addOption({ QStringList() << QLatin1String("s") << QLatin1String("shootbackAreaId")
|
||||
, QLatin1String("shootbackAreaId")
|
||||
, QLatin1String("Default: 0")
|
||||
, QLatin1String("0")
|
||||
});
|
||||
|
||||
}
|
||||
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : 0; }
|
||||
int operatorId() const { return isSet(QLatin1String("o")) ? value(QLatin1String("o")).toInt() : 10; }
|
||||
int shootbackAreaId() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : 0; }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("TGT", "log4cxx_tgt.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
int iRet = -1;
|
||||
{
|
||||
std::unique_ptr<TargetManagement::TgtTests> tgtTests(new TargetManagement::TgtTests);
|
||||
|
||||
if (!tgtTests->init(options.domainId(), options.testId(), options.operatorId(), options.shootbackAreaId()))
|
||||
return iRet;
|
||||
|
||||
tgtTests->startTest();
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = tgtTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
}
|
||||
|
||||
return iRet;
|
||||
} // main
|
||||
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* ModuleTests for Msg
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <TargetManagement/tgt_dtc.h>
|
||||
#include <TargetManagement/tgt_ftc.h>
|
||||
#include <TargetManagement/tgt_ftc_types.h>
|
||||
#include <TargetManagement/logger.h>
|
||||
#include <ExerciseEventManagement/eem_dts.h>
|
||||
#include <ParticipantManagement/ppm_dts.h>
|
||||
#include <Proxies/TrainingAreaBase/tab_dts.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class TgtTests : public QObject
|
||||
, protected TargetManagement::Interface::Ftc::ConfigureTargetReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackAreaModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackAreaRemoveReplyHandler
|
||||
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TgtTests(QObject *parent = nullptr);
|
||||
~TgtTests() = default;
|
||||
|
||||
bool init(int domainId, int testId, int operatorId, int shootbackAreaId);
|
||||
|
||||
bool testsSuccessful() const
|
||||
{
|
||||
return m_bTestsSuccessful;
|
||||
}
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void tryRequestTechnicalState();
|
||||
void tryConfigureTargetMode();
|
||||
void tryConfigureTargetWeapon();
|
||||
void tryCreateParticipant();
|
||||
void tryCreateTargetData();
|
||||
void tryCreateShootbackArea();
|
||||
void tryUpdateShootbackArea();
|
||||
void tryRemoveShootbackArea();
|
||||
void failExit();
|
||||
void ExitSuccess();
|
||||
|
||||
protected:
|
||||
void onConfigureTargetReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onShootbackAreaModifyReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void onShootbackAreaRemoveReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private:
|
||||
void checkAlarm();
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<TargetManagement::Interface::Ftc> m_ftcTgt;
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtcTgt;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dts> m_dtsPpm;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_dtsTab;
|
||||
|
||||
int m_testId{0};
|
||||
bool m_bTestsSuccessful{true};
|
||||
int m_operatorId{-1};
|
||||
int m_participantIndex{0};
|
||||
int m_shootbackAreaId{-1};
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace TargetManagement
|
||||
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
ADD_SUBDIRECTORY(UnitTestShootback)
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(LinkedSources
|
||||
log4cxxTgtUnitTestShootback.props
|
||||
)
|
||||
|
||||
SET(UnitTest_SRCS
|
||||
unit_test.cpp
|
||||
unit_test.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP( LinkedSources FILES ${LinkedSources} )
|
||||
SOURCE_GROUP( UnitTestSources FILES ${UnitTest_SRCS} )
|
||||
|
||||
IF(BUILD_TESTING
|
||||
AND TARGET svcTgtClient
|
||||
AND TARGET svcCoreClient
|
||||
AND TARGET svcEemServer
|
||||
AND TARGET svcPpmServer
|
||||
AND TARGET svcTabServer
|
||||
)
|
||||
ADD_EXECUTABLE(tgtUnitTestShootback ${LinkedSources} ${UnitTest_SRCS} )
|
||||
|
||||
TARGET_LINK_LIBRARIES(tgtUnitTestShootback
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
Qt5::Network
|
||||
RTI::nddscpp2
|
||||
|
||||
NGLLogger
|
||||
nglapplication
|
||||
|
||||
ddsconnector
|
||||
svcTgtClient
|
||||
svcCoreClient
|
||||
svcEemServer
|
||||
svcPpmServer
|
||||
svcTabServer
|
||||
LtsCommandLineParser
|
||||
)
|
||||
ADD_TEST(NAME tgtUnitTestShootback COMMAND $<TARGET_FILE:tgtUnitTestShootback>)
|
||||
|
||||
ENDIF()
|
||||
Executable
+82
@@ -0,0 +1,82 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file, stdout
|
||||
|
||||
# TGT
|
||||
###########################################################
|
||||
log4j.logger.TGT.UnitTestShootback=DEBUG
|
||||
|
||||
|
||||
|
||||
|
||||
# Appnd_File
|
||||
###########################################################
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.file=${LOG4QT_LOGDIR}/${LOG4QT_USER}_SituationMap.log
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %-5p %c{1} |#| %m (%-.30F:%L) %n
|
||||
|
||||
#log4j.appender.stdout.layout.ConversionPattern= %d %-5p %-30c |#| %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
|
||||
@@ -0,0 +1,949 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Unittest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "unit_test.h"
|
||||
|
||||
#include <TargetManagement/shootback_controller.h>
|
||||
|
||||
#include <QtTest/QTest>
|
||||
#include <QtTest/QSignalSpy>
|
||||
#include <QWeakPointer>
|
||||
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QFlags>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
const int g_targetParticipantId_1 = 5;
|
||||
const int g_targetParticipantId_2 = 6;
|
||||
|
||||
const int g_movingParticipantId_1 = 30;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication app(argc, argv);
|
||||
app.createLogger("TgtUnitTestShootback", "log4cxxTgtUnitTestShootback.props");
|
||||
|
||||
CmdLineParser options;
|
||||
|
||||
// C O M M E N T :
|
||||
// To use the domainId and exerciseId via CmdLineParser AND
|
||||
// support also parameter for QTest::qExec do not return
|
||||
// if options.init() fails...
|
||||
if(!options.init())
|
||||
{
|
||||
fprintf(stdout, "\n \e[33m usage: try -v2 testTargetAreaAssignment -d 111 -e 222 \e[0m");
|
||||
fprintf(stdout, "\n \e[33m -functions \e[0m \n\n");
|
||||
}
|
||||
|
||||
int domainId = options.value(QStringLiteral("d")).toInt();
|
||||
int exerciseId = options.value(QStringLiteral("e")).toInt();
|
||||
if (exerciseId<0)
|
||||
exerciseId = 42;
|
||||
|
||||
QSharedPointer<TargetManagement::tgtTestShootbackTarget> tc =
|
||||
QSharedPointer<TargetManagement::tgtTestShootbackTarget>(new TargetManagement::tgtTestShootbackTarget());
|
||||
|
||||
tc->setPara(domainId, exerciseId);
|
||||
|
||||
if (options.domainIdProvided())
|
||||
argc -= 2;
|
||||
if (options.exerciseIdProvided())
|
||||
argc -= 2;
|
||||
// : C O M M E N T
|
||||
|
||||
int retCode = QTest::qExec(tc.data(), argc, argv);
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
tgtTestShootbackTarget::tgtTestShootbackTarget()
|
||||
: m_logger(getLogger("UnitTestShootback"))
|
||||
{
|
||||
// register some datatypes QSignalSpy
|
||||
qRegisterMetaType<DataModification>("DataModification");
|
||||
qRegisterMetaType<TargetManagement::ShootbackArea>("TargetManagement::ShootbackArea");
|
||||
qRegisterMetaType<TargetManagement::ShootbackTarget>("TargetManagement::ShootbackTarget");
|
||||
qRegisterMetaType<TargetManagement::TargetAreaAssignment>("TargetManagement::TargetAreaAssignment");
|
||||
}
|
||||
|
||||
tgtTestShootbackTarget::~tgtTestShootbackTarget()
|
||||
{
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::initTestCase()
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " do testing with"
|
||||
<< " domainId=" << m_domainId
|
||||
<< " exerciseId=" << m_exerciseId;
|
||||
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(m_domainId, IDL::PartitionType::Exercise, m_exerciseId));
|
||||
if (!m_ddsConnector->init())
|
||||
return;
|
||||
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
m_ftcTgt = TargetManagement::Interface::Ftc::create(m_ddsConnector);
|
||||
bool bRet = m_ftcTgt->enableAll();
|
||||
|
||||
m_dtcTgt = TargetManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
bRet &= m_dtcTgt->enableAll();
|
||||
|
||||
m_dtsPpm = ParticipantManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsPpm->enableAll();
|
||||
|
||||
m_dtsTab = TrainingAreaBase::Interface::Dts::create(m_ddsConnector);
|
||||
bRet &= m_dtsTab->enableAll();
|
||||
|
||||
// time to process changed-signals:
|
||||
QTest::qWait(2000);
|
||||
|
||||
removeTestObjects();
|
||||
|
||||
if (!bRet)
|
||||
FATAL_LOG(m_logger) << LOGFUNCTION << " init failed!!!";
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::testShootbackArea()
|
||||
{
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(0); // force create
|
||||
request.name("UnitTest ShootbackArea");
|
||||
double lon = 0.15530364;
|
||||
double lat = 0.92601523;
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
request.width(100);
|
||||
request.height(100);
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackAreaModifyRequest failed");
|
||||
checkShootbackAreaChangedWasEmitted(1, __LINE__);
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackAreaId: " << m_replyShootbackAreaId;
|
||||
|
||||
|
||||
// modify
|
||||
request.id(m_replyShootbackAreaId);
|
||||
request.name("UnitTest ShootbackAreaModified");
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
checkShootbackAreaChangedWasEmitted(1, __LINE__);
|
||||
|
||||
// verify mod
|
||||
{
|
||||
TargetManagement::ShootbackArea modData = m_dtcTgt->shootbackArea(m_replyShootbackAreaId);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "modData=" << modData;
|
||||
QVERIFY2((modData.id() == m_replyShootbackAreaId), " shootbackArea failed");
|
||||
QVERIFY2((modData.name().compare(request.name()) == 0), " verify name failed");
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
{
|
||||
ShootbackAreaRemoveRequest request;
|
||||
request.id(m_replyShootbackAreaId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackAreaRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
checkShootbackAreaChangedWasEmitted(1, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testShootbackTarget()
|
||||
{
|
||||
ShootbackTargetModifyRequest request;
|
||||
|
||||
request.id(0); // force create
|
||||
// request.targetParticipantId(); // here would be the reference to the orbat
|
||||
request.name("UnitTest ShootbackTarget");
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackTargetModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackTargetId: " << m_replyShootbackTargetId;
|
||||
|
||||
|
||||
// modify
|
||||
request.id(m_replyShootbackTargetId);
|
||||
request.name("UnitTest ShootbackTargetModified");
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "spy.count()=" << spy.count();
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
|
||||
// verify mod
|
||||
{
|
||||
TargetManagement::ShootbackTarget modData = m_dtcTgt->shootbackTarget(m_replyShootbackTargetId);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "modData=" << modData;
|
||||
QVERIFY2((modData.id() == m_replyShootbackTargetId), " shootbackTarget failed");
|
||||
QVERIFY2((modData.name().compare(request.name()) == 0), " verify name failed");
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
{
|
||||
ShootbackTargetRemoveRequest request;
|
||||
request.id(m_replyShootbackTargetId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackTargetRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testTargetAreaAssignment()
|
||||
{
|
||||
TargetAreaAssignmentModifyRequest request;
|
||||
|
||||
// try to create
|
||||
request.id(0); // force create
|
||||
request.name("UnitTest TargetAreaAssignment");
|
||||
|
||||
// create
|
||||
{
|
||||
request.id(0); // force create
|
||||
request.name(QString(QStringLiteral("UnitTest-Assignment1")).toStdString());
|
||||
request.areaId(4711);
|
||||
request.targetParticipantId(4712);
|
||||
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "spy.count()=" << spy.count();
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
|
||||
m_assignmentId1 = m_replyTargetAreaAssignmentId;
|
||||
}
|
||||
|
||||
|
||||
// modify
|
||||
request.id(m_assignmentId1);
|
||||
request.name("UnitTest-Assignment1_Modified");
|
||||
{
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "spy.count()=" << spy.count();
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
|
||||
// verify mod
|
||||
{
|
||||
TargetManagement::TargetAreaAssignment modData = m_dtcTgt->targetAreaAssignment(m_replyTargetAreaAssignmentId);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << "modData=" << modData;
|
||||
QVERIFY2((modData.id() == m_replyTargetAreaAssignmentId), " targetAreaAssignment failed");
|
||||
QVERIFY2((modData.name().compare(request.name()) == 0), " verify name failed");
|
||||
}
|
||||
}
|
||||
|
||||
// remove
|
||||
{
|
||||
TargetAreaAssignmentRemoveRequest request;
|
||||
request.id(m_replyTargetAreaAssignmentId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::removeTestObjects()
|
||||
{
|
||||
// first, remove all TargetAreaAssignments:
|
||||
{
|
||||
QMap<qint32, TargetManagement::TargetAreaAssignment> allObj = m_dtcTgt->targetAreaAssignments();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove... (" << allObj.size() << " TargetAreaAssignments)";
|
||||
for (auto item: qAsConst(allObj))
|
||||
if (item.name().substr(0, 8).compare("UnitTest") == 0)
|
||||
removeAssignment(item.id());
|
||||
QTest::qWait(250); // time to process reply
|
||||
allObj = m_dtcTgt->targetAreaAssignments();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove targetAreaAssignments finished -> " << allObj.size() << " TargetAreaAssignments";
|
||||
}
|
||||
|
||||
// remove all Areas:
|
||||
{
|
||||
QMap<qint32, TargetManagement::ShootbackArea> allObj = m_dtcTgt->shootbackAreas();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove... (" << allObj.size() << " Areas)";
|
||||
for (auto item: qAsConst(allObj))
|
||||
if (item.name().substr(0, 8).compare("UnitTest") == 0)
|
||||
removeArea(item.id());
|
||||
QTest::qWait(250); // time to process reply
|
||||
allObj = m_dtcTgt->shootbackAreas();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove shootbackAreas finished -> " << allObj.size() << " Areas";
|
||||
}
|
||||
|
||||
// remove all Targets:
|
||||
{
|
||||
QMap<qint32, TargetManagement::ShootbackTarget> allObj = m_dtcTgt->shootbackTargets();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove... (" << allObj.size() << " Targets)";
|
||||
for (auto item: qAsConst(allObj))
|
||||
if (item.name().substr(0, 8).compare("UnitTest") == 0)
|
||||
removeTarget(item.id());
|
||||
QTest::qWait(250); // time to process reply
|
||||
|
||||
allObj = m_dtcTgt->shootbackTargets();
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " remove shootbackTargets finished -> " << allObj.size() << " Targets";
|
||||
}
|
||||
QTest::qWait(1000); // time to process
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::createArea(int &areaIdInOut, const QString &name, double lon, double lat)
|
||||
{
|
||||
m_replyShootbackAreaId = -1;
|
||||
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(areaIdInOut);
|
||||
request.name(name.toStdString());
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
request.width(100);
|
||||
request.height(100);
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
|
||||
qCritical() << "shootbackAreaModifyRequest ret= " << ret;
|
||||
|
||||
QVERIFY2((ret != 0), " shootbackAreaModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackAreaChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackAreaId: " << m_replyShootbackAreaId;
|
||||
|
||||
areaIdInOut = m_replyShootbackAreaId;
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::modifyArea(int &areaId, const QString &name, double lon, double lat)
|
||||
{
|
||||
ShootbackAreaModifyRequest request;
|
||||
|
||||
request.id(areaId);
|
||||
request.name(name.toStdString());
|
||||
request.position().lon(lon);
|
||||
request.position().lat(lat);
|
||||
|
||||
// create/modify
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackAreaModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackAreaModifyRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::removeArea(int areaId, bool checkUsingSpy)
|
||||
{
|
||||
ShootbackAreaRemoveRequest request;
|
||||
request.id(areaId);
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackAreaRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
if (checkUsingSpy)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackAreaChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::createTarget(int &targetIdOut, int targetParticipantId, const QString &name)
|
||||
{
|
||||
ShootbackTargetModifyRequest request;
|
||||
|
||||
request.id(targetIdOut); // force create !?
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
request.name(name.toStdString());
|
||||
request.position(Core::GeoPosition(0.149276, 0.92622, 50.0)); // 0.149276, 0.92622 -> 32u MD 70000 80000 -> 31m
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackTargetModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " got m_replyShootbackTargetId: " << m_replyShootbackTargetId;
|
||||
|
||||
targetIdOut = m_replyShootbackTargetId;
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::modifyTarget(int targetId, int targetParticipantId, const QString &name, double lon, double lat, double z)
|
||||
{
|
||||
ShootbackTargetModifyRequest request;
|
||||
|
||||
request.id(targetId);
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
request.name(name.toStdString());
|
||||
request.position(Core::GeoPosition(lon, lat, z)); // 0.149276, 0.92622 -> 32u MD 70000 80000 -> 31m
|
||||
|
||||
// modify
|
||||
{
|
||||
int32_t ret = m_ftcTgt->shootbackTargetModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " shootbackTargetModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::removeTarget(int targetId, bool checkUsingSpy)
|
||||
{
|
||||
ShootbackTargetRemoveRequest request;
|
||||
request.id(targetId); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->shootbackTargetRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
if (checkUsingSpy)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::createAssignment(int areaId, int targetParticipantId, int &assignmentIdOut, const QString &name)
|
||||
{
|
||||
TargetAreaAssignmentModifyRequest request;
|
||||
|
||||
request.id(assignmentIdOut); // force create !?
|
||||
request.name(name.toStdString());
|
||||
request.areaId(areaId);
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
|
||||
// create
|
||||
{
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " targetAreaAssignmentModifyRequest failed");
|
||||
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
|
||||
// time to process reply
|
||||
QTest::qWait(100);
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " got m_replyTargetAreaAssignmentId: " << m_replyTargetAreaAssignmentId;
|
||||
|
||||
assignmentIdOut = m_replyTargetAreaAssignmentId;
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::modifyAssignment(int areaId, int targetParticipantId, int &assignmentId, const QString &name)
|
||||
{
|
||||
TargetAreaAssignmentModifyRequest request;
|
||||
|
||||
request.id(assignmentId);
|
||||
request.name(name.toStdString());
|
||||
request.areaId(areaId);
|
||||
request.targetParticipantId(targetParticipantId);
|
||||
|
||||
// modify
|
||||
{
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentModifyRequest(request, this);
|
||||
QVERIFY2((ret != 0), " targetAreaAssignmentModifyRequest failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::removeAssignment(int id, bool checkUsingSpy)
|
||||
{
|
||||
TargetAreaAssignmentRemoveRequest request;
|
||||
request.id(id); // remove specific id
|
||||
|
||||
int32_t ret = m_ftcTgt->targetAreaAssignmentRemoveRequest(request, this);
|
||||
QVERIFY2((ret != 0), " request failed");
|
||||
|
||||
if (checkUsingSpy)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(2000);
|
||||
QVERIFY2((spy.count() == 1), " spy failed");
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<int32_t> tgtTestShootbackTarget::visiParticpantsOfTarget(int targetId)
|
||||
{
|
||||
TargetManagement::ShootbackTarget sbTarget = m_dtcTgt->shootbackTarget(targetId);
|
||||
return sbTarget.visibleParticipants();
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::moveParticipant(int participantId, double lon, double lat)
|
||||
{
|
||||
if (!m_dtsPpm)
|
||||
return;
|
||||
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " move Participant: id = " << participantId;
|
||||
ParticipantManagement::ParticipantPosition posReq;
|
||||
posReq.participantId(participantId);
|
||||
posReq.sampleTime(currentSampleTime());
|
||||
posReq.pos(Core::GeoPosition(lon, lat, 50.12345));
|
||||
posReq.partyId(2); // 0 and 1 will be skipped
|
||||
if (!m_dtsPpm->publish(posReq))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " Error publish posReq";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::checkShootbackAreaChangedWasEmitted(int number, int line)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackAreaChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(1000);
|
||||
QString msg = QString(QStringLiteral("Area-Spy failed: %1 of %2 (line=%3)")).arg(spy.count()).arg(number).arg(line);
|
||||
QVERIFY2((spy.count() == number), msg.toStdString().c_str());
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::checkShootbackTargetChangedWasEmitted(int number, int line)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::shootbackTargetChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(1000);
|
||||
QString msg = QString(QStringLiteral("Target-Spy failed: %1 of %2 (line=%3)")).arg(spy.count()).arg(number).arg(line);
|
||||
QVERIFY2((spy.count() == number), msg.toStdString().c_str());
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::checkAssignmentChangedWasEmitted(int number, int line)
|
||||
{
|
||||
QSignalSpy spy(m_dtcTgt.get(), &TargetManagement::Interface::Dtc::targetAreaAssignmentChanged);
|
||||
if (spy.count() == 0)
|
||||
spy.wait(1000);
|
||||
QString msg = QString(QStringLiteral("Assignment-Spy failed: %1 of %2 (line=%3)")).arg(spy.count()).arg(number).arg(line);
|
||||
QVERIFY2((spy.count() == number), msg.toStdString().c_str());
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::prepareDefaultSituation()
|
||||
{
|
||||
const int timeToProcess = 100;
|
||||
removeTestObjects();
|
||||
|
||||
// move outside:
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.922); // g_movingParticipantId_1 -> 30
|
||||
|
||||
// some areas
|
||||
m_areaId1 = 0;
|
||||
createArea(m_areaId1, QStringLiteral("UnitTest-Area1"), 0.155, 0.926);
|
||||
QVERIFY2((m_areaId1 > 0), " createArea failed");
|
||||
|
||||
m_areaId2 = 0;
|
||||
createArea(m_areaId2, QStringLiteral("UnitTest-Area2"), 0.155, 0.930);
|
||||
QVERIFY2((m_areaId2 > 0), " createArea failed");
|
||||
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
|
||||
// some targets
|
||||
m_targetDataId1 = 0;
|
||||
createTarget(m_targetDataId1, g_targetParticipantId_1, QStringLiteral("UnitTest-TargetDataId1_Part=5"));
|
||||
QVERIFY2((m_targetDataId1 > 0), " createTarget failed");
|
||||
|
||||
m_targetDataId2 = 0;
|
||||
createTarget(m_targetDataId2, g_targetParticipantId_2, QStringLiteral("UnitTest-TargetDataId2_Part=6"));
|
||||
QVERIFY2((m_targetDataId2 > 0), " createTarget failed");
|
||||
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
|
||||
// some assignments
|
||||
m_assignmentId1 = 0;
|
||||
createAssignment(m_areaId1, g_targetParticipantId_1, m_assignmentId1, QStringLiteral("UnitTest-Assignment1"));
|
||||
QVERIFY2((m_assignmentId1 > 0), " createAssignment failed");
|
||||
|
||||
// move Player, still outside
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.925);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(timeToProcess); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
|
||||
NOTICE_LOG(m_logger) << " -------------- DefaultSituation established --------------";
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testPlayerMoves()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// no enter
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.925);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// leave 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.927);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// enter 2
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.93);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed"); // targetId2 has no assignment -> 0
|
||||
}
|
||||
|
||||
// leave 2
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.94);
|
||||
checkShootbackTargetChangedWasEmitted(0, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testPlayerMovesLos()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
|
||||
|
||||
// move assigned target 1 slightly:
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " move target1 ...";
|
||||
modifyTarget(m_targetDataId1, g_targetParticipantId_1, QStringLiteral("UnitTest-TargetDataId1_Moved"), 0.149, 0.926, 55.0);
|
||||
|
||||
QTest::qWait(250); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// move (z) assigned target 1 to interrupt line of sight:
|
||||
{
|
||||
NOTICE_LOG(m_logger) << LOGFUNCTION << " move target1 ...";
|
||||
modifyTarget(m_targetDataId1, g_targetParticipantId_1, QStringLiteral("UnitTest-TargetDataId1_Moved"), 0.152, 0.926, 2.0);
|
||||
|
||||
QTest::qWait(250); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testPlayerRemove()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// remove ParticipantPOSTION
|
||||
m_dtsPpm->removeParticipantPositionByKey(g_movingParticipantId_1);
|
||||
{
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAreaChanges()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// move participant in the near of the target to ensure lineOfSight
|
||||
// target1: Pos 0.149276, 0.9262
|
||||
|
||||
moveParticipant(g_movingParticipantId_1, 0.149, 0.926);
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
|
||||
// move to area 1 (assigned to target1) over p1
|
||||
modifyArea(m_areaId1, QStringLiteral("UnitTest-Area1_Mod-AreaChanges"), 0.149, 0.926);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAreaRemove()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
removeArea(m_areaId1, false);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAssignmentRemove()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
removeAssignment(m_assignmentId1, false);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::testAssignmentChanges()
|
||||
{
|
||||
prepareDefaultSituation();
|
||||
|
||||
// enter 1
|
||||
{
|
||||
moveParticipant(g_movingParticipantId_1, 0.155, 0.926001);
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 1), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
// switch assignment: area1 -> area2
|
||||
modifyAssignment(m_areaId2, m_targetDataId1, m_assignmentId1, QStringLiteral("UnitTest-Assignment1_Mod"));
|
||||
|
||||
checkShootbackTargetChangedWasEmitted(1, __LINE__);
|
||||
|
||||
QTest::qWait(1000); // time to process
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId1).size() == 0), " visiParticpantsOfTarget failed");
|
||||
QVERIFY2((visiParticpantsOfTarget(m_targetDataId2).size() == 0), " visiParticpantsOfTarget failed");
|
||||
}
|
||||
|
||||
|
||||
void tgtTestShootbackTarget::cleanupTestCase()
|
||||
{
|
||||
// called one time at the end
|
||||
QTest::qWait(1000); // time to process
|
||||
removeTestObjects();
|
||||
QTest::qWait(1000); // time to process
|
||||
}
|
||||
|
||||
//
|
||||
// DdsSlots:
|
||||
//
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Area
|
||||
void tgtTestShootbackTarget::onShootbackAreaModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackAreaId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'";
|
||||
m_replyShootbackAreaId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::onShootbackAreaRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackAreaId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'"
|
||||
<< ", id="<< reply.id();
|
||||
m_replyShootbackAreaId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Target
|
||||
void tgtTestShootbackTarget::onShootbackTargetModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackTargetId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'";
|
||||
m_replyShootbackTargetId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::onShootbackTargetRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyShootbackTargetId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'"
|
||||
<< ", id="<< reply.id();
|
||||
m_replyShootbackTargetId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// TargetAreaAssignment
|
||||
void tgtTestShootbackTarget::onTargetAreaAssignmentModifyReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyTargetAreaAssignmentId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'";
|
||||
m_replyTargetAreaAssignmentId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void tgtTestShootbackTarget::onTargetAreaAssignmentRemoveReply(const Core::FunctionReplyObject &reply)
|
||||
{
|
||||
m_replyTargetAreaAssignmentId = reply.id();
|
||||
if (reply.error())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error onShootbackAreaRemoveReply - aborting: '" << reply.str() << "'"
|
||||
<< ", id="<< reply.id();
|
||||
m_replyTargetAreaAssignmentId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
qint64 tgtTestShootbackTarget::currentSampleTime()
|
||||
{
|
||||
return QDateTime::currentDateTimeUtc().toMSecsSinceEpoch();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Unittest
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <TargetManagement/tgt_dtc.h>
|
||||
#include <TargetManagement/tgt_ftc.h>
|
||||
#include <TargetManagement/tgt_ftc_types.h>
|
||||
#include <TargetManagement/logger.h>
|
||||
#include <ExerciseEventManagement/eem_dts.h>
|
||||
#include <ParticipantManagement/ppm_dts.h>
|
||||
#include <Proxies/TrainingAreaBase/tab_dts.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class tgtTestShootbackTarget : public QObject
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackAreaModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackAreaRemoveReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackTargetModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::ShootbackTargetRemoveReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::TargetAreaAssignmentModifyReplyHandler
|
||||
, protected TargetManagement::Interface::Ftc::TargetAreaAssignmentRemoveReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tgtTestShootbackTarget();
|
||||
virtual ~tgtTestShootbackTarget();
|
||||
|
||||
void setPara(int domainId, int exerciseId)
|
||||
{
|
||||
m_domainId = domainId;
|
||||
m_exerciseId = exerciseId;
|
||||
}
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase(); // one time at the beginning
|
||||
|
||||
// basics
|
||||
void testShootbackArea();
|
||||
void testShootbackTarget();
|
||||
void testTargetAreaAssignment();
|
||||
|
||||
// based on defaultSituation:
|
||||
void testPlayerMoves();
|
||||
void testPlayerMovesLos();
|
||||
|
||||
|
||||
void testPlayerRemove();
|
||||
|
||||
void testAreaChanges();
|
||||
void testAreaRemove();
|
||||
|
||||
void testAssignmentRemove();
|
||||
void testAssignmentChanges();
|
||||
|
||||
void cleanupTestCase(); // one time at the end
|
||||
|
||||
protected:
|
||||
void onShootbackAreaModifyReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onShootbackAreaRemoveReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
void onShootbackTargetModifyReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onShootbackTargetRemoveReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
void onTargetAreaAssignmentModifyReply(const Core::FunctionReplyObject &reply) override final;
|
||||
void onTargetAreaAssignmentRemoveReply(const Core::FunctionReplyObject &reply) override final;
|
||||
|
||||
private:
|
||||
qint64 currentSampleTime();
|
||||
void checkShootbackAreaChangedWasEmitted(int number, int line);
|
||||
void checkShootbackTargetChangedWasEmitted(int number, int line);
|
||||
void checkAssignmentChangedWasEmitted(int number, int line);
|
||||
void removeTestObjects();
|
||||
|
||||
void createArea(int &areaIdInOut, const QString &name, double lon, double lat);
|
||||
void modifyArea(int &areaId, const QString &name, double lon, double lat);
|
||||
void removeArea(int areaId, bool checkUsingSpy = true);
|
||||
|
||||
void createTarget(int &targetIdOut, int targetParticipantId, const QString &name);
|
||||
void modifyTarget(int targetId, int targetParticipantId, const QString &name, double lon, double lat, double z);
|
||||
void removeTarget(int targetId, bool checkUsingSpy = true);
|
||||
std::vector<int32_t> visiParticpantsOfTarget(int targetId);
|
||||
|
||||
void createAssignment(int areaId, int targetParticipantId, int &assignmentIdOut, const QString &name);
|
||||
void modifyAssignment(int areaId, int targetParticipantId, int &assignmentId, const QString &name);
|
||||
void removeAssignment(int id, bool checkUsingSpy = true);
|
||||
|
||||
void moveParticipant(int participantId, double lon, double lat);
|
||||
|
||||
void prepareDefaultSituation();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<TargetManagement::Interface::Ftc> m_ftcTgt;
|
||||
std::shared_ptr<TargetManagement::Interface::Dtc> m_dtcTgt;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dts> m_dtsPpm;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_dtsTab;
|
||||
|
||||
int m_domainId = -1;
|
||||
int m_exerciseId = -1;
|
||||
|
||||
int m_areaId1 = -1;
|
||||
int m_areaId2 = -1;
|
||||
int m_targetDataId1 = -1;
|
||||
int m_targetDataId2 = -1;
|
||||
int m_assignmentId1 = -1;
|
||||
|
||||
int m_replyShootbackAreaId = -1;
|
||||
int m_replyShootbackTargetId = -1;
|
||||
int m_replyTargetAreaAssignmentId = -1;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
} // namespace
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#include "dds_handler.h"
|
||||
|
||||
#include <DDS/DTS/generic_dts_impl.h>
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
DdsHandler::DdsHandler(int domainId, int exerciseId)
|
||||
: m_ddsConnector(std::make_shared<DDSConnector::DdsConnector>(domainId, IDL::PartitionType::Exercise, exerciseId))
|
||||
, m_logger(getLogger("DdsHandler"))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "DdsHandler(" << m_ddsConnector->getDomainId() << ") for partition: " << m_ddsConnector->getDefaultPartition();
|
||||
}
|
||||
|
||||
bool DdsHandler::init(const QStringList &qosFileList)
|
||||
{
|
||||
if (!m_ddsConnector->init(qosFileList))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error initializing dds connections - aborting";
|
||||
return false;
|
||||
}
|
||||
|
||||
// default initialize Publisher and Subscriber
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
m_ddsConnector->enableBatchedWriter(false);
|
||||
|
||||
// Pacemaker
|
||||
m_pacemaker = std::make_shared<Core::Pacemaker>(m_ddsConnector);
|
||||
m_topicLockMaster = std::make_shared<Core::TopicLockMaster>(m_ddsConnector);
|
||||
|
||||
// DTC Core (to get partitionTime)
|
||||
m_dtcCore = Core::Interface::Dtc::create(m_ddsConnector);
|
||||
m_dtcCore->enablePartitionTime();
|
||||
|
||||
// DTS Target
|
||||
m_dtsTgt = TargetManagement::Interface::Dts::create(m_ddsConnector);
|
||||
bool bRet = m_dtsTgt->enableAll();
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
// FTS Target
|
||||
m_ftsTgt = TargetManagement::Interface::Fts::create(m_ddsConnector);
|
||||
bRet &= m_ftsTgt->enableAll();
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
// DTC TrainingAreaBase
|
||||
m_dtcTab = TrainingAreaBase::Interface::Dtc::create(m_ddsConnector);
|
||||
if (!m_dtcTab->enableTargetData())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable receive TAB";
|
||||
return false;
|
||||
}
|
||||
|
||||
// FTC TrainingAreaBase
|
||||
m_ftcTab = TrainingAreaBase::Interface::Ftc::create(m_ddsConnector);
|
||||
if (!m_ftcTab->enableSendTargetData())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not enable Send TAB";
|
||||
return false;
|
||||
}
|
||||
|
||||
// Participant Management
|
||||
|
||||
m_dtcPpm = ParticipantManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
if (!(m_dtcPpm->enableParticipant() &&
|
||||
m_dtcPpm->enableParticipantPosition() &&
|
||||
m_dtcPpm->enableType() &&
|
||||
m_dtcPpm->enableEquipmentType()
|
||||
))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not initialize ParticipantManagement enableXXX data topic client";
|
||||
return false;
|
||||
}
|
||||
// Get 'static' data for all participants (playerdata)
|
||||
// Player in Referenzmap eintragen
|
||||
{
|
||||
auto cb = [this](const ParticipantManagement::Participant & participant)
|
||||
{
|
||||
if (participant.equipmentNumber().is_set())
|
||||
{
|
||||
m_partId2EquipNoMap.insert(participant.id(), participant.equipmentNumber().get());
|
||||
m_equipNo2partIdMap.insert(participant.equipmentNumber().get(), participant.id());
|
||||
}
|
||||
else
|
||||
m_partId2EquipNoMap.insert(participant.id(), 0);
|
||||
};
|
||||
m_dtcPpm->participants(cb);
|
||||
}
|
||||
|
||||
connect(m_dtcPpm.get(), &ParticipantManagement::Interface::Dtc::participantChanged,
|
||||
this, &DdsHandler::onParticipantChanged);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
int DdsHandler::participantId2EquipNo(const int participantId) const
|
||||
{
|
||||
int ret = m_partId2EquipNoMap.value(participantId, 0);
|
||||
INFO_LOG(m_logger) << "participantId2EquipNo participantId=" << participantId
|
||||
<< " EquipmentNumber=" << ret;
|
||||
return ret;
|
||||
} // end of participantId2EquipNo()
|
||||
|
||||
int DdsHandler::equipNo2participantId(const int equipmentNumber) const
|
||||
{
|
||||
int ret = m_equipNo2partIdMap.value(equipmentNumber, 0);
|
||||
INFO_LOG(m_logger) << "EquipNo2participantId equipmentNumber=" << equipmentNumber
|
||||
<< " ParticipantId=" << ret;
|
||||
return ret;
|
||||
} // end of EquipNo2participantId()
|
||||
|
||||
// ///////////////////////////////////
|
||||
// P P M (ParticipantManagement)
|
||||
// ///////////////////////////////////
|
||||
void DdsHandler::onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "onParticipantChanged";
|
||||
if (modType == DataModification::eRemoved)
|
||||
m_partId2EquipNoMap.remove(data.id());
|
||||
else
|
||||
{
|
||||
m_partId2EquipNoMap[data.id()] = data.equipmentNumber().is_set() ? data.equipmentNumber().get() : 0;
|
||||
if (data.equipmentNumber().is_set())
|
||||
m_equipNo2partIdMap.insert(data.equipmentNumber().get(), data.id());
|
||||
}
|
||||
|
||||
if (m_logger.isTraceEnabled())
|
||||
{
|
||||
for (auto i = m_partId2EquipNoMap.begin(); i != m_partId2EquipNoMap.end(); ++i)
|
||||
{
|
||||
TRACE_LOG(m_logger) << " partId2EquipNoMap.size(): " << m_partId2EquipNoMap.size()
|
||||
<< " partId: " << i.key()
|
||||
<< " eqNo: " << i.value();
|
||||
}
|
||||
}
|
||||
} // end of onParticipantChanged()
|
||||
} // Namespace PDM
|
||||
Executable
+84
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/core_dtc.h>
|
||||
#include <DDS/Core/topic_lock_master.h>
|
||||
#include <DDS/Core/core_dts_types.h>
|
||||
|
||||
#include <TargetManagement/tgt_dts.h>
|
||||
#include <TargetManagement/tgt_fts.h>
|
||||
#include <Proxies/TrainingAreaBase/tab_dtc.h>
|
||||
#include <Proxies/TrainingAreaBase/tab_ftc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <ParticipantManagement/ppm_ftc.h>
|
||||
#include <ParticipantManagement/ppm_ftc_types.h>
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class Pacemaker;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class DdsHandler final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DdsHandler(int domainId, int exerciseId);
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList());
|
||||
|
||||
std::shared_ptr<Core::Pacemaker> pacemaker() const { return m_pacemaker; }
|
||||
std::shared_ptr<Core::TopicLockMaster> topicLockMaster() const { return m_topicLockMaster; }
|
||||
std::shared_ptr<DDSConnector::DdsConnector> dds() const { return m_ddsConnector; }
|
||||
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dtc> dtcTab() const { return m_dtcTab;}
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Ftc> ftcTab() const { return m_ftcTab;}
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> dtcPpm() const {return m_dtcPpm;} ///< Pointer to DTC ParticipantManagement interface object
|
||||
std::shared_ptr<TargetManagement::Interface::Fts> ftsTgt() const { return m_ftsTgt;}
|
||||
std::shared_ptr<TargetManagement::Interface::Dts> dtsTgt() const { return m_dtsTgt;}
|
||||
|
||||
/**
|
||||
* Get equipment number for the given participant
|
||||
* @param participantId participant id to get the equipment number for
|
||||
* @return equipment number or 0 in case of failure
|
||||
*/
|
||||
int participantId2EquipNo(const int participantId) const;
|
||||
int equipNo2participantId(const int equipmentNumber) const;
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
/**
|
||||
* Handle the signals from 'ParticipantManagement'
|
||||
*/
|
||||
void onParticipantChanged(const ParticipantManagement::Participant &data, DataModification modType);
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Interface::Dtc> m_dtcCore;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
|
||||
std::shared_ptr<TargetManagement::Interface::Dts> m_dtsTgt;
|
||||
std::shared_ptr<TargetManagement::Interface::Fts> m_ftsTgt;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dtc> m_dtcTab;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Ftc> m_ftcTab;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_dtcPpm; ///< Pointer to DTC ParticipantManagement interface object
|
||||
|
||||
QMap<int, int> m_partId2EquipNoMap; ///< Reference map participant (player) to equipment number
|
||||
QMap<int, int> m_equipNo2partIdMap; ///< Reference map equipment number (player) to participant
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace TargetManagement
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
/**
|
||||
* Handler HandlerShootbackArea (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "handler_target_area_assignment.h"
|
||||
#include "handler_shootback_area.h"
|
||||
#include "object_shootback_area.h"
|
||||
|
||||
using namespace TargetManagement;
|
||||
//--------------------------------------------------------------------------
|
||||
HandlerShootbackArea::HandlerShootbackArea(MainHandler *mainHandler)
|
||||
: QObject(mainHandler)
|
||||
, ShootbackAreaModifyRequestHandler(mainHandler->dds()->ftsTgt())
|
||||
, ShootbackAreaRemoveRequestHandler(mainHandler->dds()->ftsTgt())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_dtsTgt(m_mainHandler->dds()->dtsTgt())
|
||||
, m_logger(getLogger("HandlerShootbackArea"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
HandlerShootbackArea::~HandlerShootbackArea()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
bool HandlerShootbackArea::init()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// connect(m_dtcTab.get(), &TrainingAreaBase::Interface::Dtc::targetDataChanged,
|
||||
// this, &HandlerShootbackArea::onTargetDataChanged);
|
||||
|
||||
bool bRet = true;
|
||||
// create objects
|
||||
auto cb = [this, &bRet](const Database::TgtShootbackArea & data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Reading from DB ShootbackArea with id = " << data.id;
|
||||
ObjectShootbackArea *ifs(new ObjectShootbackArea(m_mainHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(ObjectShootbackArea::toDdsData(data));
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_objectMap.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_mainHandler->db()->select(cb) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "m_objectMap.size() = " << m_objectMap.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HandlerShootbackArea::objectShootbackAreas(const std::function<void (const ObjectShootbackArea &)> &cb) const
|
||||
{
|
||||
for (const auto &sample : m_objectMap)
|
||||
if (sample)
|
||||
cb(*sample);
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void HandlerShootbackArea::onShootbackAreaModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ShootbackArea &request)
|
||||
{
|
||||
const auto ret = shootbackAreaModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
|
||||
// For ShootbackController
|
||||
emit objectChanged(ret.id(), false);
|
||||
|
||||
m_mainHandler->dds()->ftsTgt()->shootbackAreaModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerShootbackArea::shootbackAreaModifyRequest(const ShootbackArea &request)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
// modify
|
||||
if (request.id() > 0)
|
||||
{
|
||||
ObjectShootbackArea *ifs = m_objectMap.value(request.id());
|
||||
if (!ifs)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackArea with id %1 not found")).arg(request.id());
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
// create
|
||||
ObjectShootbackArea *ifs(new ObjectShootbackArea(m_mainHandler));
|
||||
auto ret = ifs->createObject(request);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
}
|
||||
else
|
||||
m_objectMap.insert(ifs->getId(), ifs);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return ret;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void HandlerShootbackArea::onShootbackAreaRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " request=" << request;
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectShootbackArea *ifs = m_objectMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackArea with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->ftsTgt()->shootbackAreaRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// // referenced by an assignment?
|
||||
// if (m_mainHandler->handlerTargetAreaAssignment() &&
|
||||
// m_mainHandler->handlerTargetAreaAssignment()->isAreaIdUsedInAny(request.id()))
|
||||
// {
|
||||
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackArea with id %1 is used.")).arg(request.id());
|
||||
// m_mainHandler->dds()->ftsTgt()->shootbackAreaRemoveReply(cookie, ret);
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
// if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
// {
|
||||
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackArea '%1' is used by another user!")).arg(ifs->getName());
|
||||
// m_mainHandler->dds()->ftsTgt()->shootbackAreaRemoveReply(cookie, ret);
|
||||
// return;
|
||||
// }
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete Object
|
||||
delete ifs;
|
||||
m_objectMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->ftsTgt()->shootbackAreaRemoveReply(cookie, ret);
|
||||
|
||||
// For ShootbackController
|
||||
if (!ret.error())
|
||||
emit objectChanged(request.id(), true);
|
||||
|
||||
return;
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* Handler HandlerShootbackArea (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <TargetManagement/tgt_dts.h>
|
||||
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class ObjectShootbackArea;
|
||||
|
||||
class HandlerShootbackArea final
|
||||
: public QObject
|
||||
, protected Interface::Fts::ShootbackAreaModifyRequestHandler
|
||||
, protected Interface::Fts::ShootbackAreaRemoveRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit HandlerShootbackArea(MainHandler *mainHandler);
|
||||
~HandlerShootbackArea();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information
|
||||
*/
|
||||
bool init();
|
||||
|
||||
ObjectShootbackArea *data(int id)
|
||||
{
|
||||
if (!m_objectMap.contains(id))
|
||||
return nullptr;
|
||||
return m_objectMap[id];
|
||||
}
|
||||
|
||||
bool objectShootbackAreas(const std::function<void(const TargetManagement::ObjectShootbackArea &data)> &cb) const;
|
||||
|
||||
const QHash<int, ObjectShootbackArea *> &getObjectMap() const { return m_objectMap; }
|
||||
|
||||
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void objectChanged(qint32 objId, bool removed);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
private: // methods
|
||||
void onShootbackAreaModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ShootbackArea &request) override;
|
||||
Core::FunctionReplyObject shootbackAreaModifyRequest(const ShootbackArea &request);
|
||||
void onShootbackAreaRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private: // attributes
|
||||
|
||||
QHash<int, ObjectShootbackArea *> m_objectMap;
|
||||
MainHandler *m_mainHandler;
|
||||
std::shared_ptr<TargetManagement::Interface::Dts> m_dtsTgt;
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace TargetManagement
|
||||
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* Handler ShootbackTargets (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "handler_target_area_assignment.h"
|
||||
#include "handler_shootback_target.h"
|
||||
#include "object_shootback_target.h"
|
||||
|
||||
using namespace TargetManagement;
|
||||
//--------------------------------------------------------------------------
|
||||
HandlerShootbackTarget::HandlerShootbackTarget(MainHandler *mainHandler)
|
||||
: QObject(mainHandler)
|
||||
, ShootbackTargetModifyRequestHandler(mainHandler->dds()->ftsTgt())
|
||||
, ShootbackTargetRemoveRequestHandler(mainHandler->dds()->ftsTgt())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_dtsTgt(m_mainHandler->dds()->dtsTgt())
|
||||
, m_logger(getLogger("HandlerShootbackTarget"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
HandlerShootbackTarget::~HandlerShootbackTarget()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
bool HandlerShootbackTarget::init()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// connect(m_dtcTab.get(), &TrainingAreaBase::Interface::Dtc::targetDataChanged,
|
||||
// this, &HandlerShootbackTarget::onTargetDataChanged);
|
||||
|
||||
bool bRet = true;
|
||||
// create objects
|
||||
auto cb = [this, &bRet](const Database::TgtShootbackTarget & data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Reading from DB ShootbackTarget with id = " << data.id;
|
||||
ObjectShootbackTarget *ifs(new ObjectShootbackTarget(m_mainHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(ObjectShootbackTarget::toDdsData(data));
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_objectMap.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_mainHandler->db()->select(cb) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "m_objectMap.size() = " << m_objectMap.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ObjectShootbackTarget *HandlerShootbackTarget::dataForTargetParticipantId(int targetParticipantId) const
|
||||
{
|
||||
for (ObjectShootbackTarget *item : qAsConst(m_objectMap))
|
||||
{
|
||||
if (!item)
|
||||
continue;
|
||||
if (item->getTargetParticipantId() == targetParticipantId)
|
||||
return item;
|
||||
} // for
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int HandlerShootbackTarget::targetDataIdForTargetParticipantId(int targetParticipantId) const
|
||||
{
|
||||
ObjectShootbackTarget *target = dataForTargetParticipantId(targetParticipantId);
|
||||
if (!target)
|
||||
return -1;
|
||||
return target->getId();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void HandlerShootbackTarget::onShootbackTargetModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ShootbackTarget &request)
|
||||
{
|
||||
const auto ret = shootbackTargetModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
else
|
||||
emit objectChanged(ret.id(), false); // For ShootbackController
|
||||
|
||||
m_mainHandler->dds()->ftsTgt()->shootbackTargetModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerShootbackTarget::shootbackTargetModifyRequest(const ShootbackTarget &request)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
// modify
|
||||
if (request.id() > 0)
|
||||
{
|
||||
ObjectShootbackTarget *ifs = m_objectMap.value(request.id());
|
||||
if (!ifs)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget with id %1 not found")).arg(request.id());
|
||||
|
||||
// since the attribute 'visibleParticipants' is *not* part of the db,
|
||||
// ignore request.visibleParticipants and use the value of the current memory:
|
||||
ShootbackTarget copy = request;
|
||||
copy.visibleParticipants(ifs->getData().visibleParticipants());
|
||||
return ifs->updateObject(copy);
|
||||
}
|
||||
// create
|
||||
ObjectShootbackTarget *ifs(new ObjectShootbackTarget(m_mainHandler));
|
||||
auto ret = ifs->createObject(request);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
}
|
||||
else
|
||||
m_objectMap.insert(ifs->getId(), ifs);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return ret;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void HandlerShootbackTarget::onShootbackTargetRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " request=" << request;
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectShootbackTarget *ifs = m_objectMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->ftsTgt()->shootbackTargetRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// // referenced by an assignment?
|
||||
// if (m_mainHandler->handlerTargetAreaAssignment() &&
|
||||
// m_mainHandler->handlerTargetAreaAssignment()->isTargetDataIdUsedInAny(request.id()))
|
||||
// {
|
||||
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget with id %1 is used.")).arg(request.id());
|
||||
// m_mainHandler->dds()->ftsTgt()->shootbackTargetRemoveReply(cookie, ret);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
// {
|
||||
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "ShootbackTarget '%1' is used by another user!")).arg(ifs->getName());
|
||||
// m_mainHandler->dds()->ftsTgt()->ShootbackTargetRemoveReply(cookie, ret);
|
||||
// return;
|
||||
// }
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete Object
|
||||
delete ifs;
|
||||
m_objectMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->ftsTgt()->shootbackTargetRemoveReply(cookie, ret);
|
||||
|
||||
// For ShootbackController
|
||||
if (!ret.error())
|
||||
emit objectChanged(request.id(), true);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Handler ShootbackTargets (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <TargetManagement/tgt_dts.h>
|
||||
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class ObjectShootbackTarget;
|
||||
|
||||
class HandlerShootbackTarget final
|
||||
: public QObject
|
||||
, protected Interface::Fts::ShootbackTargetModifyRequestHandler
|
||||
, protected Interface::Fts::ShootbackTargetRemoveRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit HandlerShootbackTarget(MainHandler *mainHandler);
|
||||
~HandlerShootbackTarget();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information
|
||||
*/
|
||||
bool init();
|
||||
|
||||
const QHash<int, ObjectShootbackTarget *> &getObjectMap() const { return m_objectMap; }
|
||||
|
||||
ObjectShootbackTarget *data(int id)
|
||||
{
|
||||
if (!m_objectMap.contains(id))
|
||||
return nullptr;
|
||||
return m_objectMap[id];
|
||||
}
|
||||
|
||||
ObjectShootbackTarget *dataForTargetParticipantId(int targetParticipantId) const;
|
||||
int targetDataIdForTargetParticipantId(int targetParticipantId) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void objectChanged(qint32 objId, bool removed);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
private: // methods
|
||||
void onShootbackTargetModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ShootbackTarget &request) override;
|
||||
Core::FunctionReplyObject shootbackTargetModifyRequest(const ShootbackTarget &request);
|
||||
void onShootbackTargetRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private: // attributes
|
||||
|
||||
QHash<int, ObjectShootbackTarget *> m_objectMap;
|
||||
MainHandler *m_mainHandler;
|
||||
std::shared_ptr<TargetManagement::Interface::Dts> m_dtsTgt;
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace TargetManagement
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
/**
|
||||
* Handler ShootbackAreas (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "handler_target_area_assignment.h"
|
||||
#include "object_target_area_assignment.h"
|
||||
|
||||
using namespace TargetManagement;
|
||||
//--------------------------------------------------------------------------
|
||||
HandlerTargetAreaAssignment::HandlerTargetAreaAssignment(MainHandler *mainHandler)
|
||||
: QObject(mainHandler)
|
||||
, TargetAreaAssignmentModifyRequestHandler(mainHandler->dds()->ftsTgt())
|
||||
, TargetAreaAssignmentRemoveRequestHandler(mainHandler->dds()->ftsTgt())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_dtsTgt(m_mainHandler->dds()->dtsTgt())
|
||||
, m_logger(getLogger("HandlerTargetAreaAssignment"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
HandlerTargetAreaAssignment::~HandlerTargetAreaAssignment()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
bool HandlerTargetAreaAssignment::init()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// connect(m_dtcTab.get(), &TrainingAreaBase::Interface::Dtc::targetDataChanged,
|
||||
// this, &HandlerTargetAreaAssignment::onTargetDataChanged);
|
||||
|
||||
bool bRet = true;
|
||||
// create objects
|
||||
auto cb = [this, &bRet](const Database::TgtTargetAreaAssignment & data)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Reading from DB TargetAreaAssignment with id = " << data.id;
|
||||
ObjectTargetAreaAssignment *ifs(new ObjectTargetAreaAssignment(m_mainHandler));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(ObjectTargetAreaAssignment::toDdsData(data));
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
bRet = false;
|
||||
return;
|
||||
}
|
||||
m_objectMap.insert(ifs->getId(), ifs);
|
||||
};
|
||||
if (!m_mainHandler->db()->select(cb) || !bRet)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "m_objectMap.size() = " << m_objectMap.size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool HandlerTargetAreaAssignment::isAreaIdUsedInAny(int areaId)
|
||||
{
|
||||
for (const ObjectTargetAreaAssignment *sample : qAsConst(m_objectMap))
|
||||
if (sample && (sample->getData().areaId() == areaId))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HandlerTargetAreaAssignment::isTargetDataIdUsedInAny(int targetDataId)
|
||||
{
|
||||
for (const ObjectTargetAreaAssignment *sample : qAsConst(m_objectMap))
|
||||
if (sample && (sample->getData().targetParticipantId() == targetDataId))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void HandlerTargetAreaAssignment::onTargetAreaAssignmentModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const TargetAreaAssignment &request)
|
||||
{
|
||||
const auto ret = TargetAreaAssignmentModifyRequest(request);
|
||||
if (ret.error())
|
||||
WARNING_LOG(m_logger) << ret();
|
||||
else
|
||||
emit objectChanged(ret.id(), false); // For ShootbackController
|
||||
|
||||
m_mainHandler->dds()->ftsTgt()->targetAreaAssignmentModifyReply(cookie, ret);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject HandlerTargetAreaAssignment::TargetAreaAssignmentModifyRequest(const TargetAreaAssignment &request)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
// modify
|
||||
if (request.id() > 0)
|
||||
{
|
||||
ObjectTargetAreaAssignment *ifs = m_objectMap.value(request.id());
|
||||
if (!ifs)
|
||||
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "TargetAreaAssignment with id %1 not found")).arg(request.id());
|
||||
return ifs->updateObject(request);
|
||||
}
|
||||
// create
|
||||
ObjectTargetAreaAssignment *ifs(new ObjectTargetAreaAssignment(m_mainHandler));
|
||||
auto ret = ifs->createObject(request);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ifs = nullptr;
|
||||
}
|
||||
else
|
||||
m_objectMap.insert(ifs->getId(), ifs);
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return ret;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void HandlerTargetAreaAssignment::onTargetAreaAssignmentRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " request=" << request;
|
||||
|
||||
Core::FunctionReplyObject ret;
|
||||
ObjectTargetAreaAssignment *ifs = m_objectMap.value(request.id());
|
||||
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "TargetAreaAssignment with id %1 not found")).arg(request.id());
|
||||
m_mainHandler->dds()->ftsTgt()->targetAreaAssignmentRemoveReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
// if (m_mainHandler->dds()->topicLockMaster()->isLocked(ifs->getData(), m_mainHandler->exerciseId()))
|
||||
// {
|
||||
// ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "TargetAreaAssignment '%1' is used by another user!")).arg(ifs->getName());
|
||||
// m_mainHandler->dds()->ftsTgt()->TargetAreaAssignmentRemoveReply(cookie, ret);
|
||||
// return;
|
||||
// }
|
||||
|
||||
ret = ifs->removeObject();
|
||||
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
else
|
||||
{
|
||||
// delete Object
|
||||
delete ifs;
|
||||
m_objectMap.remove(request.id());
|
||||
}
|
||||
|
||||
m_mainHandler->dds()->ftsTgt()->targetAreaAssignmentRemoveReply(cookie, ret);
|
||||
|
||||
// For ShootbackController
|
||||
if (!ret.error())
|
||||
emit objectChanged(request.id(), true);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Handler HandlerTargetAreaAssignment (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <TargetManagement/tgt_dts.h>
|
||||
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
class ObjectTargetAreaAssignment;
|
||||
|
||||
class HandlerTargetAreaAssignment final
|
||||
: public QObject
|
||||
, protected Interface::Fts::TargetAreaAssignmentModifyRequestHandler
|
||||
, protected Interface::Fts::TargetAreaAssignmentRemoveRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit HandlerTargetAreaAssignment(MainHandler *mainHandler);
|
||||
~HandlerTargetAreaAssignment();
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information
|
||||
*/
|
||||
bool init();
|
||||
|
||||
const QHash<int, ObjectTargetAreaAssignment *> &getObjectMap() const { return m_objectMap; }
|
||||
|
||||
bool isAreaIdUsedInAny(int areaId);
|
||||
bool isTargetDataIdUsedInAny(int targetDataId);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void objectChanged(qint32 objId, bool removed);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
private: // methods
|
||||
void onTargetAreaAssignmentModifyRequest(const rti::core::SampleIdentity &cookie,
|
||||
const TargetAreaAssignment &request) override;
|
||||
Core::FunctionReplyObject TargetAreaAssignmentModifyRequest(const TargetAreaAssignment &request);
|
||||
void onTargetAreaAssignmentRemoveRequest(const rti::core::SampleIdentity &cookie,
|
||||
const Core::RemoveElementRequest &request) override;
|
||||
|
||||
private: // attributes
|
||||
|
||||
QHash<int, ObjectTargetAreaAssignment *> m_objectMap;
|
||||
MainHandler *m_mainHandler;
|
||||
std::shared_ptr<TargetManagement::Interface::Dts> m_dtsTgt;
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace TargetManagement
|
||||
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
/**
|
||||
* Handler for player data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by hjl, SLSE, 2017-02-20
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
#include "handler_target_config.h"
|
||||
#include <LtsUtilsCore/qbytearray_byteaccess.h>
|
||||
|
||||
using namespace TargetManagement;
|
||||
|
||||
HandlerTargetConfig::HandlerTargetConfig(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, ConfigureTargetRequestHandler(ddsHandler->ftsTgt())
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_dtcTab(ddsHandler->dtcTab())
|
||||
, m_dtsTgt(ddsHandler->dtsTgt())
|
||||
, m_logger(getLogger("HandlerTargetConfig"))
|
||||
{
|
||||
} // end of ctor()
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool HandlerTargetConfig::init()
|
||||
{
|
||||
INFO_LOG(m_logger) << "init";
|
||||
connect(m_dtcTab.get(), &TrainingAreaBase::Interface::Dtc::targetDataChanged,
|
||||
this, &HandlerTargetConfig::onTargetDataChanged);
|
||||
|
||||
return true;
|
||||
} // end of init()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void HandlerTargetConfig::onTargetDataChanged(const TrainingAreaBase::TargetData &targetData, DataModification modType)
|
||||
{
|
||||
if (modType == DataModification::eRemoved)
|
||||
return;
|
||||
|
||||
uint8_t responseCmd = 100;
|
||||
TargetManagement::TargetConfig tgtTargetData;
|
||||
INFO_LOG(m_logger) << "onTargetDataChanged payload.size=" << targetData.payload().size();
|
||||
tgtTargetData.participantId(m_ddsHandler->equipNo2participantId(targetData.equipmentNumber()));
|
||||
for (size_t i = 0; i < targetData.payload().size(); i++)
|
||||
INFO_LOG(m_logger) << "payload[" << i << "]=" << targetData.payload()[i];
|
||||
|
||||
if (targetData.payload().size() < 6)
|
||||
return;
|
||||
tgtTargetData.id(0);
|
||||
tgtTargetData.tgtCommand(static_cast <TargetManagement::TgtCommand_def::type>(targetData.payload()[0] - responseCmd));
|
||||
tgtTargetData.mode(static_cast <TargetManagement::Mode_def::type>(targetData.payload()[1]));
|
||||
tgtTargetData.weapon(targetData.payload()[2]);
|
||||
INFO_LOG(m_logger) << "tgtTargetData.tgtCommand =" << tgtTargetData.tgtCommand()
|
||||
<< " mode=" << tgtTargetData.mode()
|
||||
<< " weapon=" << tgtTargetData.weapon();
|
||||
if (!m_dtsTgt->publish(tgtTargetData))
|
||||
ERROR_LOG(m_logger) << "Error publish targetData";
|
||||
} // end of onTargetDataChanged
|
||||
|
||||
void HandlerTargetConfig::onSendTargetDataReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
if (replyObject.error())
|
||||
WARNING_LOG(m_logger) << "Can not send target data to target participant : " << replyObject();
|
||||
else
|
||||
DEBUG_LOG(m_logger) << "onSendTargetDataReply for id " << replyObject.id() << " success";
|
||||
}
|
||||
|
||||
// Send to TAB
|
||||
void HandlerTargetConfig::onConfigureTargetRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ConfigureTargetRequest &request)
|
||||
{
|
||||
INFO_LOG(m_logger) << "onConfigureTargetRequest";
|
||||
Core::FunctionReplyObject reply = Core::FunctionReplyObject(request.id());
|
||||
|
||||
DEBUG_LOG(m_logger) << "HandlerTargetConfig onTargetConfigChanged participantId=" << request.participantId();
|
||||
|
||||
TrainingAreaBase::SendTargetDataRequest tgt;
|
||||
const int participantId = request.participantId();
|
||||
tgt.equipmentNumber(m_ddsHandler->participantId2EquipNo(participantId));
|
||||
tgt.participantId(request.participantId());
|
||||
|
||||
tgt.payload().push_back(request.tgtCommand().underlying());
|
||||
|
||||
switch (request.tgtCommand().underlying())
|
||||
{
|
||||
case TargetManagement::TgtCommand_def::Unknown:
|
||||
case TargetManagement::TgtCommand_def::PlaySound:
|
||||
{
|
||||
WARNING_LOG(m_logger) << "onTargetConfigChanged Command =" << request.tgtCommand() << " not handled.";
|
||||
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, reply);
|
||||
return;
|
||||
}
|
||||
case TargetManagement::TgtCommand_def::RequestTechnicalState:
|
||||
case TargetManagement::TgtCommand_def::RequestParameter:
|
||||
{
|
||||
// No specific data to add to payload
|
||||
break;
|
||||
}
|
||||
case TargetManagement::TgtCommand_def::SetMode:
|
||||
{
|
||||
if (!request.mode().is_set())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Set mode requested, but mode ist not set";
|
||||
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, Core::FunctionReplyObject(request.participantId(), tr_lts("dds", "Set mode requested, but mode is not set")));
|
||||
return;
|
||||
}
|
||||
tgt.payload().push_back(request.mode().get().underlying());
|
||||
break;
|
||||
}
|
||||
case TargetManagement::TgtCommand_def::SetWeapon:
|
||||
{
|
||||
if (!request.weapon().is_set())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Set weapon requested, but weapon ist not set";
|
||||
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, Core::FunctionReplyObject(request.participantId(), tr_lts("dds", "Set weapon requested, but weapon is not set")));
|
||||
return;
|
||||
}
|
||||
tgt.payload().push_back(request.weapon().get());
|
||||
break;
|
||||
}
|
||||
case TargetManagement::TgtCommand_def::SetParameter:
|
||||
{
|
||||
if (!request.parameterSet().is_set())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Set parameterset requested, but parameterset ist not set";
|
||||
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, Core::FunctionReplyObject(request.participantId(), tr_lts("dds", "Set parameterset requested, but parameterset is not set")));
|
||||
return;
|
||||
}
|
||||
tgt.payload().push_back(request.parameterSet().get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_ddsHandler->ftcTab()->sendTargetDataRequest(tgt, this);
|
||||
// Todo: Wait for Reply and forward?
|
||||
m_ddsHandler->ftsTgt()->configureTargetReply(cookie, reply);
|
||||
} // end of onConfigureTargetRequest
|
||||
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Handler for buildingState
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by gr, SLSE, 2018-07-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <TargetManagement/tgt_dts.h>
|
||||
#include <TargetManagement/tgt_fts.h>
|
||||
#include <TargetManagement/tgt_ftc.h>
|
||||
|
||||
#include <../Proxies/TrainingAreaBase/tab_ftc.h>
|
||||
#include <../Proxies/TrainingAreaBase/tab_dtc.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
// AES-Handling for participants within buildings
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
class HandlerTargetConfig final
|
||||
: public QObject
|
||||
, protected Interface::Fts::ConfigureTargetRequestHandler
|
||||
, protected TrainingAreaBase::Interface::Ftc::SendTargetDataReplyHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit HandlerTargetConfig(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
|
||||
~HandlerTargetConfig() = default;
|
||||
|
||||
/**
|
||||
* Initialize the handler to manage information from player management
|
||||
*/
|
||||
bool init();
|
||||
|
||||
void onSendTargetDataReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
/**
|
||||
* Handle new Target Configuration
|
||||
*/
|
||||
void onTargetDataChanged(const TrainingAreaBase::TargetData &targetData, DataModification modType);
|
||||
|
||||
private: // methoden
|
||||
void onConfigureTargetRequest(const rti::core::SampleIdentity &cookie,
|
||||
const ConfigureTargetRequest &request) override;
|
||||
Core::FunctionReplyObject configureTargetRequest(const ConfigureTargetRequest &request);
|
||||
private: // attributes
|
||||
|
||||
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler; ///< Pointer to DDS handler
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dtc> m_dtcTab;
|
||||
std::shared_ptr<TargetManagement::Interface::Dts> m_dtsTgt;
|
||||
NGL::INGLLogger &m_logger; ///< Interface to the Logging-Facility
|
||||
|
||||
};
|
||||
} // namespace TargetManagement
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=INFO, file
|
||||
|
||||
|
||||
# Service: TargetManagement
|
||||
###########################################################
|
||||
|
||||
log4j.logger.TGT=WARN
|
||||
#log4j.logger.TGT.main=DEBUG
|
||||
#log4j.logger.TGT.DdsHandler=DEBUG
|
||||
#log4j.logger.TGT.MainHandler=DEBUG
|
||||
#log4j.logger.TGT.HandlerTargetConfig=DEBUG
|
||||
#log4j.logger.TGT.ShootbackController=DEBUG
|
||||
#log4j.logger.TGT.HandlerShootbackArea=DEBUG
|
||||
#log4j.logger.TGT.HandlerShootbackTarget=DEBUG
|
||||
#log4j.logger.TGT.HandlerTargetAreaAssignment=DEBUG
|
||||
#log4j.logger.TGT.ObjectShootbackArea=DEBUG
|
||||
#log4j.logger.TGT.ObjectShootbackTarget=DEBUG
|
||||
#log4j.logger.TGT.ObjectTargetAreaAssignment=DEBUG
|
||||
#log4j.logger.TGT.ObjectTargetAreaAssignment=DEBUG
|
||||
LineOfSightCalculation
|
||||
|
||||
# Service: SituationMap
|
||||
###########################################################
|
||||
#log4j.logger.SituationMap.LineOfSightCalculation=WARN
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Lts::RollingFileAppender
|
||||
log4j.appender.file=Lts::RollingFileAppender
|
||||
log4j.appender.file.MaxFileSize=1MB
|
||||
log4j.appender.file.MaxBackupIndex=9
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d %-5p %c |#| %m (%.50F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Console
|
||||
###########################################################
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern= %d %p %c %c{1} - %m (%-.30F:%L) %n
|
||||
|
||||
|
||||
# Appnd_Syslog
|
||||
###########################################################
|
||||
log4j.appender.syslog=org.apache.log4j.SyslogAppender
|
||||
log4j.appender.syslog.Threshold=ERROR
|
||||
log4j.appender.syslog.SysLogHost=localhost
|
||||
log4j.appender.syslog.Facility=LOCAL7
|
||||
log4j.appender.syslog.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.syslog.layout.ConversionPattern= %-4r %-5p %c %x - %m
|
||||
log4j.appender.syslog.LevelRangeFilter.AcceptOnMatch=true
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMin=INFO
|
||||
log4j.appender.syslog.LevelRangeFilter.LevelMax=FATAL
|
||||
|
||||
|
||||
###########################################################
|
||||
###########################################################
|
||||
###########################################################
|
||||
# 1) Available Levels in LOG4CXX Version 0.10.0:
|
||||
# TRACE,
|
||||
# DEBUG,
|
||||
# INFO,
|
||||
# WARN,
|
||||
# ERROR
|
||||
# FATAL
|
||||
#
|
||||
# d = date/time
|
||||
# p = priority (Level)
|
||||
# c = category/channel
|
||||
# m = message
|
||||
# F = file
|
||||
# L = line
|
||||
# n = platform dependent line separator character or characters.
|
||||
# ....
|
||||
#
|
||||
# Examples for console:
|
||||
# a)
|
||||
# %d %p %c #%m# (%.50F:%L)%n
|
||||
# date/time
|
||||
# priority
|
||||
# category/channel
|
||||
# #message#
|
||||
# (Maximal 50Character des Filename von rechts:Line)
|
||||
# line separator
|
||||
#
|
||||
# b)
|
||||
# %d (%.15F:%L) %-5p %c |#| %m%n
|
||||
# date/time
|
||||
# (Maximal 15Character des Filename von rechts:Line)
|
||||
# priority, Right pad with spaces if the priority name is less than 5 characters long.
|
||||
# category/channel
|
||||
# message
|
||||
# line separator
|
||||
#
|
||||
# Examples for files:
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Building Config - logging facility
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "TGT.";
|
||||
std::string loggerName;
|
||||
const size_t len = strlen(name);
|
||||
loggerName.reserve(sizeof(ns) + len);
|
||||
loggerName.append(ns, sizeof(ns) - 1);
|
||||
loggerName.append(name, len);
|
||||
|
||||
try
|
||||
{
|
||||
return NGL::NGLLoggerBootstrap::getNGLRootLogger().
|
||||
getNGLLogger(loggerName);
|
||||
}
|
||||
catch (const std::exception &ex)
|
||||
{
|
||||
fprintf(stderr, "Error retrieving logger: %s", ex.what());
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace TargetManagement
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for TargetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "tgt_export.h"
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
TGT_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace TargetManagement
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main for TargetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "logger.h"
|
||||
#include "settings.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
|
||||
LtsCommandLineParser::LtsCommandLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
app.createLogger("TGT", options.exerciseId());
|
||||
|
||||
TargetManagement::Settings::setIniFile(options.iniFile());
|
||||
|
||||
int iRet = -3;
|
||||
{
|
||||
std::unique_ptr<TargetManagement::MainHandler> mainHandler(new TargetManagement::MainHandler);
|
||||
|
||||
if (!mainHandler->init(options.domainId(), options.exerciseId()))
|
||||
return iRet;
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
iRet = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* MainHandler for AssetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
#include <ngldb/db_service_handler.h>
|
||||
#include "settings.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_ddsHandler(nullptr)
|
||||
, m_dbHandler(nullptr)
|
||||
, m_logger(getLogger("MainHandler"))
|
||||
{}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
m_handlerTargetConfig.reset();
|
||||
|
||||
// Land400 :
|
||||
m_shootbackController.reset();
|
||||
m_elevationMap.reset();
|
||||
m_handlerTargetAreaAssignment.reset();
|
||||
m_handlerShootbackArea.reset();
|
||||
m_handlerShootbackTarget.reset();
|
||||
// : Land400
|
||||
|
||||
m_ddsHandler.reset();
|
||||
m_dbHandler.reset();
|
||||
}
|
||||
|
||||
bool MainHandler::init(int domainId, int exerciseId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "MainHandler::init";
|
||||
|
||||
// initialize database
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
if (!m_dbHandler->init(exerciseId, Settings::settings()))
|
||||
return false;
|
||||
|
||||
// initialize DDS
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
||||
if (!m_ddsHandler->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation ddsHandler failed.";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Initialisation ddsHandler succesful.";
|
||||
|
||||
NOTICE_LOG(m_logger) << "setNewState Core::RunningState::Starting ";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Starting);
|
||||
|
||||
// initialize handlerTargetConfig
|
||||
m_handlerTargetConfig = std::make_shared<HandlerTargetConfig>(m_ddsHandler, this);
|
||||
|
||||
if (!m_handlerTargetConfig->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerTargetConfig failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (TargetManagement::Settings::useL400Targets())
|
||||
{
|
||||
//
|
||||
// L400: ElevationMap, ShootbackArea, ShootbackTarget ..
|
||||
// use srtm_38_02.tif for Bremen, until general solution is provided:
|
||||
// loading ElevationMap (async):
|
||||
//
|
||||
// use srtm_38_02.tif for Bremen, until general solution is provided:
|
||||
|
||||
QString elevationFileAbs(QLatin1String("/usr/share/arcgis/resources/elevation/srtm_38_02.tif")); // srtm_38_02.tif -> Bremen
|
||||
QFileInfo fi(elevationFileAbs);
|
||||
if (!fi.exists(elevationFileAbs))
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << ", elevationFile '" << elevationFileAbs << "' doesn't exists";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_elevationMap = std::make_shared<SituationMap::ElevationMap>(fi);
|
||||
m_elevationMap->waitForInitialization(); // needs some seconds:
|
||||
|
||||
|
||||
//
|
||||
// initialize handlerShootbackArea
|
||||
m_handlerShootbackArea = std::make_shared<HandlerShootbackArea>(this);
|
||||
|
||||
if (!m_handlerShootbackArea->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerShootbackArea failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
// initialize handlerShootbackTarget
|
||||
m_handlerShootbackTarget = std::make_shared<HandlerShootbackTarget>(this);
|
||||
|
||||
if (!m_handlerShootbackTarget->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerShootbackTarget failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
// initialize handlerTargetAreaAssignment
|
||||
m_handlerTargetAreaAssignment = std::make_shared<HandlerTargetAreaAssignment>(this);
|
||||
|
||||
if (!m_handlerTargetAreaAssignment->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerTargetAreaAssignment failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
// shootbackController
|
||||
m_shootbackController = std::make_shared<ShootbackController>(this);
|
||||
bool initLos = m_shootbackController->initLOS(m_elevationMap.get());
|
||||
bool initDds = m_shootbackController->initDds(m_handlerShootbackArea,
|
||||
m_handlerShootbackTarget,
|
||||
m_handlerTargetAreaAssignment);
|
||||
|
||||
if (!(initLos && initDds))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation ShootbackController failed.";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NOTICE_LOG(m_logger) << "setNewState Core::RunningState::Running ";
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<DatabaseInterface> MainHandler::db() const
|
||||
{
|
||||
return m_dbHandler->db();
|
||||
}
|
||||
|
||||
|
||||
} // namespace TargetManagement
|
||||
Executable
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* MainHandler for AereaEffectSimulation
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "tgt_db.h"
|
||||
#include "handler_target_config.h"
|
||||
#include "handler_shootback_area.h"
|
||||
#include "handler_shootback_target.h"
|
||||
#include "handler_target_area_assignment.h"
|
||||
#include "shootback_controller.h"
|
||||
#include <ElevationMap/elevation_map.h>
|
||||
#include "logger.h"
|
||||
|
||||
namespace NGLDB
|
||||
{
|
||||
template <typename DB> class DbServiceHandler;
|
||||
}
|
||||
namespace TargetManagement
|
||||
{
|
||||
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
|
||||
|
||||
class MainHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainHandler(QObject *parent = nullptr);
|
||||
~MainHandler();
|
||||
|
||||
bool init(int domainId, int exerciseId);
|
||||
|
||||
std::shared_ptr<DdsHandler> dds() const { return m_ddsHandler; }
|
||||
std::shared_ptr<DatabaseInterface> db() const;
|
||||
|
||||
std::shared_ptr<HandlerTargetAreaAssignment> handlerTargetAreaAssignment() const { return m_handlerTargetAreaAssignment; }
|
||||
|
||||
|
||||
private:
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
|
||||
std::shared_ptr<HandlerTargetConfig> m_handlerTargetConfig;
|
||||
|
||||
// L400 :
|
||||
std::shared_ptr<HandlerShootbackArea> m_handlerShootbackArea;
|
||||
std::shared_ptr<HandlerShootbackTarget> m_handlerShootbackTarget;
|
||||
std::shared_ptr<HandlerTargetAreaAssignment> m_handlerTargetAreaAssignment;
|
||||
|
||||
std::shared_ptr<SituationMap::ElevationMap> m_elevationMap;
|
||||
std::shared_ptr<ShootbackController> m_shootbackController;
|
||||
// : L400
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
} // namespace TargetManagement
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* Handler ShootbackAreas (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "object_shootback_area.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace TargetManagement
|
||||
{
|
||||
ObjectShootbackArea::ObjectShootbackArea(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("ObjectShootbackArea"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ObjectShootbackArea::~ObjectShootbackArea()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (isValid())
|
||||
m_mainHandler->dds()->dtsTgt()->removeShootbackAreaByKey(m_data.id());
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectShootbackArea::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectShootbackArea::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackArea::createObject(const ShootbackArea &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::TgtShootbackArea dbData(toDbData(data));
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting ShootbackArea-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New TgtShootbackArea: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackArea::updateObject(const ShootbackArea &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::TgtShootbackArea dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating ShootbackArea-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for ShootbackAreaId: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackArea::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed ShootbackArea object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackArea::removeObject()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "ShootbackArea still in use"));
|
||||
|
||||
if (!m_mainHandler->db()->removeTgtShootbackArea(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "ShootbackArea with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!m_mainHandler->dds()->dtsTgt()->removeShootbackAreaByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "ShootbackArea with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void ObjectShootbackArea::onPublishData()
|
||||
{
|
||||
TRACE_LOG(m_logger) << "Publish ShootbackArea-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!m_mainHandler->dds()->dtsTgt()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing ShootbackArea-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// TargetManagement::ShootbackArea => Database::TgtShootbackArea
|
||||
Database::TgtShootbackArea ObjectShootbackArea::toDbData(const ShootbackArea &ddsData)
|
||||
{
|
||||
Database::TgtShootbackArea dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.position = QPointF(ddsData.position().lon(), ddsData.position().lat());
|
||||
dbData.width = ddsData.width();
|
||||
dbData.height = ddsData.height();
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::TgtShootbackArea => TargetManagement::ShootbackArea
|
||||
ShootbackArea ObjectShootbackArea::toDdsData(const Database::TgtShootbackArea &dbData)
|
||||
{
|
||||
ShootbackArea ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.position(Core::GeoPosition2D(dbData.position.x(), dbData.position.y()));
|
||||
ddsData.width(dbData.width);
|
||||
ddsData.height(dbData.height);
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace TargetManagement
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Handler ShootbackAreas (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <TargetManagement/tgt.hpp>
|
||||
#include <TargetManagement/tgt_db.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectShootbackArea
|
||||
{
|
||||
public:
|
||||
explicit ObjectShootbackArea(MainHandler *mainHandler);
|
||||
~ObjectShootbackArea();
|
||||
|
||||
Core::FunctionReplyObject createObject(const ShootbackArea &data);
|
||||
Core::FunctionReplyObject updateObject(const ShootbackArea &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
const ShootbackArea &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
|
||||
// convert methods
|
||||
static Database::TgtShootbackArea toDbData(const ShootbackArea &ddsData); // dds -> db
|
||||
static ShootbackArea toDdsData(const Database::TgtShootbackArea &dbData); // db -> dds
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
ShootbackArea m_data;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+217
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* Handler ShootbackTargets (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "object_shootback_target.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace TargetManagement
|
||||
{
|
||||
ObjectShootbackTarget::ObjectShootbackTarget(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("ObjectShootbackTarget"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ObjectShootbackTarget::~ObjectShootbackTarget()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (isValid())
|
||||
m_mainHandler->dds()->dtsTgt()->removeShootbackTargetByKey(m_data.id());
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectShootbackTarget::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectShootbackTarget::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackTarget::createObject(const ShootbackTarget &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::TgtShootbackTarget dbData(toDbData(data));
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting ShootbackTarget-data into database"));
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New TgtShootbackTarget: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackTarget::updateObject(const ShootbackTarget &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START, id=" << data.id()
|
||||
<< " size =" << data.visibleParticipants().size();
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::TgtShootbackTarget dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (isDifferent(dbData))
|
||||
{
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating ShootbackTarget-data into database"));
|
||||
}
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for ShootbackTargetId: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END, id=" << data.id()
|
||||
<< " size =" << data.visibleParticipants().size();
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackTarget::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed ShootbackTarget object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectShootbackTarget::removeObject()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "ShootbackTarget still in use"));
|
||||
|
||||
if (!m_mainHandler->db()->removeTgtShootbackTarget(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "ShootbackTarget with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!m_mainHandler->dds()->dtsTgt()->removeShootbackTargetByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "ShootbackTarget with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
void ObjectShootbackTarget::updateVolatileData(const std::vector<int32_t> &visibleParticipant)
|
||||
{
|
||||
m_data.visibleParticipants(visibleParticipant);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
}
|
||||
|
||||
void ObjectShootbackTarget::updateVolatileData(const Core::GeoPosition &position)
|
||||
{
|
||||
m_data.position(position);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void ObjectShootbackTarget::onPublishData()
|
||||
{
|
||||
TRACE_LOG(m_logger) << "Publish ShootbackTarget-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!m_mainHandler->dds()->dtsTgt()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing ShootbackTarget-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// TargetManagement::ShootbackTarget => Database::TgtShootbackTarget
|
||||
Database::TgtShootbackTarget ObjectShootbackTarget::toDbData(const ShootbackTarget &ddsData)
|
||||
{
|
||||
Database::TgtShootbackTarget dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.targetParticipantId = ddsData.targetParticipantId();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
|
||||
dbData.activateLaserDesignation = ddsData.activateLaserDesignation();
|
||||
dbData.activateLights = ddsData.activateLights();
|
||||
dbData.activatePopupAutomatic = ddsData.activatePopupAutomatic();
|
||||
dbData.hitsToKill = ddsData.hitsToKill();
|
||||
dbData.permanentInstalledTarget = ddsData.permanentInstalledTarget();
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::TgtShootbackTarget => TargetManagement::ShootbackTarget
|
||||
ShootbackTarget ObjectShootbackTarget::toDdsData(const Database::TgtShootbackTarget &dbData)
|
||||
{
|
||||
ShootbackTarget ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.targetParticipantId(dbData.targetParticipantId);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
|
||||
ddsData.activateLaserDesignation(dbData.activateLaserDesignation);
|
||||
ddsData.activateLights(dbData.activateLights);
|
||||
ddsData.activatePopupAutomatic(dbData.activatePopupAutomatic);
|
||||
ddsData.hitsToKill(dbData.hitsToKill);
|
||||
ddsData.permanentInstalledTarget(dbData.permanentInstalledTarget);
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
bool ObjectShootbackTarget::isDifferent(const Database::TgtShootbackTarget &dbData)
|
||||
{
|
||||
return (
|
||||
dbData.id != m_data.id() ||
|
||||
dbData.targetParticipantId != m_data.targetParticipantId() ||
|
||||
dbData.name.toStdString() != m_data.name() ||
|
||||
|
||||
dbData.activateLaserDesignation != m_data.activateLaserDesignation() ||
|
||||
dbData.activateLights != m_data.activateLights() ||
|
||||
dbData.activatePopupAutomatic != m_data.activatePopupAutomatic() ||
|
||||
dbData.hitsToKill != m_data.hitsToKill() ||
|
||||
dbData.permanentInstalledTarget != m_data.permanentInstalledTarget()
|
||||
);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace TargetManagement
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* Handler ObjectShootbackTargets (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <TargetManagement/tgt.hpp>
|
||||
#include <TargetManagement/tgt_db.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectShootbackTarget
|
||||
{
|
||||
public:
|
||||
explicit ObjectShootbackTarget(MainHandler *mainHandler);
|
||||
~ObjectShootbackTarget();
|
||||
|
||||
Core::FunctionReplyObject createObject(const ShootbackTarget &data);
|
||||
Core::FunctionReplyObject updateObject(const ShootbackTarget &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
void updateVolatileData(const std::vector<int32_t> &visibleParticipant);
|
||||
void updateVolatileData(const Core::GeoPosition &position);
|
||||
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
qint32 getTargetParticipantId() const { return m_data.targetParticipantId(); }
|
||||
const ShootbackTarget &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
|
||||
// convert methods
|
||||
static Database::TgtShootbackTarget toDbData(const ShootbackTarget &ddsData); // dds -> db
|
||||
static ShootbackTarget toDdsData(const Database::TgtShootbackTarget &dbData); // db -> dds
|
||||
bool isDifferent(const Database::TgtShootbackTarget &dbData);
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
ShootbackTarget m_data;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
/**
|
||||
* Handler TargetAreaAssignments (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "object_target_area_assignment.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace TargetManagement
|
||||
{
|
||||
ObjectTargetAreaAssignment::ObjectTargetAreaAssignment(MainHandler *mainHandler)
|
||||
: m_mainHandler(mainHandler)
|
||||
, m_logger(getLogger("ObjectTargetAreaAssignment"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
ObjectTargetAreaAssignment::~ObjectTargetAreaAssignment()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (isValid())
|
||||
m_mainHandler->dds()->dtsTgt()->removeTargetAreaAssignmentByKey(m_data.id());
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectTargetAreaAssignment::isValid() const
|
||||
{
|
||||
return m_data.id() > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool ObjectTargetAreaAssignment::isUsed() const
|
||||
{
|
||||
return m_data.isUsed();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTargetAreaAssignment::createObject(const TargetAreaAssignment &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
m_data = data;
|
||||
|
||||
if (m_data.id() <= 0)
|
||||
{
|
||||
m_data.isUsed(false);
|
||||
|
||||
Database::TgtTargetAreaAssignment dbData(toDbData(data));
|
||||
|
||||
if (!m_mainHandler->db()->insert(dbData))
|
||||
{
|
||||
QString errText = m_mainHandler->db()->getLastError().nativeErrorCode();
|
||||
ERROR_LOG(m_logger) << "Error inserting TargetAreaAssignment into database: " << m_mainHandler->db()->getLastError().text();
|
||||
if (errText.contains(QStringLiteral("23505")))
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting TargetAreaAssignment into database: unique key violation for '%1'")).arg(m_data.name());
|
||||
else
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting TargetAreaAssignment with name %1 into database: %2")).arg(m_data.name()).arg(errText);
|
||||
}
|
||||
|
||||
m_data.id(dbData.id);
|
||||
DEBUG_LOG(m_logger) << "New TgtTargetAreaAssignment: " << m_data.id();
|
||||
}
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTargetAreaAssignment::updateObject(const TargetAreaAssignment &data)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Object not valid/blocked"));
|
||||
|
||||
Database::TgtTargetAreaAssignment dbData;
|
||||
dbData = toDbData(data);
|
||||
|
||||
if (!m_mainHandler->db()->update(dbData))
|
||||
return Core::FunctionReplyObject(data.id(), tr_lts("dds", "Error updating TargetAreaAssignment-data into database"));
|
||||
|
||||
m_data = data;
|
||||
DEBUG_LOG(m_logger) << "Data changed for TargetAreaAssignmentId: " << m_data.id();
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTargetAreaAssignment::setUsed(bool isUsed)
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "Trying to update an already removed TargetAreaAssignment object"));
|
||||
|
||||
m_data.isUsed(isUsed);
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Core::FunctionReplyObject ObjectTargetAreaAssignment::removeObject()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
if (isUsed())
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "TargetAreaAssignment still in use"));
|
||||
|
||||
if (!m_mainHandler->db()->removeTgtTargetAreaAssignment(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "TargetAreaAssignment with id %1 can not be removed from DB")).arg(m_data.id());
|
||||
|
||||
if (!m_mainHandler->dds()->dtsTgt()->removeTargetAreaAssignmentByKey(m_data.id()))
|
||||
return Core::FunctionReplyObject(m_data.id(), tr_lts("dds", "TargetAreaAssignment with id %1 can not be removed from DDS")).arg(m_data.id());
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return Core::FunctionReplyObject(m_data.id());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void ObjectTargetAreaAssignment::onPublishData()
|
||||
{
|
||||
TRACE_LOG(m_logger) << "Publish TargetAreaAssignment-data to dds (" << m_data.id() << ") ...";
|
||||
|
||||
if (!m_mainHandler->dds()->dtsTgt()->publish(m_data))
|
||||
ERROR_LOG(m_logger) << "Error publishing TargetAreaAssignment-data to dds";
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// convert methods
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
// TargetManagement::TargetAreaAssignment => Database::TgtTargetAreaAssignment
|
||||
Database::TgtTargetAreaAssignment ObjectTargetAreaAssignment::toDbData(const TargetAreaAssignment &ddsData)
|
||||
{
|
||||
Database::TgtTargetAreaAssignment dbData;
|
||||
|
||||
dbData.id = ddsData.id();
|
||||
dbData.name = QString::fromStdString(ddsData.name());
|
||||
dbData.areaId = ddsData.areaId();
|
||||
dbData.targetParticipantId = ddsData.targetParticipantId();
|
||||
dbData.isActive = ddsData.isActive();
|
||||
|
||||
dbData.interval1 = ddsData.configuration().interval1();
|
||||
dbData.effect1 = ddsData.configuration().effect1();
|
||||
dbData.flash1 = ddsData.configuration().flash1();
|
||||
|
||||
dbData.interval2 = ddsData.configuration().interval2();
|
||||
dbData.effect2 = ddsData.configuration().effect2();
|
||||
dbData.flash2 = ddsData.configuration().flash2();
|
||||
|
||||
return dbData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
// Database::TgtTargetAreaAssignment => TargetManagement::TargetAreaAssignment
|
||||
TargetAreaAssignment ObjectTargetAreaAssignment::toDdsData(const Database::TgtTargetAreaAssignment &dbData)
|
||||
{
|
||||
TargetAreaAssignment ddsData;
|
||||
|
||||
ddsData.id(dbData.id);
|
||||
ddsData.name(dbData.name.toStdString());
|
||||
ddsData.areaId(dbData.areaId);
|
||||
ddsData.targetParticipantId(dbData.targetParticipantId);
|
||||
ddsData.isActive(dbData.isActive);
|
||||
|
||||
ShootbackConfiguration conf;
|
||||
conf.interval1(dbData.interval1);
|
||||
conf.effect1(dbData.effect1);
|
||||
conf.flash1(dbData.flash1);
|
||||
conf.interval2(dbData.interval2);
|
||||
conf.effect2(dbData.effect2);
|
||||
conf.flash2(dbData.flash2);
|
||||
ddsData.configuration(conf);
|
||||
|
||||
// init data not in db
|
||||
ddsData.isDeleted(false);
|
||||
ddsData.isUsed(false);
|
||||
|
||||
return ddsData;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------
|
||||
|
||||
} // Namespace TargetManagement
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Handler TargetAreaAssignments (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
|
||||
// Generated
|
||||
#include <TargetManagement/tgt.hpp>
|
||||
#include <TargetManagement/tgt_db.h>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class MainHandler;
|
||||
|
||||
class ObjectTargetAreaAssignment
|
||||
{
|
||||
public:
|
||||
explicit ObjectTargetAreaAssignment(MainHandler *mainHandler);
|
||||
~ObjectTargetAreaAssignment();
|
||||
|
||||
Core::FunctionReplyObject createObject(const TargetAreaAssignment &data);
|
||||
Core::FunctionReplyObject updateObject(const TargetAreaAssignment &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
qint32 getId() const { return m_data.id(); }
|
||||
QString getName() const { return QString::fromStdString(m_data.name()); }
|
||||
const TargetAreaAssignment &getData() const { return m_data; }
|
||||
|
||||
bool isValid() const;
|
||||
bool isUsed() const;
|
||||
Core::FunctionReplyObject setUsed(bool isUsed);
|
||||
|
||||
// convert methods
|
||||
static Database::TgtTargetAreaAssignment toDbData(const TargetAreaAssignment &ddsData); // dds -> db
|
||||
static TargetAreaAssignment toDdsData(const Database::TgtTargetAreaAssignment &dbData); // db -> dds
|
||||
|
||||
protected:
|
||||
void onPublishData();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
TargetAreaAssignment m_data;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Settings for TargetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
class NGLSettingsClass : public NGL::Settings
|
||||
{
|
||||
public:
|
||||
NGLSettingsClass()
|
||||
: NGL::Settings(s_iniFile.isEmpty() ? NGL::findProjectConfigFile() : s_iniFile)
|
||||
{}
|
||||
static void setIniFile(const QString &fn)
|
||||
{
|
||||
s_iniFile = fn;
|
||||
}
|
||||
static QString s_iniFile;
|
||||
};
|
||||
QString NGLSettingsClass::s_iniFile;
|
||||
Q_GLOBAL_STATIC(NGLSettingsClass, s)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
NGL::Settings *Settings::settings()
|
||||
{
|
||||
return s();
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::setIniFile(const QString &ini)
|
||||
{
|
||||
NGLSettingsClass::setIniFile(ini);
|
||||
}
|
||||
|
||||
bool Settings::useL400Targets()
|
||||
{
|
||||
return s()->settings()->value(QStringLiteral("TGT/useL400Targets"), false).toBool();
|
||||
}
|
||||
|
||||
} // namespace TargetManagement
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Settings for TargetManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
NGL::Settings *settings();
|
||||
void setIniFile(const QString &ini);
|
||||
|
||||
bool useL400Targets();
|
||||
}
|
||||
|
||||
} // namespace TargetManagement
|
||||
+733
@@ -0,0 +1,733 @@
|
||||
/**
|
||||
* Controller ShootbackAreas (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
|
||||
#include "shootback_controller.h"
|
||||
#include "object_shootback_area.h"
|
||||
#include "object_shootback_target.h"
|
||||
#include "object_target_area_assignment.h"
|
||||
#include "main_handler.h"
|
||||
|
||||
#include <LtsUtilsCore/outdated_position.h> // isPositionTimeOutdated
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include <ElevationMap/elevation_map.h>
|
||||
#include <ElevationMap/line_of_sight_calculation.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMapIterator>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
// which data can change:
|
||||
// ~static data
|
||||
// - onShootbackArea
|
||||
// - targetAreaAssignment
|
||||
|
||||
// ~dynamic data
|
||||
// - participantPosition
|
||||
// - targetPosition (moving target)
|
||||
|
||||
|
||||
// Step 1: Which participants are in an area?
|
||||
// onParticipantPositionChanged, onShootbackAreaChanged1, onShootbackAreaChanged2
|
||||
// -> updateInternal_participantPerArea (better updateParticipantsPerAreaCont!?)
|
||||
|
||||
// Step 2: updateInternalLos -> updateInternalLosSingleAssignment
|
||||
|
||||
// Step 3: syncExternal -> transfer data to DDS
|
||||
|
||||
//
|
||||
// some helper ease the logging of some data
|
||||
//
|
||||
QString toString(const QSet<int> &cont)
|
||||
{
|
||||
QString ret = QString(QStringLiteral("QSet<int>(%1)")).arg(cont.size());
|
||||
for (auto val : cont)
|
||||
ret += QString(QStringLiteral("(%1)")).arg(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString toString(const std::vector<int> &cont)
|
||||
{
|
||||
QString ret = QString(QStringLiteral("std::vector<int>(%1)")).arg(cont.size());
|
||||
for (auto val : cont)
|
||||
ret += QString(QStringLiteral("(%1)")).arg(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// class ShootbackController
|
||||
//
|
||||
ShootbackController::ShootbackController(MainHandler *mainHandler)
|
||||
: BaseClass(mainHandler)
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_elevationMap(nullptr)
|
||||
, m_losCalculation(nullptr)
|
||||
, m_logger(getLogger("ShootbackController"))
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
ShootbackController::~ShootbackController()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// disconnect external "signals"..
|
||||
disconnect(m_mainHandler->dds()->dtcPpm().get());
|
||||
disconnect(m_handlerShootbackArea.get());
|
||||
|
||||
// the assignments..
|
||||
disconnect(m_handlerTargetAreaAssignment.get());
|
||||
|
||||
delete m_losCalculation;
|
||||
m_losCalculation = nullptr;
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
bool ShootbackController::initLOS(SituationMap::ElevationMap *elevationMap)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START, elevationMap = " << elevationMap
|
||||
<< " isValid = " << elevationMap->isValid();
|
||||
|
||||
if (!elevationMap->isValid())
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " elevationMap not valid -> return";
|
||||
return false;
|
||||
}
|
||||
|
||||
delete m_losCalculation;
|
||||
m_elevationMap = elevationMap;
|
||||
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " m_elevationMap.isValid() =" << m_elevationMap->isValid();
|
||||
m_losCalculation = new SituationMap::LineOfSightCalculation(m_elevationMap);
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ShootbackController::initDds(std::shared_ptr<HandlerShootbackArea> handlerArea,
|
||||
std::shared_ptr<HandlerShootbackTarget> handlerTarget,
|
||||
std::shared_ptr<HandlerTargetAreaAssignment> handlerTargetAreaAssignment)
|
||||
{
|
||||
m_handlerShootbackArea = handlerArea;
|
||||
m_handlerShootbackTarget = handlerTarget;
|
||||
m_handlerTargetAreaAssignment = handlerTargetAreaAssignment;
|
||||
|
||||
// ShootbackArea
|
||||
connect(m_handlerShootbackArea.get(), &HandlerShootbackArea::objectChanged,
|
||||
this, &ShootbackController::onShootbackAreaChanged1, Qt::UniqueConnection);
|
||||
|
||||
m_handlerShootbackArea->objectShootbackAreas([this](const TargetManagement::ObjectShootbackArea & data)
|
||||
{
|
||||
onShootbackAreaChanged2(data);
|
||||
});
|
||||
|
||||
// ShootbackTarget
|
||||
connect(m_handlerShootbackTarget.get(), &HandlerShootbackTarget::objectChanged,
|
||||
this, &ShootbackController::onShootbackTargetChanged, Qt::UniqueConnection);
|
||||
|
||||
// TargetAreaAssignment
|
||||
connect(m_handlerTargetAreaAssignment.get(), &HandlerTargetAreaAssignment::objectChanged,
|
||||
this, &ShootbackController::onTargetAreaAssignmentChanged, Qt::UniqueConnection);
|
||||
|
||||
// finally:
|
||||
|
||||
// PPM:
|
||||
connect(m_mainHandler->dds()->dtcPpm().get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged,
|
||||
this, &ShootbackController::onParticipantPositionChanged, Qt::UniqueConnection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShootbackController::onShootbackAreaChanged1(qint32 areaId, bool removed)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START" << " shootbackAreaId=" << areaId << " removed=" << removed;
|
||||
|
||||
if (removed)
|
||||
{
|
||||
// handle removed area:
|
||||
if (m_participantsPerArea.contains(areaId))
|
||||
{
|
||||
m_participantsPerArea.remove(areaId);
|
||||
updateInternalLos({}, {}, {});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const QHash<int, ObjectShootbackArea *> &areaMap = m_handlerShootbackArea->getObjectMap();
|
||||
auto it = areaMap.find(areaId);
|
||||
if (it == areaMap.end())
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " obj changes, but connot be found" << " shootbackAreaId=" << areaId;
|
||||
return;
|
||||
}
|
||||
onShootbackAreaChanged2(*(it.value()));
|
||||
updateInternalLos({}, {areaId}, {});
|
||||
}
|
||||
|
||||
syncExternal();
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " shootbackAreaId=" << areaId << " removed=" << removed;
|
||||
}
|
||||
|
||||
void ShootbackController::onShootbackAreaChanged2(const TargetManagement::ObjectShootbackArea &area)
|
||||
{
|
||||
const int areaId = area.getId();
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START" << " shootbackAreaId=" << areaId;
|
||||
|
||||
// handle new/modified area and check all participants:
|
||||
const QMap<qint32, ParticipantManagement::ParticipantPosition> &participantPositions =
|
||||
m_mainHandler->dds()->dtcPpm()->participantPositions();
|
||||
for (const ParticipantManagement::ParticipantPosition &posData : participantPositions)
|
||||
{
|
||||
// ToDo: posData relevant???
|
||||
updateInternal_participantPerArea(area, posData);
|
||||
} // for
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " shootbackAreaId=" << areaId;
|
||||
}
|
||||
|
||||
void ShootbackController::onShootbackTargetChanged(qint32 targetId, bool removed)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START" << ", targetId=" << targetId << ", removed=" << removed;
|
||||
|
||||
// Note:
|
||||
// updateInternalLos is not required if (removed == true)
|
||||
// syncExternal depends on m_visibleParticipantsPerAssignment (via visibleParticipantsPerTargetParticipantId)
|
||||
|
||||
if (removed)
|
||||
{
|
||||
// Due to the foreignKey the according assignments should be removed before
|
||||
// to nothing:
|
||||
return;
|
||||
}
|
||||
else
|
||||
updateInternalLos({}, {}, {targetId});
|
||||
syncExternal();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " targetId=" << targetId << " removed=" << removed;
|
||||
}
|
||||
|
||||
void ShootbackController::onTargetAreaAssignmentChanged(qint32 assignmentId, bool removed)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START" << " assignmentId=" << assignmentId << " removed=" << removed;
|
||||
|
||||
// Note:
|
||||
// updateInternalLos is not required on removed == true
|
||||
// syncExternal depends on m_visibleParticipantsPerAssignment (via visibleParticipantsPerTargetParticipantId)
|
||||
|
||||
if (removed)
|
||||
m_visibleParticipantsPerAssignment.remove(assignmentId);
|
||||
else
|
||||
updateInternalLos({assignmentId}, {}, {});
|
||||
syncExternal();
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " assignmentId=" << assignmentId << " removed=" << removed;
|
||||
}
|
||||
|
||||
void ShootbackController::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &posData, DataModification modType)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " participantId changed, participantId=" << posData << " mod=" << modType;
|
||||
|
||||
if (!participantPositionTopicIsValid(posData))
|
||||
{
|
||||
// DEBUG_LOG(m_logger) << LOGFUNCTION << " NOT VALID, participantId=" << posData.participantId();
|
||||
return;
|
||||
}
|
||||
|
||||
const int participantId = posData.participantId();
|
||||
|
||||
bool bIsTarget = false;
|
||||
if (isTarget(participantId, bIsTarget) && bIsTarget)
|
||||
{
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " TARGET, participantId=" << participantId;
|
||||
|
||||
ObjectShootbackTarget *osbTarget = m_handlerShootbackTarget->dataForTargetParticipantId(participantId);
|
||||
if (!osbTarget)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " ObjectShootbackTarget not found for participantId=" << participantId;
|
||||
return;
|
||||
}
|
||||
osbTarget->updateVolatileData(posData.pos());
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " participantId=" << participantId << ", isTarget=" << bIsTarget;
|
||||
|
||||
if ((modType == DataModification::eAdded) || (modType == DataModification::eModified))
|
||||
{
|
||||
// update
|
||||
const QHash<int, ObjectShootbackArea *> &objMap = m_handlerShootbackArea->getObjectMap();
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " objMap.size" << objMap.size();
|
||||
|
||||
QMapIterator< int, QSet<int>> it(m_participantsPerArea);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
DEBUG_LOG(m_logger) << " areaId = " << it.key() << "-> partIdRef VORHERXX" << toString(it.value());
|
||||
}
|
||||
|
||||
for (const auto &area : qAsConst(objMap))
|
||||
{
|
||||
if (area)
|
||||
updateInternal_participantPerArea(*area, posData);
|
||||
} // for
|
||||
|
||||
{
|
||||
QMapIterator<int, QSet<int>> it_inner(m_participantsPerArea);
|
||||
while (it_inner.hasNext())
|
||||
{
|
||||
it_inner.next();
|
||||
DEBUG_LOG(m_logger) << " areaId = " << it_inner.key() << "-> partIdRef NACHHERXX" << toString(it_inner.value());
|
||||
}
|
||||
}
|
||||
|
||||
updateInternalLos({}, {}, {}, participantId);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
removeParticipantFromCont(m_participantsPerArea, participantId);
|
||||
removeParticipantFromCont(m_visibleParticipantsPerAssignment, participantId);
|
||||
}
|
||||
|
||||
syncExternal();
|
||||
}
|
||||
|
||||
|
||||
bool ShootbackController::participantPositionTopicIsValid(const ParticipantManagement::ParticipantPosition &posData)
|
||||
{
|
||||
// maybe add or replace:
|
||||
// (!LtsUtils::isPositionTimeOutdated(ddsHandler->currentPartitionTime(), sampleTime)) &&
|
||||
// participantTypeId // maybe check: typeId -> typeClassId...
|
||||
|
||||
return ((posData.participantId() > 0) &&
|
||||
(posData.partyId() >= 2) && // 0->POOLS ; 1 -> O/C Service ; 2 RED...
|
||||
(!LtsUtils::isPositionTimeOutdated(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch(), posData.sampleTime()))
|
||||
);
|
||||
}
|
||||
|
||||
bool ShootbackController::isTarget(qint32 participantId, bool &bIsTarget) const
|
||||
{
|
||||
// maybe move this code to ppm as convenience!?
|
||||
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> dtcPpm = m_mainHandler->dds()->dtcPpm();
|
||||
if (!dtcPpm)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no dtcPpm, return";
|
||||
return false;
|
||||
}
|
||||
|
||||
const ParticipantManagement::Participant &participant = dtcPpm->participant(participantId);
|
||||
if (participant.id() != participantId)
|
||||
return false;
|
||||
|
||||
const int typeId = participant.typeId();
|
||||
const ParticipantManagement::Type &type = dtcPpm->type(typeId);
|
||||
if (type.id() != typeId)
|
||||
return false;
|
||||
|
||||
const int equipmentTypeId = type.equipmentTypeId();
|
||||
const ParticipantManagement::EquipmentType &eqType = dtcPpm->equipmentType(equipmentTypeId);
|
||||
if (eqType.id() != equipmentTypeId)
|
||||
return false;
|
||||
|
||||
switch (eqType.wmsTypeClass().underlying())
|
||||
{
|
||||
case ParticipantManagement::WmsTypeClass::None:
|
||||
case ParticipantManagement::WmsTypeClass::Building:
|
||||
case ParticipantManagement::WmsTypeClass::Vehicle:
|
||||
case ParticipantManagement::WmsTypeClass::Human:
|
||||
case ParticipantManagement::WmsTypeClass::Airborne:
|
||||
case ParticipantManagement::WmsTypeClass::VehicleMarker:
|
||||
bIsTarget = false;
|
||||
break;
|
||||
case ParticipantManagement::WmsTypeClass::TargetVehicle:
|
||||
case ParticipantManagement::WmsTypeClass::TargetHuman:
|
||||
bIsTarget = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
} // switch
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShootbackController::updateInternal_participantPerArea(const ObjectShootbackArea &area,
|
||||
const ParticipantManagement::ParticipantPosition &posData)
|
||||
{
|
||||
const int areaId = area.getId();
|
||||
const int participantId = posData.participantId();
|
||||
|
||||
bool contains = areaContainsPosition(area, posData);
|
||||
|
||||
QSet<int> &partIdRef = m_participantsPerArea[areaId];
|
||||
bool alreadyInCont = partIdRef.contains(participantId);
|
||||
|
||||
DEBUG_LOG(m_logger) << " areaId = " << area.getId() << " ---> partIdRef VORHER" << toString(partIdRef);
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " "
|
||||
<< " shootbackAreaId=" << areaId
|
||||
<< " shootbackAreaName=" << area.getName()
|
||||
<< " area.position=" << area.getData().position()
|
||||
<< " participantId=" << participantId
|
||||
<< " ParticipantPosition=" << posData
|
||||
<< " contains=" << contains
|
||||
<< " alreadyInCont=" << alreadyInCont;
|
||||
|
||||
if (contains && !alreadyInCont)
|
||||
{
|
||||
// ENTER
|
||||
partIdRef.insert(participantId);
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " ENTER: participantId=" << participantId << " areaId=" << areaId;
|
||||
|
||||
}
|
||||
else if (!contains && alreadyInCont)
|
||||
{
|
||||
// LEAVE
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " ENTER: participantId=" << participantId << " areaId=" << areaId;
|
||||
partIdRef.remove(participantId);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << " areaId = " << area.getId() << " ---> partIdRef NACHER" << toString(partIdRef);
|
||||
}
|
||||
|
||||
bool ShootbackController::areaContainsPosition(const TargetManagement::ObjectShootbackArea &area,
|
||||
const ParticipantManagement::ParticipantPosition &posData)
|
||||
{
|
||||
const ShootbackArea &sbArea = area.getData();
|
||||
const LtsCoordTrans::UtmCoordinate &utmCoordCenter =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(sbArea.position().lon(), sbArea.position().lat());
|
||||
|
||||
double xMin = utmCoordCenter.x - (sbArea.width() / 2.0);
|
||||
double xMax = utmCoordCenter.x + (sbArea.width() / 2.0);
|
||||
double yMin = utmCoordCenter.y - (sbArea.height() / 2.0);
|
||||
double yMax = utmCoordCenter.y + (sbArea.height() / 2.0);
|
||||
|
||||
const LtsCoordTrans::UtmCoordinate &utmCoordParticipant =
|
||||
LtsCoordTrans::UtmCoordinate::fromGeographic(posData.pos().lon(), posData.pos().lat());
|
||||
|
||||
if (
|
||||
(xMin <= utmCoordParticipant.x) && (utmCoordParticipant.x <= xMax) &&
|
||||
(yMin <= utmCoordParticipant.y) && (utmCoordParticipant.y <= yMax)
|
||||
)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ShootbackController::removeParticipantFromCont(QMap<int, QSet<int>> &contRef, int participantId)
|
||||
{
|
||||
// removed
|
||||
QMutableMapIterator<int, QSet<int>>it(contRef);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
QSet<int> &partIdRef = it.value();
|
||||
partIdRef.remove(participantId);
|
||||
}
|
||||
}
|
||||
|
||||
QSet<int> ShootbackController::areasWithParticipant(qint32 participantId) const
|
||||
{
|
||||
QSet<int> relAreaIds;
|
||||
|
||||
QMapIterator<int, QSet<int>>it(m_participantsPerArea);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
const QSet<int> &partIdRef = it.value();
|
||||
if (partIdRef.contains(participantId))
|
||||
relAreaIds.insert(it.key()); // it.key() == areaId
|
||||
}
|
||||
return relAreaIds;
|
||||
}
|
||||
|
||||
QSet<int> ShootbackController::assignmentsWithTargetParticipantId(qint32 targetParticipantId) const
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START" << " targetParticipantId=" << targetParticipantId;
|
||||
|
||||
QSet<int> ret;
|
||||
// all assignments
|
||||
const QHash<int, ObjectTargetAreaAssignment *> &assignmentMap = m_handlerTargetAreaAssignment->getObjectMap();
|
||||
for (ObjectTargetAreaAssignment *targetAreaAssignment : assignmentMap)
|
||||
{
|
||||
if (!targetAreaAssignment)
|
||||
continue;
|
||||
|
||||
if (targetAreaAssignment->getData().targetParticipantId() == targetParticipantId)
|
||||
ret += targetAreaAssignment->getId();
|
||||
} // for
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END" << " areaId=" << targetParticipantId;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool idIsRelevantHelper(const QSet<int> &container, int id)
|
||||
{
|
||||
if (container.isEmpty())
|
||||
return true;
|
||||
return container.contains(id);
|
||||
}
|
||||
|
||||
void ShootbackController::updateInternalLos(const QSet<int> &changingAssignmentIds, // ~static
|
||||
const QSet<int> &changingAreaIds, // ~static
|
||||
const QSet<int> &changingTartgetIds, // ~dynamic
|
||||
int changedParticipantId) // ~dynamic
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " START"
|
||||
<< ", changingAssigmentIds=" << toString(changingAssignmentIds)
|
||||
<< ", changingAreaIds=" << toString(changingAreaIds)
|
||||
<< ", changingTartgetIds=" << toString(changingTartgetIds)
|
||||
<< ", changedParticipantId=" << changedParticipantId;
|
||||
|
||||
// loop over every assignment
|
||||
const QHash<int, ObjectTargetAreaAssignment *> &allAssignments = m_handlerTargetAreaAssignment->getObjectMap();
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " allAssignments.size() " << allAssignments.size();
|
||||
|
||||
for (ObjectTargetAreaAssignment *assignment : allAssignments)
|
||||
{
|
||||
if (!assignment)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " continue, curAssignment " << assignment->getId();
|
||||
continue;
|
||||
}
|
||||
|
||||
// 1. check changingAssigmentIds
|
||||
const int assignmentId = assignment->getId();
|
||||
if (!idIsRelevantHelper(changingAssignmentIds, assignmentId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " continue, curAssignment " << assignment->getId();
|
||||
continue;
|
||||
}
|
||||
|
||||
const TargetAreaAssignment &assignmentData = assignment->getData();
|
||||
|
||||
// 2. check changingAreaIds
|
||||
const int areaId = assignmentData.areaId();
|
||||
if (!idIsRelevantHelper(changingAreaIds, areaId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " continue, curAssignment " << assignment->getId();
|
||||
continue;
|
||||
}
|
||||
|
||||
// 3. check changingTartgetIds
|
||||
const int targetParticpantId = assignmentData.targetParticipantId();
|
||||
const int targetDataId = m_handlerShootbackTarget->targetDataIdForTargetParticipantId(targetParticpantId);
|
||||
if (!idIsRelevantHelper(changingTartgetIds, targetDataId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " continue, curAssignment " << assignment->getId()
|
||||
<< ", changingTartgetIds=" << toString(changingTartgetIds)
|
||||
<< ", targetParticpantId=" << targetParticpantId
|
||||
<< ", targetDataId=" << targetDataId;
|
||||
continue;
|
||||
}
|
||||
|
||||
// 4. check changedParticipantId
|
||||
if (changedParticipantId > 0)
|
||||
{
|
||||
// Note: m_participantsPerArea is up-to-date
|
||||
QSet<int> areasWithPart = areasWithParticipant(changedParticipantId);
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " areasWithPart=" << areasWithPart.size();
|
||||
for (auto curAreaId : qAsConst(areasWithPart))
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " -> curAreaId=" << curAreaId;
|
||||
|
||||
if (!idIsRelevantHelper(areasWithPart, areaId))
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " continue, curAssignment " << assignment->getId();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// real work:
|
||||
// one assignment -> single target, single area, some participants (which are in that single area):
|
||||
|
||||
if (!updateInternalLosSingleAssignment(assignment))
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " updateInternalLosSingleAssignment failed, assignmentId=" << assignment->getId();
|
||||
|
||||
} // for
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END"
|
||||
<< ", changingAssigmentIds=" << changingAssignmentIds.size()
|
||||
<< ", changingAreaIds=" << changingAreaIds.size()
|
||||
<< ", changingTartgetIds=" << changingTartgetIds.size()
|
||||
<< ", changedParticipantId=" << changedParticipantId;
|
||||
}
|
||||
|
||||
bool ShootbackController::updateInternalLosSingleAssignment(ObjectTargetAreaAssignment *assignment)
|
||||
{
|
||||
if (!assignment)
|
||||
return false;
|
||||
const int assignmentId = assignment->getId();
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START, assignmentId=" << assignmentId;
|
||||
|
||||
|
||||
const TargetAreaAssignment &assignmentData = assignment->getData();
|
||||
const int areaId = assignmentData.areaId();
|
||||
const int targetParticipantId = assignmentData.targetParticipantId();
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " START, assignmentId=" << assignmentId
|
||||
<< ", areaId = " << areaId
|
||||
<< ", targetParticipantId = " << targetParticipantId;
|
||||
|
||||
ObjectShootbackArea *area = m_handlerShootbackArea->data(areaId);
|
||||
if (!area)
|
||||
{
|
||||
// The area seems to be removed (no foreignKey area <-> assignment??)
|
||||
// Neverless, for this assignment -> area there are no participants visible:
|
||||
// clear container:
|
||||
m_visibleParticipantsPerAssignment[assignmentId] = {};
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no area for areaId=" << areaId;
|
||||
return false;
|
||||
}
|
||||
|
||||
ObjectShootbackTarget *target = m_handlerShootbackTarget->dataForTargetParticipantId(targetParticipantId);
|
||||
if (!target)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no target for targetParticipantId=" << targetParticipantId;
|
||||
return false;
|
||||
}
|
||||
|
||||
QSet<int> visiPartCont;
|
||||
|
||||
if (m_participantsPerArea.contains(areaId))
|
||||
{
|
||||
QSet<int> &partIdRef = m_participantsPerArea[areaId];
|
||||
for (auto participantId : qAsConst(partIdRef))
|
||||
{
|
||||
// check lineOfSight:
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " check lineOfSight for: assignmentId=" << assignmentId
|
||||
<< ", areaId = " << areaId
|
||||
<< ", targetParticipantId = " << targetParticipantId
|
||||
<< ", participantId=" << participantId;
|
||||
|
||||
// 1 targetGeoPos
|
||||
ShootbackTarget sbTarget = target->getData();
|
||||
const Core::GeoPosition &sbTargetGeoPos = sbTarget.position();
|
||||
|
||||
// 2 participantId -> geoPos:
|
||||
const ParticipantManagement::ParticipantPosition &participantPos =
|
||||
m_mainHandler->dds()->dtcPpm()->participantPosition(participantId);
|
||||
|
||||
if (participantPos.participantId() != participantId)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " no position for participantId=" << participantId;
|
||||
return false;
|
||||
}
|
||||
const Core::GeoPosition &participantGeoPos = participantPos.pos();
|
||||
|
||||
bool visi = lineOfSight(sbTargetGeoPos, participantGeoPos);
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " current targetId = " << target->getId() << " visi = " << visi;
|
||||
|
||||
if (visi)
|
||||
visiPartCont.insert(participantId);
|
||||
else
|
||||
visiPartCont.remove(participantId);
|
||||
} // for
|
||||
|
||||
} // if (m_participantsPerArea.contains(areaId))
|
||||
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " assignmentId = " << assignmentId
|
||||
<< " visiPartCont.size() " << visiPartCont.size();
|
||||
|
||||
// store at member
|
||||
m_visibleParticipantsPerAssignment[assignmentId] = visiPartCont;
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END, assignmentId=" << assignmentId;
|
||||
return true;
|
||||
}
|
||||
|
||||
QSet<int> ShootbackController::visibleParticipantsPerTargetParticipantId(int targetParticipantId)
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START, targetParticipantId = " << targetParticipantId;
|
||||
|
||||
QSet<int> visiPartPerTarget;
|
||||
|
||||
const QSet<int> &assignmentsWithTargetParticipantIdCont = assignmentsWithTargetParticipantId(targetParticipantId);
|
||||
for (auto assignmentId : assignmentsWithTargetParticipantIdCont)
|
||||
{
|
||||
if (m_visibleParticipantsPerAssignment.contains(assignmentId))
|
||||
visiPartPerTarget += m_visibleParticipantsPerAssignment[assignmentId];
|
||||
}
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END, targetParticipantId = " << targetParticipantId
|
||||
<< ", visiPartPerTarget = " << toString(visiPartPerTarget);
|
||||
return visiPartPerTarget;
|
||||
}
|
||||
|
||||
void ShootbackController::syncExternal()
|
||||
{
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " START";
|
||||
|
||||
// loop over all targets
|
||||
const QHash<int, ObjectShootbackTarget *> &allTargets = m_handlerShootbackTarget->getObjectMap();
|
||||
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " allTargets.size() " << allTargets.size();
|
||||
|
||||
for (ObjectShootbackTarget *target : allTargets)
|
||||
{
|
||||
if (!target)
|
||||
continue;
|
||||
|
||||
const QSet<int> &visiPartPerTarget = visibleParticipantsPerTargetParticipantId(target->getTargetParticipantId()); // QSet -> unique and sorted
|
||||
std::vector<int32_t> visiPartPerTargetStd;
|
||||
visiPartPerTargetStd.reserve(visiPartPerTarget.size());
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " targetId " << target->getId() << ", visiPartPerTarget = " << toString(visiPartPerTarget);
|
||||
for (auto id : qAsConst(visiPartPerTarget))
|
||||
visiPartPerTargetStd.push_back(id);
|
||||
|
||||
|
||||
const ShootbackTarget &sbTarget = target->getData();
|
||||
if (visiPartPerTargetStd != sbTarget.visibleParticipants())
|
||||
{
|
||||
// data has changed
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " targetId differ -> updateObject..";
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " visiOld =" << toString(sbTarget.visibleParticipants());
|
||||
INFO_LOG(m_logger) << LOGFUNCTION << " visiNew =" << toString(visiPartPerTargetStd);
|
||||
target->updateVolatileData(visiPartPerTargetStd); // update and publish
|
||||
}
|
||||
} // for
|
||||
|
||||
TRACE_LOG(m_logger) << LOGFUNCTION << " END";
|
||||
}
|
||||
|
||||
|
||||
bool ShootbackController::lineOfSight(const Core::GeoPosition &observerPos, const Core::GeoPosition &targetPos) const
|
||||
{
|
||||
DEBUG_LOG(m_logger) << LOGFUNCTION << " calculate m_losCalculation = " << m_losCalculation
|
||||
<< ", observerPos=" << observerPos
|
||||
<< ", targetPos=" << targetPos;
|
||||
|
||||
if (!m_losCalculation)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " Error: no m_losCalculation";
|
||||
return false;
|
||||
}
|
||||
|
||||
SituationMap::ObserverTargetData observerTarget(Point3D(observerPos.lon(), observerPos.lat(), observerPos.z() + 2.0), // 2.0m als Augenhöhe
|
||||
Point3D(targetPos.lon(), targetPos.lat(), observerPos.z() + 2.0) // 2.0m als Augenhöhe
|
||||
);
|
||||
|
||||
bool success = m_losCalculation->calculate(observerTarget);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
ERROR_LOG(m_logger) << LOGFUNCTION << " calculate failed:"
|
||||
<< " observerPos=" << observerPos
|
||||
<< " targetPos=" << targetPos;
|
||||
return false;
|
||||
}
|
||||
|
||||
const SituationMap::LineOfSightVisibility visi = observerTarget.lineOfSightVisibility();
|
||||
return SituationMap::LineOfSightVisibility::Visible == visi;
|
||||
}
|
||||
|
||||
} // Namespace TargetManagement
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Controller ShootbackAreas (L400)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by N. Thoden, NLE, 06.04.2020
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "handler_shootback_area.h"
|
||||
#include "handler_shootback_target.h"
|
||||
#include "handler_target_area_assignment.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace SituationMap
|
||||
{
|
||||
class LineOfSightCalculation;
|
||||
class ElevationMap;
|
||||
}
|
||||
|
||||
|
||||
namespace TargetManagement
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief The ShootbackController class is created for ShootbackTarget of L400.
|
||||
*/
|
||||
class ShootbackController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
using BaseClass = QObject;
|
||||
|
||||
explicit ShootbackController(MainHandler *mainHandler);
|
||||
virtual ~ShootbackController();
|
||||
|
||||
bool initLOS(SituationMap::ElevationMap *elevationMap);
|
||||
bool initDds(std::shared_ptr<HandlerShootbackArea> handlerArea,
|
||||
std::shared_ptr<HandlerShootbackTarget> handlerTarget,
|
||||
std::shared_ptr<HandlerTargetAreaAssignment> handlerTargetAreaAssignment);
|
||||
|
||||
protected Q_SLOTS:
|
||||
void onShootbackAreaChanged1(qint32 areaId, bool removed);
|
||||
void onShootbackAreaChanged2(const TargetManagement::ObjectShootbackArea &area);
|
||||
|
||||
void onShootbackTargetChanged(qint32 targetId, bool removed);
|
||||
|
||||
void onTargetAreaAssignmentChanged(qint32 assignmentId, bool removed);
|
||||
|
||||
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &posData, DataModification modType);
|
||||
|
||||
protected:
|
||||
bool participantPositionTopicIsValid(const ParticipantManagement::ParticipantPosition &posData);
|
||||
bool isTarget(qint32 participantId, bool &bIsTarget) const;
|
||||
|
||||
void removeParticipantFromCont(QMap<int, QSet<int>> &contRef, int participantId);
|
||||
void updateInternal_participantPerArea(const TargetManagement::ObjectShootbackArea &area,
|
||||
const ParticipantManagement::ParticipantPosition &posData);
|
||||
bool areaContainsPosition(const TargetManagement::ObjectShootbackArea &area,
|
||||
const ParticipantManagement::ParticipantPosition &posData);
|
||||
QSet<int> areasWithParticipant(qint32 participantId) const;
|
||||
QSet<int> assignmentsWithTargetParticipantId(qint32 targetParticipantId) const;
|
||||
|
||||
void updateInternalLos(const QSet<int> &changingAssignmentIds, // ~static
|
||||
const QSet<int> &changingAreaIds, // ~static
|
||||
const QSet<int> &changingTartgetIds, // ~dynamic
|
||||
int changedParticipantId = 0); // ~dynamic
|
||||
|
||||
bool updateInternalLosSingleAssignment(ObjectTargetAreaAssignment *assignment);
|
||||
|
||||
QSet<int> visibleParticipantsPerTargetParticipantId(int targetParticipantId);
|
||||
|
||||
bool lineOfSight(const Core::GeoPosition &observerPos, const Core::GeoPosition &targetPos) const;
|
||||
|
||||
void syncExternal();
|
||||
|
||||
private:
|
||||
MainHandler *m_mainHandler;
|
||||
|
||||
QMap<int, QSet<int>> m_participantsPerArea;
|
||||
QMap<int, QSet<int>> m_visibleParticipantsPerAssignment;
|
||||
|
||||
std::shared_ptr<HandlerShootbackArea> m_handlerShootbackArea;
|
||||
std::shared_ptr<HandlerShootbackTarget> m_handlerShootbackTarget;
|
||||
std::shared_ptr<HandlerTargetAreaAssignment> m_handlerTargetAreaAssignment;
|
||||
|
||||
SituationMap::ElevationMap *m_elevationMap; // do not delete at dtor
|
||||
SituationMap::LineOfSightCalculation *m_losCalculation;
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace TargetManagement
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Export definitions
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-08-04
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
|
||||
#ifndef TGT_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define TGT_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCTGTCOMMON_LIB)
|
||||
# define TGT_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define TGT_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef TGT_CLIENT_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define TGT_CLIENT_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCTGTCLIENT_LIB)
|
||||
# define TGT_CLIENT_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define TGT_CLIENT_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef TGT_SERVER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define TGT_SERVER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCTGTSERVER_LIB)
|
||||
# define TGT_SERVER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define TGT_SERVER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<service namespace="TargetManagement" abbreviation="TGT" procNames="TargetManagement" exerciseDependency="Exercise" groups="ExercisePreparation,ExerciseExecution,ExercisePaused,ExerciseAfterActionReview">
|
||||
<rcs>
|
||||
<Id Id="$Id: ea_export_script.txt 41311 2018-04-23 09:43:45Z ehrlicher $"/>
|
||||
<HeadURL HeadURL="$HeadURL: svn://slssvn/TDS/branches/product/devel/trunk/Lts/Common/CodeGen/ea_export_script.txt $"/>
|
||||
<Author Author="$Author: ehrlicher $"/>
|
||||
</rcs>
|
||||
<operatorRights offset="33"/>
|
||||
<topicTypes>
|
||||
<topicType name="ParticipantsPerArea">
|
||||
<column name="shootbackAreatId" idlType="long"/>
|
||||
<column name="visibleParticipants" idlType="sequence<long>"/>
|
||||
</topicType>
|
||||
<topicType name="ShootbackArea" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="position" idlType="Core::GeoPosition2D"/>
|
||||
<column name="width" idlType="double"/>
|
||||
<column name="height" idlType="double"/>
|
||||
</topicType>
|
||||
<topicType name="ShootbackTarget" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="targetParticipantId" idlType="long"/>
|
||||
<column name="activateLaserDesignation" idlType="boolean"/>
|
||||
<column name="activateLights" idlType="boolean"/>
|
||||
<column name="activatePopupAutomatic" idlType="boolean"/>
|
||||
<column name="hitsToKill" idlType="long"/>
|
||||
<column name="permanentInstalledTarget" idlType="boolean"/>
|
||||
<column name="position" idlType="Core::GeoPosition"/>
|
||||
<column name="visibleParticipants" idlType="sequence<long>"/>
|
||||
</topicType>
|
||||
<topicType name="TargetAreaAssignment" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0" baseValueType="Core::BaseEntity">
|
||||
<column name="areaId" idlType="long"/>
|
||||
<column name="targetParticipantId" idlType="long"/>
|
||||
<column name="isActive" idlType="boolean"/>
|
||||
<column name="configuration" idlType="ShootbackConfiguration"/>
|
||||
</topicType>
|
||||
<topicType name="ShootbackConfiguration">
|
||||
<column name="interval1" idlType="long"/>
|
||||
<column name="flash1" idlType="boolean"/>
|
||||
<column name="effect1" idlType="Effect"/>
|
||||
<column name="interval2" idlType="long"/>
|
||||
<column name="flash2" idlType="boolean"/>
|
||||
<column name="effect2" idlType="Effect"/>
|
||||
</topicType>
|
||||
<topicType name="ConfigureTargetRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="participantId" idlType="long" comment=" "/>
|
||||
<column name="tgtCommand" idlType="TgtCommand"/>
|
||||
<column name="mode" idlType="Mode" isOptional="1"/>
|
||||
<column name="weapon" idlType="long" isOptional="1"/>
|
||||
<column name="parameterSet" idlType="long" isOptional="1"/>
|
||||
</topicType>
|
||||
<topicType name="TargetConfig" isDataObject="1" autosubscribe="1" routeToClient="1" routeToServer="0" routeInReplay="0">
|
||||
<column name="id" idlType="long" isKey="1"/>
|
||||
<column name="participantId" idlType="long"/>
|
||||
<column name="weapon" idlType="long"/>
|
||||
<column name="mode" idlType="Mode"/>
|
||||
<column name="tgtCommand" idlType="TgtCommand"/>
|
||||
</topicType>
|
||||
</topicTypes>
|
||||
<functionTopics>
|
||||
<functionTopic name="ShootbackAreaModify" requestTopicType="ShootbackArea" replyTopicType="Core::FunctionReply" requestTopicName="ShootbackAreaModifyRequest" replyTopicName="ShootbackAreaModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="ConfigureTarget" requestTopicType="ConfigureTargetRequest" replyTopicType="Core::FunctionReply" requestTopicName="ConfigureTargetRequest" replyTopicName="ConfigureTargetReply" routeInReplay="0"/>
|
||||
<functionTopic name="ShootbackAreaRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="ShootbackAreaRemoveRequest" replyTopicName="ShootbackAreaRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="ShootbackTargetModify" requestTopicType="ShootbackTarget" replyTopicType="Core::FunctionReply" requestTopicName="ShootbackTargetModifyRequest" replyTopicName="ShootbackTargetModifyReply" routeInReplay="0"/>
|
||||
<functionTopic name="ShootbackTargetRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="ShootbackTargetRemoveRequest" replyTopicName="ShootbackTargetRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="TargetAreaAssignmentRemove" requestTopicType="Core::RemoveElementRequest" replyTopicType="Core::FunctionReply" requestTopicName="TargetAreaAssignmentRemoveRequest" replyTopicName="TargetAreaAssignmentRemoveReply" routeInReplay="0"/>
|
||||
<functionTopic name="TargetAreaAssignmentModify" requestTopicType="TargetAreaAssignment" replyTopicType="Core::FunctionReply" requestTopicName="TargetAreaAssignmentModifyRequest" replyTopicName="TargetAreaAssignmentModifyReply" routeInReplay="0"/>
|
||||
</functionTopics>
|
||||
<tables>
|
||||
<table name="tgt_effect_type">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
<table name="tgt_shootback_target">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="target_participant_id" datatype="integer"/>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="activate_laser_designation" datatype="boolean"/>
|
||||
<column name="permanent_installed_target" datatype="boolean"/>
|
||||
<column name="activate_lights" datatype="boolean"/>
|
||||
<column name="hits_to_kill" datatype="integer"/>
|
||||
<column name="activate_popup_automatic" datatype="boolean"/>
|
||||
</table>
|
||||
<table name="tgt_shootback_area">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="position" datatype="point_2d"/>
|
||||
<column name="width" datatype="real"/>
|
||||
<column name="height" datatype="real"/>
|
||||
</table>
|
||||
<table name="tgt_target_area_assignment">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
<column name="target_participant_id" datatype="integer"/>
|
||||
<column name="area_id" datatype="integer"/>
|
||||
<column name="is_active" datatype="boolean" default="false"/>
|
||||
<column name="interval1" datatype="integer"/>
|
||||
<column name="flash1" datatype="boolean"/>
|
||||
<column name="effect1" datatype="integer" isForeignKey="1"/>
|
||||
<column name="interval2" datatype="integer"/>
|
||||
<column name="flash2" datatype="boolean"/>
|
||||
<column name="effect2" datatype="integer" isForeignKey="1"/>
|
||||
<foreignKey name="FK_tgt_target_area_assignment_tgt_effect_type_1">
|
||||
<source table="tgt_target_area_assignment" column="effect1"/>
|
||||
<destination table="tgt_effect_type" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_tgt_target_area_assignment_tgt_effect_type_2">
|
||||
<source table="tgt_target_area_assignment" column="effect2"/>
|
||||
<destination table="tgt_effect_type" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="tgt_config">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="participant_id" datatype="integer"/>
|
||||
</table>
|
||||
</tables>
|
||||
<views/>
|
||||
<dbServiceStructs>
|
||||
<serviceStruct name="TgtConfig" table="tgt_config"/>
|
||||
<serviceStruct name="TgtShootbackArea" table="tgt_shootback_area"/>
|
||||
<serviceStruct name="TgtShootbackTarget" table="tgt_shootback_target"/>
|
||||
<serviceStruct name="TgtTargetAreaAssignment" table="tgt_target_area_assignment"/>
|
||||
<table name="tgt_config"/>
|
||||
<table name="tgt_shootback_area"/>
|
||||
<table name="tgt_shootback_target"/>
|
||||
<table name="tgt_target_area_assignment"/>
|
||||
</dbServiceStructs>
|
||||
<enumerations>
|
||||
<enumeration name="Effect" table="tgt_effect_type">
|
||||
<attribute key="NearMiss" value="0"/>
|
||||
<attribute key="MobilityKill" value="1"/>
|
||||
<attribute key="WeaponKill" value="2"/>
|
||||
</enumeration>
|
||||
<enumeration name="Mode">
|
||||
<attribute key="Deactivated" value="0"/>
|
||||
<attribute key="ShootBack" value="1"/>
|
||||
<attribute key="ShootFirst" value="2"/>
|
||||
<attribute key="NoWeapon" value="3"/>
|
||||
</enumeration>
|
||||
<enumeration name="TgtCommand">
|
||||
<attribute key="Unknown" value="0"/>
|
||||
<attribute key="RequestTechnicalState" value="1"/>
|
||||
<attribute key="SetMode" value="2"/>
|
||||
<attribute key="SetWeapon" value="3"/>
|
||||
<attribute key="PlaySound" value="4"/>
|
||||
<attribute key="RequestParameter" value="5"/>
|
||||
<attribute key="SetParameter" value="6"/>
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
</service>
|
||||
Reference in new issue
Block a user