简体   繁体   English

使用 OPC UA Java Legacy 连接到 Matrikon 服务器

[英]Connect to Matrikon server with OPC UA Java Legacy

I am trying to connect to an OPC server of a Siemens S7 1200 PLC.我正在尝试连接到 Siemens S7 1200 PLC 的 OPC 服务器。 For this I used the Matrikon application That is configured on my local machine.为此,我使用了在本地机器上配置的Matrikon 应用程序 With the JeasyOPC library I can make the connection, so it is like this:JeasyOPC库我可以建立连接,所以它是这样的:

JOpc jopc = new JOpc("localhost","Matrikon.OPC.SiemensPLC.1","JOPC1"); JOpc jopc = new JOpc("localhost","Matrikon.OPC.SiemensPLC.1","JOPC1");

JOpc.coInitialize(); JOpc.coInitialize();

But this library can only be used in Windows and has problems when compiling binaries in 64.但是这个库只能在 Windows 下使用,在 64 位编译二进制文件时会出现问题。

So I have tried with OPC Foundation UA JAVA Legacy and I would like to make the same connection, however in the examples we ask for many more things:所以我已经尝试过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);

I would like to emulate the operation of jeasyOPC as far as possible, in any case I can not find any example that works for me.我想尽可能模拟jeasyOPC的操作,无论如何我找不到任何适合我的例子。

I would appreciate any example that would help me have a base client that would work with the Matrikon server我将不胜感激任何可以帮助我拥有可与 Matrikon 服务器一起使用的基本客户端的示例

Thank you.谢谢你。

Okay.好的。 I answer to myself.我自己回答。 After many searches I have found my error: There are two types of OPC: DA and UA.经过多次搜索,我发现了我的错误:有两种类型的 OPC:DA 和 UA。

The first of all (the DA) is to which I could connect with:首先(DA)是我可以连接的:

JOpc jopc = new JOpc ("localhost", "Matrikon.OPC.SiemensPLC.1", "JOPC1"); JOpc jopc = new JOpc ("localhost", "Matrikon.OPC.SiemensPLC.1", "JOPC1");

This version of the protocol is the one used historicaménte windows, uses COM libraries and can only be implemented under a Windows computer.该版本的协议是使用历史悠久的 windows 协议,使用 COM 库,只能在 Windows 计算机下实现。

The second, the OPC UA, is the new implementation and connects like this:第二个,OPC UA,是新的实现,连接如下:

String url = "opc.tcp: // localhost: 102 /"; String url = "opc.tcp://localhost:102/"; // ServerExample1 // 服务器示例1

This version is already compatible with Windows, Linux and any system that is capable of running the libria.此版本已与 Windows、Linux 和任何能够运行 libria 的系统兼容。

The problem was that, in my case, the S7 1200 only uses OPC DA, which made the UA option unfeasible for me if it did not use a compatible gateway.问题是,就我而言,S7 1200 仅使用 OPC DA,如果它不使用兼容网关,那么 UA 选项对我来说是不可行的。

I hope this information will help someone who is in my situation.我希望这些信息对处于我这种情况的人有所帮助。

Greetings.你好。

Instead jEasy you can try jinterop library. 相反,您可以尝试jinterop库。 It supports x64. 它支持x64。

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

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