From 50c62c35463b62a3a7acebf9ebe22d44f1c6dca2 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Thu, 19 Feb 2026 12:29:05 +0100 Subject: Log attribute reads to debug console and replace raw C++ types with Qt equivalents Connect QOpcUaNode::attributeRead signal to new handler that logs read results (value or error code) to the debug console via BobinkClient::statusMessage. Add nameFromAttribute() helper. Replace const char* arrays with QLatin1StringView, bare string literals with QStringLiteral, uint with quint32, int with qint32. Rename statusLog to debugLog in Main.qml for consistency. --- src/BobinkClient.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'src/BobinkClient.cpp') diff --git a/src/BobinkClient.cpp b/src/BobinkClient.cpp index e7f6d0d..f8303a3 100644 --- a/src/BobinkClient.cpp +++ b/src/BobinkClient.cpp @@ -9,6 +9,8 @@ #include #include +using namespace Qt::Literals::StringLiterals; + BobinkClient *BobinkClient::s_instance = nullptr; static QString @@ -22,10 +24,11 @@ defaultPkiDir () static void ensurePkiDirs (const QString &base) { - for (const auto *sub : { "own/certs", "own/private", "trusted/certs", - "trusted/crl", "issuers/certs", "issuers/crl" }) + for (const auto sub : + { u"own/certs"_s, u"own/private"_s, u"trusted/certs"_s, + u"trusted/crl"_s, u"issuers/certs"_s, u"issuers/crl"_s }) { - QDir ().mkpath (base + QLatin1Char ('/') + QLatin1String (sub)); + QDir ().mkpath (base + QLatin1Char ('/') + sub); } } @@ -85,19 +88,20 @@ BobinkClient::setupClient () connect (m_client, &QOpcUaClient::errorChanged, this, [this] (QOpcUaClient::ClientError error) { - static const char *names[] - = { "NoError", - "InvalidUrl", - "AccessDenied", - "ConnectionError", - "UnknownError", - "UnsupportedAuthenticationInformation", - "InvalidAuthenticationInformation", - "InvalidEndpointDescription", - "NoMatchingUserIdentityTokenFound", - "UnsupportedSecurityPolicy", - "InvalidPki" }; - int idx = static_cast (error); + static const QLatin1StringView names[] = { + "NoError"_L1, + "InvalidUrl"_L1, + "AccessDenied"_L1, + "ConnectionError"_L1, + "UnknownError"_L1, + "UnsupportedAuthenticationInformation"_L1, + "InvalidAuthenticationInformation"_L1, + "InvalidEndpointDescription"_L1, + "NoMatchingUserIdentityTokenFound"_L1, + "UnsupportedSecurityPolicy"_L1, + "InvalidPki"_L1, + }; + qint32 idx = static_cast (error); if (idx > 0 && idx <= 10) emit connectionError ( QStringLiteral ("Client error: %1").arg (names[idx])); @@ -564,7 +568,7 @@ BobinkClient::handleConnectError (QOpcUaErrorState *errorState) emit connectionError ( QStringLiteral ("Connection error at step %1, code 0x%2") .arg (static_cast (errorState->connectionStep ())) - .arg (static_cast (errorState->errorCode ()), 8, 16, + .arg (static_cast (errorState->errorCode ()), 8, 16, QLatin1Char ('0'))); } } -- cgit v1.2.3