Creates an instance of OpcuaConnector with the given options.
OPC UA options
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Gets the OPC UA client session, as defined by the interface
ClientSession
of node-opcua-client
package.
The client session of the connector can be used to access OPC UA client functionality which is not exposed by connector methods.
Returns undefined
if the OPC UA client is not connected, i.e. session
is not existing.
Browse the given OPC UA data item, i.e. asynchronously receive a list of all its OPC UA child nodes.
OPC UA data source for an OPC UA item to browse
optional OPC UA browse description options as defined in interface BrowseDescriptionOptions
a promise that resolves to an array of ReferenceDescription
objects describing child nodes (imported from node-opcua-client
) or
rejects if the given item couldn't be browsed.
Calls an OPC UA method on the given object node. The method is specified by its method node, and the input arguments.
OPC UA data source of the object node that provides the method
OPC UA data source of the method node to call
an array of objects defining OPC UA data type and value of input arguments.
a promise that resolves to an array of result values for the output arguments of the method call; the promise rejects if the given method call fails.
Asynchronously connects to the OPC UA server, creates a session emitting
a sessionCreated
event, and starts monitoring OPC UA data items if
requested.
Asynchronously disconnects from the OPC UA server, closing the client
session and emitting a sessionClosed
event.
Reads metadata of an OPC UA Analog Item defined by the given data source.
OPC UA data source for an OPC UA Analog Item
a promise that resolves to an OpcuaAnalogDataItem
object or
rejects if analog data item cannot be read.
Reads an attribute value of an OPC UA item defined by the given data source and resolves it in the returned promise.
OPC UA data source for an OPC UA item
an OPC UA compliant AttributeId as defined by enum AttributeIds
a promise that resolves to the attribute value of the given item or rejects if attribute value can't be read or coerced
Reads the value of an OPC UA variable defined by the given data source and resolves it in the returned promise.
OPC UA data source for an OPC UA variable
a promise that resolves to the value of the given variable or rejects if value can't be read or coerced
Register the given OPC UA data sources.
If a given data source identifier has already been registered (e.g. if specified in constructor options), the given data source is silently ignored.
object hash of data sources identified by a unique key
Writes the value of an OPC UA variable defined by the given data source.
OPC UA data source for an OPC UA variable
value to write
a promise that resolves if the variable as been written successfully or rejects if value can't be coerced or written
Generated using TypeDoc
A connector service that provides base OPC UA Client functionality to be used by a Coaty controller class.
Create an instance of this service class in the
onInit
method of the controller passing inOpcuaOptions
. Invokeconnect
on this service in theonCommunicationManagerStarting
method. Invokedisconnect
on this service in theonCommunicationManagerStopping
method.Invoke
registerDataSources
to register OPC UA data sources at run time, in addition to any data sources specified in the constructor options.Register event handlers on the
OpcuaConnector.on()
method to get notified of data value changes of a monitored data source item ("dataValueChange"
event), of errors ("error"
event), and of OPC UA session establishment.The event handler signatures are defined as follows:
// Emitted whenever an OPC UA error occurs. on("error", (error: any) => void); // Emitted whenever a monitored OPC UA data item changes its value. on("dataValueChange", ( dataSourceIdentifier: string, dataSource: OpcuaDataSource, dataValue: any, sourceTimestamp?: Date, // undefined if not provided by OPC UA server ) => void); // Emitted when the OPC UA client session has been created or closed. // You can access the session object using the getter `opcuaClientSession`. on("sessionCreated", () => void); on("sessionClosed", () => void);
This class also provides convenience methods to read and write variable values, to read attribute values, to read analog item metadata, to browse data items, and to call OPC UA methods.
Note: To enable debug logging on the OPC UA client library level, set the process environment variable
DEBUG
toALL
.This service only runs in a Node.js runtime, not in a browser.