1 package de.dlr.bt.stc.source.rsi.util; 2 3 import java.io.IOException; 4 import java.net.InetSocketAddress; 5 import java.net.SocketAddress; 6 import java.nio.ByteBuffer; 7 import java.nio.channels.DatagramChannel; 8 9 public class RSISender { 10 public static final String TESTMESSAGE = """ 11 <Rob TYPE="KUKA"> 12 <RIst X="0.0" Y="1.0" Z="2.0" A="3.0" B="4.0" C="5.5" /> 13 <AIPos A1="0.0" A2="0.0" A3="0.0" A4="0.0" A5="0.0" A6="0.0" /> 14 <IPOC>123645634563</IPOC> 15 <Mode>1</Mode> 16 <Offset>0</Offset> 17 </Rob>"""; 18 19 public static void main(String[] args) throws IOException { 20 sendMessage(TESTMESSAGE, 12345, 2); 21 } 22 23 static void sendMessage(String message, int port, int repetitions) throws IOException { 24 try (DatagramChannel dc = DatagramChannel.open()) { 25 SocketAddress sa = new InetSocketAddress("127.0.0.1", port); 26 ByteBuffer bb = ByteBuffer.wrap(message.getBytes()); 27 28 for (int i = 0; i < repetitions; i++) 29 dc.send(bb, sa); 30 } 31 } 32 }