Collector OPC UA
  • 01 Sep 2021
  • 10 Minutes to read
  • Contributors
  • Dark
    Light
  • PDF

Collector OPC UA

  • Dark
    Light
  • PDF

Article summary

The purpose of this article is to be a reference for the OPC UA collector part of the full Data Collection Module documentation

Prerequisite

A Starter package (SiteManager + accounts) 


Config main

The Config main (array of objects, mandatory) contain the following fields:

FunctionTypeImportanceDescription
ConfigNamestringmandatoryUnique name for this configuration file. Follows the rules for names.
ConfigDescriptionstringoptionaltext describing this configuration.
CheckpointIntervalinteger == 0 or >= 60optionalThe interval with which all data from the internal datasample cache is saved to disk. This more unstable (power) the SiteManager, the more often data should be saved. Saving it often, however will also cost performance and wear on the hard-disk/flash. A value of 0 means, never checkpoint, otherwise it means interval in seconds between saves. If not specified the value 15 * 60 (15 minutes) is used.
AlarmsSavedinteger >= 4optionalThe number of alarms saved in the store-and-forward database. If this values is not specified, it will default to 32.
WaitForNTPbooleanoptionalSynchronize DCM data collection with NTP time. If this parameter is true, all DCM collectors will not begin collecting data until NTP is enabled and configured and NTP has synchronized date/time. If not specified, the value is true.

Since the JSON format itself doesn't define a comment notation, DCM accepts a fieldname comment with any type of value in any section.

Example of comment

"Comment": "Example of a comment for use in any section.": 


OPC UA Collector main

The Collectors (array of objects, mandatory ) list of elements contains the following fields:

FunctionTypeImportanceDescription
CollectorNamestringmandatoryUnique name (within this confguration file) of a device to collect data from. (This is the name used in the agent configuration.) Follows the normal rules for names.
CollectorDescriptionstringoptionalDescription of this collector. (For your use, no system function)
CollectorIPAddrstringoptionalDefault IP address (or DNS name) for the device to be polled. The agent Target IP address will take precedence over this.
CollectorPortnointeger > 0 and < 65535optionalDefault port number for the device to be polled. The agent Target Port number will take precedence over this. If neither CollectorPortno nor agent Target Port Number is specified, the appropriate port will be used, depending on the Protocol parameter value.
AliasstringoptionalThis is the CollectorName of another collector, from which all the parameters (except CollectorName , CollectorDescription , CollectorIPAddr and CollectorPortno ) are copied. An alias cannot refer to another alias.
Protocolstring-enummandatoryThe protocol used to collect data. Currently 3 possible values exist: "OPC-UA/TCP", "Modbus/TCP", "Http/GET" and "Simulator".
ConnectRetryMininteger > 0mandatoryThe minimum number of seconds before trying to re-establish a connection to the device being sampled. An exponential backoff algorithm is used to retry connection establishment, starting after ConnectRetryMin and increasing to ConnectRetryMax.
ConnectRetryMaxinteger > 0mandatoryThe maximum number of seconds before trying to re-establish a connection to the device being sampled.
OPCUAAccessObjectoptionalCollection of parameters needed to access a given OPC-UA/TCP server.
SamplePointsArray of objectsmandatoryList of samples to be collected, possibly aggregated and stored in the Store'n'Forward database.

OPCUAAccess

Note
The Security mode is an EXPERIMENTAL new feature and all security-related configuration is subject to change.
Important
OPCUAUsername and OPCUAPassword are deprecated and will probably be removed in a future release. 

The OPCUAAccess object contains the following elements: 

FunctionTypeImportanceDescription




OPCUASecurityModestring-enumoptionalThe security mode for the communication channel between DCM (OPC-UA client) and the OPC-UA server. Currently 3 possible values exists: "none", "sign" or "signencrypt". Unless specified otherwise, "none" is set as default.
OPCUASecurityPolicystringmaybe-optional
The security policy is mandatory, when the OPCUASecurityMode is "sign" or "signencrypt". Currently 5 possible values exists:
"none"
"Basic128Rsa15"
"Basic256"
"Basic256Sha256"
"Aes128_Sha256_RsaOaep".
If not specified, "none" will be used.
OPCUACertificatestringoptionalThe name of the certificate used for authentication during the collection of data if the OPCUASecurityMode is "sign" or "signencrypt". If not specified, the name opcua-cert- CollectorName will be used. If such a certificate does not exist in the certificate store, it will be created.
OPCUAPrivateKeystringoptionalThe name of the private key to use for encryption during collecting of data if the OPCUASecurityMode is "sign" or "signencrypt". If not specified, the name opcua-pkey- CollectorName will be used. If such a private key does not exist in the certificate store, it will be created.
OPCUAServerCertificatesarray of stringsoptionalThe name of the certificates imported from the OPC-UA server(s), that the collector retrieves data from. If no server is specified, any server will be accepted as being valid. If specified as an empty array, then all certificates of the OPC-UA Server certificate type will be used. OPCUAUserTokenType (string-enum, mandatory) The user authentication methods used when collecting data. Currently 4 possible values exists: "anonymous", "username", "certificate" or "issuedtoken".
OPCUAUserTokenTypestring-enummandatoryThe user authentication methods used when collecting data. Currently 4 possible values exists: "anonymous", "username", "certificate" or "issuedtoken".
OPCUAUserTokenNamestringmaybe-optional

The name of the 'username/password information', 'certificate' or 'issuedtoken' to use. Mandatory if OPCUAUserTokenType is "username", "certificate" or "issuedtoken". The name refers to an entry in the certificate store, which should contain the following:

  • For "username"- a file with 2 lines of text: 
  • The username and the password. 
  • For "certificate": an X.509 certificate. For "issuedtoken": a BASE64 encoded text file.
OPCUAUsernamestringmaybe-optionalThe username to use for the OPC-UA session. To use OPCUAUsername it is a requirement that Securitypolicy + Security Mode is set to something other than "none".
Note that this parameter is deprecated and will probably be removed in a future release. Instead, we recommend using OPCUAUserTokenName as it is more flexible and secure. 
OPCUAPasswordstringmaybe-optionalThe password to use for the OPC-UA session. To use OPCUAPassword it is a requirement that Securitypolicy + Security Mode is set to something other than "none".
Note that this parameter is deprecated and will probably be removed in a future release. Instead, we recommend using OPCUAUserTokenName as it is more flexible and secure.
OPCUAPathstringoptionaladditional path component to the URL used for connecting to the OPC-UA server.
OPCUABrowseRootIds
array of OPCUABrowseRootId
optional

The OPC-UA node id to start browsing for relative browse paths from.

OPCUATimeStampPolicystring-enummandatoryThe timestamp to mark collected data with. Currently 3 possible values exists: "source", "server" or "dcm". If the polled OPC-UA server doesn't support the requested timestamp, DCM will fall back from Source->Server->DCM. This field also serves as the default value for the optional field OPCUATimeStampPolicy in sample OPCUAObject.
OPCUATimeoutinteger > 0optionalTimeout (in millisecond) for OPC-UA query requests. If not present the value 5000 is used.

Samplepoint

The SamplePoints objects contains the following elements:

FunctionTypeImportanceDescription
SampleNamestringmandatoryName of this sampled value (sometimes called a tagname). Follows the normal rules for names.
SampleDescriptionstringoptionalis a text description of this sample value.
SampleUnitstringoptionalis a description of the unit measurement for this sample.
SampleGroupstringoptionaldesignates (in some datasrvs) that all samplepoints in that group should be handled (displayed) together. The DCM system itself places no meaning on this group affiliation.
SamplesSavedinteger > 0optional
is the number of values collected that is saved in the Store'n'Forward database even after the values have been sent to all dataservers. When 0 is specified, the value can be used in aggregators. but nothing is sent via dataservers to cloud system. If left unspecified, values are only saved in the Store'n'Forward database until they have been delivered to all dataservers.
OnlySaveOnChangedbooloptionalCheck if new sample values should only be saved to the store-and-forward database if the values have changed since last sample. If not set, it is false.
ChangeLimit
Integer/DoubleoptionalOnly used if OnlySaveOnChanged is true. This describes a limit for what "changed" means. If a new sample value is this amount less or more than the previous sample value, it is considered the "same" value. This is a simple hysteresis to filter out inaccurate (jitter) measurements.
SampleDataTypestring-enummandatoryThe type of data collected. The possible values are: "bool" (1 bit), "sbyte" (8 bit signed), "byte" (8 bit unsigned), "int16" (16 bit signed), "uint16" (16 bit unsigned), "int32" (32 signed), "uint32" (32 bit unsigned), "int64" (64 bit signed), "uint64" (64 bit unsigned), "float" (32 bit), "double" (64 bit), "string" (variable text up to 24575 bytes. Includes terminating NUL), "data" (variable data up to 24575 bytes). This collector might not support all SampleDataTypes. 
SampleMaxVDataSize
integer > 0 and <= 24575
optional
is the max size of variable data enforced for this sample. This is only relevant for SampleDataType "string" or "data". If not specified, the value is 1024.
SampleLowerLimitinteger/doubleoptionalThe lower limit for the collected data. If the collected data value is less than SampleLowerLimit it is evaluated in accordance with SampleLimitDiscard and SampleLimitAlarm.
SampleUpperLimitinteger/doubleoptionalThe upper limit for the collected data. If the collected data value is more than SampleUpperLimit it is evaluated in accordance with SampleLimitDiscard and SampleLimitAlarm.
SampleLimitDiscardboolmaybe-optionalChecks if a sample limit violation results in the sample value being discarded. Mandatory if either SampleLowerLimit or SampleUpperLimit is present.
SampleLimitAlarmboolmaybe-optionalChecks if a sample limit violation generates an alarm. Mandatory if either SampleLowerLimit or SampleUpperLimit is present.
OPCUAObjectObjectmaybe-optionalDescription of how to address a specific OPC-UA object, when values are collected from it. Mandatory if the protocol type is "OPC-UA/TCP".

OPCUABrowseRootId

TheOPCUABrowseRootId object contains the following fields:

FunctionTypeImportanceDescription
BrowseRootID
integer >= 0mandatoryis a unique ID for this entry. (Used by the OPCUAObject entries).
NodeIdNameSpaceIndex
integer >= 0 and < 65535
maybe-optional
This is the OPC-UA NodeID type. (ID type of the tag) The possible values are: "numeric", "string", "guid" or "bytestring".
NodeIdType
string-enum
mandatory
This is the OPC-UA NodeID type. The possible values are: "numeric", "string", "guid", "bytestring" or "browsename".
NodeIdNumeric
integer >= 0 and < 4294967295
maybe-optional
This is OPC-UA NodeID numeric value. Only mandatory if the value of NodeIdType is "numeric".
NodeIdString
string
maybe-optional
This is OPC-UA NodeID string value. Only mandatory if the value of NodeIdType is "string" or "browsename". For "browsename" it is the node browsename to be searched for, starting from OPCUABrowseRootId and forwards in the tree.
NodeIdGuid
string
maybe-optional
This is OPC-UA NodeID GUID value. Only mandatory if the value of NodeIdType is "guid". The format is hex-digits with hyphens enclosed in curly brackets: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} (38 characters).
NodeIdByteString
string
maybe-optional
This is OPC-UA NodeID byte string value. Only mandatory if the value of NodeIdType is "bytestring". The format is hex-digits. Must not be an empty string and must contain a even number of hex digits.
NodeIdBrowsePath
array of strings
maybe-optional
This is OPC-UA NodeID browse path. Only mandatory if the value of NodeIdType is "browsename". This browsepath is relative to official OPC-UA root folder namespaceindex 0 (numeric: 84). Each string in the array follows the OPC-10000-3 section C.2.3 syntax ([<namespaceindex>:]<browsename>) where the <namespaceindex>: can be omitted if namespaceindex is 0.

OPCUAObject

The OPCUAObject object contains the following fields:

FunctionTypeImportanceDescription
NodeIdNameSpaceIndexinteger >= 0 and < 65535maybe-optional
This is the OPC-UA namespace index. When NodeIdType is "browsename", this index is not used and is therefore optional.
NodeIdTypestring-enummandatoryThis is the OPC-UA NodeID type. The possible values are: "numeric", "string", "guid", "bytestring" or "browsename".
NodeIdNumericintegermaybe-optionalThis is OPC-UA NodeID numeric value. Only mandatory if the value of NodeIdType is "numeric".
NodeIdStringstringmaybe-optionalThis is OPC-UA NodeID string value. Only mandatory if the value of NodeIdType is "string".
NodeIdGuidstringmaybe-optionalThis is OPC-UA NodeID GUID value. Only mandatory if the value of NodeIdType is "guid". The format is hex-digits with hyphens enclosed in curly brackets: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} (38 characters).
BrowseRootREF
integer >= 0
integer >= 0
This is a reference to the OPCUABrowseRootIds element with the same value of it's field OPCUABrowseRootId. This field is only used, when the NodeIdType is "browsename".
NodeIdBrowsePath
array of strings
maybe-optional
This is OPC-UA NodeID browse path. Only mandatory if the value of NodeIdType is "browsename". This browsepath is relative to the browseroot specified with the BrowseRootREF value. If the BrowseRootREF is left unspecified, it is an absolute browsepath starting from the "Root" node. Each string in the array follows the OPC-10000-3 section C.2.3 syntax ([<namespaceindex>:]<browsename>) where the <namespaceindex>: can be omitted if namespaceindex is 0.
NodeIdByteStringstringmaybe-optionalThis is OPC-UA NodeID byte string value. Only mandatory if the value of NodeIdType is "bytestring". The format is hex-digits. Must not be an empty string and must contain an even number of hex digits.
OPCUASampleInterval
integer >= 0
mandatory
The number of seconds between each sample of this OPC-UA object. If the interval is 0, only event-driven polling is used.
OPCUATimeStampPolicystring-enumoptionalThe timestamp to mark this sample data with. Currently 3 possible values exists: "source", "server" or "dcm". If this field is not present the OPCUATimeStampPolicy filed from the OPCUAAccess object, this sample belongs to, will be used instead.


Example of collector with OPCUAAccess, Samplepoints and OPCUAObject objects:

{
 "CollectorName": "OmronOPCUA",
 "CollectorDescription": "Example Omron NX1 with OPC-UA Server",
 "Protocol": "OPC-UA/TCP",
 "ConnectRetryMin": 2,
 "ConnectRetryMax": 240,
 "OPCUAAccess": {
  "OPCUASecurityPolicy": "none",
  "OPCUAUserTokenType": "anonynmous",
  "OPCUATimeStampPolicy": "dcm"
  },
 "SamplePoints": [
 {
 "SampleName": "Temp1",
 "SampleDescription": "B1 Potmeter",
 "SamplesSaved": 1000,
 "SampleDataType": "int16",
 "SampleLimitDiscard": true,
 "SampleUpperLimit": 8100,
 "SampleLowerLimit": 0,
 "SampleLimitAlarm": false,
 "OPCUAObject": {
  "NodeIdNameSpaceIndex": 4,
  "NodeIdType": "string",
  "NodeIdString": "Analog1",
  "OPCUASampleInterval": 4
  }
  }
 ]
}


Example of collector for OPC UA server on Siemens PLC

{
  "CollectorDescription": "Example with Siemens PLC w/OPC-UA Server",
  "CollectorName": "Test2OPCUA",
  "ConnectRetryMax": 240,
  "ConnectRetryMin": 10,
  "OPCUAAccess": {
   "OPCUASecurityPolicy": "none",
   "OPCUATimeStampPolicy": "dcm",
   "OPCUAUserTokenType": "anonynmous"
   },
  "Protocol": "OPC-UA/TCP",
  "SamplePoints": [
 {
  "OPCUAObject": {
  "NodeIdNameSpaceIndex": 3,
  "NodeIdString": "\"DB_MRUSim\".\"Out\"",
  "NodeIdType": "string",
  "OPCUASampleInterval": 1
 },
  "SampleDataType": "double",
  "SampleDescription": "AHC curve",
  "SampleName": "AHC",
  "SamplesSaved": 10
  }
 ]
}


See complete OPC UA examples in the "Related articles" section below. 


Was this article helpful?