Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+174
@@ -0,0 +1,174 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
INCLUDE(MacroRTIDDSGen)
|
||||
INCLUDE(MacroCodeGenIdl)
|
||||
|
||||
SET(xml_FILE gim_service.xml)
|
||||
|
||||
#
|
||||
# --- Library svcGimCommon --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_common
|
||||
gim_export.h
|
||||
logger.cpp
|
||||
logger.h
|
||||
)
|
||||
|
||||
# Generate gim_enums.idl / gim.idl
|
||||
CODEGEN_IDL_SVC(SRCS_common ${xml_FILE})
|
||||
# Generate gim_db_impl.cpp/.h, gim_db.h
|
||||
CODEGEN_DATABASE(SRCS_common ${xml_FILE})
|
||||
|
||||
# Generate *.cpp/*.hpp from idl
|
||||
RTIDDSGEN(SRCS_common gim_enums.idl)
|
||||
RTIDDSGEN(SRCS_common gim.idl)
|
||||
|
||||
# Generate gim_dt[s,c]_types.h, gim_ft[s,c]_types.h
|
||||
CODEGEN_TOPIC_TYPEDEFS(SRCS_common ${xml_FILE})
|
||||
# Generate gim_[d|f]tc.h
|
||||
CODEGEN_CLIENT_TOPICS_IFC(SRCS_common ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcGimCommon SHARED ${SRCS_common})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcGimCommon
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
NGL_TARGET_LINK_LIBRARIES(svcGimCommon
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
ngldb
|
||||
ddscore
|
||||
LtsUtilsCore
|
||||
NGLLogger
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcGimCommon)
|
||||
|
||||
#
|
||||
# --- Library svcGimClient --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_client
|
||||
gim_export.h
|
||||
gim_dtc_impl_custom.cpp
|
||||
gim_dtc_impl_custom.h
|
||||
)
|
||||
# generate gim_[d|f]tc.h, gim_[d|f]tc_impl.[cpp|h]
|
||||
CODEGEN_CLIENT_TOPICS_IMPL(SRCS_client ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV WS svcGimClient SHARED ${SRCS_client})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcGimClient
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcGimClient
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
PUBLIC
|
||||
svcGimCommon
|
||||
ddsftc
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcGimClient)
|
||||
|
||||
#
|
||||
# --- Library svcGimServer --------------------------------------------------------------------------------
|
||||
#
|
||||
SET(SRCS_server
|
||||
gim_export.h
|
||||
)
|
||||
# generate gim_[d|f]ts.h, gim_[d|f]ts_impl.[cpp|h]
|
||||
CODEGEN_SERVER_TOPICS(SRCS_server ${xml_FILE})
|
||||
|
||||
NGL_ADD_LIBRARY(AAR SV svcGimServer SHARED ${SRCS_server})
|
||||
NGL_TARGET_INCLUDE_DIRECTORIES(svcGimServer
|
||||
PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(svcGimServer
|
||||
PRIVATE
|
||||
RTI::nddscpp2
|
||||
ddsconnector
|
||||
ddsfts
|
||||
PUBLIC
|
||||
svcGimCommon
|
||||
ngldb
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcGimServer)
|
||||
|
||||
#
|
||||
# --- Topic Type Plugin --------------------------------------------------------------
|
||||
#
|
||||
CREATE_TOPIC_TYPE_PLUGIN(${xml_FILE})
|
||||
|
||||
#
|
||||
# --- RecordReplayPlugin --------------------------------------------------------------
|
||||
#
|
||||
CREATE_RECORD_REPLAY_PLUGIN(${xml_FILE} SRCS_exe)
|
||||
|
||||
#
|
||||
# --- Executable svcGuezIedManagement (sGIM) -------------------------------------------------
|
||||
#
|
||||
LIST(APPEND SRCS_exe
|
||||
main.cpp
|
||||
main_handler.cpp
|
||||
main_handler.h
|
||||
dds_handler.cpp
|
||||
dds_handler.h
|
||||
settings.cpp
|
||||
settings.h
|
||||
handler_ied.cpp
|
||||
handler_ied.h
|
||||
object_ied.cpp
|
||||
object_ied.h
|
||||
${xml_FILE}
|
||||
)
|
||||
|
||||
# Generate gim.sql, gim.xml
|
||||
CODEGEN_SQL(SRCS_exe ${xml_FILE})
|
||||
|
||||
NGL_ADD_SVC_ICON(SRCS_exe)
|
||||
NGL_ADD_EXECUTABLE(AAR SV svcGuezIedManagement ${SRCS_exe})
|
||||
NGL_TARGET_LINK_LIBRARIES(svcGuezIedManagement
|
||||
Qt5::Core
|
||||
svcCoreClient
|
||||
svcGimCommon
|
||||
svcGimServer
|
||||
svcPpmClient
|
||||
svcTabClient
|
||||
ddsconnector
|
||||
nglsettings
|
||||
ProjectConfig
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
ngltools
|
||||
LtsUtilsCore
|
||||
|
||||
svcEsmServer
|
||||
svcGmpServer
|
||||
svcCodServer
|
||||
)
|
||||
NGL_INSTALL_TARGET(svcGuezIedManagement)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_gim.props DESTINATION bin)
|
||||
NGL_ADD_TARGET_LINK(svcGuezIedManagement sGIM)
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_gim.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# Uncomment if necessary
|
||||
#ADD_SUBDIRECTORY(UnitTests)
|
||||
#ADD_SUBDIRECTORY(ModuleTests)
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Dassow Philipp, SLEA, 2017-07-20
|
||||
*/
|
||||
|
||||
#include "dds_handler.h"
|
||||
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
|
||||
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(" << domainId << ") 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();
|
||||
|
||||
// Pacemaker
|
||||
m_pacemaker = std::make_shared<Core::Pacemaker>(m_ddsConnector);
|
||||
m_topicLockMaster = std::make_shared<Core::TopicLockMaster>(m_ddsConnector);
|
||||
|
||||
m_ddsDts = GuezIedManagement::Interface::Dts::create(m_ddsConnector);
|
||||
m_ddsFts = GuezIedManagement::Interface::Fts::create(m_ddsConnector);
|
||||
|
||||
bool bRet = m_ddsDts->enableAll();
|
||||
INFO_LOG(m_logger) << "Dts initialised";
|
||||
|
||||
bRet &= m_ddsFts->enableAll();
|
||||
INFO_LOG(m_logger) << "Fts initialised";
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
} // Namespace PDM
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* DdsHandler for DDS
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-02
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/Core/topic_lock_master.h>
|
||||
#include <GuezIedManagement/gim_dts.h>
|
||||
#include <GuezIedManagement/gim_fts.h>
|
||||
#include "logger.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class Pacemaker;
|
||||
}
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
class DdsHandler final
|
||||
{
|
||||
public:
|
||||
DdsHandler(int domainId, int exerciseId);
|
||||
~DdsHandler() = default;
|
||||
|
||||
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<GuezIedManagement::Interface::Dts> dts() const { return m_ddsDts; }
|
||||
std::shared_ptr<GuezIedManagement::Interface::Fts> fts() const { return m_ddsFts; }
|
||||
std::shared_ptr<DDSConnector::DdsConnector> dds() const { return m_ddsConnector; }
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<Core::Pacemaker> m_pacemaker;
|
||||
std::shared_ptr<Core::TopicLockMaster> m_topicLockMaster;
|
||||
std::shared_ptr<GuezIedManagement::Interface::Dts> m_ddsDts;
|
||||
std::shared_ptr<GuezIedManagement::Interface::Fts> m_ddsFts;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
|
||||
} // namespace GuezIedManagement
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Custom gim dtc functions (extends aes_dtc_impl.cpp/.h)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#include "gim_dtc_impl_custom.h"
|
||||
#include <DDS/DTC/generic_dtc.h>
|
||||
#include <DDS/Generic/generic_data_reader.h>
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
Ied DtcImplCustom::iedForEquipmentNumber(int equipmentNumber) const
|
||||
{
|
||||
for (const auto &ied : m_iedCont)
|
||||
{
|
||||
if (ied.equipmentNumber() == equipmentNumber)
|
||||
return ied;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
} // Interface
|
||||
} // namespace GuezIedManagement
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Custom gim dtc functions (extends aes_dtc_impl.cpp/.h)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <GuezIedManagement/gim_dtc_impl.h>
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
namespace Interface
|
||||
{
|
||||
class DtcImplCustom final : public Interface::DtcImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
using Interface::DtcImpl::DtcImpl;
|
||||
Ied iedForEquipmentNumber(int equipmentNumber) const override;
|
||||
};
|
||||
} // Interface
|
||||
} // namespace GuezIedManagement
|
||||
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 GIM_COMMON_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define GIM_COMMON_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCGIMCOMMON_LIB)
|
||||
# define GIM_COMMON_EXPORT Q_DECL_EXPORT
|
||||
# ifndef WIN32
|
||||
# ifdef NDDSUSERDllExport
|
||||
# undef NDDSUSERDllExport
|
||||
# endif
|
||||
# define NDDSUSERDllExport Q_DECL_EXPORT
|
||||
# endif
|
||||
# else
|
||||
# define GIM_COMMON_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GIM_CLIENT_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define GIM_CLIENT_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCGIMCLIENT_LIB)
|
||||
# define GIM_CLIENT_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define GIM_CLIENT_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef GIM_SERVER_EXPORT
|
||||
# ifdef BUILD_STATIC_LIBRARIES
|
||||
# define GIM_SERVER_EXPORT
|
||||
# else
|
||||
# if defined(MAKE_SVCGIMSERVER_LIB)
|
||||
# define GIM_SERVER_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define GIM_SERVER_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<service namespace="GuezIedManagement" abbreviation="GIM" procNames="GuezIedManagement" exerciseDependency="Exercise" groups="ExercisePreparation,ExerciseExecution,ExercisePaused,ExerciseAfterActionReview">
|
||||
<rcs>
|
||||
<Id Id="$Id$"/>
|
||||
<HeadURL HeadURL="$HeadURL$"/>
|
||||
<Author Author="$Author$"/>
|
||||
</rcs>
|
||||
<operatorRights offset="3">
|
||||
<guiPlugin name="Pairing" offset="1">
|
||||
<operatorRightGroup name="IED Pairing" description="Edit Pairings">
|
||||
<operatorRight right="PairingEdit" value="1" description="Edit Pairings"/>
|
||||
</operatorRightGroup>
|
||||
</guiPlugin>
|
||||
</operatorRights>
|
||||
<tables>
|
||||
<table name="gim_ied">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="equipment_number" datatype="integer"/>
|
||||
<column name="type_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="remote_trigger" datatype="boolean"/>
|
||||
<column name="switch_trigger" datatype="boolean"/>
|
||||
<column name="light_barrier_trigger" datatype="boolean"/>
|
||||
<column name="taut_wire_trigger" datatype="boolean"/>
|
||||
<column name="explosive_force" datatype="integer"/>
|
||||
<column name="party_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="pairing_state_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="paired_participant_id" datatype="integer" isOptional="1" isForeignKey="1"/>
|
||||
<column name="paired_ops_id" datatype="integer" isOptional="1" isForeignKey="1"/>
|
||||
<column name="tactical_state_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="pyrotechnics" datatype="boolean"/>
|
||||
<column name="batterywarnings" datatype="integer"/>
|
||||
<column name="electronics_error_state_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="pyrotechnics1_error_state_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="pyrotechnics2_error_state_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="pyrotechnics3_error_state_id" datatype="integer" isForeignKey="1"/>
|
||||
<column name="symbol" datatype="text"/>
|
||||
<column name="sample_time" datatype="bigint"/>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_type">
|
||||
<source table="gim_ied" column="type_id"/>
|
||||
<destination table="gim_ied_type" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_tactical_state">
|
||||
<source table="gim_ied" column="tactical_state_id"/>
|
||||
<destination table="gim_ied_tactical_state" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_pairing_state">
|
||||
<source table="gim_ied" column="pairing_state_id"/>
|
||||
<destination table="gim_ied_pairing_state" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_ppm_participant">
|
||||
<source table="gim_ied" column="paired_participant_id"/>
|
||||
<destination service="ParticipantManagement" serviceAbbr="ppm" table="ppm_participant" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_ism_asset">
|
||||
<source table="gim_ied" column="paired_ops_id"/>
|
||||
<destination service="InfrastructureManagement" serviceAbbr="ism" schema="ism" table="ism_asset" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_electronics_error">
|
||||
<source table="gim_ied" column="electronics_error_state_id"/>
|
||||
<destination table="gim_ied_error" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_pyrotechnics1_error">
|
||||
<source table="gim_ied" column="pyrotechnics1_error_state_id"/>
|
||||
<destination table="gim_ied_error" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_pyrotechnics2_error">
|
||||
<source table="gim_ied" column="pyrotechnics2_error_state_id"/>
|
||||
<destination table="gim_ied_error" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_gim_ied_pyrotechnics3_error">
|
||||
<source table="gim_ied" column="pyrotechnics3_error_state_id"/>
|
||||
<destination table="gim_ied_error" column="id"/>
|
||||
</foreignKey>
|
||||
<foreignKey name="FK_gim_ied_ppm_party">
|
||||
<source table="gim_ied" column="party_id"/>
|
||||
<destination service="ParticipantManagement" serviceAbbr="ppm" table="ppm_party" column="id"/>
|
||||
</foreignKey>
|
||||
</table>
|
||||
<table name="gim_ied_error">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
<table name="gim_ied_pairing_state">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
<table name="gim_ied_tactical_state">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
<table name="gim_ied_type">
|
||||
<column name="id" datatype="integer" isPrimaryKey="1">
|
||||
<sequence start="1" increment="1"/>
|
||||
</column>
|
||||
<column name="name" datatype="text"/>
|
||||
</table>
|
||||
</tables>
|
||||
<views/>
|
||||
<dbServiceStructs>
|
||||
<serviceStruct name="GimIed" table="gim_ied"/>
|
||||
<table name="gim_ied"/>
|
||||
</dbServiceStructs>
|
||||
<topicTypes>
|
||||
<topicType name="Ied" isDataObject="1" routeToClient="1" routeToServer="0" routeInReplay="0" recordTopic="1" baseValueType="Core::BaseEntityWithSampleTime">
|
||||
<column name="equipmentNumber" idlType="long"/>
|
||||
<column name="type" idlType="IedType"/>
|
||||
<column name="remoteTrigger" idlType="boolean"/>
|
||||
<column name="switchTrigger" idlType="boolean"/>
|
||||
<column name="lightBarrierTrigger" idlType="boolean"/>
|
||||
<column name="tautWireTrigger" idlType="boolean"/>
|
||||
<column name="explosiveForce" idlType="long"/>
|
||||
<column name="pairingState" idlType="IedPairingState"/>
|
||||
<column name="pairedParticipantId" idlType="long" isOptional="1"/>
|
||||
<column name="pairedOpsId" idlType="long" isOptional="1"/>
|
||||
<column name="partyId" idlType="long"/>
|
||||
<column name="tacticalState" idlType="IedTacticalState"/>
|
||||
<column name="pyrotechnics" idlType="boolean"/>
|
||||
<column name="batteryWarnings" idlType="long"/>
|
||||
<column name="electronicsError" idlType="IedError"/>
|
||||
<column name="pyrotechnics1Error" idlType="IedError"/>
|
||||
<column name="pyrotechnics2Error" idlType="IedError"/>
|
||||
<column name="pyrotechnics3Error" idlType="IedError"/>
|
||||
<column name="symbol" idlType="string"/>
|
||||
</topicType>
|
||||
<topicType name="IedPosition" isDataObject="1" routeToClient="1" routeToServer="0" routeInReplay="0" recordTopic="1" baseValueType="Core::BaseEntityWithSampleTime">
|
||||
<column name="position" idlType="Core::GeoPosition"/>
|
||||
</topicType>
|
||||
<topicType name="PairIedRequest">
|
||||
<column name="id" idlType="long"/>
|
||||
<column name="pairingState" idlType="IedPairingState"/>
|
||||
<column name="pairedParticipantId" idlType="long" isOptional="1"/>
|
||||
<column name="pairedOpsId" idlType="long" isOptional="1"/>
|
||||
</topicType>
|
||||
</topicTypes>
|
||||
<functionTopics>
|
||||
<functionTopic name="PairIed" requestTopicType="PairIedRequest" replyTopicType="Core::FunctionReply" requestTopicName="PairIedRequest" replyTopicName="PairIedReply" routeInReplay="0"/>
|
||||
</functionTopics>
|
||||
<customDtcFunctions>
|
||||
<customDtcFunction>
|
||||
<function name="iedForEquipmentNumber" returns="Ied" isConst="1">
|
||||
<parameter pos="1" name="equipmentNumber" type="int"/>
|
||||
</function>
|
||||
</customDtcFunction>
|
||||
</customDtcFunctions>
|
||||
<enumerations>
|
||||
<enumeration name="IedError" table="gim_ied_error">
|
||||
<attribute key="NoError" value="0"/>
|
||||
<attribute key="DeviceMissing" value="1"/>
|
||||
</enumeration>
|
||||
<enumeration name="IedPairingState" table="gim_ied_pairing_state">
|
||||
<attribute key="NotPaired" value="1"/>
|
||||
<attribute key="PairedToParticipant" value="2"/>
|
||||
<attribute key="PairedToOps" value="3"/>
|
||||
</enumeration>
|
||||
<enumeration name="IedTacticalState" table="gim_ied_tactical_state">
|
||||
<attribute key="NotActive" value="0"/>
|
||||
<attribute key="Active" value="1"/>
|
||||
<attribute key="Defused" value="2"/>
|
||||
<attribute key="TriggeredBySwitch" value="3"/>
|
||||
<attribute key="TriggeredByRemote" value="4"/>
|
||||
<attribute key="TriggeredByLightBarrier" value="5"/>
|
||||
<attribute key="TriggeredByTautWire" value="6"/>
|
||||
<attribute key="TriggeredByControlDevice" value="7"/>
|
||||
<attribute key="Unknown" value="255"/>
|
||||
</enumeration>
|
||||
<enumeration name="IedType" table="gim_ied_type">
|
||||
<attribute key="SuicideIed" value="1"/>
|
||||
<attribute key="IedSmallPyro" value="2"/>
|
||||
<attribute key="IedBigPyro" value="3"/>
|
||||
</enumeration>
|
||||
</enumerations>
|
||||
</service>
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
/**
|
||||
* Handler definition and state IED
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLEA, 2017-07-20
|
||||
*/
|
||||
|
||||
#include "handler_ied.h"
|
||||
#include "object_ied.h"
|
||||
#include "main_handler.h"
|
||||
#include "gim_db.h"
|
||||
|
||||
#include <Proxies/TrainingAreaBase/tab_dtc.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <ngldb/dbtransaction.h>
|
||||
#include <ngldb/nsqlquery.h>
|
||||
|
||||
#include <GuezIedManagement/gim_record_replay_plugin.h>
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
|
||||
HandlerIed::HandlerIed(MainHandler *mainHandler,
|
||||
const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, Interface::Fts::PairIedRequestHandler(ddsHandler->fts())
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_tabDtc(nullptr)
|
||||
, m_ppmDtc(nullptr)
|
||||
, m_db(db)
|
||||
, m_logger(getLogger("HandlerIed"))
|
||||
{}
|
||||
|
||||
HandlerIed::~HandlerIed()
|
||||
{
|
||||
qDeleteAll(m_iedObjMap);
|
||||
m_db = nullptr;
|
||||
m_tabDtc = nullptr;
|
||||
m_ppmDtc = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
}
|
||||
|
||||
bool HandlerIed::init()
|
||||
{
|
||||
// initialize PPM DTC
|
||||
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsHandler->dds());
|
||||
if (!m_ppmDtc->enableParticipantPosition())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "PPM DTC enableParticipantPosition() failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_ppmDtc->enableParticipant())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "PPM DTC enableParticipant() failed.";
|
||||
return false;
|
||||
}
|
||||
if (!m_ppmDtc->enableParty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "PPM DTC enableParty() failed.";
|
||||
return false;
|
||||
}
|
||||
|
||||
QVector<Database::GimIed> dataVec;
|
||||
// read all Ieds from database
|
||||
if (!m_db->select(dataVec))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error reading data from database!";
|
||||
return false;
|
||||
}
|
||||
|
||||
// create Ied objects
|
||||
for (const Database::GimIed &data : qAsConst(dataVec))
|
||||
{
|
||||
ObjectIed *ifs(new ObjectIed(m_ddsHandler, m_db, m_ppmDtc, this));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(data);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
return false;
|
||||
}
|
||||
m_iedObjMap.insert(ifs->getId(), ifs);
|
||||
}
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_exeObjMap.size() = " << m_iedObjMap.size();
|
||||
|
||||
// Initialize RecordReplay to get initial IedPosition
|
||||
RecordReplayPlugin recordReplay;
|
||||
// no ddsconnector - we don't want to publish data here
|
||||
recordReplay.initDtc(nullptr, m_mainHandler->exerciseId());
|
||||
|
||||
NSqlQuery q(m_db->database());
|
||||
recordReplay.readIedPositionAt(q, QDateTime::currentMSecsSinceEpoch());
|
||||
|
||||
// key is sampleTime -> multiMap
|
||||
QMultiMap<qint64, GuezIedManagement::IedPosition> latestPositions = recordReplay.getIedPositionMap();
|
||||
|
||||
DEBUG_LOG(m_logger) << "Starting to read IED positions from record replay. Size: "
|
||||
<< latestPositions.size();
|
||||
|
||||
for (auto it = latestPositions.begin(); it != latestPositions.end(); ++it)
|
||||
{
|
||||
const auto &pos = it.value();
|
||||
ObjectIed *currentIed = m_iedObjMap.value(pos.id());
|
||||
|
||||
if (currentIed == nullptr)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got position for non existing IED-Id: " << pos.id();
|
||||
continue;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "Setting position for IED-Id " << pos.id();
|
||||
currentIed->setPosition(it.value());
|
||||
}
|
||||
|
||||
m_tabDtc = TrainingAreaBase::Interface::Dtc::create(m_ddsHandler->dds());
|
||||
|
||||
if (!m_tabDtc->enableDefinitionIed() ||
|
||||
!m_tabDtc->enableStateIed())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not initialize TraininAreaBase data topic client";
|
||||
return false;
|
||||
}
|
||||
|
||||
connect(m_tabDtc.get(), &TrainingAreaBase::Interface::Dtc::definitionIedChanged,
|
||||
this, &HandlerIed::onDefinitionIed);
|
||||
connect(m_tabDtc.get(), &TrainingAreaBase::Interface::Dtc::stateIedChanged,
|
||||
this, &HandlerIed::onStateIed);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline IedTacticalState toTacticalState(int tacticalState)
|
||||
{
|
||||
switch (tacticalState)
|
||||
{
|
||||
case 0:
|
||||
return IedTacticalState::NotActive;
|
||||
case 1:
|
||||
return IedTacticalState::Active;
|
||||
case 2:
|
||||
return IedTacticalState::Defused;
|
||||
case 3:
|
||||
return IedTacticalState::TriggeredBySwitch;
|
||||
case 4:
|
||||
return IedTacticalState::TriggeredByRemote;
|
||||
case 5:
|
||||
return IedTacticalState::TriggeredByLightBarrier;
|
||||
case 6:
|
||||
return IedTacticalState::TriggeredByTautWire;
|
||||
case 7:
|
||||
return IedTacticalState::TriggeredByControlDevice;
|
||||
case 255:
|
||||
break;
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
return IedTacticalState::Unknown;
|
||||
}
|
||||
|
||||
static void assignBaseData(const TrainingAreaBase::IedBaseData &inData, Database::GimIed &outData)
|
||||
{
|
||||
outData.equipmentNumber = inData.iedId();
|
||||
outData.tacticalStateId = toTacticalState(inData.tacticalState());
|
||||
outData.pyrotechnics = inData.statePyrotechnics();
|
||||
outData.sampleTime = inData.sampleTime();
|
||||
}
|
||||
|
||||
void HandlerIed::onDefinitionIed(const TrainingAreaBase::DefinitionIed &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded && modType != DataModification::eModified)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "onDefinitionIed: " << data;
|
||||
|
||||
Database::GimIed newData;
|
||||
|
||||
assignBaseData(data, newData);
|
||||
newData.typeId = static_cast<IedType::inner_enum>(data.type());
|
||||
newData.remoteTrigger = data.remoteTrigger();
|
||||
newData.switchTrigger = data.switchTrigger();
|
||||
newData.lightBarrierTrigger = data.lightBarrierTrigger();
|
||||
newData.tautWireTrigger = data.tautWireTrigger();
|
||||
newData.explosiveForce = data.explosiveForce();
|
||||
|
||||
if (m_ppmDtc->party(data.partyId()).id() > 0)
|
||||
newData.partyId = data.partyId(); // use party from telegram
|
||||
else
|
||||
newData.partyId = getPartyIdFromParticipantEquipmentNumber(data.equipmentNumber()); // use party from equipmentNumber
|
||||
|
||||
newData.pairingStateId = static_cast<IedPairingState::inner_enum>(data.pairingState());
|
||||
switch (newData.pairingStateId.underlying())
|
||||
{
|
||||
case IedPairingState_def::PairedToParticipant:
|
||||
newData.pairedParticipantId.setValue(data.pairedId().get());
|
||||
break;
|
||||
case IedPairingState_def::PairedToOps:
|
||||
newData.pairedOpsId.setValue(data.pairedId().get());
|
||||
break;
|
||||
case IedPairingState_def::NotPaired:
|
||||
break;
|
||||
}
|
||||
|
||||
// set symbol / sidc
|
||||
// Note:
|
||||
// Special: triggered Ied<Small|Big> has seperate SIDC:
|
||||
// "M25D|CMPL|10014000001103000000"); // SIDC for IED (OHNE ZickZack)
|
||||
// "M25D|CMPL|10014000001103010000"); // SIDC for IED (MIT ZickZack)
|
||||
// ^
|
||||
// | -> Therefore suppress Injury
|
||||
// handled at guez_ied_to_map.cpp and gim_info_dialog.cpp
|
||||
switch (newData.typeId.underlying())
|
||||
{
|
||||
case IedType_def::SuicideIed:
|
||||
newData.symbol = QStringLiteral("AP6D|CMPL|10014000001103040000"); //SIDC for suicide bomber
|
||||
break;
|
||||
case IedType_def::IedSmallPyro:
|
||||
case IedType_def::IedBigPyro:
|
||||
newData.symbol = QStringLiteral("AP6D|CMPL|10014000001103000000"); // SIDC for IED (OHNE ZickZack)
|
||||
break;
|
||||
} // switch
|
||||
|
||||
int id = getIdByEquipmentnumber(newData.equipmentNumber);
|
||||
|
||||
if (m_iedObjMap.contains(id))
|
||||
m_iedObjMap[id]->updateDefinition(newData);
|
||||
else
|
||||
{
|
||||
ObjectIed *ifs(new ObjectIed(m_ddsHandler, m_db, m_ppmDtc, this));
|
||||
Core::FunctionReplyObject ret = ifs->createObject(newData);
|
||||
if (ret.error())
|
||||
{
|
||||
delete ifs;
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
return;
|
||||
}
|
||||
m_iedObjMap.insert(ifs->getId(), ifs);
|
||||
auto it = m_orphanedStateIed.find(data.iedId());
|
||||
if (it != m_orphanedStateIed.end())
|
||||
{
|
||||
auto defState = it.value();
|
||||
m_orphanedStateIed.erase(it);
|
||||
|
||||
defState.tacticalState(data.tacticalState());
|
||||
defState.statePyrotechnics(data.statePyrotechnics());
|
||||
defState.sampleTime(data.sampleTime());
|
||||
onStateIed(defState, DataModification::eAdded);
|
||||
}
|
||||
id = ifs->getId();
|
||||
}
|
||||
|
||||
m_iedObjMap[id]->setPosition(newData.sampleTime, Core::GeoPosition(data.position().lon(), data.position().lat(), 0));
|
||||
}
|
||||
|
||||
static inline IedError toIedError(int err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case 0:
|
||||
return IedError::NoError;
|
||||
case 1:
|
||||
return IedError::DeviceMissing;
|
||||
}
|
||||
Q_ASSERT(false);
|
||||
return IedError::DeviceMissing;
|
||||
}
|
||||
|
||||
void HandlerIed::onStateIed(const TrainingAreaBase::StateIed &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded && modType != DataModification::eModified)
|
||||
return;
|
||||
|
||||
DEBUG_LOG(m_logger) << "onStateIed: " << data;
|
||||
|
||||
// only overwrite state for existing IEDs
|
||||
if (m_iedObjMap.contains(getIdByEquipmentnumber(data.iedId())))
|
||||
{
|
||||
Database::GimIed newData;
|
||||
|
||||
assignBaseData(data, newData);
|
||||
newData.batterywarnings = data.batteryWarnings();
|
||||
newData.electronicsErrorStateId = toIedError(data.errorStateElectronics());
|
||||
newData.pyrotechnics1ErrorStateId = toIedError(data.errorStatePyrotechnics1());
|
||||
newData.pyrotechnics2ErrorStateId = toIedError(data.errorStatePyrotechnics2());
|
||||
newData.pyrotechnics3ErrorStateId = toIedError(data.errorStatePyrotechnics3());
|
||||
|
||||
m_iedObjMap[getIdByEquipmentnumber(newData.equipmentNumber)]->updateState(newData);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << "StateIed without an existing IED - got no DefinitionIED? " << data;
|
||||
m_orphanedStateIed.insert(data.iedId(), data);
|
||||
}
|
||||
}
|
||||
|
||||
void HandlerIed::onPairIedRequest(const rti::core::SampleIdentity &cookie,
|
||||
const PairIedRequest &request)
|
||||
{
|
||||
Core::FunctionReplyObject ret;
|
||||
|
||||
INFO_LOG(m_logger) << "onPairIedRequest id = " << request.id();
|
||||
|
||||
ObjectIed *ifs = m_iedObjMap.value(request.id());
|
||||
if (ifs == nullptr)
|
||||
{
|
||||
ret = Core::FunctionReplyObject(request.id(), tr_lts("dds", "IED with id %1 not found")).arg(request.id());
|
||||
m_ddsHandler->fts()->pairIedReply(cookie, ret);
|
||||
return;
|
||||
}
|
||||
|
||||
Database::GimIed data;
|
||||
data.pairingStateId = request.pairingState();
|
||||
|
||||
switch (request.pairingState().underlying())
|
||||
{
|
||||
case IedPairingState_def::PairedToParticipant:
|
||||
{
|
||||
data.pairedParticipantId.setValue(request.pairedParticipantId().get());
|
||||
data.partyId = m_ppmDtc->participant(request.pairedParticipantId().get()).partyId();
|
||||
break;
|
||||
}
|
||||
case IedPairingState_def::PairedToOps:
|
||||
{
|
||||
data.pairedOpsId.setValue(request.pairedOpsId().get());
|
||||
break;
|
||||
}
|
||||
case IedPairingState_def::NotPaired:
|
||||
break;
|
||||
}
|
||||
|
||||
ret = ifs->updatePairingState(data);
|
||||
if (ret.error())
|
||||
ERROR_LOG(m_logger) << ret();
|
||||
|
||||
m_ddsHandler->fts()->pairIedReply(cookie, ret);
|
||||
}
|
||||
|
||||
int HandlerIed::getIdByEquipmentnumber(const int number) const
|
||||
{
|
||||
for (const auto &obj : m_iedObjMap)
|
||||
{
|
||||
if (obj->getEquipmentnumber() == number)
|
||||
return obj->getId();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int HandlerIed::getPartyIdFromParticipantEquipmentNumber(const int equipmentNumber) const
|
||||
{
|
||||
const QMap<int, ParticipantManagement::Participant> participants = m_ppmDtc->participants();
|
||||
|
||||
for (const auto &participant : participants)
|
||||
{
|
||||
if (participant.equipmentNumber() == equipmentNumber)
|
||||
return participant.partyId();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // Namespace GuezIedManagement
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Handler definition and state IED
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLEA, 2017-07-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Proxies/TrainingAreaBase/tab_dtc.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
#include "gim_fts.h"
|
||||
#include "gim_db.h"
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
class ObjectIed;
|
||||
class MainHandler;
|
||||
class HandlerIed final : public QObject
|
||||
, protected Interface::Fts::PairIedRequestHandler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
HandlerIed(MainHandler *mainHandler,
|
||||
const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
~HandlerIed();
|
||||
|
||||
bool init();
|
||||
|
||||
private slots:
|
||||
void onDefinitionIed(const TrainingAreaBase::DefinitionIed &data, DataModification modType);
|
||||
void onStateIed(const TrainingAreaBase::StateIed &data, DataModification modType);
|
||||
|
||||
private:
|
||||
void onPairIedRequest(const rti::core::SampleIdentity &cookie,
|
||||
const PairIedRequest &request) override;
|
||||
int getIdByEquipmentnumber(const int number) const;
|
||||
int getPartyIdFromParticipantEquipmentNumber(const int equipmentNumber) const;
|
||||
|
||||
private:
|
||||
QMap<int, ObjectIed *> m_iedObjMap;
|
||||
QMap<int, TrainingAreaBase::StateIed> m_orphanedStateIed;
|
||||
MainHandler *m_mainHandler;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dtc> m_tabDtc;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: GUEZ IED Management
|
||||
###########################################################
|
||||
#log4j.logger.GIM=DEBUG
|
||||
#log4j.logger.GIM.main=DEBUG
|
||||
#log4j.logger.GIM.DdsHandler=DEBUG
|
||||
#log4j.logger.GIM.HandlerIed=DEBUG
|
||||
#log4j.logger.GIM.MainHandler=DEBUG
|
||||
#log4j.logger.GIM.ObjectIed=DEBUG
|
||||
#log4j.logger.GIM.HandlerIed=DEBUG
|
||||
|
||||
# Service Codification Management
|
||||
###########################################################
|
||||
#log4j.logger.COD=DEBUG
|
||||
#log4j.logger.COD.DdsHandler=DEBUG
|
||||
#log4j.logger.COD.Initialization=DEBUG
|
||||
#log4j.logger.COD.HandlerCodificationData=DEBUG
|
||||
#log4j.logger.COD.ObjectCodificationData=DEBUG
|
||||
|
||||
# Service Evaluations
|
||||
###########################################################
|
||||
#log4j.logger.EVL=DEBUG
|
||||
#log4j.logger.EVL.DdsHandler=DEBUG
|
||||
#log4j.logger.EVL.Initialization=DEBUG
|
||||
#log4j.logger.EVL.HandlerComment=DEBUG
|
||||
#log4j.logger.EVL.ObjectComment=DEBUG
|
||||
#log4j.logger.EVL.HandlerCriterium=DEBUG
|
||||
#log4j.logger.EVL.ObjectCriterium=DEBUG
|
||||
#log4j.logger.EVL.ObjectEvaluationElement=DEBUG
|
||||
#log4j.logger.EVL.EvlTests=DEBUG
|
||||
|
||||
# Service Effect Show Management
|
||||
###########################################################
|
||||
#log4j.logger.ESM=DEBUG
|
||||
#log4j.logger.ESM.DdsHandler=DEBUG
|
||||
#log4j.logger.ESM.Initialization=DEBUG
|
||||
#log4j.logger.ESM.HandlerAesData=DEBUG
|
||||
#log4j.logger.ESM.ObjectAesData=DEBUG
|
||||
#log4j.logger.ESM.HandlerEffectShow=DEBUG
|
||||
#log4j.logger.ESM.ObjectEffectShow=DEBUG
|
||||
|
||||
# Service Guez Minelayer Processing
|
||||
###########################################################
|
||||
#log4j.logger.GMP=DEBUG
|
||||
#log4j.logger.GMP.DdsHandler=DEBUG
|
||||
#log4j.logger.GMP.Initialization=DEBUG
|
||||
#log4j.logger.GMP.HandlerMinelayerData=DEBUG
|
||||
|
||||
# Appnd_File
|
||||
###########################################################
|
||||
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 GuezIedManagement
|
||||
{
|
||||
|
||||
LOGGER_T getLogger(const char *name)
|
||||
{
|
||||
static const char ns[] = "GIM.";
|
||||
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 GuezIedManagement
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Logging for GuezIedManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include "gim_export.h"
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
using LOGGER_T = NGL::INGLLogger &;
|
||||
|
||||
GIM_COMMON_EXPORT LOGGER_T getLogger(const char *name);
|
||||
inline LOGGER_T getLogger(const QString &loggerName)
|
||||
{
|
||||
return getLogger(loggerName.toUtf8().constData());
|
||||
}
|
||||
} // namespace GuezIedManagement
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main for GuezIedManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
|
||||
#include "main_handler.h"
|
||||
#include "logger.h"
|
||||
#include "settings.h"
|
||||
#include <GuezMinelayerProcessing/settings.h>
|
||||
#include <CodificationManagement/settings.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
|
||||
LtsCommandLineParser::LtsCommandLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
app.createLogger("GIM", options.exerciseId());
|
||||
|
||||
GuezIedManagement::Settings::setIniFile(options.iniFile());
|
||||
GuezMinelayerProcessing::Settings::setIniFile(options.iniFile());
|
||||
CodificationManagement::Settings::setIniFile(options.iniFile());
|
||||
|
||||
int iRet = -3;
|
||||
{
|
||||
std::unique_ptr<GuezIedManagement::MainHandler> mainHandler(new GuezIedManagement::MainHandler);
|
||||
|
||||
if (!mainHandler->init(options.domainId(), options.exerciseId()))
|
||||
return iRet;
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
iRet = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* MainHandler for GuezIedManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow 2017-07-20
|
||||
*/
|
||||
|
||||
#include "main_handler.h"
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
#include <DDS/Core/pacemaker.h>
|
||||
#include <ngldb/db_service_handler.h>
|
||||
#include <CodificationManagement/initialization.h>
|
||||
#include <EffectShowManagement/initialization.h>
|
||||
#include <GuezMinelayerProcessing/initialization.h>
|
||||
|
||||
#include "handler_ied.h"
|
||||
#include "settings.h"
|
||||
|
||||
using namespace GuezIedManagement;
|
||||
|
||||
MainHandler::MainHandler()
|
||||
: m_handlerIed(nullptr)
|
||||
, m_ddsHandler(nullptr)
|
||||
, m_dbHandler(nullptr)
|
||||
, m_codService(nullptr)
|
||||
, m_esmService(nullptr)
|
||||
, m_gmpService(nullptr)
|
||||
, m_exerciseId(0)
|
||||
, m_logger(getLogger("MainHandler"))
|
||||
{}
|
||||
|
||||
MainHandler::~MainHandler()
|
||||
{
|
||||
delete m_codService;
|
||||
delete m_esmService;
|
||||
delete m_gmpService;
|
||||
m_handlerIed = nullptr;
|
||||
m_ddsHandler = nullptr;
|
||||
m_dbHandler = nullptr;
|
||||
}
|
||||
|
||||
bool MainHandler::init(int domainId, int exerciseId)
|
||||
{
|
||||
m_exerciseId = exerciseId;
|
||||
const QString errStr = initInternal(domainId, exerciseId);
|
||||
if (!errStr.isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << errStr;
|
||||
if (m_ddsHandler && m_ddsHandler->pacemaker())
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::StartingError, errStr);
|
||||
return false;
|
||||
}
|
||||
m_ddsHandler->pacemaker()->setNewState(Core::RunningState::Running, errStr);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString MainHandler::initInternal(int domainId, int exerciseId)
|
||||
{
|
||||
// initialize database
|
||||
m_dbHandler = std::make_shared<DbHandler>();
|
||||
if (!m_dbHandler->init(exerciseId, Settings::settings()))
|
||||
return QStringLiteral("Initialisation dbHandler failed.");
|
||||
|
||||
// initialize DDS
|
||||
m_ddsHandler = std::make_shared<DdsHandler>(domainId, exerciseId);
|
||||
if (!m_ddsHandler->init())
|
||||
return QStringLiteral("Initialisation ddsHandler failed.");
|
||||
|
||||
// initialize handler ied
|
||||
m_handlerIed = std::make_shared<HandlerIed>(this, m_ddsHandler, m_dbHandler->db());
|
||||
if (!loadFromDatabase())
|
||||
return QStringLiteral("Initialisation m_handlerIed failed.");
|
||||
|
||||
m_codService = new CodificationManagement::Initialization;
|
||||
if (!m_codService->initialize(m_ddsHandler->dds(), m_dbHandler->db()->database()) ||
|
||||
!m_codService->loadFromDatabase())
|
||||
return QStringLiteral("Can not initialize COD service.");
|
||||
|
||||
m_esmService = new EffectShowManagement::Initialization;
|
||||
if (!m_esmService->initialize(m_ddsHandler->dds(), m_dbHandler->db()->database()) ||
|
||||
!m_esmService->loadFromDatabase())
|
||||
return QStringLiteral("Can not initialize ESM service.");
|
||||
|
||||
m_gmpService = new GuezMinelayerProcessing::Initialization;
|
||||
if (!m_gmpService->initialize(m_ddsHandler->dds()) ||
|
||||
!m_gmpService->loadFromDatabase())
|
||||
return QStringLiteral("Can not initialize GMP service.");
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool MainHandler::loadFromDatabase()
|
||||
{
|
||||
if (!m_ddsHandler || !m_dbHandler || !m_handlerIed)
|
||||
return false;
|
||||
if (!m_handlerIed->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Initialisation HandlerIED failed.";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Philipp Dassow, SLEA, 2017-07-20
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <memory>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "gim_db.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace CodificationManagement
|
||||
{
|
||||
class Initialization;
|
||||
}
|
||||
namespace EffectShowManagement
|
||||
{
|
||||
class Initialization;
|
||||
}
|
||||
namespace GuezMinelayerProcessing
|
||||
{
|
||||
class Initialization;
|
||||
}
|
||||
namespace NGLDB
|
||||
{
|
||||
template <typename DB> class DbServiceHandler;
|
||||
}
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
using DbHandler = NGLDB::DbServiceHandler<DatabaseInterface>;
|
||||
class HandlerIed;
|
||||
class MainHandler
|
||||
{
|
||||
public:
|
||||
MainHandler();
|
||||
~MainHandler();
|
||||
|
||||
bool init(int domainId, int exerciseId);
|
||||
int exerciseId () const { return m_exerciseId; }
|
||||
|
||||
bool loadFromDatabase();
|
||||
|
||||
private:
|
||||
QString initInternal(int domainId, int exerciseId);
|
||||
private:
|
||||
std::shared_ptr<HandlerIed> m_handlerIed;
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DbHandler> m_dbHandler;
|
||||
|
||||
CodificationManagement::Initialization *m_codService;
|
||||
EffectShowManagement::Initialization *m_esmService;
|
||||
GuezMinelayerProcessing::Initialization *m_gmpService;
|
||||
|
||||
int m_exerciseId;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
} // namespace GuezIedProcessing
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
/**
|
||||
* Handler for the HMI language
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* created by Philipp Dassow 2017-07-20
|
||||
*/
|
||||
|
||||
#include "object_ied.h"
|
||||
|
||||
#include <gim.hpp>
|
||||
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
|
||||
ObjectIed::ObjectIed(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_ddsHandler(ddsHandler)
|
||||
, m_db(db)
|
||||
, m_ppmDtc(ppmDtc)
|
||||
, m_logger(getLogger("ObjectIed"))
|
||||
{
|
||||
}
|
||||
|
||||
ObjectIed::~ObjectIed()
|
||||
{
|
||||
m_ddsHandler->dts()->removeIedByKey(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectIed::createObject(const Database::GimIed &data)
|
||||
{
|
||||
m_data = data;
|
||||
if (m_data.id <= 0)
|
||||
{
|
||||
if(!m_db->insert(m_data))
|
||||
{
|
||||
return Core::FunctionReplyObject(0, tr_lts("dds", "Error inserting IED-data into database"));
|
||||
}
|
||||
|
||||
// Id is serial -> will be generated by db => inside m_data after db-insert
|
||||
DEBUG_LOG(m_logger) << "New IED-Id: " << m_data.id;
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "Ied created sucessfully.";
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectIed::updateDefinition(const Database::GimIed &data)
|
||||
{
|
||||
assignBaseData(data);
|
||||
m_data.typeId = data.typeId;
|
||||
m_data.remoteTrigger = data.remoteTrigger;
|
||||
m_data.tautWireTrigger = data.tautWireTrigger;
|
||||
m_data.lightBarrierTrigger = data.lightBarrierTrigger;
|
||||
m_data.switchTrigger = data.switchTrigger;
|
||||
m_data.explosiveForce = data.explosiveForce;
|
||||
m_data.symbol = data.symbol;
|
||||
assignPairingState(data);
|
||||
|
||||
return updateObject();
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectIed::updateState(const Database::GimIed &data)
|
||||
{
|
||||
assignBaseData(data);
|
||||
m_data.batterywarnings = data.batterywarnings;
|
||||
m_data.electronicsErrorStateId = data.electronicsErrorStateId;
|
||||
m_data.pyrotechnics1ErrorStateId = data.pyrotechnics1ErrorStateId;
|
||||
m_data.pyrotechnics2ErrorStateId = data.pyrotechnics2ErrorStateId;
|
||||
m_data.pyrotechnics3ErrorStateId = data.pyrotechnics3ErrorStateId;
|
||||
|
||||
return updateObject();
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectIed::updatePairingState(const Database::GimIed &data)
|
||||
{
|
||||
assignPairingState(data);
|
||||
|
||||
return updateObject();
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectIed::removeObject()
|
||||
{
|
||||
if (!m_db->removeGimIed(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "IED with id %1 can not be removed from DB")).arg(m_data.id);
|
||||
|
||||
if (!m_ddsHandler->dts()->removeIedByKey(m_data.id))
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "IED with id %1 can not be removed from DDS")).arg(m_data.id);
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectIed::setPosition(int64_t sampleTime, const Core::GeoPosition &pos)
|
||||
{
|
||||
setPosition(IedPosition(m_data.id,
|
||||
"IedPosition",
|
||||
false,
|
||||
true,
|
||||
sampleTime,
|
||||
pos));
|
||||
}
|
||||
|
||||
void ObjectIed::setPosition(const IedPosition &position)
|
||||
{
|
||||
m_position = position;
|
||||
publishPosition();
|
||||
}
|
||||
|
||||
void ObjectIed::onPublishData()
|
||||
{
|
||||
GuezIedManagement::Ied ddsData;
|
||||
|
||||
ddsData.id(m_data.id);
|
||||
ddsData.equipmentNumber(m_data.equipmentNumber);
|
||||
ddsData.type(IedType(m_data.typeId));
|
||||
ddsData.remoteTrigger(m_data.remoteTrigger);
|
||||
ddsData.switchTrigger(m_data.switchTrigger);
|
||||
ddsData.lightBarrierTrigger(m_data.lightBarrierTrigger);
|
||||
ddsData.tautWireTrigger(m_data.tautWireTrigger);
|
||||
ddsData.explosiveForce(m_data.explosiveForce);
|
||||
ddsData.partyId(m_data.partyId);
|
||||
ddsData.pairingState(IedPairingState(m_data.pairingStateId));
|
||||
|
||||
switch(ddsData.pairingState().underlying())
|
||||
{
|
||||
case IedPairingState_def::PairedToParticipant:
|
||||
{
|
||||
ddsData.pairedParticipantId().set(m_data.pairedParticipantId.toInt());
|
||||
connect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &ObjectIed::onParticipantPositionChanged, Qt::UniqueConnection);
|
||||
break;
|
||||
}
|
||||
case IedPairingState_def::PairedToOps:
|
||||
{
|
||||
ddsData.pairedOpsId().set(m_data.pairedOpsId.toInt());
|
||||
//todo: connect to ISM for OPS-Position
|
||||
disconnect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &ObjectIed::onParticipantPositionChanged);
|
||||
break;
|
||||
}
|
||||
case IedPairingState_def::NotPaired:
|
||||
{
|
||||
disconnect(m_ppmDtc.get(), &ParticipantManagement::Interface::Dtc::participantPositionChanged, this, &ObjectIed::onParticipantPositionChanged);
|
||||
//todo: disconnect from ISM for OPS-Position
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ddsData.tacticalState(IedTacticalState(m_data.tacticalStateId));
|
||||
ddsData.pyrotechnics(m_data.pyrotechnics);
|
||||
ddsData.batteryWarnings(m_data.batterywarnings);
|
||||
ddsData.electronicsError(IedError(m_data.electronicsErrorStateId));
|
||||
ddsData.pyrotechnics1Error(IedError(m_data.pyrotechnics1ErrorStateId));
|
||||
ddsData.pyrotechnics2Error(IedError(m_data.pyrotechnics2ErrorStateId));
|
||||
ddsData.pyrotechnics3Error(IedError(m_data.pyrotechnics3ErrorStateId));
|
||||
ddsData.symbol(m_data.symbol.toStdString());
|
||||
ddsData.sampleTime(m_data.sampleTime);
|
||||
|
||||
INFO_LOG(m_logger) << "Publish IED-data to dds (" << m_data.id << ") ...";
|
||||
|
||||
if (!m_ddsHandler->dts()->publish(ddsData))
|
||||
ERROR_LOG(m_logger) << "Error publishing IED-data to dds";
|
||||
}
|
||||
|
||||
void ObjectIed::onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType)
|
||||
{
|
||||
if (modType != DataModification::eAdded && modType != DataModification::eModified)
|
||||
return;
|
||||
|
||||
if (data.participantId() == m_data.pairedParticipantId.toInt())
|
||||
setPosition(data.sampleTime(), data.pos());
|
||||
}
|
||||
|
||||
void ObjectIed::assignBaseData(const Database::GimIed &data)
|
||||
{
|
||||
m_data.equipmentNumber = data.equipmentNumber;
|
||||
m_data.tacticalStateId = data.tacticalStateId;
|
||||
m_data.pyrotechnics = data.pyrotechnics;
|
||||
m_data.sampleTime = data.sampleTime;
|
||||
}
|
||||
|
||||
void ObjectIed::assignPairingState(const Database::GimIed &data)
|
||||
{
|
||||
m_data.pairedParticipantId = data.pairedParticipantId;
|
||||
m_data.pairedOpsId = data.pairedOpsId;
|
||||
m_data.partyId = data.partyId;
|
||||
|
||||
switch(data.pairingStateId.underlying())
|
||||
{
|
||||
case IedPairingState_def::PairedToParticipant:
|
||||
{
|
||||
ParticipantManagement::ParticipantPosition position = m_ppmDtc->participantPosition(m_data.pairedParticipantId.toInt());
|
||||
setPosition(position.sampleTime(), position.pos());
|
||||
break;
|
||||
}
|
||||
case IedPairingState_def::PairedToOps:
|
||||
{
|
||||
// todo get Ops-Position
|
||||
break;
|
||||
}
|
||||
case IedPairingState_def::NotPaired:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_data.pairingStateId = data.pairingStateId;
|
||||
}
|
||||
|
||||
Core::FunctionReplyObject ObjectIed::updateObject()
|
||||
{
|
||||
if (!isValid())
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Trying to update an already removed IED object"));
|
||||
|
||||
INFO_LOG(m_logger) << "Trying to updateObject IedData with id = " << m_data.id;
|
||||
|
||||
if (!m_db->update(m_data))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Failed to update IedData with id = " << m_data.id;
|
||||
return Core::FunctionReplyObject(m_data.id, tr_lts("dds", "Error updating IED-data with id %1 in database")).arg(m_data.id);
|
||||
}
|
||||
|
||||
INFO_LOG(m_logger) << "IED-Data changed sucessfully.";
|
||||
|
||||
// Publish Data via DTS
|
||||
onPublishData();
|
||||
|
||||
return Core::FunctionReplyObject(m_data.id);
|
||||
}
|
||||
|
||||
void ObjectIed::publishPosition()
|
||||
{
|
||||
if (!m_ddsHandler->dts()->publish(m_position))
|
||||
ERROR_LOG(m_logger) << "Error publishing IED-position to dds";
|
||||
}
|
||||
|
||||
bool ObjectIed::isValid() const
|
||||
{
|
||||
return m_data.id > 0;
|
||||
}
|
||||
|
||||
} // Namespace GuezIedManagement
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* Exercise object
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include "dds_handler.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include <DDS/Core/function_reply_object.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
|
||||
// Generated
|
||||
#include <GuezIedManagement/gim_db.h>
|
||||
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
class ObjectIed final : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ObjectIed(const std::shared_ptr<DdsHandler> &ddsHandler,
|
||||
const std::shared_ptr<DatabaseInterface> &db,
|
||||
const std::shared_ptr<ParticipantManagement::Interface::Dtc> &ppmDtc,
|
||||
QObject *parent = nullptr);
|
||||
~ObjectIed();
|
||||
|
||||
Core::FunctionReplyObject createObject(const Database::GimIed &data);
|
||||
Core::FunctionReplyObject updateDefinition(const Database::GimIed &data);
|
||||
Core::FunctionReplyObject updateState(const Database::GimIed &data);
|
||||
Core::FunctionReplyObject updatePairingState(const Database::GimIed &data);
|
||||
Core::FunctionReplyObject removeObject();
|
||||
|
||||
int getId() const { return m_data.id; }
|
||||
int getEquipmentnumber() const { return m_data.equipmentNumber; }
|
||||
void setPosition(int64_t sampleTime, const Core::GeoPosition &pos);
|
||||
void setPosition(const IedPosition &position);
|
||||
|
||||
protected slots:
|
||||
void onPublishData();
|
||||
|
||||
private slots:
|
||||
void onParticipantPositionChanged(const ParticipantManagement::ParticipantPosition &data, DataModification modType);
|
||||
|
||||
private:
|
||||
void assignBaseData(const Database::GimIed &data);
|
||||
void assignPairingState(const Database::GimIed &data);
|
||||
Core::FunctionReplyObject updateObject();
|
||||
inline void publishPosition();
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
std::shared_ptr<DdsHandler> m_ddsHandler;
|
||||
std::shared_ptr<DatabaseInterface> m_db;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
Database::GimIed m_data;
|
||||
IedPosition m_position;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Settings for GuezIedManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
#include <nglsettings/nglsettings_settings.h>
|
||||
#include <ngltools/ngltools_filesystem.h>
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
} // namespace GuezIedManagement
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Settings for GuezIedManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <QString>
|
||||
|
||||
namespace NGL
|
||||
{
|
||||
class Settings;
|
||||
}
|
||||
|
||||
namespace GuezIedManagement
|
||||
{
|
||||
namespace Settings
|
||||
{
|
||||
NGL::Settings *settings();
|
||||
void setIniFile(const QString &ini);
|
||||
}
|
||||
|
||||
} // namespace GuezIedManagement
|
||||
Reference in new issue
Block a user