RootNodeManager.addnode not reflecting my VariableAttribute

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

Moderator: uasdknet

Post Reply
dennisi
Full Member
Full Member
Posts: 9
Joined: 27 May 2015, 05:49

RootNodeManager.addnode not reflecting my VariableAttribute

Post by dennisi »

Hello Guys,

I have a question regarding RootNodeManager.AddNode function. I have successfully added new node however, the attribute is not correct.

here is my code

Code: Select all

 AddNodeSettings settings = new AddNodeSettings()
                    {
                        ParentNodeId = new NodeId(parentNodeId, nsIndex),
                        ReferenceTypeId = ReferenceTypeIds.HasComponent,
                        RequestedNodeId = requestedNodeId,
                        BrowseName = new QualifiedName(sNodeName, nsIndex),
                        Attributes = new VariableAttributes()
                        {
                            DisplayName = sNodeName,
                            DataType = DataTypeIds.Double,
                            AccessLevel = (AccessLevels.CurrentReadOrWrite | AccessLevels.HistoryReadOrWrite),
                            UserAccessLevel = (AccessLevels.CurrentReadOrWrite | AccessLevels.HistoryReadOrWrite),
                            ValueRank = ValueRanks.Scalar,
                            Historizing = true,
                            Value = Convert.ToDouble(sValue)                           
                        }

StatusCode error = myRootManager.AddNode(dviServer.DefaultRequestContext, settings, out requestedNodeId);

when i re-browse it in UA Expert, the value is null and the data type was set to BaseDataType which i expected to be double. Do I miss something? Thanks

User avatar
Support Team
Hero Member
Hero Member
Posts: 3072
Joined: 18 Mar 2011, 15:09

Re: RootNodeManager.addnode not reflecting my VariableAttrib

Post by Support Team »

Hello,

You need to specify the attributes you want to set at the node.

Code: Select all

            AddNodeSettings settings = new AddNodeSettings()
                   {
                       //...
                       Attributes = new VariableAttributes()
                       {
                           //...
                           SpecifiedAttributes = (uint)NodeAttributesMask.Value | (uint)NodeAttributesMask.DataType | (uint)NodeAttributesMask.ValueRank | (uint)NodeAttributesMask.Historizing | (uint)NodeAttributesMask.AccessLevel
                       }
                   };
For attributes that are not specified in the SpecifiedAttributes mask, the attribute value from the TypeDefinition is used.

Best regards
Support Team

Post Reply