I am trying to connect to an OPC server of a Siemens S7 1200 PLC. For this I used the Matrikon application That is configured on my local machine. With the JeasyOPC library I can make the connection, so it is like this:
JOpc jopc = new JOpc("localhost","Matrikon.OPC.SiemensPLC.1","JOPC1");
JOpc.coInitialize();
But this library can only be used in Windows and has problems when compiling binaries in 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:
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.
I would appreciate any example that would help me have a base client that would work with the Matrikon server
Thank you.
Okay. I answer to myself. After many searches I have found my error: There are two types of OPC: DA and UA.
The first of all (the DA) is to which I could connect with:
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.
The second, the OPC UA, is the new implementation and connects like this:
String url = "opc.tcp: // localhost: 102 /"; // ServerExample1
This version is already compatible with Windows, Linux and any system that is capable of running the 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.
I hope this information will help someone who is in my situation.
Greetings.