Page 1 of 1

OPC-UA DataType and TypeDefinition

Posted: 18 Mar 2023, 12:53
by JohnBurr
Very many of the variables in the Unified Automation demo server (.NET SDK) have a HasTypeDefinition of “BaseDataVariableType” and one example is the Demo.Static.Scalar.Boolean varialbe. I believe this use of the HasTypeDefinition is compliant with the specification, but is it typical or best practice? Someone is telling me that all variables with a data type of Boolean should have a HasTypeDefinition of "TwoStateDescreteType" but I cannot confirm this. I can find information about a variable's DataType and about a HasTypeDefintion reference in the specifications and I find information about deriving custom object types, but I cannot find this kind of advice, nor can I find a reference server that claims to be following best practices. My use case is essentially providing an OPC-UA server that shows values that come from an embedded controller that is much like a PLC. I am particularly interested in understanding Integers that have enumerated values (such as 0 means "red" and 1 means "blue" and 2 means "green") and in Booleans with and without associated text for the meaning of True and False. Thank you in advance for any advice or reading material.

Re: OPC-UA DataType and TypeDefinition

Posted: 30 May 2023, 18:35
by Support Team
Hello John,

If the semantic information for a Boolean is available, you can expose it via a TwoStateDiscreteType. There is an example in our DemoServers (Demo > 010_ComplianceTest > DA Profile > DiscreteType). If the semantic information is available for an unsigned integer, you can expose it via a MultiStateDiscreteType or a MultiStateValueDiscreteType. Alternatively you can create an enumerated DataType and use this Enumeration for the Variables.