Skip to content

Latest commit

 

History

History
190 lines (157 loc) · 12.1 KB

README.md

File metadata and controls

190 lines (157 loc) · 12.1 KB

OPC-DA Client

This driver implements a client for the OPC-DA protocol.

This driver uses the OPC DA/AE/HDA Solution .NET from Technosoftware, licensed under GPL 3.0.

https://github.com/technosoftware-gmbh/opcdaaehda-client-solution-net

The driver can have multiple connections to OPC-DA servers on multiple computers, as 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 or the Autotag function should be enabled.

Configure a driver instance

To create a new OPC-DA client instance, insert a new document in the protocolDriverInstances collection using a command like below or use the Admin UI to create a new entry.

use json_scada_db_name
db.protocolDriverInstances.insert({
        protocolDriver: "OPC-DA",
        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-DA". 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.

Configure client connections to OPC-DA servers

Each instance for this driver can have many client connection defined that must be described in the protocolConnections collection. Also the Admin UI can be use to add a new connection.

use json_scada_db_name
db.protocolConnections.insert({
    protocolDriver: "OPC-DA",
    protocolDriverInstanceNumber: 1.0,
    protocolConnectionNumber: 5001.0,
    name: "PLCDA1",
    description: "PLCDA1 - OPC-DA",
    enabled: true,
    commandsEnabled: true,
    endpointURLs: ["opcda://localhost/SampleCompany.DaSample.30"],
    topics: [],
    giInterval: 300,
    autoCreateTags: true,
    autoCreateTagPublishingInterval: 5.0,
    autoCreateTagSamplingInterval: 0.0,
    autoCreateTagQueueSize: 0.0,
    deadBand: 5.0,
    hoursShift: 0.0,
    timeoutMs: 20000,
    useSecurity: false,
    localCertFilePath: "",
    peerCertFilePath: "",
    password: "",
    username: "",
    stats: {}
});

Parameters for communication with OPC-DA servers.

  • protocolDriver [String] - Name of the protocol driver, must be "OPC-DA". 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. Use multiple entries for redundant servers. Entries must be defined in the following form "opcda://hostname/ServiceName". Mandatory 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] - Currently not used. Mandatory parameter.
  • autoCreateTagQueueSize [Double] - Currently not used. Mandatory parameter.
  • deadBand [Double] - Default dead-band (percent) for generating data updates by exception. Mandatory parameter.
  • hoursShift [Double] - Time shift to be applied to server timestamps (hours). Mandatory parameter.
  • giInterval [Double] - Integrity interval (seconds). Mandatory parameter.
  • topics [Array of Strings] - List of browse paths where to create tags automatically. Mandatory parameter.
  • timeoutMs [Double] - Currently not used. Mandatory parameter.
  • useSecurity [Boolean] - Use (true) or not (false) certificates. Mandatory parameter.
  • localCertFilePath [String] - Name of the file that contains the certificate that will be presented to the remote side of the connection. Mandatory parameter.
  • peerCertFilePath [String] - Name of the file that contains the certificate used to verify the server. Mandatory parameter.
  • username [String] - Username for authentication. Domain can be specified like this: "domain/username". Leave empty if not required by the server. Mandatory parameter.
  • password [String] - Password for authentication. Leave empty if not required by the server. Mandatory parameter.
  • stats [Object] - Protocol statistics updated by the driver. Mandatory parameter.

Configure JSON-SCADA tags for update (reading from an OPC-DA Server)

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":"PLCDA1.Square Waves.Boolean"}, {
    $set: {
        protocolSourceConnectionNumber: 5001.0,
        protocolSourceCommonAddress: "Square Waves",
        protocolSourceObjectAddress: "Square Waves.Boolean",
        protocolSourceASDU: "StatusCode",
        protocolSourcePublishingInterval: 5.0,
        protocolSourceSamplingInterval: 0.0,
        protocolSourceQueueSize: 0.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] - Branch name when autotag used. Leave empty if not known. Just documental. Mandatory parameter.
  • protocolSourceObjectAddress [String] - OPC-DA item Id. Mandatory parameter.
  • protocolSourceASDU [String] - Data type as detected by the library when autotag used: Boolean | SByte | Byte | Int16 | UInt16 | Int32 | UInt32, | Int64 | UInt64 | DateTime | Decimal | Float | Double | String | Type[] (array with elements of a type). Leave empty if not known. Just documental, not really used. Mandatory parameter.
  • protocolSourcePublishingInterval [Double] - Currently unused. Mandatory parameter.
  • protocolSourceSamplingInterval [Double] - Currently unused. Mandatory parameter.
  • protocolSourceQueueSize [Double] - Currently unused. Mandatory parameter.
  • protocolSourceDiscardOldest [Boolean] - Currently unused. Mandatory parameter.
  • kconv1 [Double] - Analog conversion factor: multiplier. Use -1 to invert digital values. Mandatory parameter.
  • kconv2 [Double] - Analog conversion factor: adder. Mandatory parameter.

Configure JSON-SCADA command tags (writing to an OPC-DA Server)

Create a regular command tag. Configure the connection number, OPCDA node id (object address) and OPCDA type (ASDU).

use json_scada_db_name
db.realtimeData.updateOne({"tag":"PLCDA1.Square Waves.Boolean.Cmd"}, {
    $set: {
        protocolSourceConnectionNumber: 5001.0,
        protocolSourceCommonAddress: "Square Waves",
        protocolSourceObjectAddress: "Square Waves.Boolean",
        protocolSourceASDU: "VT_BOOL",
        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] - Branch name. Not really used, just documental. Mandatory parameter.
  • protocolSourceObjectAddress [String] - OPC-DA Node Id. This address must be unique in a connection (for commands). Mandatory parameter.
  • protocolSourceASDU [String] - Data type: VT_BOOL | VT_I1 | VT_UI1 | VT_I2 | VT_UI2 | VT_I4 | VT_UI4, | VT_I8 | VT_UI8 | VT_DATE | VT_R4 | VT_R8 | VT_CY | VT_BSTR | VT_TYPE[] (array with elements of a type). Mandatory parameter.
  • kconv1 [Double] - Analog conversion factor: multiplier. Use -1 to invert digital values. Mandatory parameter.
  • kconv2 [Double] - Analog conversion factor: adder. Mandatory parameter.

Send commands by inserting document into commandsQueue collection

Commands can be also send via code or mongoshell by inserting documents into the into commandsQueue collection.

use json_scada_db_name
db.commandsQueue.insert(
{
"protocolSourceConnectionNumber": 5001,
"protocolSourceCommonAddress": "Square Waves",
"protocolSourceObjectAddress": "Square Waves.Boolean",
"protocolSourceASDU": "VT_BOOL",
"protocolSourceCommandDuration": 0,
"protocolSourceCommandUseSBO": false,
"pointKey": 500100000011,
"tag": "PLCDA1.Square Waves.Boolean.Cmd",
"timeTag": {
    "$date": "2025-06-15T13:16:53.291Z"
},
"value": 1,
"valueString": "true",
"originatorUserName": "admin",
"originatorIpAddress": "127.0.0.1"
});

Command Line Arguments

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".

Troubleshooting OPC-DA remote access

https://technosoftware.com/help/OPCDaAeHdaClientSolutionNet/20/#topic5.html

Example of JSON-SCADA Protocol Driver Instances and Connections Numbering

Driver instances and connections