12/06/2021
Hi
If I have a type defined that derives from Enumeration, with fields defined such that the identifiers are powers of two, can a value be returned which is bitwise OR of multiple fields?
For example, MyEnumerationType which derives from Enumeration
FieldA = 1, FieldB = 2, FieldC = 4
Then a Variable with DataType=MyEnumerationType and the value = 3, indicating to the client that both FieldA and FieldB are applicable
Thanks
05/30/2017
You need to use an OptionSet - not an Enumeration.
https://reference.opcfoundatio.....rt3/5.8.3/
The OptionSetValues Property shall provide an array of LocalizedText containing the human-readable representation for each bit.
12/06/2021
Thanks Randy
This is unfortunate, because it appears OptionSet is not supported by the model compiler. I see you made this commit in 2018: https://github.com/OPCFoundati.....a01d365824 so I wondered if I am doing anything wrong.
Should the base type for a defined OptionSet be OptionSet? When I define the type:
<DataType SymbolicName="MD:MyEnumerationType" BaseType="OpcUa:OptionSet" IsOptionSet="true">
<Fields>
<Field Name="FieldA" Identifier="1"/>
<Field Name="FieldB" Identifier="2"/>
<Field Name="FieldC" Identifier="4"/>
</Fields>
</DataType>
The model compiler tries to produce a C# enum that is derived from Opc.Ua.OptionSet, which of course then fails to compile (because Opc.Ua.OptionSet is a class).
Additionally, any class that tries to use create a variable of this OptionSet generates invalid IEncoder functions, as it tries to call the non-existent function IEncoder.WriteUserDefined in order to encode the option set.
05/30/2017
<!-- UpdateBehavior -->
<DataType SymbolicName="DI:UpdateBehavior" BaseType="OpcUa:UInt32" IsOptionSet="true">
<Fields>
<Field Name="KeepsParameters" BitMask="0001">
<Description>If KeepsParameters is not set, the device will lose its configuration during update. The Client should do a backup of the parameters before the update and restore them afterwards.</Description>
</Field>
<Field Name="WillDisconnect" BitMask="0002">
<Description>If WillDisconnect is set, the OPC UA Server will restart during installation. This can be the case if the update is about the firmware of the device that hosts the OPC UA Server.</Description>
</Field>
<Field Name="RequiresPowerCycle" BitMask="0004">
<Description>If RequiresPowerCycle is set, the devices require a manual power off / power on for installation.</Description>
</Field>
<Field Name="WillReboot" BitMask="0008">
<Description>If WillReboot is set, the device will reboot during the update, inclusive of embedded infrastructure elements like an integrated switch. An update Client should take this into account since the devices behind an integrated switch are not reachable for that time.</Description>
</Field>
<Field Name="NeedsPreparation" BitMask="0010">
<Description>If NeedsPreparation is not set, the Client can install the update without maintaining the PrepareForUpdateStateMachine. This can be used to support an installation without stopping the software.</Description>
</Field>
</Fields>
</DataType>
Moderators-Specifications
Moderators-Companion
Moderators-Implementation
Moderators-Certification
Moderators-COM
02/24/2014
The OPC Foundation specification define OptionSet in two manners, depending on the use case. There is an OptionSet datatype that is a subtype of structure which is composed of two bytestrings (one for value and one for valid bits). There is an OptionSetType VariableType which can be used for the same purpose. As a guideline the DataType would be used when the bit mask is fixed and applies to several Variables. The VariableType would be used when the bit mask is specific for only that Variable. The VariableType allows the value to be any of a number of datatypes (this includes integers), what Randy showed is the definition of an optionset that is a subtype of integer.
Paul Hunkar - DSInteroperability
1 Guest(s)