【发布时间】:2026-02-10 03:45:01
【问题描述】:
我正在尝试连接到 Siemens S7 1200 PLC 的 OPC 服务器。为此,我使用了Matrikon application 这是在我的本地机器上配置的。使用JeasyOPC library我可以建立连接,所以它是这样的:
JOpc jopc = new JOpc("localhost","Matrikon.OPC.SiemensPLC.1","JOPC1");
JOpc.coInitialize();
但是这个库只能在 Windows 中使用,在 64 位编译二进制文件时会出现问题。
所以我尝试了OPC Foundation UA JAVA Legacy 并且我想建立相同的连接,但是在示例中我们要求更多的东西:
String publicHostname = InetAddress.getLocalHost().getHostName(); String url = "opc.tcp://localhost:102/"; // ServerExample1 // String url = "Matrikon.OPC.SiemensPLC.1"; // This not work for me EndpointDescription[] endpoints = myClient.discoverEndpoints(url);
我想尽可能地模拟 jeasyOPC 的操作,无论如何我找不到任何适合我的例子。
如果有任何示例可以帮助我拥有可以与 Matrikon 服务器一起使用的基本客户端,我将不胜感激
谢谢。
【问题讨论】:
标签: java client opc siemens s7-1200