Optional Types of Children and their children

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
Darren Whittall
Jr. Member
Jr. Member
Posts: 1
Joined: 23 Apr 2019, 19:30

Optional Types of Children and their children

Post by Darren Whittall »

Hi,

I am creating a server for training purposes and would like to know how to create instances on the OPC UA server of the types which have a modelling rule optional.
I have used the OptionalBrowsePaths property in CreateObjectSettings to define which optional types I want to create, but this only works for the immediate children.
I would like to create instances of ALL optional types in the model including the children's children...

Can somebody please explain how to do this?

Thanks

MortenSchou
Full Member
Full Member
Posts: 9
Joined: 14 Feb 2018, 10:49

Re: Optional Types of Children and their children

Post by MortenSchou »

Hi Darren,

You can do this by specifying the children of children in OptionalBrowsePaths as follows (example adding optional TransitionTime of ActiveState of AlarmConditionType):

Code: Select all

            var alarmConditionObject = CreateObject(Server.DefaultRequestContext, new CreateObjectSettings
            {
                ParentNodeId = ...,
                ReferenceTypeId = ReferenceTypeIds.HasCondition,
                RequestedNodeId = ...,
                BrowseName = ...,
                TypeDefinitionId = ObjectTypeIds.AlarmConditionType,
                OptionalBrowsePaths = new List<string> { "LatchedState", "Reset", AbsoluteName.ToString("ActiveState","TransitionTime") }
            });
Basically, you use the AbsoluteName.ToString to construct the browse path to the optional children of children to include.

MortenSchou
Full Member
Full Member
Posts: 9
Joined: 14 Feb 2018, 10:49

Re: Optional Types of Children and their children

Post by MortenSchou »

Found out how to do this...

Done by specifying the children of children in OptionalBrowsePaths as follows (example adding optional TransitionTime of ActiveState of AlarmConditionType):

Code: Select all

            var alarmConditionObject = CreateObject(Server.DefaultRequestContext, new CreateObjectSettings
            {
                ParentNodeId = ...,
                ReferenceTypeId = ReferenceTypeIds.HasCondition,
                RequestedNodeId = ...,
                BrowseName = ...,
                TypeDefinitionId = ObjectTypeIds.AlarmConditionType,
                OptionalBrowsePaths = new List<string> { "LatchedState", "Reset", AbsoluteName.ToString("ActiveState","TransitionTime") }
            });
Basically, you use the AbsoluteName.ToString to construct the browse path to the optional children of children to include.

Post Reply