int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QCoreApplication::setApplicationName("Kassomat"); QCoreApplication::setApplicationVersion("0.0.1"); QString deviceName = "ttyACM0"; bool headless = false; { QCommandLineParser parser; parser.setApplicationDescription("Kassomat"); parser.addHelpOption(); parser.addVersionOption(); // Add option to select the device name QCommandLineOption deviceNameOption(QStringList() << "n" << "name", QCoreApplication::translate("main", "the <name> of the device to connect to."), QCoreApplication::translate("main", "device name")); parser.addOption(deviceNameOption); // Add option to run headless QCommandLineOption headlessOption("headless", QCoreApplication::translate("main", "run headless")); parser.addOption(headlessOption); // Process the actual command line arguments given by the user parser.process(app); // Evaluate the arguments and set the variables if(parser.isSet(deviceNameOption)) { deviceName = parser.value(deviceNameOption); } headless = parser.isSet(headlessOption); } try { // setup the KassomatController KassomatController kassomatController; kassomatController.setSmartPayoutDevice(deviceName); kassomatController.test(); while (true) { qDebug() << "polling the device now"; kassomatController.poll(); sleep(2); } // setup the DatabaseController DatabaseController databaseController; // initialize the logging QsLogging::Logger& logger = QsLogging::Logger::instance(); //logger.setLoggingLevel(QsLogging::TraceLevel); QsLogging::DestinationPtr destSQL( QsLogging::DestinationPtr(new QsLogDestSQL) ); logger.addDestination(destSQL); //QList<Product *> p; GenericModel<Project> projectlist(databaseController.listProjects(false)); //p = databaseController.listProducts(); //productlist.addItems(p); qmlRegisterType<Product>("db.product",1,0,"productlist"); // QtQuick2ApplicationViewer viewer; // //in .qml files eine variable namens "controller" global verfuegbar machen // viewer.rootContext()->setContextProperty("controller", &kassomatController); // viewer.rootContext()->setContextProperty("projectlist", &projectlist ); // viewer.rootContext()->setContextProperty("database", &databaseController ); // viewer.setMainQmlFile(QStringLiteral("qml/kassomat/main.qml")); // viewer.showExpanded(); QQmlEngine engine; engine.rootContext()->setContextProperty("controller", &kassomatController); engine.rootContext()->setContextProperty("projectlist", &projectlist); engine.rootContext()->setContextProperty("database", &databaseController); if(! headless) { QQmlComponent component(&engine, QUrl::fromLocalFile("./qml/kassomat/main.qml")); component.create(); } return app.exec(); } catch(char const *msg) { qFatal("FATAL Error: %s", msg); return 1; } }
void NodeLauncher<T>::run() { QCoreApplication::setOrganizationName(Settings::ORGANIZATION_NAME); QCoreApplication::setOrganizationDomain(Settings::DOMAIN_NAME); QLoggingCategory::setFilterRules("qt.network.ssl.warning=false"); qsrand(QDateTime::currentMSecsSinceEpoch()); #ifndef Q_OS_ANDROID LogHandler::setLogging(true); #endif opts.setApplicationDescription("Robust real-time communication and control software for robots"); opts.addHelpOption(); opts.addVersionOption(); QCommandLineOption localHostOption(QStringList() << "l" << "local-host", QCoreApplication::translate("main", "Select server host to listen."), QCoreApplication::translate("main", "local-host")); opts.addOption(localHostOption); QCommandLineOption localPortOption(QStringList() << "p" << "local-port", QCoreApplication::translate("main", "Select server port to listen."), QCoreApplication::translate("main", "local-port")); opts.addOption(localPortOption); QCommandLineOption remoteHostOption(QStringList() << "r" << "remote-host", QCoreApplication::translate("main", "Select remote host to target."), QCoreApplication::translate("main", "remote-host")); opts.addOption(remoteHostOption); QCommandLineOption remotePortOption(QStringList() << "o" << "remote-port", QCoreApplication::translate("main", "Select remote port to target."), QCoreApplication::translate("main", "remote-port")); opts.addOption(remotePortOption); QCommandLineOption headlessOption(QStringList() << "h" << "head-less", QCoreApplication::translate("main", "Don't display GUI"), QCoreApplication::translate("main", "head-less")); opts.addOption(headlessOption); // Process the actual command line arguments given by the user QStringList arguments; for(int i=0; i<argc; ++i) { arguments<<argv[i]; } opts.process(arguments); headless=opts.isSet(headlessOption); app=(headless?(new QCoreApplication(argc, argv)):(new QApplication(argc, argv))); //qDebug()<<(headless?"HEADLESS":"GUI ENABLED"); if(nullptr!=app) { start(); QSurfaceFormat format=QSurfaceFormat::defaultFormat(); format.setVersion( OCTOMY_QT_OGL_VERSION_MAJOR, OCTOMY_QT_OGL_VERSION_MINOR ); format.setProfile( QSurfaceFormat::OCTOMY_QT_OGL_SURFACE_PROFILE ); format.setRenderableType( QSurfaceFormat::OpenGL); format.setOption(QSurfaceFormat::DebugContext); format.setDepthBufferSize(24); format.setStencilBufferSize(0); format.setSwapBehavior(QSurfaceFormat::TripleBuffer); format.setSwapInterval(1); QSurfaceFormat::setDefaultFormat(format); Q_INIT_RESOURCE(icons); Q_INIT_RESOURCE(images); Q_INIT_RESOURCE(3d); ret=app->exec(); qDebug()<<QFileInfo( QCoreApplication::applicationFilePath()).fileName() << " done, quitting"; } else { qWarning()<<"ERROR: no app, quitting"; } stop(); }