Page 1 of 1

Optional Types of Children and their children

Posted: 30 Apr 2019, 08:59
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

Re: Optional Types of Children and their children

Posted: 10 Oct 2019, 15:44
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.

Re: Optional Types of Children and their children

Posted: 10 Oct 2019, 15:45
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.