Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
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