//// Objects // /// <summary> /// Helper to create an Object-Node. Note: __NO__ NodeId is created by the default! Must be done by outer functionality!! /// </summary> /// <param name="parent">Parent node</param> /// <param name="browseDisplayName">Name displayed in the node tree</param> /// <param name="typeDefinitionId">Type of the Object</param> /// <param name="modellingRule">Modeling Rule, if not None</param> /// <returns>The node</returns> public BaseObjectState CreateAddObject( NodeState parent, string browseDisplayName, NodeId referenceTypeFromParentId = null, NodeId typeDefinitionId = null, AasUaNodeHelper.ModellingRule modellingRule = AasUaNodeHelper.ModellingRule.None, string extraName = null) { var x = AasUaNodeHelper.CreateObject(parent, browseDisplayName, typeDefinitionId: typeDefinitionId, modellingRule: modellingRule, extraName: extraName); x.NodeId = nodeMgr.New(nodeMgr.SystemContext, x); nodeMgr.AddPredefinedNode(nodeMgr.SystemContext, x); if (parent != null) { parent.AddChild(x); } if (referenceTypeFromParentId != null) { parent.AddReference(referenceTypeFromParentId, false, x.NodeId); if (referenceTypeFromParentId == ReferenceTypeIds.HasComponent) { x.AddReference(referenceTypeFromParentId, true, parent.NodeId); } if (referenceTypeFromParentId == ReferenceTypeIds.HasProperty) { x.AddReference(referenceTypeFromParentId, true, parent.NodeId); } } return(x); }
//// Objects // /// <summary> /// Helper to create an Object-Node. Note: __NO__ NodeId is created by the default! Must be done by outer /// functionality!! /// </summary> /// <param name="parent">Parent node</param> /// <param name="mode">Type or instance</param> /// <param name="browseDisplayName">Name displayed in the node tree</param> /// <param name="referenceTypeFromParentId"></param> /// <param name="typeDefinitionId">Type of the Object</param> /// <param name="modellingRule">Modeling Rule, if not None</param> /// <param name="extraName"></param> /// <returns>The node</returns> public BaseObjectState CreateAddObject( NodeState parent, AasUaBaseEntity.CreateMode mode, string browseDisplayName, NodeId referenceTypeFromParentId = null, NodeId typeDefinitionId = null, AasUaNodeHelper.ModellingRule modellingRule = AasUaNodeHelper.ModellingRule.None, string extraName = null) { var x = AasUaNodeHelper.CreateObject(parent, browseDisplayName, typeDefinitionId: typeDefinitionId, modellingRule: modellingRule, extraName: extraName); x.NodeId = nodeMgr.NewFromParent(nodeMgr.SystemContext, mode, x, parent); nodeMgr.AddPredefinedNode(nodeMgr.SystemContext, x); if (parent != null) { parent.AddChild(x); } if (referenceTypeFromParentId != null) { if (parent != null) { if (!parent.ReferenceExists(referenceTypeFromParentId, false, x.NodeId)) { parent.AddReference(referenceTypeFromParentId, false, x.NodeId); } if (referenceTypeFromParentId == ReferenceTypeIds.HasComponent) { x.AddReference(referenceTypeFromParentId, true, parent.NodeId); } if (referenceTypeFromParentId == ReferenceTypeIds.HasProperty) { x.AddReference(referenceTypeFromParentId, true, parent.NodeId); } } //// nodeMgr.AddReference(parentNodeId, new AasReference(referenceTypeId, false, x.NodeId)); } //// if (typeDefinitionId != null) //// { //// x.TypeDefinitionId = typeDefinitionId; //// x.AddReference(ReferenceTypeIds.HasTypeDefinition, false, typeDefinitionId); //// // nodeMgr.AddReference(x.NodeId, new AasReference(ReferenceTypeIds.HasTypeDefinition, false, //// // typeDefinitionId)); //// } return(x); }