Example #1
0
        //// Reference types
        //

        public ReferenceTypeState CreateAddReferenceType(
            string browseDisplayName, string inverseName,
            uint preferredNumId = 0, bool useZeroNS = false, NodeId sourceId = null, ExpandedNodeId extraSubtype = null)
        {
            // create node itself
            var x = new ReferenceTypeState();

            x.BrowseName  = browseDisplayName;
            x.DisplayName = browseDisplayName;
            x.InverseName = inverseName;
            x.Symmetric   = false;
            x.IsAbstract  = false;
            x.NodeId      = nodeMgr.NewType(nodeMgr.SystemContext, AasUaBaseEntity.CreateMode.Type, x, preferredNumId);
            nodeMgr.AddPredefinedNode(nodeMgr.SystemContext, x);

            // set Subtype reference
            if (sourceId == null)
            {
                sourceId = new NodeId(32, 0);
            }
            nodeMgr.AddExternalReferencePublic(sourceId, ReferenceTypeIds.HasSubtype, false,
                                               x.NodeId, nodeMgrExternalReferences);

            if (extraSubtype != null)
            {
                x.AddReference(ReferenceTypeIds.HasSubtype, isInverse: true, extraSubtype);
            }

            // done
            return(x);
        }
Example #2
0
        /// <summary>
        /// Creates a new reference type.
        /// </summary>
        private ReferenceTypeState CreateReferenceType(NodeState parent, IDictionary <NodeId, IList <IReference> > externalReferences, string path, string name)
        {
            ReferenceTypeState type = new ReferenceTypeState();

            type.SymbolicName  = name;
            type.SuperTypeId   = ReferenceTypeIds.NonHierarchicalReferences;
            type.NodeId        = new NodeId(path, NamespaceIndex);
            type.BrowseName    = new QualifiedName(name, NamespaceIndex);
            type.DisplayName   = type.BrowseName.Name;
            type.WriteMask     = AttributeWriteMask.None;
            type.UserWriteMask = AttributeWriteMask.None;
            type.IsAbstract    = false;
            type.Symmetric     = true;
            type.InverseName   = name;

            IList <IReference> references = null;

            if (!externalReferences.TryGetValue(ReferenceTypeIds.NonHierarchicalReferences, out references))
            {
                externalReferences[ReferenceTypeIds.NonHierarchicalReferences] = references = new List <IReference>();
            }

            references.Add(new NodeStateReference(ReferenceTypeIds.HasSubtype, false, type.NodeId));

            if (parent != null)
            {
                parent.AddReference(ReferenceTypes.Organizes, false, type.NodeId);
                type.AddReference(ReferenceTypes.Organizes, true, parent.NodeId);
            }

            AddPredefinedNode(SystemContext, type);
            return(type);
        }