Inheritance with MultiStateDiscreteType|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Inheritance with MultiStateDiscreteType
Avatar
Christian Von Arnim
New Member
Members
Forum Posts: 2
Member Since:
07/25/2017
sp_UserOfflineSmall Offline
1
02/20/2020 - 06:22
sp_Permalink sp_Print sp_EditHistory

Hello everyone,

I have a question about inheritance in combination with MultiStateDiscreteType. Does a subtype have to take all values of the base type and can add additional values?

Is the address space shown below correct?

Image Enlarger

 

In the case of enums, I know that the subtype may only use a selection of values from the parent enum, but no new values can be added.

Best regards

Christian

Avatar
Randy Armstrong
Admin
Forum Posts: 1451
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/21/2020 - 18:00
sp_Permalink sp_Print sp_EditHistory

MultiStateDiscreteType variables do not have the same semantics of an Enumeration since every instance has its own set of values as specified in the EnumValues or EnumString property on the instance. This means subtypes of MultiStateDiscreteType do not/cannot restrict the allowed values. If you need the semantics of an Enumeration you should use a normal variable with an Enumeration DataType.

Avatar
Christian Von Arnim
New Member
Members
Forum Posts: 2
Member Since:
07/25/2017
sp_UserOfflineSmall Offline
3
02/24/2020 - 23:29
sp_Permalink sp_Print

Thank you very much for the answer. In my particular case, there is a need for an extensible "enum", which contains a fixed set of values that must be included in every extension.

Randy Armstrong said
This means subtypes of MultiStateDiscreteType do not/cannot restrict the allowed values.

Are there any rules for inheritance of MultiStateDiscreteType? Do existing values still have to be included in the subtype? Can a subtype overwrite a value of the base class (change the name)?

 

E.g. Is this changing of values possible/intended?

Base type:
0: Off
1: On

 

Derived data type:
0: Off
1: Setup
2: Online

 

I hope that no values can be overwritten and that a set of predefined values is ensured in all subtypes.
In the end I need such a variable:

Variable: PowerState   DataType=BasePowerstate

BasePowerState->EnumStrings
0: Off
1: On

 

ImplementationSpecific_PowerState_1((inherit from BasePowerState)->EnumString
0: Off
1: On
2: LowPowerMode
3: StandBy
...

 

Best regards

Christian

Avatar
Randy Armstrong
Admin
Forum Posts: 1451
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
02/25/2020 - 05:52
sp_Permalink sp_Print

If you want those semantics then use a DataItemType with a Enumeration DataType.

Clients are expected to read the EnumValues/EnumStrings Property for each instance of a MultiStateVariable so the inheritance hierarchy will not restrict the values. Subtypes of MultiStateVariable ony restrict the DataType that can be used (i.e. UInteger -> UInt32).

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 18
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1351
Posts: 4579