diff options
| -rw-r--r-- | .gitmodules | 3 | ||||
| -rw-r--r-- | CMakeLists.txt | 11 | ||||
| -rw-r--r-- | Main.qml | 1 | ||||
| m--------- | deps/QtXpl2 | 0 | ||||
| -rw-r--r-- | main.cpp | 98 |
5 files changed, 59 insertions, 54 deletions
diff --git a/.gitmodules b/.gitmodules index 99134b0..ef290a5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "deps/BobinkQtOpcUa"] path = deps/BobinkQtOpcUa url = https://git.tvcloud.fr/BobinkQtOpcUa +[submodule "deps/QtXpl2"] + path = deps/QtXpl2 + url = https://git.tvcloud.fr/QtXpl2 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b0403c..262cf71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ set(QT_QML_GENERATE_QMLLS_INI # and initialized submodules: git submodule update --init --recursive add_subdirectory(deps/BobinkQtOpcUa) +# ── QtXpl2 ──────────────────────────────────────────────────────────────── TCP +# client for the Alchemie XPL2 printhead remote protocol. +add_subdirectory(deps/QtXpl2) + # Ensure the qml/ import directory exists before qmlimportscanner runs file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/qml") @@ -36,7 +40,8 @@ qt_add_qml_module( QML_FILES Main.qml IMPORT_PATH - "${CMAKE_BINARY_DIR}/deps/BobinkQtOpcUa/qml") + "${CMAKE_BINARY_DIR}/deps/BobinkQtOpcUa/qml" + "${CMAKE_BINARY_DIR}/deps/QtXpl2/qml") # Executable goes to bin/ to avoid clashing with the QML module directory set_target_properties( @@ -45,8 +50,8 @@ set_target_properties( # Link against BobinkQtOpcUaplugin (not BobinkQtOpcUa). The "plugin" target # includes the QML type registration needed for `import Bobink`. -target_link_libraries(BobinkQtOpcUaAppTemplate PRIVATE Qt6::Quick - BobinkQtOpcUaplugin) +target_link_libraries(BobinkQtOpcUaAppTemplate + PRIVATE Qt6::Quick BobinkQtOpcUaplugin QtXpl2plugin) # ── Runtime quirks ────────────────────────────────────────────────────────── # BobinkQtOpcUa builds open62541 as a shared library. The QtOpcUa backend plugin @@ -4,6 +4,7 @@ import QtQuick import QtQuick.Controls import Bobink // This should properly integrate with qmlls +import Xpl2 // This should properly integrate with qmlls as well ApplicationWindow { id: root diff --git a/deps/QtXpl2 b/deps/QtXpl2 new file mode 160000 +Subproject 4c50201a2048b7ffcc1b7086c9617112cb54050 @@ -7,78 +7,74 @@ #include <QQmlApplicationEngine> #include <QtQml/QQmlExtensionPlugin> -Q_IMPORT_QML_PLUGIN (BobinkPlugin) +Q_IMPORT_QML_PLUGIN(BobinkPlugin) +Q_IMPORT_QML_PLUGIN(Xpl2Plugin) /** @brief Custom log handler matching open62541 server log format. */ -static void -logHandler (QtMsgType type, const QMessageLogContext &ctx, const QString &msg) -{ +static void logHandler(QtMsgType type, const QMessageLogContext &ctx, + const QString &msg) { // Color only the type/category tag. const char *color = ""; const char *label = "debug"; - switch (type) - { - case QtDebugMsg: - label = "debug"; - break; - case QtInfoMsg: - color = "\x1b[32m"; - label = "info"; - break; - case QtWarningMsg: - color = "\x1b[33m"; - label = "warning"; - break; - case QtCriticalMsg: - color = "\x1b[31m"; - label = "critical"; - break; - case QtFatalMsg: - color = "\x1b[1;31m"; - label = "fatal"; - break; - } + switch (type) { + case QtDebugMsg: + label = "debug"; + break; + case QtInfoMsg: + color = "\x1b[32m"; + label = "info"; + break; + case QtWarningMsg: + color = "\x1b[33m"; + label = "warning"; + break; + case QtCriticalMsg: + color = "\x1b[31m"; + label = "critical"; + break; + case QtFatalMsg: + color = "\x1b[1;31m"; + label = "fatal"; + break; + } // Shorten "qt.opcua.plugins.open62541.sdk.client" → "client". - QLatin1StringView cat (ctx.category ? ctx.category : "default"); - qsizetype dot = cat.lastIndexOf (QLatin1Char ('.')); + QLatin1StringView cat(ctx.category ? ctx.category : "default"); + qsizetype dot = cat.lastIndexOf(QLatin1Char('.')); if (dot >= 0) - cat = cat.sliced (dot + 1); + cat = cat.sliced(dot + 1); // "debug/client", "warning/network", etc. — padded to 20 chars. - QByteArray tag - = QByteArray (label) + '/' + QByteArray (cat.data (), cat.size ()); + QByteArray tag = QByteArray(label) + '/' + QByteArray(cat.data(), cat.size()); // Format UTC offset as "(UTC+0100)" to match open62541 server logs. - QDateTime now = QDateTime::currentDateTime (); - qint32 offset = now.offsetFromUtc (); + QDateTime now = QDateTime::currentDateTime(); + qint32 offset = now.offsetFromUtc(); QChar sign = offset >= 0 ? u'+' : u'-'; - offset = qAbs (offset); - QString ts = now.toString (u"yyyy-MM-dd HH:mm:ss.zzz") - + QStringLiteral (" (UTC%1%2%3)") - .arg (sign) - .arg (offset / 3600, 2, 10, QLatin1Char ('0')) - .arg ((offset % 3600) / 60, 2, 10, QLatin1Char ('0')); + offset = qAbs(offset); + QString ts = now.toString(u"yyyy-MM-dd HH:mm:ss.zzz") + + QStringLiteral(" (UTC%1%2%3)") + .arg(sign) + .arg(offset / 3600, 2, 10, QLatin1Char('0')) + .arg((offset % 3600) / 60, 2, 10, QLatin1Char('0')); - fprintf (stderr, "[%s] %s%-20.*s\x1b[0m %s\n", qPrintable (ts), color, - static_cast<int> (tag.size ()), tag.data (), qPrintable (msg)); + fprintf(stderr, "[%s] %s%-20.*s\x1b[0m %s\n", qPrintable(ts), color, + static_cast<int>(tag.size()), tag.data(), qPrintable(msg)); } -int -main (int argc, char *argv[]) -{ +int main(int argc, char *argv[]) { // Load the locally-built OpcUa backend plugin (open62541). - QCoreApplication::addLibraryPath (QStringLiteral (QTOPCUA_PLUGIN_PATH)); + QCoreApplication::addLibraryPath(QStringLiteral(QTOPCUA_PLUGIN_PATH)); - qInstallMessageHandler (logHandler); + qInstallMessageHandler(logHandler); - QGuiApplication app (argc, argv); + QGuiApplication app(argc, argv); QQmlApplicationEngine engine; - QObject::connect ( + QObject::connect( &engine, &QQmlApplicationEngine::objectCreationFailed, &app, - [] () { QCoreApplication::exit (1); }, Qt::QueuedConnection); + []() { QCoreApplication::exit(1); }, Qt::QueuedConnection); - engine.loadFromModule ("BobinkQtOpcUaAppTemplate", "Main"); - return app.exec (); + engine.loadFromModule("BobinkQtOpcUaAppTemplate", "Main"); + return app.exec(); } |
