예제 #1
0
        public NodeStateCollection GenerateInjectNodeStates()
        {
            // new list
            var res = new NodeStateCollection();

            // Missing Object Types
            res.Add(AasUaNodeHelper.CreateObjectType("BaseInterfaceType",
                                                     ObjectTypeIds.BaseObjectType, new NodeId(17602, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("DictionaryFolderType",
                                                     ObjectTypeIds.FolderType, new NodeId(17591, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("DictionaryEntryType",
                                                     ObjectTypeIds.BaseObjectType, new NodeId(17589, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("UriDictionaryEntryType",
                                                     new NodeId(17589, 0), new NodeId(17600, 0)));
            res.Add(AasUaNodeHelper.CreateObjectType("IrdiDictionaryEntryType",
                                                     new NodeId(17589, 0), new NodeId(17598, 0)));

            // Missing Reference Types
            res.Add(AasUaNodeHelper.CreateReferenceType("HasDictionaryEntry", "DictionaryEntryOf",
                                                        ReferenceTypeIds.NonHierarchicalReferences, new NodeId(17597, 0)));
            res.Add(AasUaNodeHelper.CreateReferenceType("HasInterface", "InterfaceOf",
                                                        ReferenceTypeIds.NonHierarchicalReferences, new NodeId(17603, 0)));
            res.Add(AasUaNodeHelper.CreateReferenceType("HasAddIn", "AddInOf",
                                                        ReferenceTypeIds.HasComponent, new NodeId(17604, 0)));

            // deliver list
            return(res);
        }
        //// 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);
        }
        //// Object types
        //

        /// <summary>
        /// Helper to create an ObjectType-Node and it to the information model.
        /// </summary>
        /// <param name="browseDisplayName">Name displayed in the node tree</param>
        /// <param name="superTypeId">Base class or similar</param>
        /// <param name="preferredNumId">Numerical id of the node in the default name space to be set fixed</param>
        /// <param name="descriptionKey">Lookup a Description on AAS literal/ refSemantics</param>
        /// <param name="modellingRule">Modeling Rule, if not None</param>
        public BaseObjectTypeState CreateAddObjectType(
            string browseDisplayName,
            NodeId superTypeId,
            uint preferredNumId   = 0,
            string descriptionKey = null,
            AasUaNodeHelper.ModellingRule modellingRule = AasUaNodeHelper.ModellingRule.None)
        {
            var x = AasUaNodeHelper.CreateObjectType(browseDisplayName, superTypeId, descriptionKey: descriptionKey);

            x.NodeId = nodeMgr.NewType(nodeMgr.SystemContext, x, preferredNumId);
            nodeMgr.AddPredefinedNode(nodeMgr.SystemContext, x);
            return(x);
        }
예제 #4
0
        //// 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);
        }
예제 #5
0
        //// Properties
        //

        /// <summary>
        /// Helper to create an PropertyState-Node for a certain type and add it to the information model.
        /// Note: __NO__ NodeId is created by the default! Must be done by outer functionality!!
        /// </summary>
        /// <typeparam name="T">C# type of the proprty</typeparam>
        /// <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="dataTypeId">Data type, such as String.. Given by DataTypeIds...</param>
        /// <param name="value">Value of the type T or Null</param>
        /// <param name="referenceTypeFromParentId"></param>
        /// <param name="typeDefinitionId">Type definition; independent from DataType!</param>
        /// <param name="valueRank">-1 or e.g. 1 for array</param>
        /// <param name="defaultSettings">Apply default settings for a normal Property</param>
        /// <param name="modellingRule">Modeling Rule, if not None</param>
        /// <returns>NodeState</returns>
        public PropertyState <T> CreateAddPropertyState <T>(
            NodeState parent, AasUaBaseEntity.CreateMode mode,
            string browseDisplayName,
            NodeId dataTypeId, T value,
            NodeId referenceTypeFromParentId = null,
            NodeId typeDefinitionId          = null,
            int valueRank        = -2,
            bool defaultSettings = false,
            AasUaNodeHelper.ModellingRule modellingRule = AasUaNodeHelper.ModellingRule.None)
        {
            // apply cumulative settings
            if (defaultSettings)
            {
                referenceTypeFromParentId = ReferenceTypeIds.HasProperty;
                typeDefinitionId          = VariableTypeIds.PropertyType;
                if (valueRank == -2)
                {
                    valueRank = -1;
                }
            }

            // make Property
            var x = new PropertyState <T>(parent);

            x.BrowseName  = "" + browseDisplayName;
            x.DisplayName = "" + browseDisplayName;
            x.Description = new LocalizedText("en", browseDisplayName);
            x.DataType    = dataTypeId;
            if (valueRank > -2)
            {
                x.ValueRank = valueRank;
            }
            // ReSharper disable once RedundantCast
            x.Value = (T)value;
            AasUaNodeHelper.CheckSetModellingRule(modellingRule, x);
            x.NodeId = nodeMgr.New(nodeMgr.SystemContext, mode, x);

            // add Node
            nodeMgr.AddPredefinedNode(nodeMgr.SystemContext, x);
            if (parent != null)
            {
                parent.AddChild(x);
            }

            // set relations
            if (referenceTypeFromParentId != null)
            {
                if (parent != 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);
                    }
                }
            }
            if (typeDefinitionId != null)
            {
                x.TypeDefinitionId = typeDefinitionId;
            }

            x.AccessLevel     = AccessLevels.CurrentReadOrWrite;
            x.UserAccessLevel = AccessLevels.CurrentReadOrWrite;

            return(x);
        }