Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
Executable
+31
@@ -0,0 +1,31 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS
|
||||
initialisation.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(HDRS
|
||||
initialisation.h
|
||||
)
|
||||
|
||||
NGL_ADD_EXECUTABLE(AAR SV NO_TRANSLATION tDataSampleGenerator ${SRCS} ${HDRS})
|
||||
NGL_TARGET_LINK_LIBRARIES(tDataSampleGenerator
|
||||
Qt5::Core
|
||||
ddsdts
|
||||
ddsgen
|
||||
ddsconnector
|
||||
svcExmCommon
|
||||
svcPpmCommon
|
||||
ProjectConfig
|
||||
LtsCommandLineParser
|
||||
NGLLogger
|
||||
nglcoreapplication
|
||||
ngltools
|
||||
)
|
||||
NGL_INSTALL_TARGET(tDataSampleGenerator)
|
||||
NGL_INSTALL(AAR SV FILES log4cxx_tdsg.props DESTINATION bin)
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* Initialisation for Publisher
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <DDS/DDSConnector/publisher.h>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ExerciseManagement/exm_enums.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
#include <QVariant>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace DataSampleGenerator
|
||||
{
|
||||
|
||||
Initialisation::Initialisation(int domainId, int exerciseId)
|
||||
: DDSConnector::DdsConnector(domainId, IDL::PartitionType::Exercise, exerciseId)
|
||||
, m_isUsed(0)
|
||||
, m_participantId(222)
|
||||
, m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("DataSampleGenerator.Initialisation"))
|
||||
|
||||
{
|
||||
INFO_LOG(m_logger) << "Initialisation for partition: " << getDefaultPartition();
|
||||
}
|
||||
|
||||
bool Initialisation::init(const QStringList &qosFileList)
|
||||
{
|
||||
if (!DDSConnector::DdsConnector::init(qosFileList))
|
||||
return false;
|
||||
|
||||
// Initialisation publisher
|
||||
initPublisher();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Initialisation::generateTestData(const QString &type)
|
||||
{
|
||||
m_isUsed = !m_isUsed;
|
||||
|
||||
if (type == QLatin1String("ExerciseManagement::Exercise"))
|
||||
{
|
||||
ExerciseManagement::Exercise data;
|
||||
|
||||
data.id(999);
|
||||
data.name("TestExe");
|
||||
data.isUsed(m_isUsed);
|
||||
data.partitionName("Exe999");
|
||||
data.state(ExerciseManagement::ExerciseState::Started);
|
||||
data.isDeleted(false);
|
||||
|
||||
getPublisher()->write(data);
|
||||
|
||||
}
|
||||
else if (type == QLatin1String("ParticipantManagement::ExerciseParticipant"))
|
||||
{
|
||||
ParticipantManagement::Participant data;
|
||||
|
||||
data.id(m_participantId);
|
||||
data.symbol(std::string("231"));
|
||||
//data.relatedUnit(1);
|
||||
|
||||
data.equipmentNumber (1111);
|
||||
|
||||
data.isSimulated(true);
|
||||
data.sampleTime(QDateTime::currentMSecsSinceEpoch());
|
||||
//data.isNBCProtectionActivated(false);
|
||||
|
||||
getPublisher()->write(data);
|
||||
|
||||
data.id(m_participantId+10);
|
||||
getPublisher()->write(data);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WARNING_LOG(m_logger) << "TopicType " << type << " not implemented.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // Namespace DataSampleGenerator
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Initialisation for Publisher
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <dds/dds.hpp>
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
|
||||
namespace NGL {
|
||||
class INGLLogger;
|
||||
}
|
||||
|
||||
namespace DDSConnector
|
||||
{
|
||||
class DdsConnector;
|
||||
class Publisher;
|
||||
}
|
||||
|
||||
namespace DataSampleGenerator
|
||||
{
|
||||
class Initialisation : public DDSConnector::DdsConnector
|
||||
{
|
||||
public:
|
||||
Initialisation(int domainId, int exerciseId);
|
||||
~Initialisation() = default;
|
||||
|
||||
bool init(const QStringList &qosFileList = QStringList()) override final;
|
||||
|
||||
void generateTestData(const QString &type);
|
||||
|
||||
private:
|
||||
// only for testing
|
||||
bool m_isUsed;
|
||||
int m_participantId;
|
||||
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
log4j.reset=true
|
||||
log4j.rootLogger=WARN, file
|
||||
|
||||
# Service: PlayerManagement
|
||||
###########################################################
|
||||
|
||||
log4j.logger.DataSampleGenerator.main=DEBUG
|
||||
log4j.logger.DataSampleGenerator.Initialisation=DEBUG
|
||||
log4j.logger.DataSampleGenerator.PlayerData=INFO
|
||||
log4j.logger.DataSampleGenerator.Settings=DEBUG
|
||||
log4j.logger.DataSampleGenerator.Subscriber=DEBUG
|
||||
log4j.logger.DataSampleGenerator.SubscriberListener=DEBUG
|
||||
#log4j.logger.DataSampleGenerator.SubscriberListener=INFO
|
||||
log4j.logger.DataSampleGenerator.Publisher=INFO
|
||||
#log4j.logger.DataSampleGenerator.Publisher=DEBUG
|
||||
log4j.logger.DataSampleGenerator.PMDataListener=DEBUG
|
||||
log4j.logger.GenericBase=DEBUG
|
||||
log4j.logger.Generic.DataWriter=DEBUG
|
||||
log4j.logger.Generic.DataReader=DEBUG
|
||||
log4j.logger.Generic.TopicSql=DEBUG
|
||||
|
||||
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}_spm.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:
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* main (TopicDataGenerator)
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include "initialisation.h"
|
||||
|
||||
#include <DDS/Generic/generic_base.h>
|
||||
|
||||
#include <ExerciseManagement/exm.hpp>
|
||||
#include <ParticipantManagement/ppm.hpp>
|
||||
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QSet>
|
||||
#include <QThread>
|
||||
#include <QVector>
|
||||
#include <string>
|
||||
|
||||
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("s") << QLatin1String("maxSamples"),
|
||||
QLatin1String("Default: 0 (infinite loop)"),
|
||||
QLatin1String("Max Samples"),
|
||||
QLatin1String("0") } );
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("doType"),
|
||||
QLatin1String("ExerciseManagement::Exercise|Participant::Participant"),
|
||||
QLatin1String("doType"),
|
||||
QLatin1String("ExerciseManagement::Exercise") } );
|
||||
}
|
||||
|
||||
int maxSamples() const { return isSet(QLatin1String("s")) ? value(QLatin1String("s")).toInt() : -1; }
|
||||
|
||||
QString getDoType() const
|
||||
{
|
||||
return value(QLatin1String("t"));
|
||||
}
|
||||
|
||||
bool init()
|
||||
{
|
||||
LtsCommandLineParser::init(false);
|
||||
if (isSet(QLatin1String("h")))
|
||||
{
|
||||
fprintf(stdout, "\ndoType: ExerciseManagement::Exercise\n");
|
||||
fprintf(stdout, "\ndoType: Participant::Participant\n");
|
||||
fprintf(stdout, "\n\n");
|
||||
showHelp();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main ( int argc, char**argv )
|
||||
{
|
||||
NGLCoreApplication app ( argc, argv );
|
||||
app.createLogger("DataSampleGenerator.main", "log4cxx_tdsg.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
// TODO: Use plugins of services
|
||||
const auto doType = options.getDoType();
|
||||
DEBUG_LOG(app.baseLogger()) << "Using doType (" << doType << ")";
|
||||
|
||||
DataSampleGenerator::Initialisation *initTDGen = new DataSampleGenerator::Initialisation(options.domainId(), options.exerciseId());
|
||||
if (!initTDGen->init())
|
||||
{
|
||||
delete initTDGen;
|
||||
return -2;
|
||||
}
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
// if maxSamples == 0 => infinite loop
|
||||
long maxSamples = options.maxSamples();
|
||||
|
||||
int receive_period = 4;
|
||||
for (long i = 0; (maxSamples == 0) || (i < maxSamples) ; ++i)
|
||||
{
|
||||
initTDGen->generateTestData(doType);
|
||||
QThread::sleep(receive_period);
|
||||
}
|
||||
|
||||
delete initTDGen;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user