MandatoryPlaceholder in optional subcomponent of another type|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
MandatoryPlaceholder in optional subcomponent of another type
Avatar
sxdev
New Member
Members
Forum Posts: 2
Member Since:
09/04/2019
sp_UserOfflineSmall Offline
1
02/03/2022 - 01:43
sp_Permalink sp_Print

Hello,

I would like to know how to model the following architecture:

  ListItemType (subtype of BaseObjectType)
  ListType (subtype of BaseObjectType) -HasComponent-> <ListItem> (ListItemType; MandatoryPlaceholder)

When I have another type that uses the ListType as such:
  AggregatingType (subtype of BaseObjectType) -HasComponent-> List (ListType; Optional)

Is the AggregatingType modelled correctly already, or does the MandatoryPlaceholder enforce an instance like this:
  AggregatingType (subtype of BaseObjectType) -HasComponent-> List (ListType; Optional) -HasComponent-> ListItem (ListItemType)

For my understanding, the MandatoryPlaceholder shall not enforce the "ListItem" as in the second case, but please correct me if I'm wrong.

Thanks

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/03/2022 - 13:19
sp_Permalink sp_Print sp_EditHistory

If you create an instance of a ListType in another type then that instance shall have one instance of ListItemType since every instances must honour the contract set by ListType.

If this does not make sense you need to use OptionalPlaceholder in ListType .

It is also not clear why you would would create generic List classes when the elements often need to be redefined with a subtype of ListItemType for each contained list (i.e. AggregatingListItemType). In this case you would add a second OptionalPlaceholder on the instance in  AggregatingType. The interpretation of the API is both OptionalPlaceholder criteria need to be satisfied in instances of AggregatingType.

Avatar
sxdev
New Member
Members
Forum Posts: 2
Member Since:
09/04/2019
sp_UserOfflineSmall Offline
3
02/04/2022 - 01:04
sp_Permalink sp_Print

Thanks for the quick reply. The type names are just illustrating the problem, the list is not supposed to be generic.

Let's say, I remove the ListType and create the model like this:
  ListItemType (subtype of BaseObjectType)
  AggregatingType (subtype of BaseObjectType)
      -HasComponent-> List (FolderType; Optional)
          -HasComponent-> <ListItem> (ListItemType; MandatoryPlaceholder)

Then, an instance of the AggregatingType must only instantiate at least one ListItemType, if it also instantiates the List?

But I will probably just change to OptionalPlaceholder.

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
4
02/04/2022 - 02:41
sp_Permalink sp_Print sp_EditHistory

Yes, every instance of AggregatingType would have to have at least 1 instance of ListItemType.

When designing a model with MandatoryPlaceholder it often makes sense to add a "Default" instance node into the type.

i.e.

"ListType"

+ "Default" (ListItemType, Mandatory)

+ "<ItemName>" (ListItemType, MandatoryPlaceholder)

This will ensure the minimum 1 instance is automatically created on instantiation and you do not need special logic.

If that design pattern does not make sense for you then OptionalPlaceholder may be a better fit.

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