Modelling a tree structure with the Composite pattern?|OPC UA Implementation: Stacks, Tools, and Samples|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
Modelling a tree structure with the Composite pattern?
Avatar
Jonas
Member
Members
Forum Posts: 8
Member Since:
06/13/2017
sp_UserOfflineSmall Offline
1
07/17/2017 - 08:25
sp_Permalink sp_Print sp_EditHistory

Dear All,

Modelling an address space I came across a situation where the classical composite pattern might be helpful (e.g. according to https://en.wikipedia.org/wiki/.....te_pattern). However, I don't seem to find a suitable way to do that in OPC-UA. Maybe I don't see the obvious solution?

Things I currently think are the case:

  1. It is not possible to model an object or variable which contains an array of objects or variables. Only data assigned to a Variable (DataType) can be declared as an array (via ValueRank and ArrayDimension which don't exist for Objects and Variables).
  2. Point 1 prevents the composite pattern at the level of Objects and Variables because the Composite object/variable needs to be able to keep a list of Component objects/variables.
  3. Because of 1 and 2, I'm left with DataType Structures. Starting with a DataType derived from Structure I can create something akin to a composite structure, but it doesn't feel right to do it at that level.

Any comments, hints how to model a generic tree structure are much appreciated.

Best regards,

Jonas

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
07/20/2017 - 04:53
sp_Permalink sp_Print

1) This is not true. The ExposesItsArray ModellingRule is used for this purpose. You can find examples in Part 5 such as the SamplingIntervalDiagnosticsArrayType.

You can also use the Mandatory/OptionalPlaceholder modelling rules. For example, from the Wiki page model you would create

ComponentType [ObjectType]

+ Leaf [Object | ModellingRule = Mandatory]

++ Operation [Method]

+ Composites [Object | ModellingRule = Mandatory]

++ <CompositeName> [Object | ModellingRule = OptionalPlaceholder | TypeDefinition = CompositeType]

++ Add [Method]

++ Remove [Method]

 

CompositeType [ObjectType]

+ Operation [Method]

 

The new PubSub configuration model makes extensive use of this pattern.

Avatar
Jonas
Member
Members
Forum Posts: 8
Member Since:
06/13/2017
sp_UserOfflineSmall Offline
3
08/03/2017 - 04:34
sp_Permalink sp_Print

Thank you Randy,

Glad to hear that my assumption 1) is wrong 🙂

I've also seen now the 'OptionalPlaceholder' approach in the Device Integration Specification.

And thank you for sketching the composite model. Much appreciated!

Best regards,

Jonas

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