This driver implements a client for the OPC-UA protocol.
This driver uses the OPC Foundation's .NET Standard library compiled to .NET 5.0 target platform.
https://github.com/OPCFoundation/UA-.NETStandard
The driver can have multiple connections to OPC-UA servers on multiple computers, if needed. To configure the driver it is necessary to create one or more driver instances and at least one connection per instance. Also the tags intended to be updated should be configured appropriately.
To create a new OPC-UA client instance, insert a new document in the protocolDriverInstances collection using a command like this:
use json_scada_db_name
db.protocolDriverInstances.insert({
protocolDriver: "OPC-UA",
protocolDriverInstanceNumber: 1,
enabled: true,
logLevel: 1,
nodeNames: ["mainNode"],
activeNodeName: "mainNode",
activeNodeKeepAliveTimeTag: new Date(),
keepProtocolRunningWhileInactive: false
});
- protocolDriver [String] - Name of the protocol driver, must be "OPC-UA". Mandatory parameter.
- protocolDriverInstanceNumber [Double] - Number of the instance. Use 1 to N to number instances. For the same driver instance numbers should be unique. The instance number makes possible to run use multiple processes of the driver, each one with a distinct configuration. Mandatory parameter.
- enabled [Boolean] - Controls the enabling of the instance. Use false here to disable the instance. Mandatory parameter.
- logLevel [Double] - Number code for log level (0=minimum,1=basic,2=detailed,3=debug). Too much logging (levels 2 and 3) can affect performance. Mandatory parameter.
- nodeNames [Array of Strings]- Array of node names that can run the instance. Use more than one node for redundancy. Each redundant instance running on separate nodes will have the same connections and data enabled for scanning and update. Mandatory parameter.
- activeNodeName [String] - Name of the protocol driver that is currently active. This is updated by the drivers for redundancy control.Optional.
- activeNodeKeepAliveTimeTag [Date] - This is updated regularly by the active driver. Optional.
- keepProtocolRunningWhileInactive [Boolean] - Define a driver will keep the protocol running while not the main active driver. Currently only the false value is supported. Optional.
Changes in the protocolDriverInstances config requires that the driver instances processes be restarted to be effective.
Each instance for this driver can have many client connection defined that must be described in the protocolConnections collection.
use json_scada_db_name
db.protocolConnections.insert({
protocolDriver: "OPC-UA",
protocolDriverInstanceNumber: 1.0,
protocolConnectionNumber: 81.0,
name: "PLC1",
description: "PLC1 - OPC-UA",
enabled: true,
commandsEnabled: true,
endpointURLs: ["opc.tcp://opcuaserver.com:48010"],
configFileName: "../conf/Opc.Ua.DefaultClient.Config.xml",
autoCreateTags: true,
autoCreateTagPublishingInterval: 2.5,
autoCreateTagSamplingInterval: 0.0,
autoCreateTagQueueSize: 5.0,
timeoutMs: 20000,
useSecurity: false,
topics: [],
giInterval: 300.0,
hoursShift: 0.0,
stats: {}
});
Parameters for communication with OPC-UA servers.
- protocolDriver [String] - Name of the protocol driver, must be "OPC-UA". Mandatory parameter.
- protocolDriverInstanceNumber [Double] - Number of the instance. Use 1 to N to number instances. For the same driver instance numbers should be unique. The instance number makes possible to run use multiple processes of the driver, each one with a distinct configuration. Mandatory parameter.
- protocolConnectionNumber [Double] - Number code for the protocol connection. This must be unique for all connections over all drivers on a system. This number is be used to define the connection that can update a tag. Mandatory parameter.
- name [String] - Name for a connection. Will be used for logging. Mandatory parameter.
- description [String] - Description for the purpose of a connection. Just documental. Optional parameter.
- enabled [Boolean] - Controls the enabling of the connection. Use false here to disable the connection. Mandatory parameter.
- commandsEnabled [Boolean] - Allows to disable commands (messages in control direction) for a connection. Use false here to disable commands. Mandatory parameter.
- endpointURLs [Array of Strings] - Array of server endpoints URLs (only the first server is currently supported). Mandatory parameter.
- configFileName [String] - Name of the config file (with absolute path or relative to the bin folder). Default="../conf/Opc.Ua.DefaultClient.Config.xml". Use this file or crete new files to configure certificates and other OPC-UA parameters for a connection. Optional parameter.
- autoCreateTags [Boolean] - When true the driver will create tags for every data point found in the server, all points will be subscribed. When false, only preconfigured tags will be updated. Mandatory parameter.
- autoCreateTagPublishingInterval [Double] - Default publishing interval in seconds for subscription of auto created tags. Mandatory parameter.
- autoCreateTagSamplingInterval [Double] - Default sampling interval in seconds for subscription of auto created tags. Mandatory parameter.
- autoCreateTagQueueSize [Double] - Default queue size for subscription of auto created tags. Mandatory parameter.
- timeoutMs [Double] - Timeout for keepalive messages. Mandatory parameter.
- useSecurity [Boolean] - Use (true) or not (false) secure encrypted connection. Mandatory parameter.
- hoursShift [Double] - Time shift to be applied to server timestamps (hours). Mandatory parameter.
- giInterval [Double] - Integrity interval for items not on subscription (seconds). Mandatory parameter.
- topics [Array of Strings] - List of browse paths where to create tags automatically (e.g. "/Objects/Path", "Boiler"). Mandatory parameter.
- stats [Object] - Protocol statistics updated by the driver. Mandatory parameter.
Each tag to be update on a connection must have a protocol source set configured. Only one source connection can update a tag.
Select a tag for a update on a connection as below.
use json_scada_db_name
db.realtimeData.updateOne({"tag":"Demo.Dynamic.Scalar.StatusCode"}, {
$set: {
protocolSourceConnectionNumber: 81.0,
protocolSourceCommonAddress: "Subscription1",
protocolSourceObjectAddress: "ns=2;s=Demo.Dynamic.Scalar.StatusCode",
protocolSourceASDU: "StatusCode",
protocolSourcePublishingInterval: 5.0,
protocolSourceSamplingInterval: 0.0,
protocolSourceQueueSize: 5.0,
protocolSourceDiscardOldest: true,
kconv1: 1.0,
kconv2: 0.0
}
});
- protocolConnectionNumber [Double] - Number code for the protocol connection. Only this protocol connection can update the tag. Mandatory parameter.
- protocolSourceCommonAddress [String] - Not used, keep as empty string. Mandatory parameter.
- protocolSourceObjectAddress [String] - OPC-UA Node Id. This address must be unique in a connection (for supervised points). Mandatory parameter.
- protocolSourceASDU [String] - Data type: Boolean | SByte | Byte | Int16 | UInt16 | Int32 | UInt32, | StatusCode | Int64 | UInt64 | DateTime | Guid | Float | Double | String | ByteString | XmlElement | NodeId | ExpandedNodeId | LocaleId | QualifiedName | LocalizedText | Number | Integer | UInteger | Enumeration | ExtensionObject | JSON (JSON in a string) | [, Array Range]. E.g. UInt64,0:10. Mandatory parameter.
- protocolSourcePublishingInterval [Double] - Publishing interval in seconds for the subscription group (repeat the same value for all members of a subscription). Leave at zero if not a subscription. Mandatory parameter.
- protocolSourceSamplingInterval [Double] - Sampling interval in seconds requested for the server. Only meaningful for subscriptions. Use zero for auto adjust on the server. Mandatory parameter.
- protocolSourceQueueSize [Double] - Queue size for buffering of changes in the server between reports. Only meaningful for subscriptions. Use zero to avoid buffering. Mandatory parameter.
- protocolSourceDiscardOldest [Boolean] - What to do when changes queue overflows. Use true to discard oldest changes.Only meaningful for subscriptions. Mandatory parameter.
- kconv1 [Double] - Analog conversion factor: multiplier. Use -1 to invert digital values. Mandatory parameter.
- kconv2 [Double] - Analog conversion factor: adder. Mandatory parameter.
Create a regular command tag. Configure the connection number, OPCUA node id (object address) and OPCUA type (ASDU).
use json_scada_db_name
db.realtimeData.updateOne({"tag":"a_command_tag"}, {
$set: {
protocolSourceConnectionNumber: 81.0,
protocolSourceCommonAddress: "",
protocolSourceObjectAddress: "ns=2;s=Demo.Dynamic.Scalar.Byte",
protocolSourceASDU: "Byte",
kconv1: 1.0,
kconv2: 0.0
}
});
- protocolConnectionNumber [Double] - Number code for the protocol connection. Only this protocol connection can command this tag. Mandatory parameter.
- protocolSourceCommonAddress [String] - Not used, keep as empty string. Mandatory parameter.
- protocolSourceObjectAddress [String] - OPC-UA Node Id. This address must be unique in a connection (for commands). Mandatory parameter.
- protocolSourceASDU [String] - Data type: Boolean | SByte | Byte | Int16 | UInt16 | Int32 | UInt32, | Int64 | UInt64 | DateTime | Float | Double | String. Mandatory parameter.
- kconv1 [Double] - Analog conversion factor: multiplier. Use -1 to invert digital values. Mandatory parameter.
- kconv2 [Double] - Analog conversion factor: adder. Mandatory parameter.
This driver has the following command line arguments.
- 1st arg. - Instance Number [Integer] - Instance number to be executed. Optional argument, default=1.
- 2nd arg. - Log. Level [Integer] - Log level (0=minimum,1=basic,2=detailed,3=debug). Optional argument, default=1.
- 3rd arg. - Config File Path/Name [String] - Complete path/name of the JSON-SCADA config file. Optional argument, default="../conf/json-scada.json".