summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Keller <Rainer.Keller@qt.io>2019-04-15 14:27:17 +0200
committerRainer Keller <Rainer.Keller@qt.io>2019-04-17 07:02:24 +0000
commit97afee838172bedfb65c015fe40c3e46f34f4722 (patch)
treeca864960b3d72f96f32340ae57b16649253db592
parent81d3dc2d926e95d807d016d4eb2616b97c11832b (diff)
qml: Provide current endpoint to QML
Change-Id: I30f25e7f044b239e180b38ebebf34a35a86563e1 Reviewed-by: Jannis Völker <jannis.voelker@basyskom.com>
-rw-r--r--src/imports/opcua/opcuaconnection.cpp16
-rw-r--r--src/imports/opcua/opcuaconnection.h3
-rw-r--r--tests/auto/declarative/AbsoluteNodeTest.qml4
3 files changed, 23 insertions, 0 deletions
diff --git a/src/imports/opcua/opcuaconnection.cpp b/src/imports/opcua/opcuaconnection.cpp
index b309848..7d62e25 100644
--- a/src/imports/opcua/opcuaconnection.cpp
+++ b/src/imports/opcua/opcuaconnection.cpp
@@ -156,6 +156,14 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \qmlproperty QOpcUaEndpointDescription Connection::currentEndpoint
+ \since 5.13
+
+ An endpoint description of the server to which the connection is connected to.
+ When the connection is not established, an empty endpoint description is returned.
+*/
+
+/*!
\qmlsignal Connection::readNodeAttributesFinished(readResults)
Emitted when the read request, started using \l readNodeAttributes(), is finished.
@@ -322,6 +330,14 @@ QStringList OpcUaConnection::namespaces() const
return m_client->namespaceArray();
}
+QOpcUaEndpointDescription OpcUaConnection::currentEndpoint() const
+{
+ if (!m_client || !m_connected)
+ return QOpcUaEndpointDescription();
+
+ return m_client->endpoint();
+}
+
void OpcUaConnection::setAuthenticationInformation(const QOpcUaAuthenticationInformation &authenticationInformation)
{
if (!m_client)
diff --git a/src/imports/opcua/opcuaconnection.h b/src/imports/opcua/opcuaconnection.h
index 452f875..29590ca 100644
--- a/src/imports/opcua/opcuaconnection.h
+++ b/src/imports/opcua/opcuaconnection.h
@@ -60,6 +60,7 @@ class OpcUaConnection : public QObject
Q_PROPERTY(QOpcUaAuthenticationInformation authenticationInformation READ authenticationInformation WRITE setAuthenticationInformation)
Q_PROPERTY(QStringList supportedSecurityPolicies READ supportedSecurityPolicies CONSTANT)
Q_PROPERTY(QJSValue supportedUserTokenTypes READ supportedUserTokenTypes CONSTANT)
+ Q_PROPERTY(QOpcUaEndpointDescription currentEndpoint READ currentEndpoint)
public:
OpcUaConnection(QObject *parent = nullptr);
@@ -72,6 +73,8 @@ public:
bool isDefaultConnection() const;
QStringList namespaces() const;
+ QOpcUaEndpointDescription currentEndpoint() const;
+
QOpcUaAuthenticationInformation authenticationInformation() const;
Q_INVOKABLE bool readNodeAttributes(const QJSValue &value);
diff --git a/tests/auto/declarative/AbsoluteNodeTest.qml b/tests/auto/declarative/AbsoluteNodeTest.qml
index ceb8581..05cd905 100644
--- a/tests/auto/declarative/AbsoluteNodeTest.qml
+++ b/tests/auto/declarative/AbsoluteNodeTest.qml
@@ -95,6 +95,10 @@ Item {
compare(node1.status, QtOpcUa.Node.Status.Valid);
tryCompare(node1, "monitored", true);
compare(node1.publishingInterval, 100.0);
+
+ compare(connection.currentEndpoint.endpointUrl, "opc.tcp://localhost:43344/");
+ compare(connection.currentEndpoint.securityPolicy, "http://opcfoundation.org/UA/SecurityPolicy#None");
+ compare(connection.currentEndpoint.server.applicationUri, "urn:unconfigured:application");
}
QtOpcUa.ValueNode {