aboutsummaryrefslogtreecommitdiffstats
path: root/jetting-interface/main.cpp
blob: b88bd37109ac0e6b70872b855ac6673c58296c1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * @file   main.cpp
 * @brief  Entry point for the Jetting Interface demo application.
 */
#include "Xpl2Client.h"

#include <QCommandLineParser>
#include <QGuiApplication>
#include <QQmlApplicationEngine>

#include <QtQml/QQmlExtensionPlugin>
Q_IMPORT_QML_PLUGIN (Xpl2Plugin)

int
main (int argc, char *argv[])
{
  qSetMessagePattern ("JI         [%{time HH:mm:ss.zzz}] %{message}");

  QGuiApplication app (argc, argv);

  QCommandLineParser parser;
  parser.addOption ({ "wire-debug", "Log raw wire TX/RX to dev log" });
  parser.addOption ({ "printheads",
                      "Number of simulated printheads (default 10)", "N",
                      "10" });
  parser.addHelpOption ();
  parser.process (app);

  if (parser.isSet ("wire-debug"))
    Xpl2Client::enableWireDebug ();

  int phCount = qBound (1, parser.value ("printheads").toInt (), 99);

  QQmlApplicationEngine engine;
  engine.setInitialProperties ({ { "demoPhCount", phCount } });
  QObject::connect (
      &engine, &QQmlApplicationEngine::objectCreationFailed, &app,
      [] () { QCoreApplication::exit (1); }, Qt::QueuedConnection);

  engine.loadFromModule ("JettingInterfaceDemo", "Main");
  return app.exec ();
}