简体   繁体   English

如何将我的信息 Model 中的可选节点实例化到我的 OPC UA 服务器(.Net 环境)中

[英]How to instantiate an Optional Node from my Information Model into my OPC UA Server ( .Net Environement)

I am a beginner in OPC UA server development.我是 OPC UA 服务器开发的初学者。 I am working on .NET environment to create an server with my own Information Model which is created on UAModeler.我正在 .NET 环境中使用我自己的在 UAModeler 上创建的信息 Model 创建服务器。

when I instantiate the nodes available in my information model, only those which are set as Mandatory are successfully instantiated.当我实例化我的信息 model 中可用的节点时,只有那些设置为 Mandatory 的节点才能成功实例化。 I am trying to find a way how can I instantiate the remaining nodes also which are by purpose set as Optional for Modeling rule.我试图找到一种方法如何实例化剩余的节点,这些节点也被目的设置为可选的建模规则。

Below snippet of my code from Node Manager class:下面是来自节点管理器 class 的我的代码片段:

`Console.WriteLine("Loading the Im 2.1 Model."); `Console.WriteLine("正在加载 Im 2.1 Model。"); ImportUaNodeset(Assembly.GetEntryAssembly(), "informationmodel_2.0.xml"); ImportUaNodeset(Assembly.GetEntryAssembly(), "informationmodel_2.0.xml"); Console.WriteLine("IM Sucessfully Loaded"); Console.WriteLine("IM 成功加载");

            CreateObjectSettings settings = new CreateObjectSettings()
            {
                ParentNodeId = UnifiedAutomation.UaBase.ObjectIds.ObjectsFolder,
                ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                RequestedNodeId = new NodeId("IM", DefaultNamespaceIndex),
                BrowseName = new QualifiedName("Departments", DefaultNamespaceIndex),
                TypeDefinitionId = UnifiedAutomation.UaBase.ObjectTypeIds.FolderType

            };
            ObjectNode controllersNode = CreateObject(Server.DefaultRequestContext, settings);

            settings = new CreateObjectSettings()
            {
                ParentNodeId = controllersNode.NodeId,
                ReferenceTypeId = UnifiedAutomation.UaBase.ReferenceTypeIds.Organizes,
                RequestedNodeId = new NodeId(DepartmentA, DefaultNamespaceIndex),
                BrowseName = new QualifiedName(DepartmentA, DefaultNamespaceIndex),
                TypeDefinitionId = new NodeId(My.MyIm.ObjectTypes.BodyshopProductionEquipmentType, DefaultNamespaceIndex)

            };

            CreateObject(Server.DefaultRequestContext, settings);
            
            ProductionDataNode = FindInMemoryNode(new NodeId(DepartmentA + ".ProductionData", DefaultNamespaceIndex)) as VariableNode;
            CounterPerTypeNode = FindInMemoryNode(new NodeId(DepartmentA + ".ProductionData.CounterPerType", DefaultNamespaceIndex)) as VariableNode;`
           

any suggestions or similar solved examples would be highly appreaciated.任何建议或类似的已解决示例都将受到高度评价。

thanks谢谢

I have no experience with the unified-automation-sdk but in the OPCFoundation Stack you have to create the nodes manually.我没有使用统一自动化 SDK 的经验,但在 OPCFoundation 堆栈中,您必须手动创建节点。

This is typically done in CreateAddressSpace method of Node Manager class, see Boiler example .这通常在节点管理器 class 的CreateAddressSpace方法中完成,请参阅锅炉示例

Modelling Role optional indicates that the server has to decide if the creation is required or not.建模角色可选指示服务器必须决定是否需要创建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM