Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+32
@@ -0,0 +1,32 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
# Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
log4cxx_vsg.props
|
||||
main.cpp
|
||||
main_handler.cpp
|
||||
main_handler.h
|
||||
proxy_emulator.cpp
|
||||
proxy_emulator.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV VulnerabilityStateGenerator ${SRCS} NO_TRANSLATION)
|
||||
|
||||
NGL_TARGET_LINK_LIBRARIES(VulnerabilityStateGenerator
|
||||
Qt5::Core
|
||||
Qt5::Network
|
||||
ddsconnector
|
||||
LtsCommandLineParser
|
||||
nglcoreapplication
|
||||
NGLLogger
|
||||
svcPpmClient
|
||||
svcTabServer
|
||||
LtsCoordTrans
|
||||
)
|
||||
|
||||
NGL_INSTALL_TARGET(VulnerabilityStateGenerator)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_vsg.props DESTINATION bin)
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# DdsView (DataSampleGenerator/DataSampleReceiver)
|
||||
###########################################################
|
||||
|
||||
log4j.logger.TopicDiscoverer=ERROR
|
||||
log4j.logger.TopicDiscoverer.BuiltinSubscriptionListener=ERROR
|
||||
log4j.logger.TopicDiscoverer.BuiltinPublicationListener=ERROR
|
||||
|
||||
log4j.logger.DataSampleReceiver.Initialisation=WARN
|
||||
log4j.logger.DataSampleReceiver.Subscriber=WARN
|
||||
|
||||
log4j.logger.ParticipantDataGenerator.main=INFO
|
||||
log4j.logger.ParticipantDataGenerator.MainHandler=INFO
|
||||
|
||||
log4j.logger.GenericBase=WARN
|
||||
log4j.logger.Generic.DynamicDataWriter=INFO
|
||||
log4j.logger.Generic.DynamicDataReader=INFO
|
||||
log4j.logger.Generic.DataWriter=INFO
|
||||
log4j.logger.Generic.DataReader=INFO
|
||||
log4j.logger.Generic.Subscriber=INFO
|
||||
log4j.logger.Generic.DTC=INFO
|
||||
log4j.logger.Generic.DTS=INFO
|
||||
log4j.logger.DTC=INFO
|
||||
log4j.logger.DTC.SubscriberListener=WARN
|
||||
log4j.logger.DTS=INFO
|
||||
log4j.logger.DDSConnector=INFO
|
||||
log4j.logger.DdsView=DEBUG
|
||||
log4j.logger.DdsView.Subscriber=INFO
|
||||
|
||||
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}_ddsview.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 %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:
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main for VulnerabilityStateGenerator
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <QtNetwork/QNetworkInterface>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include "main_handler.h"
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
CmdLineParser options;
|
||||
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
// Check alle 30 Sekunden
|
||||
app.createLogger("VSG ", "log4cxx_vsg.props");
|
||||
VulnerabilityStateGenerator::MainHandler mainHandler;
|
||||
|
||||
NGL::INGLLogger &logger = app.logger("main");
|
||||
|
||||
int iRet = -1;
|
||||
if (!mainHandler.init(options.domainId(), options.exerciseId()))
|
||||
{
|
||||
ERROR_LOG(logger) << "Could not init MainHandler\n"
|
||||
<< "Please make shure, that the following procs are running:\n"
|
||||
<< "svcParticipantManagement -d " << options.domainId() << " -e 0\n"
|
||||
<< "svcParticipantManagement -d " << options.domainId() << " -e " << options.exerciseId() << "\n"
|
||||
<< "... shutting down";
|
||||
return iRet;
|
||||
}
|
||||
|
||||
STARTUP_LOG(logger);
|
||||
|
||||
iRet = app.exec();
|
||||
|
||||
SHUTDOWN_LOG(logger);
|
||||
|
||||
return iRet;
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
#include "main_handler.h"
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QElapsedTimer>
|
||||
#include "proxy_emulator.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
VulnerabilityStateGenerator::MainHandler::MainHandler(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_domainId(0)
|
||||
, m_exerciseId(0)
|
||||
, m_proxyEmulator(nullptr)
|
||||
, m_genTimer(new QTimer())
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("MainHandler"))
|
||||
{
|
||||
}
|
||||
|
||||
VulnerabilityStateGenerator::MainHandler::~MainHandler()
|
||||
{
|
||||
}
|
||||
|
||||
bool VulnerabilityStateGenerator::MainHandler::init(int32_t domainId, int32_t exerciseId)
|
||||
{
|
||||
m_domainId = domainId;
|
||||
m_exerciseId = exerciseId;
|
||||
|
||||
delete m_proxyEmulator;
|
||||
m_proxyEmulator = nullptr;
|
||||
|
||||
// DdsConnector
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing DdsConnector ...";
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(m_domainId, IDL::PartitionType::Exercise, m_exerciseId));
|
||||
if (!m_ddsConnector->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init DdsConnector";
|
||||
return false;
|
||||
}
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
// dtc
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing PPM DTC ...";
|
||||
m_ppmDtc = ParticipantManagement::Interface::Dtc::create(m_ddsConnector);
|
||||
QThread::msleep(100);
|
||||
if (!m_ppmDtc->enableAll())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init PPM DTC";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
fillMapFromEnum();
|
||||
|
||||
DEBUG_LOG(m_logger) << "m_vsMap.size(): " << m_vsMap.size();
|
||||
|
||||
// ProxyEmulator
|
||||
DEBUG_LOG(m_logger) << "Creating and initializing ProxyEmulator ...";
|
||||
m_proxyEmulator = new ProxyEmulator(m_ddsConnector, this);
|
||||
QThread::msleep(100);
|
||||
if (!m_proxyEmulator->init())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init ProxyEmulator";
|
||||
return false;
|
||||
}
|
||||
|
||||
m_partMap = m_ppmDtc->participants();
|
||||
|
||||
m_proxyEmulator->giveInitState(m_partMap);
|
||||
|
||||
connect(m_genTimer, &QTimer::timeout, this, &MainHandler::setNewState);
|
||||
m_genTimer->start(1000);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void VulnerabilityStateGenerator::MainHandler::quit()
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Are the following procs running?\n"
|
||||
<< "svcParticipantManagement -d " << m_domainId << " -e 0\n"
|
||||
<< "svcParticipantManagement -d " << m_domainId << " -e " << m_exerciseId << "\n"
|
||||
<< "... shutting down";
|
||||
QCoreApplication::exit(-1);
|
||||
}
|
||||
|
||||
|
||||
ProjectDataManagement::VulnerabilityState VulnerabilityStateGenerator::MainHandler::randomVulnerabilityState()
|
||||
{
|
||||
ProjectDataManagement::VulnerabilityState result;
|
||||
|
||||
qsrand(QDateTime::currentMSecsSinceEpoch());
|
||||
unsigned int index = 0;
|
||||
if (m_vsMap.size() > 0)
|
||||
index = qrand() % m_vsMap.size();
|
||||
|
||||
|
||||
return m_vsMap.value(index);
|
||||
|
||||
}
|
||||
|
||||
void VulnerabilityStateGenerator::MainHandler::setNewState()
|
||||
{
|
||||
for (auto it = m_partMap.begin(); it != m_partMap.end(); ++it)
|
||||
{
|
||||
if (it.value().equipmentNumber().is_set() && it.value().equipmentNumber().get() > 0)
|
||||
m_proxyEmulator->publishNewState(randomVulnerabilityState(), it.value());
|
||||
}
|
||||
}
|
||||
|
||||
void VulnerabilityStateGenerator::MainHandler::fillMapFromEnum()
|
||||
{
|
||||
m_vsMap.insert(0, ProjectDataManagement::VulnerabilityState_def::CombatReady);
|
||||
m_vsMap.insert(1, ProjectDataManagement::VulnerabilityState_def::LightDamage);
|
||||
m_vsMap.insert(2, ProjectDataManagement::VulnerabilityState_def::MediumDamage);
|
||||
m_vsMap.insert(3, ProjectDataManagement::VulnerabilityState_def::HeavyDamage);
|
||||
m_vsMap.insert(4, ProjectDataManagement::VulnerabilityState_def::MobilityKill);
|
||||
m_vsMap.insert(5, ProjectDataManagement::VulnerabilityState_def::VisibleMobilityKill);
|
||||
m_vsMap.insert(6, ProjectDataManagement::VulnerabilityState_def::WeaponSystemDamage);
|
||||
m_vsMap.insert(7, ProjectDataManagement::VulnerabilityState_def::VisibleWeaponSystemDamage);
|
||||
m_vsMap.insert(8, ProjectDataManagement::VulnerabilityState_def::CatastrophicKill);
|
||||
m_vsMap.insert(9, ProjectDataManagement::VulnerabilityState_def::TemporarySeverance);
|
||||
m_vsMap.insert(10, ProjectDataManagement::VulnerabilityState_def::NearMiss);
|
||||
m_vsMap.insert(11, ProjectDataManagement::VulnerabilityState_def::HitWithNoEffect);
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main for ParticipantManagement
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
#pragma once
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVector>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ParticipantManagement/ppm_dtc.h>
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <proxy_emulator.h>
|
||||
|
||||
class QTimer;
|
||||
|
||||
namespace VulnerabilityStateGenerator
|
||||
{
|
||||
class MainHandler
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MainHandler(QObject *parent = nullptr);
|
||||
~MainHandler();
|
||||
|
||||
bool init(int32_t domainId, int32_t exerciseId);
|
||||
|
||||
|
||||
private: // methods
|
||||
void quit();
|
||||
ProjectDataManagement::VulnerabilityState randomVulnerabilityState();
|
||||
void fillMapFromEnum();
|
||||
|
||||
private Q_SLOTS:
|
||||
void setNewState();
|
||||
|
||||
|
||||
private: // attributes
|
||||
int32_t m_domainId;
|
||||
int32_t m_exerciseId;
|
||||
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<ParticipantManagement::Interface::Dtc> m_ppmDtc;
|
||||
ProxyEmulator *m_proxyEmulator;
|
||||
QMap<qint32, ProjectDataManagement::VulnerabilityState> m_vsMap;
|
||||
QMap<qint32,ParticipantManagement::Participant> m_partMap;
|
||||
QTimer *m_genTimer;
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ProxyEmulator class emulates FTs of the TetraRadio Proxy to send position data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
|
||||
#include "proxy_emulator.h"
|
||||
#include <QtCore/QDateTime>
|
||||
#include <QtCore/QThread>
|
||||
#include <QPointF>
|
||||
#include <QMap>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
VulnerabilityStateGenerator::ProxyEmulator::ProxyEmulator(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_ddsConnector(ddsConnector)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger(metaObject()->className()))
|
||||
{}
|
||||
|
||||
bool VulnerabilityStateGenerator::ProxyEmulator::init()
|
||||
{
|
||||
m_tabDts = (TrainingAreaBase::Interface::Dts::create(m_ddsConnector));
|
||||
|
||||
DEBUG_LOG(m_logger) << "Initializing TAB DTS ...";
|
||||
if (!m_tabDts->enableAll())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Could not init TAB DTS";
|
||||
return false;
|
||||
}
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VulnerabilityStateGenerator::ProxyEmulator::giveInitState(const QMap<qint32, ParticipantManagement::Participant> &participants)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << participants.size()
|
||||
<< " participants found. Trying to give them init states."
|
||||
;
|
||||
int participantsWithEquipmentNumber = 0;
|
||||
for (auto it = participants.begin(); it != participants.end(); ++it)
|
||||
{
|
||||
const ParticipantManagement::Participant ¤tParticipant = it.value();
|
||||
|
||||
if (currentParticipant.equipmentNumber().is_set())
|
||||
{
|
||||
++participantsWithEquipmentNumber;
|
||||
TrainingAreaBase::EquipmentState state;
|
||||
|
||||
state.equipmentNumber(currentParticipant.equipmentNumber().get());
|
||||
state.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
state.vulnerabilityState(ProjectDataManagement::VulnerabilityState_def::CombatReady);
|
||||
|
||||
m_tabDts->publish(state);
|
||||
}
|
||||
}
|
||||
|
||||
if (participants.size() != participantsWithEquipmentNumber)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "Actually gave "
|
||||
<< participantsWithEquipmentNumber
|
||||
<< " participants an init position, because the rest does not have an equipment number"
|
||||
;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "... done";
|
||||
}
|
||||
}
|
||||
|
||||
void VulnerabilityStateGenerator::ProxyEmulator::publishNewState(ProjectDataManagement::VulnerabilityState newState, ParticipantManagement::Participant participant)
|
||||
{
|
||||
TrainingAreaBase::EquipmentState state;
|
||||
|
||||
state.equipmentNumber(participant.equipmentNumber().get());
|
||||
state.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
state.vulnerabilityState(newState);
|
||||
|
||||
DEBUG_LOG(m_logger) << "participantId: " << participant.id() << ", state: " << newState << ", equipNo: " << participant.equipmentNumber().get();
|
||||
m_tabDts->publish(state);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* The ProxyEmulator class emulates FTs of the TetraRadio Proxy to send position data
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Hannes Baeuerle, SLSE, 2016-08-09
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QVector>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <TrainingAreaBase/tab_dts.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
namespace VulnerabilityStateGenerator
|
||||
{
|
||||
class ProxyEmulator
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProxyEmulator(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector, QObject *parent = nullptr);
|
||||
|
||||
bool init();
|
||||
|
||||
void giveInitState(const QMap<qint32, ParticipantManagement::Participant> &participants);
|
||||
void publishNewState(ProjectDataManagement::VulnerabilityState newState, ParticipantManagement::Participant participant);
|
||||
|
||||
private: // methods
|
||||
|
||||
private: // attributes
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<TrainingAreaBase::Interface::Dts> m_tabDts;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user