Visualizing dynamically created nodes in UAExpert

158 Views Asked by At

I can dynamically create a node through method node calls, but cannot see it in UAExpert without manually looking for it (Createcustomnode with same nodeId shows the node in 'data access view'). Restarting UAExpert after node creation doesn't fix this issue. How can I solve this problem?

Thanks

public ServiceResult AddNodeMethod(ISystemContext context, MethodState method, IList<object> inputArgs, IList<object> outputArgs0)
    {

        BaseDataVariableState variable = new BaseDataVariableState(opcUaServer);

        variable.SymbolicName = "THISISATEST";
        variable.ReferenceTypeId = ReferenceTypes.Organizes;
        variable.TypeDefinitionId = VariableTypeIds.BaseDataVariableType;
        variable.NodeId = new NodeId((uint)2099, NamespaceIndex);
        variable.BrowseName = new QualifiedName("TEST2");
        variable.DisplayName = new LocalizedText("en", "Thisisatest");
        variable.WriteMask = AttributeWriteMask.DisplayName | AttributeWriteMask.Description;
        variable.UserWriteMask = AttributeWriteMask.DisplayName | AttributeWriteMask.Description;
        variable.DataType = DataTypeIds.Int32;
        variable.ValueRank = ValueRanks.Scalar;
        variable.AccessLevel = AccessLevels.CurrentReadOrWrite;
        variable.UserAccessLevel = AccessLevels.CurrentReadOrWrite;
        variable.Historizing = false;
        variable.Value = 0;
        variable.StatusCode = StatusCodes.Good;
        variable.Timestamp = DateTime.UtcNow;

        if (opcUaServer != null)
        {
            AddPredefinedNode(SystemContext, variable);
        }

        if(FindNodeInAddressSpace(variable.NodeId) != null){
            Console.WriteLine("Node succesfully created");
            return ServiceResult.Good;
        }
        return new ServiceResult(2);
    }
1

There are 1 best solutions below

5
eglease On

You need add a parent to your node.

For example, if you are creating a root folder, your parent would be

ParentNodeId = ObjectIds.ObjectsFolder,
ParentAsOwner = true,

This will allow your OPC UA Client like UaExpert to browse to your node from the parent object.

Note: If you have ParentAsOwner = true, deleting the parent would delete the child node but if your child is a large and complex object, this could take time.