OPC_UA I/O Interface for OPC UA compliant devices

Interface: OPC_UA
Revision: 24.11.10
Date: 2026-04-09

General

This page provides the documentation of the HALCON OPC UA interface. Only interface-specific parameters and features are described here. For general information of the operators for I/O interfaces please have a look at the HALCON Operator Reference.
Registered customers can download the latest revision of this interface from the MVTec WWW server.

System Requirements

Interface Versioning

MVTec interfaces for digital I/O and image acquisition are always compatible to a range of HALCON versions. Therefore, the versioning scheme both describes the compatibility of the interface and also the revision of the interface itself. An interface version always consists of three numbers, separated by dots, i.e. 18.11.5. The first two numbers describe the minimum HALCON version the interface is compatible with. For the example version 18.11.5 this means that the interface is compatible with all HALCON versions since HALCON 18.11. The last number describes the revision of the interface, in this example this is revision 5.

Installation

Only when installing or updating the interface manually follow these steps:

Upgrading From Version 20.11.6 Or Earlier

Starting with version 20.11.7, this interface uses OpenSSL 3.

Features

Limitations

Connecting to an OPC UA server

The open_io_device operator is used to connect to an OPC UA server. Specify the URL of the server to connect to in the IODeviceName parameter. The server URL is generally in the form 'opc.tcp://Server' or 'opc.tcp://Server:Port' if the server is not using the default OPC UA port (4840).

If the server you wish to connect to is registered with an OPC UA discovery server, you can get its URL from the query_io_interface operator using the 'io_device_names' generic parameter if the discovery server is reachable via the URL 'opc.tcp://localhost:4840', or from the control_io_interface operator using the 'discovery' action if it is not. Please see the example opc_ua_discovery.hdev for details. The following security policies are supported:

Converting data between HALCON and OPC UA

OPC UA has a rich set of data types that have to be mapped to the HALCON control tuple data types integer, real and string on input and output. HALCON OPC UA I/O device interface supports the following built-in OPC UA data types and their derivatives:

Writing OPC UA variant nodes (BaseDataType)

When writing a variable node the OPC UA interface internally needs to know a concrete data type in order to correctly compose the write request to the server. The default behavior for the interface is to internally cast the tuple values to the OPC UA DataTypes Int64, String or Double if no additional information is provided. Additionally, it is possible to specify one of the built-in data types for a variable using HALCON dictionaries, to do this the dictionary for a value must contain the following two keys:

Specifying OPC UA nodes

OPC UA nodes are referenced by using their node ID written as a string following the OPC UA XML schema as the channel parameter in the query_io_device and open_io_channel operators. See the section on converting OPC UA data types above on how to write node IDs. In addition to writing the namespace's index, you can also write the namespace's URI enclosed in ^ characters.

The following are all valid ways to refer to the server's ServerStatus node:

'i=2256'
'ns=0;i=2256'
'ns=^http://opcfoundation.org/UA/^;i=2256'

OPC UA Event Handling

Event handling via message queues is supported on the device-level and on the channel-level. On the device-level, this can be used to receive messages when the connection status to the server changes. On the channel-level, subscriptions to variable nodes data changes and for fired events, based on the available EventTypes on the object node, are supported. A message queue handle to a channel or device can be provided to receive updates on the available events. The process to start monitoring events is the following:
  1. Open the device or a channel to a node (variable or object instance).
  2. Get a list of the available events on the device or channel by using the parameter 'available_event_names'.
  3. (For EventTypes) From the available events use the 'event_selector' to start the configuration process.
  4. (For EventTypes) From the selected event query the available event data using the parameter 'available_event_data'.
  5. (For EventTypes) From the available event data set the data you are interested on by using the 'event_data' parameter.
  6. Provide a message queue handle to the channel or device by using the parameter 'event_message_queue'. As soon as the message queue handle is registered updates will start becoming available.
  7. Handle the incoming messages in the message queue with the attached event data.
  8. Removing/Stopping event updates is done by setting the parameter 'event_message_queue' to 0 (or HNULL).
After dequeuing a message for an event, the information contained in the message can be accessed using the operator get_message_tuple. The message will always contain the following information: Depending on the event additional data might be attached to the message: Message queues are handled in a FIFO manner, therefore handling multiple variable and/or event subscriptions in the same message queue requires processing all incoming events as they become available.

Please see the following examples for more information:

Operator control_io_interface

control_io_interface(::IOInterfaceName, Action, Argument:Result)
Perform an action on the I/O interface.
Parameter Values Default Type Description
IOInterfaceName 'OPC_UA' [] string HALCON I/O interface name.
Action string Name of the action to perform.
     'create_certificate' Create a self-signed X509 certificate and store it in the file-based OpenSSL certificate store. This action takes 13 arguments.
          Argument '<path to certificate store>', '<basename of certificate>', <keylength>, '<URI>', '<DNS>', <valid time (in seconds)>, '<common name>', '<organization>', '<organization unit>', '<locality>', '<state>', '<country>', '<domain component>' integer, float, string The first argument is the path to the certificate store (either be relative to the working directory or an absolute path), followed by the base name to store the certificate under (without the file extension). The third argument is the keylength to use (in bits). The fourth and fifth parameters are a URI and a DNS name, respectively, used to set the "X509v9 Subject Alternative Name". The fifth parameter is the valid time of the certificate in seconds.
The final seven arguments are the common name, organization, organization unit, locality, state, country and domain component to use for the issuer and subject of the certificate.
          Result '<X.509 certificate in DER format, Base64 encoded>' string The X.509 certificate in DER format, encoded as a Base64 string.
     'discovery' Query an OPC UA discovery server to find OPC UA servers. The URL of the server to query must be passed as the only argument.
          Argument '<discovery server URL>' string The URL of the discovery server to query.
          Result 'application_type:<application type>|application_uri:<application URI>|product_uri:<product URI>|application_name:<application name>|gateway_server:<gateway server IP address>|discovery_profile_uri:<uri>|url:<server url>[url:<server url>]' string A list of OPC UA servers.
     'endpoints' If used as a parameter to get_io_device_param, returns all endpoints of the server the device is connected to. It cannot be combined with any other queries.
If used as an action for control_io_interface, returns all endpoints of the server reachable via the URL given as the only argument.
          Argument '<server URL>' string The URL of OPC UA server to query.
          Result 'endpoint_url:<server url>[|server_certificate:<certificate>]|message_security_mode:<mode>|security_policy_uri:<policy>|transport_profile_uri:<profile>|security_level:<level>' string A list of OPC UA endpoints.
     'parse_certificate' Take OpenSSL certificates in DER form and translate them into a human readable string presentation.
          Argument '<X.509 certificate in DER format, Base64 encoded>' string X.509 certificate(s) in DER format, encoded as a Base64 string(s).
          Result 'CommonName:<common name>|Issuer.commonName:<common name of issuer>|Issuer.organization:<organization of issuer>|Issuer.organizationUnit:<organization unit of issuer>|Issuer.state:<state of issuer>|Issuer.country:<country of issuer>|ValidFrom:<valid from date>|ValidTo:<valid to date>' string
     'save_certificate' Save an OpenSSL certificate in the file-based OpenSSL certificate store.
          Argument '<Path to the certificate store>', '<Basename of certificate>', '<X.509 certificate in DER format, Base64 encoded>' string The first argument is the path to the certificate store, followed by the base name of the certificate (i.e., without the file extension). The final argument is the certificate in DER form, passed as a Base64 encoded string.
          Result none
     'status_code_to_string' Return the string representation of a OPC UA status code.
          Result string
     'strerror' Convert OPC UA status codes into human readable strings.
          Argument <error code> integer
          Result '<error string>' string
     'thumbprint_certificate' Returns the SHA1 thumbprints of OpenSSL certificates.
          Argument '<X.509 certificate in DER format, Base64 encoded>' string X.509 certificate(s) in DER format, encoded as a Base64 string(s).
          Result '<hex string>' string
     'validate_certificate' Check the validity of OpenSSL certificates against those stored in the file-based OpenSSL certificate store.
          Argument '<Path to certificate store>', '<X.509 certificate in DER format, Base64 encoded>' string The first argument is the path to the certificate store, followed by the certificates in DER form passed as Base64 encoded strings.
          Result 'false', 'true' string If a certificate is valid, 'true' is returned for it, 'false' otherwise. Note that there will be one less return value than arguments.
Argument [] integer, real, string List of arguments for the action.
Result integer, real, string List of results returned by the action.

Operator query_io_interface

query_io_interface(::IOInterfaceName, Query:Result)
Query information about the specified I/O device interface.
Parameter Values Type Description
IOInterfaceName 'OPC_UA' string HALCON I/O interface name.
Query string Parameter name of the query.
     'io_device_info' ['device:<device URL>'] string Returns a list of device names. The names are determined by making an OPC UA FindServers service call to an OPC UA discovery server that must be listening on TCP port 4840 of the localhost interface.
     'io_device_names' <device URL> string Returns a list of device names that can be passed to open_io_device. The names are determined by making an OPC UA FindServers service call to an OPC UA discovery server that must be listening on TCP port 4840 of the localhost interface.
     'param_name' '<parameter>'[,'<parameter>'...] string List of parameters that can be specified for the operator in question.
     'revision' '<version>.<revision>.<build>' string Revision number of the OPC_UA interface.
Result integer, real, string List of result values (according to Query).

Operator open_io_device

open_io_device(::IOInterfaceName, IODeviceName, GenParamName, GenParamValue:IODeviceHandle)
Open and configure an I/O device.
Parameter Values Default Type Description
IOInterfaceName 'OPC_UA' [] string HALCON I/O interface name.
IODeviceName [] string I/O device name.
GenParamName [] string Dynamic parameter names.
     'application_name' '<name>' 'HALCON OPC UA interface' string The client application name used for the session.
     'application_uri' '<URI>' 'HALCON OPC UA interface' string The client application URI used for the session.
     'certificate_store' '<filesystem path>' string Set the path to the file-based OpenSSL certificate store to use. This should be a directory with the subdirectories 'certs' for the trusted certificates (both server and client), 'crl' for the revocation list(s), and 'private' to store the client private keys.
     'client_certificate_name' '<name>' string When using the file-based OpenSSL certificate store, the name of the client certificate to use. There must exist a name.der and name.pem file for the certificate and the private key, respectively.
     'connect_timeout' <milliseconds> 5000 integer Timeout value in milliseconds for establishing the connection to the OPC UA server.
     'encrypt_password_check' 'disable', 'enable' 'enable' string This parameter prevents the client from sending unencrypted passwords without user interaction. This happens if the ServerNonce(1) is null or if the PasswordEncryptionMode is set to NONE on the server. If a server does not support encryption or does not require it due to an oversight in the configuration then this parameter should be set to 'disable'.
(1) OPC UA Part 4 - Services 1.03.
     'event_message_queue' 0 handle The user can specify a message queue in which to receive a message when certain events are triggered on the server. Setting the value to 0 (or HNULL) unregister the message queue and stops the updates. For more information please refer to the section 'OPC UA Event Handling'.
     'event_selector' string The user can specify an event from the channel or device, from which to receive a notification in the form of a HALCON message when the event triggers. For more information please refer to the section 'OPC UA Event Handling'.
     'message_security_mode' 'none', 'sign', 'sign/encrypt' 'none' string Security mode to use for the session.
     'product_uri' '<URI>' 'HALCON' string The client product URI used for the session.
     'security_policy' 'http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep', 'http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss', 'http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15', 'http://opcfoundation.org/UA/SecurityPolicy#Basic256', 'http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256', 'http://opcfoundation.org/UA/SecurityPolicy#None' 'http://opcfoundation.org/UA/SecurityPolicy#None' string Name of the security policy to use for the session.
     'server_certificate' '<X.509 certificate in DER format, Base64 encoded>' '' string If used as a parameter to open_io_device, sets the server certificate to use for the connection. The certificate should be in DER form, encoded as a Base64 string. The certificate must match that of the server being connected to.
If used as a parameter to get_io_device_param, returns the server certificate (in DER form as a Base64 encoded string) that was passed to open_io_device when the connection was established, or an empty string if no certificate was specified.
     'session_locale' '<RFC3066 locale specifier>' 'en-US' string The locale to use for this session, using a language tag as specified in RFC 3066.
     'session_name' '<unique session name>' string The session name. This should be unique for each instance of the client.
     'session_timeout' <milliseconds> 1.2e6 integer, float Timeout value in milliseconds for the session. If the network connection is broken for longer than the session timeout, the session is considered disconnected.
     'trusted_certificate_for_user_token' 'disable', 'enable' 'enable' string This parameter prevents the client from sending unencrypted passwords without user interaction. The user token on a server must be encrypted with a certificate in the client's trusted list. This is required even if the security of the server is NONE. This flag can be used to disable the check.
     'user_name' '<name>' string The (optional) user name for the session. When used with open_io_device or set_io_device_param, 'user_password' must be set in the same operator call.
     'user_password' '<password>' string The (optional) user password for the session. When used with open_io_device or set_io_device_param, 'user_name' must be set in the same operator call.
     'watchdog_time' <milliseconds> 5000 integer The time between watchdog checks in milliseconds.
     'watchdog_timeout' <milliseconds> 5000 integer The timeout for watchdog calls in milliseconds. After one unsuccessful call the timeout will be two times this value for the next call.
GenParamValue [] integer, real, string Dynamic parameter values.
IODeviceHandle handle Handle of the opened I/O device.

Operator control_io_device

control_io_device(::IODeviceHandle, Action, Argument:Result)
Perform an action on the I/O device.
Parameter Values Default Type Description
IODeviceHandle handle Handle of the opened I/O device.
Action string Name of the action to perform.
     'namespace' Convert the specified namespaces into the corresponding namespace indexes.
          Argument '<namespace>' string The namespace as a text string.
          Result '<namespace index>' integer The namespace index, or -1 if the namespace is undefined.
     'translate' Translate an OPC UA browse path into a node id.
          Argument '<NodeId>', '<browse path>' string If no arguments are given, returns the root of the OPC UA node tree. Otherwise, two arguments are required. The first argument is the ID of the node the path starts at, and the second argument is the path to translate. If an empty string ('') is passed for the start node, the root of the OPC UA node tree is used.
The browse path follows the syntax described in "OPC Unified Architecture, Part 4". A browse path consists of one or more subpaths. Each subpath must be written in one of the following forms:

/[ns:]BrowseName - Follow any subtype of the HierarchicalReferences reference type.
.[ns:]BrowseName - Follow any subtype of the Aggregates reference type.
<[#][!][ns:]ReferenceType>BrowseName - Follow a reference of type ReferenceType, or a subtype thereof. If '#' is specified, the reference type must match exactly, i.e., subtypes are not followed. If '!' is specified, an inverse lookup is done.
In all forms, [ns:] is an optional namespace index consisting of one or more digits followed by a colon (':'). If no namespace index is given, namespace index 0 is assumed by default. BrowseName is the target node's BrowseName attribute, while ReferenceType is the name of the reference type. If the ReferenceType or BrowseName contains any of the reserved characters '/', '.', '<', '>', '#', '!', or '&', it must be escaped by a prefixed '&'.
          Result '<NodeId>' string
Argument [] integer, real, string List of arguments for the action.
Result integer, real, string List of result values returned by the action.

Operator set_io_device_param

set_io_device_param(::IODeviceHandle, GenParamName, GenParamValue:)
Configure a specific I/O device instance.
Parameter Values Default Type Description
IODeviceHandle handle Handle of the opened I/O device.
GenParamName [] string Parameter names.
     'event_data' string The user can specify data to be deliver along with the event notification. The available data is determined by the event properties. For more information please refer to the section 'OPC UA Event Handling'.
     'event_message_queue' 0 handle The user can specify a message queue in which to receive a message when certain events are triggered on the server. Setting the value to 0 (or HNULL) unregister the message queue and stops the updates. For more information please refer to the section 'OPC UA Event Handling'.
     'event_selector' string The user can specify an event from the channel or device, from which to receive a notification in the form of a HALCON message when the event triggers. For more information please refer to the section 'OPC UA Event Handling'.
     'user_name' '<name>' string The (optional) user name for the session. When used with open_io_device or set_io_device_param, 'user_password' must be set in the same operator call.
     'user_password' '<password>' string The (optional) user password for the session. When used with open_io_device or set_io_device_param, 'user_name' must be set in the same operator call.
GenParamValue [] integer, real, string, handle Parameter values to set.

Operator get_io_device_param

get_io_device_param(::IODeviceHandle, GenParamName:GenParamValue)
Query settings of an I/O device instance.

There may exist additional parameter attributes, which can be accessed as 'ParamNames.AttributeName'. The following standard attributes may be available:
Parameter Values Type Description
IODeviceHandle handle Handle of the opened I/O device.
GenParamName string Parameter names.
     'application_name' '<name>' string The client application name used for the session.
     'application_uri' '<URI>' string The client application URI used for the session.
     'available_event_data' string List of all the available data in the event selected in the event_selector.Please read the event handling section for more information.
     'available_event_names' string List of all the available events from the channel or device.Please read the event handling section for more information.
     'connect_timeout' <milliseconds> integer Timeout value in milliseconds for establishing the connection to the OPC UA server.
     'connection_status' 'Disconnected', 'Connected', 'NewSessionCreated', 'ConnectionWarningWatchdogTimeout', 'ConnectionErrorApiReconnect', 'ServerShutdown', 'unknown' string Returns the current status of the server connection as a string.
     'encrypt_password_check' 'disable', 'enable' string This parameter prevents the client from sending unencrypted passwords without user interaction. This happens if the ServerNonce(1) is null or if the PasswordEncryptionMode is set to NONE on the server. If a server does not support encryption or does not require it due to an oversight in the configuration then this parameter should be set to 'disable'.
(1) OPC UA Part 4 - Services 1.03.
     'endpoints' 'endpoint_url:<server url>[|server_certificate:<certificate>]|message_security_mode:<mode>|security_policy_uri:<policy>|transport_profile_uri:<profile>|security_level:<level>' string If used as a parameter to get_io_device_param, returns all endpoints of the server the device is connected to. It cannot be combined with any other queries.
If used as an action for control_io_interface, returns all endpoints of the server reachable via the URL given as the only argument.
     'event_data' string The user can specify data to be deliver along with the event notification. The available data is determined by the event properties. For more information please refer to the section 'OPC UA Event Handling'.
     'event_message_queue' handle The user can specify a message queue in which to receive a message when certain events are triggered on the server. Setting the value to 0 (or HNULL) unregister the message queue and stops the updates. For more information please refer to the section 'OPC UA Event Handling'.
     'event_selector' string The user can specify an event from the channel or device, from which to receive a notification in the form of a HALCON message when the event triggers. For more information please refer to the section 'OPC UA Event Handling'.
     'io_device_name' <device URL> string Return the URL of the server the device is connected to.
     'message_security_mode' 'none', 'sign', 'sign/encrypt' string Security mode to use for the session.
     'namespaces' '<namespace>'[,'<namespace>',...] string Returns all OPC UA namespaces as a tuple of strings for the specified connection. The namespaces are returned in the same order as they are defined on the server, i.e., the fourth element of the return tuple corresponds to the fourth namespace on the server.
     'param_name' '<parameter>'[,'<parameter>'...] string List of parameters that can be specified for the operator in question.
     'product_uri' '<URI>' string The client product URI used for the session.
     'security_policy' 'http://opcfoundation.org/UA/SecurityPolicy#Aes128_Sha256_RsaOaep', 'http://opcfoundation.org/UA/SecurityPolicy#Aes256_Sha256_RsaPss', 'http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15', 'http://opcfoundation.org/UA/SecurityPolicy#Basic256', 'http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256', 'http://opcfoundation.org/UA/SecurityPolicy#None' string Name of the security policy to use for the session.
     'server_certificate' '<X.509 certificate in DER format, Base64 encoded>' string If used as a parameter to open_io_device, sets the server certificate to use for the connection. The certificate should be in DER form, encoded as a Base64 string. The certificate must match that of the server being connected to.
If used as a parameter to get_io_device_param, returns the server certificate (in DER form as a Base64 encoded string) that was passed to open_io_device when the connection was established, or an empty string if no certificate was specified.
     'session_locale' '<RFC3066 locale specifier>' string The locale to use for this session, using a language tag as specified in RFC 3066.
     'session_name' '<unique session name>' string The session name. This should be unique for each instance of the client.
     'session_timeout' <milliseconds> integer, float Timeout value in milliseconds for the session. If the network connection is broken for longer than the session timeout, the session is considered disconnected.
     'trusted_certificate_for_user_token' 'disable', 'enable' string This parameter prevents the client from sending unencrypted passwords without user interaction. The user token on a server must be encrypted with a certificate in the client's trusted list. This is required even if the security of the server is NONE. This flag can be used to disable the check.
     'user_name' '<name>' string The (optional) user name for the session. When used with open_io_device or set_io_device_param, 'user_password' must be set in the same operator call.
     'user_password' '<password>' string The (optional) user password for the session. When used with open_io_device or set_io_device_param, 'user_name' must be set in the same operator call.
     'user_token_type' 'Anonymous', 'Certificate', 'IssuedToken', 'UserName' string Returns the type of user token currently used by the connection to the device.
     'watchdog_time' <milliseconds> integer The time between watchdog checks in milliseconds.
     'watchdog_timeout' <milliseconds> integer The timeout for watchdog calls in milliseconds. After one unsuccessful call the timeout will be two times this value for the next call.
GenParamValue integer, real, string, handle Parameter values.

Operator query_io_device

query_io_device(::IODeviceHandle, IOChannelName, Query:Result)
Query information about channels of the specified I/O device.
Parameter Values Type Description
IODeviceHandle handle Handle of the opened I/O device.
IOChannelName string Channel names to query.
Query string Name of the query.
     'access_level' [0..255] integer AccessLevel attribute of the OPC UA node(s). This attribute is mandatory for all Variable node classes.
     'array_dimensions' <number> integer ArrayDimensions attribute of the OPC UA node(s). This attribute is optional for variable and variable type nodes.
     'attributes' 'access_level', 'array_dimensions', 'contains_no_loops', 'data_type', 'description', 'display_name', 'event_notifier', 'historizing', 'inverse_name', 'is_abstract', 'minimum_sampling_interval', 'node_class', 'node_id', 'symmetric', 'user_access_level', 'user_executable', 'user_write_mask', 'value_rank', 'write_mask' string Returns a list of OPC UA attributes defined for the specified node. Only a single node may be specified, and no other queries may be requested in this call to query_io_device.
     'browse' <NodeId>,<NodeClass>,<BrowseName>[,<NodeId>,<NodeClass>,<BrowseName>,...] string Returns a list of subnodes of the specified node. Only a single node may be specified. If an empty node ([]) is specified, browsing starts at the root of the OPC UA node tree. For each node, three HALCON string elements are returned - the node id, the node class, and the browse name. No other queries may be requested in this call to query_io_device. If the node id refers to a node on a different server, it is returned as an ExpandedNodeId, otherwise it is returned as a normal node id that can be used as a channel name for subsequent channel operations.
     'browse_name' '<ns>:<name>' string BrowseName attribute of the OPC UA node(s). The browse name is returned in the form '<ns>:<name>', with <ns> being the index of the namespace the browse name is located in. This attribute is mandatory for all node classes.
     'contains_no_loops' 'false', 'true' string ContainsNoLoops attribute of the OPC UA node(s). This attribute is mandatory for view nodes.
     'data_type_definition' handle Information about the datatype of a variable node or about a datatype node. This always includes the datatype name, the metatype and, if available, additional metadata. For structures, optionsets and unions, information about the fields is included (see parameter 'fields'). The available information is returned in a HALCON dictionary.
     'data_type' 'Boolean', 'Byte', 'ByteString', 'DataValue', 'DateTime', 'DiagnosticInfo', 'Double', 'Duration', 'ExpandedNodeId', 'ExtensionObject', 'Float', 'Guid', 'Image', 'ImageBMP', 'ImageGIF', 'ImageJPG', 'ImagePNG', 'Int16', 'Int32', 'Int64', 'Integer', 'LocalizedText', 'LocaleId', 'NodeId', 'Null', 'QualifiedName', 'SByte', 'StatusCode', 'String', 'UInt16', 'UInt32', 'UInt64', 'UInteger', 'Unknown', 'UtcTime', 'Variant', 'XmlElement' string The node's datatype attribute. This attribute is mandatory for data type, variable and variable type nodes.
     'description' '<description>' string Description attribute of the OPC UA node(s). This attribute is optional for all node classes.
     'display_name' '<name>' string DisplayName attribute of the OPC UA node(s). This attribute is mandatory for all node classes.
     'enum_values' handle If the passed node is an enumeration, return the possible numerical values together with the name and description. If the passed node is not an enum an exception will be thrown. The available information is returned in a HALCON dictionary.
     'event_notifier' <number> integer EventNotifier attribute of the OPC UA node(s). This attribute is mandatory for object and view nodes.
     'executable' 'false', 'true' string Executable attribute of the OPC UA node(s). This attribute is mandatory for method nodes.
     'fields' string If the passed node is a Structure, Union or OptionSet return the fields of the datatype definition, otherwise an exception will be thrown. The available information is returned in a HALCON dictionary with a numeric key for each field. The information for each field always includes the datatype name, the metatype and, if available, additional metadata. The OPC UA attributes value_rank and, if available, array_dimensions provide information about the array characteristics of the field.
     'historizing' 'false', 'true' string Historizing attribute of the OPC UA node(s). This attribute is mandatory for variable nodes.
     'inverse_name' '<name>' string InverseName attribute of the OPC UA node(s). This attribute is optional for reference type nodes.
     'io_channel_name' '<name>' string Returns the name this channel was opened with. For OPC UA, this is the node id in XML string representation.
     'is_abstract' 'false', 'true' string IsAbstract attribute of the OPC UA node(s). This attribute is mandatory for object type, reference type and variable type nodes.
     'meta_type' 'Enumeration', 'Structure', 'Union', 'Option Set', ''<BuildIn>'' string Returns if the node can be interpreted as an Enumeration, Structure, Union, OptionSet or other data type.
     'method_arguments' handle Information about the input and output arguments of a method. The available information is returned in a HALCON dictionary with keys 'input_arguments' and 'output_arguments'. If the method has no input or output arguments, an empty tuple is stored under the respective key. Each argument has a name and a description. Additionally, information about the expected type is returned.
     'minimum_sampling_interval' <number> integer, float MinimumSamplingInterval attribute of the OPC UA node(s). This attribute is optional for variable nodes.
     'node_class' 'DataType', 'Method', 'Object', 'ObjectType', 'ReferenceType', 'Unknown', 'Variable', 'VariableType', 'View' string NodeClass attribute of the OPC UA node(s). This attribute is mandatory for all nodes.
     'node_id' '<NodeId>' string NodeId attribute of the OPC UA node(s). The node id is used to uniquely identify every node on a server. Use it as the channel name for query_io_device and open_io_channel.
     'option_set_values' handle If the passed node is a struct of the OptionSet data type, return the description of each bit on the bitmask on the OptionSetValues property. If the passed node is not an OptionSet, an exception will be thrown. The available information is presented in a HALCON dictionary.
     'param_name' '<parameter>'[,'<parameter>'...] string List of parameters that can be specified for the operator in question.
     'symmetric' 'false', 'true' string Symmetric attribute of the OPC UA node(s). This attribute is mandatory for reference type nodes.
     'user_access_level' [0..255] integer UserAccessLevel attribute of the OPC UA node(s). This attribute is mandatory for variable nodes.
     'user_executable' 'false', 'true' string UserExecutable attribute of the OPC UA node(s). This attribute is mandatory for method nodes.
     'user_write_mask' <bitmask> integer UserWriteMask attribute of the OPC UA node(s). This attribute is optional for all node classes.
     'value.access' 'ro', 'wo', 'rw', 'na', 'ni' string Return the access of the value of a Variable node.
     'value_rank' <number> integer ValueRank attribute of the OPC UA node(s). This attribute is mandatory for variable and variable type nodes.
     'write_mask' <bitmask> integer WriteMask attribute of the OPC UA node(s). This attribute is optional for all node classes.
Result integer, real, string List of values (according to Query).

Operator open_io_channel

open_io_channel(::IODeviceHandle, IOChannelName, GenParamName, GenParamValue:IOChannelHandle)
Open and configure I/O channels.
Parameter Values Default Type Description
IODeviceHandle handle Handle of the opened I/O device.
IOChannelName string HALCON I/O channel names of the specified device.
GenParamName [] string Parameter names.
     'cached' 'false', 'true' 'false' string If 'true', the channel's value is not read directly from the server in response to a read_io_channel call; instead the last known value received (either published by the server, or read in response to a previous read_io_channel call) is returned. If no value has been cached for the channel, a read request is sent to the server regardless of the setting of the 'cached' parameter.
The 'cached' parameter is automatically set to 'true' for subscribed channels, and to 'false' for unsubscribed channels. Note that manually setting 'cached' to 'true' for an unsubscribed channel is possible; read_io_channel will then return the cached value instead of reading the current value from the server for this channel as if it where subscribed.
     'discard_oldest' 'false', 'true' 'false' string Discard oldest subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'event_message_queue' 0 handle The user can specify a message queue in which to receive a message when certain events are triggered on the server. Setting the value to 0 (or HNULL) unregister the message queue and stops the updates. For more information please refer to the section 'OPC UA Event Handling'.
     'event_selector' string The user can specify an event from the channel or device, from which to receive a notification in the form of a HALCON message when the event triggers. For more information please refer to the section 'OPC UA Event Handling'.
     'method_target_node' '<NodeId>' string NodeId of the target object used when calling a method. Methods typically belong to a object, which provides the context for the method invocation. Methods are also allowed to belong to multiple objects. This parameter is used to specify the target object, on which the method should be invoked. To call a method, this parameter must be set, even when the target object is unique.
     'priority' [0..255] 0 integer Priority subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'publishing_interval' <milliseconds> 0 integer, float Interval in which the server should publish the channel's value in milliseconds. If this parameter is set to a value greater than zero, the channel is subscribed from the server; if it is set to 0 the channel is unsubscribed.
If the parameter 'sampling_interval' is set but 'publishing_interval' is not, 'publishing_interval' is set to twice the value of 'sampling_interval' by default.
     'queue_size' <number> 0 integer Queue size subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'sampling_interval' <milliseconds> 0 integer, float Interval in which the server should sample the channel in milliseconds. This value should be less or equal than the value of parameter 'publishing_interval'.
If the parameter 'publishing_interval' is set but 'sampling_interval' is not, 'sampling_interval' is set to half the value of 'publishing_interval' by default.
     'use_memory_blocks' 'disable', 'enable' 'disable' string This parameter has an affect only if the open channel is a variable node that is of the data type ByteString or one of its sub-types (e.g., ImageJPG, ImagePNG, ImageGIF, etc.) or if it is an Array of the data type Byte or SByte or one of its sub-types. When this parameter is enable the value of the variable can be written or read as a HALCON memory block handle.
GenParamValue [] integer, real, string Parameter values.
IOChannelHandle handle Handles of the opened I/O channel.

Operator control_io_channel

control_io_channel(::IOChannelHandle, Action, Argument:Result)
Perform an action on I/O channels.
Parameter Values Default Type Description
IOChannelHandle handle Handles of the opened I/O channels.
Action string Name of the action to perform.
     'method_call' Call a server method. To find out if a method is executable before calling it, query for the attributes 'executable' and 'user_executable'. To call a method successfully, the provided input tuple must contain values which match the datatypes of the input arguments. The rules in section 'Converting data between HALCON and OPC UA' apply. To know which datatypes the method expects, use the io channel parameter 'arguments'. The output tuple will contain the result of the method. If the server returns a bad status code, an exception will be raised.
Argument [] integer, real, string List of arguments for the action.
Result integer, real, string List of values returned by the action.

Operator set_io_channel_param

set_io_channel_param(::IOChannelHandle, GenParamName, GenParamValue:)
Set specific parameters of I/O channels.
Parameter Values Default Type Description
IOChannelHandle handle Handles of the opened I/O channels.
GenParamName [] string Parameter names.
     'cached' 'false', 'true' 'false' string If 'true', the channel's value is not read directly from the server in response to a read_io_channel call; instead the last known value received (either published by the server, or read in response to a previous read_io_channel call) is returned. If no value has been cached for the channel, a read request is sent to the server regardless of the setting of the 'cached' parameter.
The 'cached' parameter is automatically set to 'true' for subscribed channels, and to 'false' for unsubscribed channels. Note that manually setting 'cached' to 'true' for an unsubscribed channel is possible; read_io_channel will then return the cached value instead of reading the current value from the server for this channel as if it where subscribed.
     'discard_oldest' 'false', 'true' 'false' string Discard oldest subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'event_data' string The user can specify data to be deliver along with the event notification. The available data is determined by the event properties. For more information please refer to the section 'OPC UA Event Handling'.
     'event_message_queue' 0 handle The user can specify a message queue in which to receive a message when certain events are triggered on the server. Setting the value to 0 (or HNULL) unregister the message queue and stops the updates. For more information please refer to the section 'OPC UA Event Handling'.
     'event_namespace_filter' string Filter the EvenTypes available base on the namespace of the type.
     'event_selector' string The user can specify an event from the channel or device, from which to receive a notification in the form of a HALCON message when the event triggers. For more information please refer to the section 'OPC UA Event Handling'.
     'method_target_node' '<NodeId>' string NodeId of the target object used when calling a method. Methods typically belong to a object, which provides the context for the method invocation. Methods are also allowed to belong to multiple objects. This parameter is used to specify the target object, on which the method should be invoked. To call a method, this parameter must be set, even when the target object is unique.
     'priority' [0..255] 0 integer Priority subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'publishing_interval' <milliseconds> 0 integer, float Interval in which the server should publish the channel's value in milliseconds. If this parameter is set to a value greater than zero, the channel is subscribed from the server; if it is set to 0 the channel is unsubscribed.
If the parameter 'sampling_interval' is set but 'publishing_interval' is not, 'publishing_interval' is set to twice the value of 'sampling_interval' by default.
     'queue_size' <number> 0 integer Queue size subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'sampling_interval' <milliseconds> 0 integer, float Interval in which the server should sample the channel in milliseconds. This value should be less or equal than the value of parameter 'publishing_interval'.
If the parameter 'publishing_interval' is set but 'sampling_interval' is not, 'sampling_interval' is set to half the value of 'publishing_interval' by default.
     'use_memory_blocks' 'disable', 'enable' 'disable' string This parameter has an affect only if the open channel is a variable node that is of the data type ByteString or one of its sub-types (e.g., ImageJPG, ImagePNG, ImageGIF, etc.) or if it is an Array of the data type Byte or SByte or one of its sub-types. When this parameter is enable the value of the variable can be written or read as a HALCON memory block handle.
GenParamValue [] integer, real, string, handle Parameter values to set.

Operator get_io_channel_param

get_io_channel_param(::IOChannelHandle, GenParamName:GenParamValue)
Query specific parameters of I/O channels.

There may exist additional parameter attributes, which can be accessed as 'ParamNames.AttributeName'. The following standard attributes may be available:
Parameter Values Type Description
IOChannelHandle handle Handles of the opened I/O channels.
GenParamName string Parameter names.
     'access_level' [0..255] integer AccessLevel attribute of the OPC UA node(s). This attribute is mandatory for all Variable node classes.
     'array_dimensions' <number> integer ArrayDimensions attribute of the OPC UA node(s). This attribute is optional for variable and variable type nodes.
     'attributes' 'access_level', 'array_dimensions', 'contains_no_loops', 'data_type', 'description', 'display_name', 'event_notifier', 'historizing', 'inverse_name', 'is_abstract', 'minimum_sampling_interval', 'node_class', 'node_id', 'symmetric', 'user_access_level', 'user_executable', 'user_write_mask', 'value_rank', 'write_mask' string Returns a list of OPC UA attributes defined for the specified node. Only a single node may be specified, and no other queries may be requested in this call to query_io_device.
     'available_event_data' string List of all the available data in the event selected in the event_selector.Please read the event handling section for more information.
     'available_event_names' string List of all the available events from the channel or device.Please read the event handling section for more information.
     'browse_name' '<ns>:<name>' string BrowseName attribute of the OPC UA node(s). The browse name is returned in the form '<ns>:<name>', with <ns> being the index of the namespace the browse name is located in. This attribute is mandatory for all node classes.
     'cached' 'false', 'true' string If 'true', the channel's value is not read directly from the server in response to a read_io_channel call; instead the last known value received (either published by the server, or read in response to a previous read_io_channel call) is returned. If no value has been cached for the channel, a read request is sent to the server regardless of the setting of the 'cached' parameter.
The 'cached' parameter is automatically set to 'true' for subscribed channels, and to 'false' for unsubscribed channels. Note that manually setting 'cached' to 'true' for an unsubscribed channel is possible; read_io_channel will then return the cached value instead of reading the current value from the server for this channel as if it where subscribed.
     'contains_no_loops' 'false', 'true' string ContainsNoLoops attribute of the OPC UA node(s). This attribute is mandatory for view nodes.
     'data_type' 'Boolean', 'Byte', 'ByteString', 'DataValue', 'DateTime', 'DiagnosticInfo', 'Double', 'Duration', 'ExpandedNodeId', 'ExtensionObject', 'Float', 'Guid', 'Image', 'ImageBMP', 'ImageGIF', 'ImageJPG', 'ImagePNG', 'Int16', 'Int32', 'Int64', 'Integer', 'LocalizedText', 'LocaleId', 'NodeId', 'Null', 'QualifiedName', 'SByte', 'StatusCode', 'String', 'UInt16', 'UInt32', 'UInt64', 'UInteger', 'Unknown', 'UtcTime', 'Variant', 'XmlElement' string The node's datatype attribute. This attribute is mandatory for data type, variable and variable type nodes.
     'data_type_definition' handle Information about the datatype of a variable node or about a datatype node. This always includes the datatype name, the metatype and, if available, additional metadata. For structures, optionsets and unions, information about the fields is included (see parameter 'fields'). The available information is returned in a HALCON dictionary.
     'description' '<description>' string Description attribute of the OPC UA node(s). This attribute is optional for all node classes.
     'discard_oldest' 'false', 'true' string Discard oldest subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'display_name' '<name>' string DisplayName attribute of the OPC UA node(s). This attribute is mandatory for all node classes.
     'enum_values' handle If the passed node is an enumeration, return the possible numerical values together with the name and description. If the passed node is not an enum an exception will be thrown. The available information is returned in a HALCON dictionary.
     'event_data' string The user can specify data to be deliver along with the event notification. The available data is determined by the event properties. For more information please refer to the section 'OPC UA Event Handling'.
     'event_message_queue' handle The user can specify a message queue in which to receive a message when certain events are triggered on the server. Setting the value to 0 (or HNULL) unregister the message queue and stops the updates. For more information please refer to the section 'OPC UA Event Handling'.
     'event_namespace_filter' string Filter the EvenTypes available base on the namespace of the type.
     'event_notifier' <number> integer EventNotifier attribute of the OPC UA node(s). This attribute is mandatory for object and view nodes.
     'event_selector' string The user can specify an event from the channel or device, from which to receive a notification in the form of a HALCON message when the event triggers. For more information please refer to the section 'OPC UA Event Handling'.
     'executable' 'false', 'true' string Executable attribute of the OPC UA node(s). This attribute is mandatory for method nodes.
     'fields' string If the passed node is a Structure, Union or OptionSet return the fields of the datatype definition, otherwise an exception will be thrown. The available information is returned in a HALCON dictionary with a numeric key for each field. The information for each field always includes the datatype name, the metatype and, if available, additional metadata. The OPC UA attributes value_rank and, if available, array_dimensions provide information about the array characteristics of the field.
     'historizing' 'false', 'true' string Historizing attribute of the OPC UA node(s). This attribute is mandatory for variable nodes.
     'inverse_name' '<name>' string InverseName attribute of the OPC UA node(s). This attribute is optional for reference type nodes.
     'io_channel_name' '<name>' string Returns the name this channel was opened with. For OPC UA, this is the node id in XML string representation.
     'is_abstract' 'false', 'true' string IsAbstract attribute of the OPC UA node(s). This attribute is mandatory for object type, reference type and variable type nodes.
     'meta_type' 'Enumeration', 'Structure', 'Union', 'Option Set', ''<BuildIn>'' string Returns if the node can be interpreted as an Enumeration, Structure, Union, OptionSet or other data type.
     'method_arguments' handle Information about the input and output arguments of a method. The available information is returned in a HALCON dictionary with keys 'input_arguments' and 'output_arguments'. If the method has no input or output arguments, an empty tuple is stored under the respective key. Each argument has a name and a description. Additionally, information about the expected type is returned.
     'method_target_node' '<NodeId>' string NodeId of the target object used when calling a method. Methods typically belong to a object, which provides the context for the method invocation. Methods are also allowed to belong to multiple objects. This parameter is used to specify the target object, on which the method should be invoked. To call a method, this parameter must be set, even when the target object is unique.
     'minimum_sampling_interval' <number> integer, float MinimumSamplingInterval attribute of the OPC UA node(s). This attribute is optional for variable nodes.
     'node_class' 'DataType', 'Method', 'Object', 'ObjectType', 'ReferenceType', 'Unknown', 'Variable', 'VariableType', 'View' string NodeClass attribute of the OPC UA node(s). This attribute is mandatory for all nodes.
     'node_id' '<NodeId>' string NodeId attribute of the OPC UA node(s). The node id is used to uniquely identify every node on a server. Use it as the channel name for query_io_device and open_io_channel.
     'option_set_values' handle If the passed node is a struct of the OptionSet data type, return the description of each bit on the bitmask on the OptionSetValues property. If the passed node is not an OptionSet, an exception will be thrown. The available information is presented in a HALCON dictionary.
     'param_name' '<parameter>'[,'<parameter>'...] string List of parameters that can be specified for the operator in question.
     'priority' [0..255] integer Priority subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'publishing_interval' <milliseconds> integer, float Interval in which the server should publish the channel's value in milliseconds. If this parameter is set to a value greater than zero, the channel is subscribed from the server; if it is set to 0 the channel is unsubscribed.
If the parameter 'sampling_interval' is set but 'publishing_interval' is not, 'publishing_interval' is set to twice the value of 'sampling_interval' by default.
     'queue_size' <number> integer Queue size subscription property. If this parameter is set, at least one of the parameters 'publishing_interval' or 'sampling_interval' must also be set.
     'sampling_interval' <milliseconds> integer, float Interval in which the server should sample the channel in milliseconds. This value should be less or equal than the value of parameter 'publishing_interval'.
If the parameter 'publishing_interval' is set but 'sampling_interval' is not, 'sampling_interval' is set to half the value of 'publishing_interval' by default.
     'symmetric' 'false', 'true' string Symmetric attribute of the OPC UA node(s). This attribute is mandatory for reference type nodes.
     'use_memory_blocks' 'disable', 'enable' string This parameter has an affect only if the open channel is a variable node that is of the data type ByteString or one of its sub-types (e.g., ImageJPG, ImagePNG, ImageGIF, etc.) or if it is an Array of the data type Byte or SByte or one of its sub-types. When this parameter is enable the value of the variable can be written or read as a HALCON memory block handle.
     'user_access_level' [0..255] integer UserAccessLevel attribute of the OPC UA node(s). This attribute is mandatory for variable nodes.
     'user_executable' 'false', 'true' string UserExecutable attribute of the OPC UA node(s). This attribute is mandatory for method nodes.
     'user_write_mask' <bitmask> integer UserWriteMask attribute of the OPC UA node(s). This attribute is optional for all node classes.
     'value_rank' <number> integer ValueRank attribute of the OPC UA node(s). This attribute is mandatory for variable and variable type nodes.
     'write_mask' <bitmask> integer WriteMask attribute of the OPC UA node(s). This attribute is optional for all node classes.
GenParamValue integer, real, string, handle Parameter values.

Operator read_io_channel

read_io_channel(::IOChannelHandle:Value, Status)
Read a value from the specified I/O channels. If multiple channels are specified, they must all belong to the same device.
Parameter Values Type Description
IOChannelHandle handle Handles of the opened I/O channels.
Value integer, real, string, handle Read value.
Status integer Status of read value. A status of '0' indicates success, while any other value indicates an error condition as returned by the OPC UA communication stack.

Operator write_io_channel

write_io_channel(::IOChannelHandle, Value:Status)
Write a value to the specified I/O channels. If multiple channels are specified, they must all belong to the same device.
Parameter Values Type Description
IOChannelHandle handle Handles of the opened I/O channels.
Value integer, real, string, handle Write values.
Status integer Status of written values. A status of '0' indicates success, while any other value indicates an error condition as returned by the OPC UA communication stack.

Operator close_io_channel

close_io_channel(::IOChannelHandle:)
Close I/O channels.
Parameter Type Description
IOChannelHandle handle Handles of the opened I/O channels.

Operator close_io_device

close_io_device(::IODeviceHandle:)
Close the specified I/O device.
Parameter Type Description
IODeviceHandle handle Handle of the opened I/O device.

Usage of third-party libraries

This interface depends on third-party libraries. See the file third_party_opc_ua.txt in the HALCON base directory for copyright and license information. Libraries are used without modifications unless explicitly stated in the file.

You can request the source for those third-party libraries licensed under GPL or LGPL via email to info@mvtec.com with the subject "Request source code of third-party libraries".

OpenSSL

This software uses OpenSSL 3 for secure communication with OPC UA servers. It was configured and built with the options no-idea, no-mdc2, no-ntt, and no-rc5 to avoid patent issues.

On Linux, you can use the system-provided OpenSSL libraries if they are binary compatible with OpenSSL 3 by removing libcrypto.so.3 and libssl.so.3 from the directory $HALCONROOT/lib/$HALCONARCH/thirdparty.

If bugs are found in the version of OpenSSL provided by MVTec and you do not want to wait for an update of the interface, you can compile and use your own version.

HDevelop Examples

For this interface the following examples are available:

Release Notes


Legal disclaimer regarding hyperlinks: This page may provide users with access by hypertext links to external, non-MVTec websites. Any such access is provided with the understanding that the contents of non-MVTec sites are beyond the control of MVTec Software GmbH, that MVTec Software GmbH makes no representations whatsoever about such sites, and that users shall proceed at their own risk. MVTec Software GmbH is not responsible for the privacy practices or the content of external, non-MVTec websites.
Copyright notes: © Copyright MVTec Software GmbH. All rights reserved. Unless otherwise stated, the copyright and similar rights in the contents of this page, including but not limited to all text, designs and images appearing herein, are copyrighted works owned by MVTec Software GmbH. "MVTec Software GmbH" and "HALCON" are registered trademarks of MVTec Software GmbH. All other brand names, designs, service marks and trademarks (whether or not registered) referenced or used herein are the property of their respective owners.