将整数写入 OPC UA 服务器 - “类型不同”错误

Posted

技术标签:

【中文标题】将整数写入 OPC UA 服务器 - “类型不同”错误【英文标题】:Write integer to OPC UA server - “not of the same type” error 【发布时间】:2021-04-01 03:08:49 【问题描述】:

我已经定义了一个 OPC UA 客户端

 var client = new OpcClient("opc.tcp://localhost:4840");
 client.Connect();

这可以正常工作并连接到我也编写的服务器。 客户端也可以阅读

var status = client.WriteNode("ns=2;s=Temperature", 999);

当我想向服务器写入一个值时,问题就出来了:

var status = client.WriteNode("ns=2;s=Temperature", 999);

我得到了错误:

“为属性提供的值与属性值的类型不同。”

那个链接 Write Boolean to OPC UA server - "not of the same type" error 没有帮助。

我使用了 Opc.UaFx 实现。

提前致谢

帕特里克

【问题讨论】:

您的“读取”代码示例包含另一个写入示例 【参考方案1】:

只需添加关键字double:

var status = client.WriteNode("ns=2;s=Temperature", (double)999);

【讨论】:

以上是关于将整数写入 OPC UA 服务器 - “类型不同”错误的主要内容,如果未能解决你的问题,请参考以下文章