From 6a4ba1bb21eea36a9cded712f77ff34d08bffb29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Rom=C3=A1n?= Date: Mon, 9 Aug 2021 13:07:22 -0700 Subject: [PATCH] feat: add new OPC-UA functions - [system.opcua.addConnection](https://docs.inductiveautomation.com/display/DOC81/system.opcua.addConnection) - [system.opcua.removeConnection](https://docs.inductiveautomation.com/display/DOC81/system.opcua.removeConnection) --- src/system/__init__.py | 4 ++-- src/system/opcua.py | 53 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/system/__init__.py b/src/system/__init__.py index 371de84..6b26b3c 100644 --- a/src/system/__init__.py +++ b/src/system/__init__.py @@ -13,5 +13,5 @@ Scripting section. """ -__version__ = "8.1.7" -__build__ = "2021060314" +__version__ = "8.1.9" +__build__ = "2021080617" diff --git a/src/system/opcua.py b/src/system/opcua.py index a66f106..b170872 100644 --- a/src/system/opcua.py +++ b/src/system/opcua.py @@ -10,7 +10,42 @@ from __future__ import print_function -__all__ = ["callMethod"] +__all__ = ["addConnection", "callMethod", "removeConnection"] + + +def addConnection( + name, + description, + discoveryUrl, + endpointUrl, + securityPolicy, + securityMode, + settings, +): + """Adds a new OPC UA connection. + + Args: + name (str): Name to assign to the new connection. + description (str): Description assigned to the new OPC UA + connection. + discoveryUrl (str): Endpoint URL to use for discovery + services. + endpointUrl (str): Endpoint URL to use for session services. + securityPolicy (str): The name of the SecurityPolicy to use. + securityMode (str): The name of the MessageSecurityMode to + use. + settings (dict): A dictionary of additional settings to apply + to the connection. + """ + print( + name, + description, + discoveryUrl, + endpointUrl, + securityPolicy, + securityMode, + settings, + ) def callMethod(connectionName, objectId, methodId, inputs): @@ -37,3 +72,19 @@ def callMethod(connectionName, objectId, methodId, inputs): """ print(connectionName, objectId, methodId, inputs) return None, None, None + + +def removeConnection(name): + """Removes an OPC UA Connection. + + Args: + name (str): The name of the OPC UA connection to remove. + + Returns: + bool: A boolean value representing whether the function was + able to remove the connection. Returns True if the + connection was successfully removed. Returns False if the + connection was not removed. + """ + print(name) + return True