OpcUaConnection

OpcUaConnection — represents and configures an OPC UA client connection.

Synopsis

class OpcUaConnection
{
    ConnectionName;
    IsEnabled;
    ProtocolType;
    Encoding;
    SecurityPolicy;
    SecurityMode;
    UserTokenType;
    DiscoveryServerURI;
    EndpointURI;
    IsSelectAllVariableNodes;
    IsManuallySelectNodes;
    UserTokenKey;
    UserTokenValue;
    DataDomain;
    IsTransmitOnlyGood;
    IsLoadMetadata;
    IsAcceptIncompleteAck;
    IgnoreServerState;
    NotReceiveNullValue;
    MaximumUpdateRate;
    QueueSize;
    ReadBehaviorType;
    WriteBehaviorType;
    ValidationOptions;
    MaximumBrowseNodes;
    IsReadOnly;
    WaitForRunningMs;
    PauseBeforeReadingMs;
    ModelPropsAsValues;
    AcceptInvalidServerCert;
    MaxRequestItemCount;
    UseMultipleSubscriptions;
    ReadAlarms;
    AlarmDataDomain;
    TransportQuotas;
    AddNodeIdToAcConditionNames;
}
    

Description

This class represents and configures an OPC UA client connection. The manually-selected node list associated with this configuration is not held in an instance variable but is accessible with methods of this class.

Instance Variables

ConnectionName

A string that uniquely identifies this OPC UA connection. It is set by the constructor and used in all UA commands.

IsEnabled

Controls whether this connection is enabled. The default value is nil (disabled). When t the connection is enabled.

ProtocolType

The transport protocol used for the connection. The default value is OPC_UA_PROTOCOL_TYPE_TCP. Other valid values are:

OPC_UA_PROTOCOL_TYPE_HTTP
OPC_UA_PROTOCOL_TYPE_HTTPS
 
Encoding

The extension object encoding used for communication. The default value is OPC_UA_EXTENSION_OBJECT_ENCODING_NONE (0). Other valid values are:

OPC_UA_EXTENSION_OBJECT_ENCODING_BINARY (1)
OPC_UA_EXTENSION_OBJECT_ENCODING_XML (2)
OPC_UA_EXTENSION_OBJECT_ENCODING_ENCODEABLE_OBJECT (3)
 
SecurityPolicy

The security policy applied to the connection. The default value is OPC_UA_SECURITY_POLICY_NONE. Other valid values are:

OPC_UA_SECURITY_POLICY_Basic128Rsa15
OPC_UA_SECURITY_POLICY_Basic256
OPC_UA_SECURITY_POLICY_Basic256Sha256
OPC_UA_SECURITY_POLICY_Https
 
SecurityMode

The message security mode for the connection. The default value is OPC_UA_SECURITY_MODE_NONE (1). Other valid values are:

OPC_UA_SECURITY_MODE_SIGN (2)
OPC_UA_SECURITY_MODE_SIGN_AND_ENCRYPT (3)
 
UserTokenType

The type of user authentication token. The default value is OPC_UA_USER_TOKEN_TYPE_ANONYMOUS (0). Other valid values are:

OPC_UA_USER_TOKEN_TYPE_USERNAME (1)
OPC_UA_USER_TOKEN_TYPE_CERTIFICATE (2)
 
DiscoveryServerURI

The URI of the OPC UA discovery server. The default value is an empty string.

EndpointURI

The URI of the OPC UA server endpoint to connect to. The default value is an empty string.

IsSelectAllVariableNodes

Controls whether all variable nodes on the server are automatically selected for monitoring. The default value is nil (disabled).

IsManuallySelectNodes

Controls whether nodes are manually selected for monitoring rather than automatically discovered. The default value is t (enabled).

UserTokenKey

The key component of the user authentication token, such as a username or certificate path. The default value is an empty string.

UserTokenValue

The value component of the user authentication token, such as a password or certificate password. The default value is an empty string.

DataDomain

The data domain in which the connection's data points are stored. The default value is default.

IsTransmitOnlyGood

Controls whether only data with Good quality status is transmitted. The default value is nil (disabled). Otherwise t (true) transmits only data with Good quality status.

IsLoadMetadata

Controls whether metadata is loaded from the OPC UA server. The default value is nil (disabled). Otherwise t (true) enables metadata loading.

IsAcceptIncompleteAck

Controls whether incomplete acknowledgments from the server are accepted. The default value is nil (disabled). Otherwise t (true) enables incomplete acknowledgments.

IgnoreServerState

Controls whether the server state is ignored when establishing the connection. The default value is nil (disabled). Otherwise t (true) ignores the server state.

NotReceiveNullValue

Controls whether null data values from the server are rejected. The default value is nil (disabled, meaning null values are accepted). Otherwise t (true) does not accept null values.

MaximumUpdateRate

The maximum update rate in milliseconds for data subscriptions. The default value is 1000.

QueueSize

The size of the monitored item queue on the server. The default value is 1.

ReadBehaviorType

The read behavior type for the connection. The default value is OPC_UA_SUBSCRIPTION. Other valid values are:

OPC_UA_SYNCREAD
OPC_UA_ASYNCREAD
OPC_UA_SYNCCACHEREAD
 
WriteBehaviorType

The write behavior type for the connection. The default value is OPC_UA_SYNCHRONOUS_WRITE. The other valid value is OPC_UA_ASYNCHRONOUS_WRITE.

ValidationOptions

A bitmask of certificate validation options controlling which certificate errors are suppressed or checked. The default value is OPC_UA_SUPPRESS_CERTIFICATE_EXPIRED (0x1).

MaximumBrowseNodes

The maximum number of nodes that can be returned when browsing the server address space. The default value is 200000.

IsReadOnly

Controls whether the connection is read-only, preventing writes to the server. The default value is nil (false). Otherwise t (true) stops writing to the server.

WaitForRunningMs

Deprecated. Do not modify. Any changes may introduce unexpected behavior.

PauseBeforeReadingMs

The time in milliseconds to pause before reading data after the connection is established. The default value is 0.

ModelPropsAsValues

Controls whether model properties are treated as data values. The default value is nil (disabled). Otherwise t (true) treats them as data values.

AcceptInvalidServerCert

Controls whether invalid server certificates are accepted without validation. The default value is nil (disabled). Otherwise t (true) accepts them.

MaxRequestItemCount

The maximum number of items that can be included in a single request to the server. The default value is 500.

UseMultipleSubscriptions

Controls whether multiple subscriptions are used for monitoring items. The default value is t (enabled). Otherwise nil (false) means they are not.

ReadAlarms

Controls whether alarms and conditions are read from the server. The default value is nil (disabled). Otherwise t (true) enables reads.

AlarmDataDomain

The data domain in which alarm data points are stored. The default value is OPCAE.

TransportQuotas

An OpcUaTransportQuotas instance that holds the transport quota settings for this connection. It is initialized to a new OpcUaTransportQuotas object with default values.

AddNodeIdToAcConditionNames

Controls whether the node ID is appended to alarm and condition names. The default value is nil (disabled). Otherwise t (true) appends the node ID.

Methods

constructor(connectionName)

Initializes a new OPC UA connection with the given connectionName. This is invoked by the new operator when instantiating an OpcUaConnection instance. All configuration properties are set to default values, including default transport quota values. The manually-selected nodes list associated with this configuration is not set by the constructor but is accessible with methods from this class.

modify(parameter, value)

Changes a single configuration parameter in the current editing session.

detach()

Releases the connection from the editing context.

applyConfig()

A convenience method that iterates over all instance variables of this connection object and sets the values in the editing session.

setEnabled(value)

Sets the IsEnabled property in this connection's editing session. When enabled, the connection actively communicates with the OPC UA server.

setProtocolType(value)

Sets the ProtocolType property in this connection's editing session. The protocol type determines how the client communicates with the server.

setEncoding(value)

Sets the Encoding property in this connection's editing session. The encoding determines how extension objects are serialized for transport.

setSecurityPolicy(value)

Sets the SecurityPolicy property in this connection's editing session. The security policy determines the encryption and signing algorithms used for the connection.

setSecurityMode(value)

Sets the SecurityMode property in this connection's editing session. The security mode determines whether messages are signed, encrypted, or neither.

setUserTokenType(value)

Sets the UserTokenType property in this connection's editing session. The token type determines the authentication method used when connecting to the server.

setDiscoveryServerURI(value)

Sets the DiscoveryServerURI property in this connection's editing session. The discovery server URI is used to locate available OPC UA server endpoints.

setEndpointURI(value)

Sets the EndpointURI property in this connection's editing session. The endpoint URI specifies the address of the OPC UA server to connect to.

setLoadAllNodesOnServer(value)

Sets the IsSelectAllVariableNodes property in this connection's editing session. When enabled, all variable nodes on the server are automatically selected for monitoring.

setManuallySelectNodes(value)

Sets the IsManuallySelectNodes property in this connection's editing session. When enabled, the user must explicitly specify which nodes to monitor rather than relying on automatic discovery.

setUserName(value)

Sets the username for authentication by updating both the UserTokenType to USERNAME and the UserTokenKey to the provided value. This automatically switches the connection to username/password authentication mode.

setUserPassword(value)

Sets the password for authentication by updating both the UserTokenType to USERNAME and the UserTokenValue to the provided value. This automatically switches the connection to username/password authentication mode.

setCertificatePath(value)

Sets the certificate path for authentication by updating both the UserTokenType to CERTIFICATE and the UserTokenKey to the provided path. This automatically switches the connection to certificate-based authentication mode.

setCertificatePassword(value)

Sets the certificate password for authentication by updating both the UserTokenType to CERTIFICATE and the UserTokenValue to the provided password. This automatically switches the connection to certificate-based authentication mode.

setMyCertificate()

Switches the connection to certificate-based authentication using the built-in My Certificate key. It sets the UserTokenType to CERTIFICATE, clears the UserTokenValue, and sets the UserTokenKey to My Certificate.

setDataDomainName(value)

Sets the DataDomain property in this connection's editing session. The data domain determines which DataHub domain the connection's data points are stored in.

setTransmitOnlyGood(value)

Sets the IsTransmitOnlyGood property in this connection's editing session. When enabled, only data values with good quality status are transmitted from the server.

setLoadMetadata(value)

Sets the IsLoadMetadata property in this connection's editing session. When enabled, metadata such as engineering units and data types is loaded from the OPC UA server.

setAcceptIncompleteAck(value)

Sets the IsAcceptIncompleteAck property in this connection's editing session. When enabled, the client accepts incomplete publish acknowledgments from the server.

setIgnoreServerState(value)

Sets the IgnoreServerState property in this connection's editing session. When enabled, the client does not check the server's reported state before proceeding with operations.

setDoNotAcceptNullData(value)

Sets the NotReceiveNullValue property in this connection's editing session. When enabled, the client rejects null data values received from the server.

setMaximumUpdateRate(value)

Sets the MaximumUpdateRate property in this connection's editing session. This controls the fastest rate in milliseconds at which the server publishes data updates to the client.

setQueueSize(value)

Sets the QueueSize property in this connection's editing session. The queue size determines how many data change notifications the server buffers per monitored item before publishing.

setReadBehaviorType(value)

Sets the ReadBehaviorType property in this connection's editing session. The read behavior type determines how the client reads data from the server.

setWriteBehaviorType(value)

Sets the WriteBehaviorType property in this connection's editing session. The write behavior type determines whether writes to the server are performed synchronously or asynchronously.

setValidationOptions(value)

Sets the ValidationOptions property in this connection's editing session. The validation options are a bitmask that controls which certificate validation checks are suppressed or enforced.

setMaximumBrowseNodes(value)

Sets the MaximumBrowseNodes property in this connection's editing session. This limits the number of nodes returned when browsing the server's address space.

setReadOnly(value)

Sets the IsReadOnly property in this connection's editing session. When enabled, the client is prevented from writing values to the OPC UA server.

setPauseBeforeReadingMs(value)

Sets the PauseBeforeReadingMs property in this connection's editing session. This introduces a delay in milliseconds after the connection is established before the client begins reading data.

setModelPropertiesAsValues(value)

Sets the ModelPropsAsValues property in this connection's editing session. When enabled, model properties from the OPC UA server are exposed as data values in the DataHub.

setAcceptInvalidServerCert(value)

Sets the AcceptInvalidServerCert property in this connection's editing session. When enabled, the client accepts server certificates that fail validation checks.

setMaximumRequestItemCount(value)

Sets the MaxRequestItemCount property in this connection's editing session. This limits the number of items that can be included in a single read or write request to the server.

setUseMultipleSubscriptions(value)

Sets the UseMultipleSubscriptions property in this connection's editing session. When enabled, the client creates multiple subscriptions for monitoring items instead of a single subscription.

setReadAlarms(value)

Sets the ReadAlarms property in this connection's editing session. When enabled, the client subscribes to alarms and conditions from the OPC UA server.

setAlarmDataDomainName(value)

Sets the AlarmDataDomain property in this connection's editing session. The alarm data domain determines which DataHub domain alarm data points are stored in.

setAddNodeIdToConditionNames(value)

Sets the AddNodeIdToAcConditionNames property in this connection's editing session. When enabled, the node ID is appended to alarm and condition names to ensure uniqueness.

setOperationTimeout(value)

Sets the TransportQuotas.OperationTimeout property in this connection's editing session. This controls how long the client waits for a response from the server before timing out.

setMaxStringLength(value)

Sets the TransportQuotas.MaxStringLength property in this connection's editing session. This limits the maximum length in bytes of string values that can be sent or received.

setMaxByteStringLength(value)

Sets the TransportQuotas.MaxByteStringLength property in this connection's editing session. This limits the maximum length in bytes of byte string values that can be sent or received.

setMaxArrayLength(value)

Sets the TransportQuotas.MaxArrayLength property in this connection's editing session. This limits the maximum number of elements in an array that can be sent or received.

setMaxMessageSize(value)

Sets the TransportQuotas.MaxMessageSize property in this connection's editing session. This limits the maximum size in bytes of a single OPC UA message.

setMaxBufferSize(value)

Sets the TransportQuotas.MaxBufferSize property in this connection's editing session. This limits the maximum size in bytes of the send and receive buffers.

setChannelLifetime(value)

Sets the TransportQuotas.ChannelLifetime property in this connection's editing session. This controls how long in milliseconds the secure channel remains valid before it must be renewed.

setSecurityTokenLifetime(value)

Sets the TransportQuotas.SecurityTokenLifetime property in this connection's editing session. This controls how long in milliseconds the security token remains valid before it must be renewed.

addItem(pointName, nodeId, separator)

Sends a command to add a single monitored item to this connection's editing session. The item maps the string representation of an OPC UA NodeId to a DataHub point name and uses the specified separator for hierarchical separation of the point name components in the DataHub Data Viewer.

removeItem(pointName, separator)

Sends a command to remove a single monitored item from this connection's editing session.

addItems(listOfLists)

Sends a command to add multiple monitored items to this connection's editing session in a single operation.

This method will accept either of two Gamma script list of lists structures holding the data point information for convenience.

Structure A example

local structureAlistOfLists = list(
    list("ns=2;s=Scalar_Static_Duration", 
         "CTT.Scalar.Scalar_Static.Scalar_Static_Duration", "."),
    list("ns=2;s=Scalar_Static_Double",     
         "CTT.Scalar.Scalar_Static.Scalar_Static_Double", "."),
    list("ns=2;s=Scalar_Static_DateTime",   
         "CTT.Scalar.Scalar_Static.Scalar_Static_DateTime", "."),
    list("ns=2;s=Scalar_Static_ByteString", 
         "CTT.Scalar.Scalar_Static.Scalar_Static_ByteString", "."),
    list("ns=2;s=Scalar_Static_Byte",       
         "CTT.Scalar.Scalar_Static.Scalar_Static_Byte", "."),
    list("ns=2;s=Scalar_Static_Boolean",    
         "CTT.Scalar.Scalar_Static.Scalar_Static_Boolean", ".")
);
							

Structure B example

Local structureBListOfLists = list(
    list("ns=2;s=Scalar_Static_Duration",   
         list("CTT", "Scalar", "Scalar_Static", 
             "Scalar_Static_Duration")),
    list("ns=2;s=Scalar_Static_Double",     
         list("CTT", "Scalar", "Scalar_Static", 
             "Scalar_Static_Double")),
    list("ns=2;s=Scalar_Static_DateTime",   
         list("CTT", "Scalar", "Scalar_Static", 
             "Scalar_Static_DateTime")),
    list("ns=2;s=Scalar_Static_ByteString", 
         list("CTT", "Scalar", "Scalar_Static", 
              "Scalar_Static_ByteString")),
    list("ns=2;s=Scalar_Static_Byte",       
         list("CTT", "Scalar", "Scalar_Static", 
              "Scalar_Static_Byte")),
    list("ns=2;s=Scalar_Static_Boolean",    
         list("CTT", "Scalar", "Scalar_Static",
              "Scalar_Static_Boolean"))
);
							
removeItems(listOfLists)

Sends a command to remove multiple monitored items from this connection's editing session in a single operation. It accepts the same list of lists structure as addItems.

removeItemsRegex(pattern)

Sends a command to remove all monitored items whose names match the specified regular expression pattern.

applyItems(listOfLists)

Provides an atomic way to completely replace the monitored items list in a configuration by first removing all existing items using a ".*" regex pattern, then adding the new items from the provided list. If the removal step fails, the add step is skipped. Accepts the same list of lists structure as addItems.

getManuallySelectNodesList()

Sends a command to retrieve the list of nodes that have been manually selected for monitoring on this connection. Returns a list of lists structure that is described by example structure B in addItems.