简体   繁体   English

使用UA-.NET调用OPC-UA方法

[英]Call OPC-UA method with UA-.NET

I am trying to call an OPC-UA method "ReadVar" from a SINUMERIK 840d, by using the Open OPC-UA.NET implementation at https://github.com/OPCFoundation/UA-.NET 我试图通过使用Open OPC-UA.NET实现从SINUMERIK 840d调用OPC-UA方法“ReadVar”, 网址https://github.com/OPCFoundation/UA-.NET

I have limited knowledge about how to use this stack implementation and wonder if somebody has a lightweight example of how to use it to connect to the OPC-UA server and call the method from C# code? 我对如何使用这个堆栈实现的知识有限,并想知道是否有人有一个轻量级的例子,说明如何使用它连接到OPC-UA服务器并从C#代码调用该方法?

I have tried with the Unified Automation trial binary client to test to call this method and it works perfectly. 我已经尝试使用Unified Automation试用二进制客户端来测试调用此方法,并且它运行良好。 I also would wonder what is the key benefits (except for obvious ones with support etc) of buying a commercial OPC-UA SDK rather than using the above mentioned open source version. 我也想知道购买商用OPC-UA SDK而不是使用上面提到的开源版本的主要好处(除了显而易见的支持等)。

You have to know the node id of the method, the node id of the "object" of the method, and its arguments. 您必须知道方法的节点ID,方法的“对象”的节点ID及其参数。 Using the example provided in the OPC-UA .Net you can execute classic "hello world" :-) 使用OPC-UA .Net中提供的示例,您可以执行经典的“hello world”:-)

IList<object> val = session.Call(  
  // I know that this node holds the method I like to use
  new NodeId("Methods", 2), 
  // and I know this node is "hello" method 
  new NodeId("Methods_Hello", 2), 
  "world");

Console.WriteLine(val[0]);

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

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