aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demo/ConnectionPage.qml13
-rw-r--r--demo/Main.qml2
-rw-r--r--src/OpcUaClient.cpp22
-rw-r--r--src/OpcUaMonitoredNode.cpp26
4 files changed, 41 insertions, 22 deletions
diff --git a/demo/ConnectionPage.qml b/demo/ConnectionPage.qml
index ba41246..dda77e1 100644
--- a/demo/ConnectionPage.qml
+++ b/demo/ConnectionPage.qml
@@ -35,8 +35,8 @@ Page {
nameFilters: ["DER certificates (*.der)", "All files (*)"]
title: "Select Certificate"
- onAccepted: certFileField.text = selectedFile.toString().replace(
- "file://", "")
+ onAccepted: certFileField.text = decodeURIComponent(
+ selectedFile.toString().replace("file://", ""))
}
FileDialog {
@@ -46,8 +46,9 @@ Page {
nameFilters: ["Key files (*.pem *.crt)", "All files (*)"]
title: "Select Private Key"
- onAccepted: keyFileField.text = selectedFile.toString().replace(
- "file://", "")
+ onAccepted: keyFileField.text = decodeURIComponent(selectedFile.toString(
+ ).replace(
+ "file://", ""))
}
FolderDialog {
@@ -56,8 +57,8 @@ Page {
currentFolder: "file://" + trustFolderField.text
title: "Select Trust Folder"
- onAccepted: trustFolderField.text = selectedFolder.toString().replace(
- "file://", "")
+ onAccepted: trustFolderField.text = decodeURIComponent(
+ selectedFolder.toString().replace("file://", ""))
}
ColumnLayout {
diff --git a/demo/Main.qml b/demo/Main.qml
index f0f3674..02bc31e 100644
--- a/demo/Main.qml
+++ b/demo/Main.qml
@@ -38,6 +38,8 @@ ApplicationWindow {
function onConnectionError(message) {
debugConsole.appendLog("Connection error: " + message);
connectionPage.autoConnectFailed = true;
+ certTrustDialog.close();
+ keyPasswordDialog.close();
}
function onDiscoveringChanged() {
diff --git a/src/OpcUaClient.cpp b/src/OpcUaClient.cpp
index d212ab2..8835a08 100644
--- a/src/OpcUaClient.cpp
+++ b/src/OpcUaClient.cpp
@@ -173,7 +173,11 @@ OpcUaClient::connectToServer ()
QStringLiteral ("Invalid server URL: %1").arg (m_serverUrl));
return;
}
- m_client->requestEndpoints (url);
+ if (!m_client->requestEndpoints (url))
+ {
+ emit connectionError (
+ QStringLiteral ("Failed to send endpoint request"));
+ }
}
void
@@ -354,11 +358,14 @@ OpcUaClient::handlePasswordRequired (QString keyFilePath, QString *password,
m_keyPassword.clear ();
emit privateKeyPasswordRequired (keyFilePath, previousTryWasInvalid);
- QEventLoop loop;
- m_keyPassLoop = &loop;
- QTimer::singleShot (30000, &loop, &QEventLoop::quit);
- loop.exec ();
- m_keyPassLoop = nullptr;
+ if (m_keyPassword.isEmpty ())
+ {
+ QEventLoop loop;
+ m_keyPassLoop = &loop;
+ QTimer::singleShot (30000, &loop, &QEventLoop::quit);
+ loop.exec ();
+ m_keyPassLoop = nullptr;
+ }
*password = m_keyPassword;
}
@@ -448,7 +455,8 @@ OpcUaClient::doDiscovery ()
QUrl url (m_discoveryUrl);
if (!url.isValid ())
return;
- m_client->findServers (url);
+ if (!m_client->findServers (url))
+ emit statusMessage (QStringLiteral ("Failed to send discovery request"));
}
void
diff --git a/src/OpcUaMonitoredNode.cpp b/src/OpcUaMonitoredNode.cpp
index beec934..1c125fc 100644
--- a/src/OpcUaMonitoredNode.cpp
+++ b/src/OpcUaMonitoredNode.cpp
@@ -132,7 +132,7 @@ OpcUaMonitoredNode::setupNode ()
return;
auto *client = OpcUaClient::instance ();
- if (!client || !client->connected ())
+ if (!client || !client->connected () || !client->opcuaClient ())
return;
m_node = client->opcuaClient ()->node (m_nodeId);
@@ -152,12 +152,14 @@ OpcUaMonitoredNode::setupNode ()
connect (m_node, &QOpcUaNode::disableMonitoringFinished, this,
&OpcUaMonitoredNode::handleDisableMonitoringFinished);
- m_node->readAttributes (
- QOpcUa::NodeAttribute::DisplayName | QOpcUa::NodeAttribute::Description
- | QOpcUa::NodeAttribute::NodeClass | QOpcUa::NodeAttribute::DataType
- | QOpcUa::NodeAttribute::ValueRank
- | QOpcUa::NodeAttribute::ArrayDimensions
- | QOpcUa::NodeAttribute::AccessLevel);
+ if (!m_node->readAttributes (QOpcUa::NodeAttribute::DisplayName
+ | QOpcUa::NodeAttribute::Description
+ | QOpcUa::NodeAttribute::NodeClass
+ | QOpcUa::NodeAttribute::DataType
+ | QOpcUa::NodeAttribute::ValueRank
+ | QOpcUa::NodeAttribute::ArrayDimensions
+ | QOpcUa::NodeAttribute::AccessLevel))
+ qWarning () << "OpcUaMonitoredNode: readAttributes failed for" << m_nodeId;
if (m_monitored)
startMonitoring ();
@@ -195,7 +197,10 @@ OpcUaMonitoredNode::startMonitoring ()
if (!m_node || !m_monitored)
return;
QOpcUaMonitoringParameters params (m_publishingInterval);
- m_node->enableMonitoring (QOpcUa::NodeAttribute::Value, params);
+ if (!m_node->enableMonitoring (QOpcUa::NodeAttribute::Value, params))
+ qWarning ()
+ << "OpcUaMonitoredNode: enableMonitoring failed to dispatch for"
+ << m_nodeId;
}
void
@@ -203,7 +208,10 @@ OpcUaMonitoredNode::stopMonitoring ()
{
if (!m_node)
return;
- m_node->disableMonitoring (QOpcUa::NodeAttribute::Value);
+ if (!m_node->disableMonitoring (QOpcUa::NodeAttribute::Value))
+ qWarning ()
+ << "OpcUaMonitoredNode: disableMonitoring failed to dispatch for"
+ << m_nodeId;
}
/* ======================================