/// <summary cref="NodeSource.CreateNode" /> protected override void CreateNode(NodeId parentId, NodeId referenceTypeId) { CheckNodeManagerState(); VariableTypeAttributes attributes = new VariableTypeAttributes(); attributes.SpecifiedAttributes = (uint)NodeAttributesMask.DisplayName; attributes.DisplayName = DisplayName; NodeManager.CreateVariableType( parentId, NodeId, BrowseName, attributes); }
public NodeId CreateVariableType( NodeId parentId, NodeId nodeId, QualifiedName browseName, VariableTypeAttributes attributes) { return null; }
/// <summary> /// Creates an VariableType node in the address space. /// </summary> public NodeId CreateVariableType( NodeId parentId, NodeId nodeId, QualifiedName browseName, VariableTypeAttributes attributes) { try { m_lock.Enter(); // check for null node id. if (NodeId.IsNull(nodeId)) { nodeId = CreateUniqueNodeId(); } // check if node id exists. if (m_nodes.Exists(nodeId)) { throw ServiceResultException.Create(StatusCodes.BadNodeIdExists, "NodeId '{0}' already exists.", nodeId); } // find parent. IVariableType parent = GetManagerHandle(parentId) as IVariableType; if (parent == null) { throw ServiceResultException.Create(StatusCodes.BadParentNodeIdInvalid, "Parent node '{0}' does not exist or is not an VariableType.", parentId); } // validate reference. ValidateReference(parent, ReferenceTypeIds.HasSubtype, false, NodeClass.VariableType); // validate browse name. if (QualifiedName.IsNull(browseName)) { throw ServiceResultException.Create(StatusCodes.BadBrowseNameInvalid, "BrowsName must not be empty."); } // create node. VariableTypeNode node = new VariableTypeNode(); node.NodeId = nodeId; node.NodeClass = NodeClass.VariableType; node.BrowseName = browseName; UpdateAttributes(node, attributes); // Value if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.Value) != 0) { node.Value = attributes.Value; } else { node.Value = Variant.Null; } // DataType if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.DataType) != 0) { node.DataType = attributes.DataType; } else { node.DataType = DataTypes.BaseDataType; } // ValueRank if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.ValueRank) != 0) { node.ValueRank = attributes.ValueRank; } else { node.ValueRank = ValueRanks.Scalar; } // ArrayDimensions if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.ArrayDimensions) != 0) { node.ArrayDimensions = attributes.ArrayDimensions; } else { node.ArrayDimensions = null; } // IsAbstract if (attributes != null && (attributes.SpecifiedAttributes & (uint)NodeAttributesMask.IsAbstract) != 0) { node.IsAbstract = attributes.IsAbstract; } else { node.IsAbstract = false; } // add reference from parent. AddReference(parent, ReferenceTypeIds.HasSubtype, false, node, true); // add node. AddNode(node); // return the new node id. return node.NodeId; } finally { m_lock.Exit(); } }