-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMain.java
76 lines (67 loc) · 2.96 KB
/
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import de.re.eeip.EEIPClient;
import de.re.eeip.cip.datatypes.ConnectionType;
import de.re.eeip.cip.datatypes.Priority;
import de.re.eeip.cip.datatypes.RealTimeFormat;
import de.re.eeip.cip.exception.CIPException;
import java.io.Console;
import java.io.IOException;
import java.util.List;
/**
* This example shows the Implicit Messaging of a Wago 750-352 in Java
* Hardware Configuration:
* Coupler: 750-352
* Digital Input: 750-402 4-Channel
* Digital Input: Beckhoff KL1012 2-Channel
* Analog Input: Beckhoff KL3202 2-Channel
* Digital Outout: 750-501 2-Channel
* Termination: 750-600
*
* Documentation: http://www.wago.de/download.esm?file=%5Cdownload%5C00368362_0.pdf&name=m07500352_xxxxxxxx_0en.pdf
*/
public class Main
{
public static void main(String[] args) throws InterruptedException {
EEIPClient eipClient = new EEIPClient();
try {
System.out.println("Fisrst Register a session");
eipClient.RegisterSession("192.168.1.3");
//Parameters for Originator -> Target communication
eipClient.setO_T_InstanceID(101); //Output Assembly 65hex
eipClient.setO_T_Length(1);
eipClient.setO_T_RealTimeFormat(RealTimeFormat.Header32Bit);
eipClient.setO_T_ownerRedundant(false);
eipClient.setO_T_priority(Priority.Urgent);
eipClient.setO_T_variableLength(false);
eipClient.setO_T_connectionType(ConnectionType.Point_to_Point);
//Parameters for Target -> Originator communication
eipClient.setT_O_InstanceID(104); //Input Assembly 68hex
eipClient.setT_O_Length(6);
eipClient.setT_O_RealTimeFormat(RealTimeFormat.Modeless);
eipClient.setT_O_ownerRedundant(false);
eipClient.setT_O_priority(Priority.Urgent);
eipClient.setT_O_variableLength(false);
eipClient.setT_O_connectionType(ConnectionType.Multicast);
eipClient.O_T_IOData[0] = (byte)0xff;
System.out.println("Send Forward open to initiate IO Messaging");
eipClient.ForwardOpen();
for (int i = 0; i < 50; i++)
{
System.out.println("Byte 0: "+eipClient.T_O_IOData[0]);
System.out.println("Byte 1: "+eipClient.T_O_IOData[1]);
System.out.println("Byte 2: "+eipClient.T_O_IOData[2]);
System.out.println("Byte 3: "+eipClient.T_O_IOData[3]);
System.out.println("Byte 4: "+eipClient.T_O_IOData[4]);
System.out.println("Byte 5: "+eipClient.T_O_IOData[5]);
Thread.sleep(500);
}
System.out.println("Send Forward Close");
eipClient.ForwardClose();
System.out.println("Unregister Session");
eipClient.UnRegisterSession();
} catch (IOException e) {
e.printStackTrace();
} catch (CIPException e) {
e.printStackTrace();
}
}
}