package charly.demo; import charly.client.*; import charly.server.devices.ChRobDeviceException; /** A very simple class for sending a string to a GPIB-device. * You can view the <a href="doc-files/ChSimpleRob.java.html">source here</a>. */ public class ChSimpleRob { public static void main(String args[]) throws Exception { System.out.println("usage: ChSimpleRob [TCP/IP-address]"); ChConnect conn=new ChConnect(args.length==0?"localhost":args[0]); ChTask task=new ChTask("Simple Rob"); ChRobClient rob=new ChRobClient(conn); task.addResource(conn, rob.getResourceName()); // resource: ROB3 as a device task.start(true); // wait until ROB3 is free for my task rob.setTask(task); // tell rob that it can use the ROB3 reserved for this application try { int currPos=rob.getAxisPos(2); // getting current position of axis nr 2 System.out.println("Axis Nr 2 has the position:"+currPos); System.out.println("Moving Axis Nr 2"); rob.setAxisPos(2, (currPos+50)%256); } catch(ChRobDeviceException e) { System.out.println("ROB3 has problems:"+e.getMessage()); } catch(Exception e) { System.out.println("An unexpected exception occured:"+e); } task.stop(); System.out.println("bye"); System.exit(0); // This is not really necessary, but because it // takes some time until that the system detects that there is // no activity any more on the RMI-system, this method call // shortens the waiting time immensely } }