Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+126
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* Display Panel Simulator main programm; collects commandline options
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Florian Schult, SLSE, 2016-03-18
|
||||
*/
|
||||
|
||||
#include <nglapplication/nglapplication.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
#include <memory>
|
||||
|
||||
#include "displayPanelSimulatorWidget.h"
|
||||
#include "nglsettings.h"
|
||||
#include "cmdlineparser.h"
|
||||
|
||||
/**
|
||||
* Main entry point for program.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
NGLApplication application(argc, argv);
|
||||
|
||||
application.setOrganizationName(QStringLiteral("RME"));
|
||||
application.setApplicationName(QStringLiteral("Dot Matrix Display Simulator"));
|
||||
application.createLogger("DispSim", "log4cxx_displayPanelSimulator.props");
|
||||
|
||||
int ret = -1;
|
||||
|
||||
{
|
||||
std::unique_ptr<CmdLineParser> parser(new CmdLineParser);
|
||||
if (!parser->init())
|
||||
return ret;
|
||||
|
||||
QCommandLineOption modeOption({ QLatin1String("m"), QLatin1String("mode")}, QLatin1String("mode (not valid for use with -c)"), QLatin1String("?"));
|
||||
QCommandLineOption portOption({ QLatin1String("p"), QLatin1String("port")}, QLatin1String("Port(s), comma separated; better be over 9000"), QLatin1String("9000"));
|
||||
QCommandLineOption showPortOption({ QLatin1String("s"), QLatin1String("showport")}, QLatin1String("Set, for showing the portnumbers"));
|
||||
QCommandLineOption countOption({ QLatin1String("c"), QLatin1String("count")}, QLatin1String("Ports added on startport; ignored, when port has multiple"), QLatin1String("-1"));
|
||||
QCommandLineOption windowOption({ QLatin1String("w"), QLatin1String("window")}, QLatin1String("Starts application in window mode (overrides ini)"));
|
||||
QCommandLineOption inifileOption({ QLatin1String("i"), QLatin1String("inifile")}, QLatin1String("Path/Name for saving and loading settings to an .ini File"), QLatin1String("my.ini"));
|
||||
QCommandLineOption graphicOption({ QLatin1String("g"), QLatin1String("graphic")}, QLatin1String("Path/Name for loading a graphic from a .png File"), QLatin1String("rde.ico"));
|
||||
|
||||
parser->addOption(modeOption);
|
||||
parser->addOption(portOption);
|
||||
parser->addOption(showPortOption);
|
||||
parser->addOption(countOption);
|
||||
parser->addOption(windowOption);
|
||||
parser->addOption(inifileOption);
|
||||
parser->addOption(graphicOption);
|
||||
|
||||
parser->addHelpOption();
|
||||
parser->process(application);
|
||||
|
||||
|
||||
// ---------- Getting mode ----------
|
||||
if (parser->isSet(modeOption))
|
||||
parser->setMode(parser->value(modeOption));
|
||||
QString mode = parser->mode();
|
||||
|
||||
|
||||
// ---------- Getting ports ----------
|
||||
QStringList portList = parser->value(portOption).split(QLatin1Char(','));
|
||||
// QStringList portList = parser->port().split(QLatin1Char(','));
|
||||
portList.removeAll(QStringLiteral("0"));
|
||||
QVector<int> portNumbers;
|
||||
|
||||
// ---------- Count ports ----------
|
||||
if (parser->isSet(countOption))
|
||||
{
|
||||
int count = parser->value(countOption).toInt();
|
||||
parser->setPortCount(count);
|
||||
}
|
||||
|
||||
if (portList.count() > 1)
|
||||
{
|
||||
portNumbers.reserve(portList.size());
|
||||
for (const QString &s : qAsConst(portList))
|
||||
portNumbers << s.toInt();
|
||||
}
|
||||
else if (portList.count() == 1 && !portList.first().isEmpty())
|
||||
{
|
||||
portNumbers.reserve(parser->portCount());
|
||||
for (int i = 0; i < parser->portCount(); ++i)
|
||||
portNumbers << (portList[0].toInt() + i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no port given -> use default
|
||||
}
|
||||
|
||||
// ---------- Getting showPort option ----------
|
||||
if (parser->isSet(showPortOption))
|
||||
parser->setShowPort(true);
|
||||
|
||||
// ---------- Getting window option ----------
|
||||
if (parser->isSet(windowOption))
|
||||
parser->setWindow(true);
|
||||
|
||||
|
||||
// ---------- Getting inifile option ----------
|
||||
if (parser->isSet(inifileOption))
|
||||
parser->setIni(parser->value(inifileOption));
|
||||
NGLSettings::instance(parser->ini());
|
||||
|
||||
|
||||
// ---------- Gettings Image Path/Name ----------
|
||||
if (parser->isSet(graphicOption))
|
||||
parser->setImagePath(parser->value(graphicOption));
|
||||
|
||||
NGL::INGLLogger &logger = application.baseLogger();
|
||||
|
||||
STARTUP_LOG(logger);
|
||||
|
||||
std::unique_ptr<DisplayPanelSimulatorWidget> displayPanelWidget(new DisplayPanelSimulatorWidget);
|
||||
|
||||
if (displayPanelWidget->initialize(mode, portNumbers, !parser->windowMode(), parser->showPort(), parser->imagePath()) != 0)
|
||||
exit(-1);
|
||||
|
||||
ret = application.exec();
|
||||
SHUTDOWN_LOG(logger);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user