Chapter 10 Application Programmer’s Interface
10-26 ER1 User Guide
i++;
_port = Integer.valueOf(args[i]).intValue();
}
}
// Help.
else if (args[i].compareTo("-h") == 0) {
usage();
}
else {
usage();
}
}
}
public void usage()
{
System.out.println("usage: java TestClient [options]");
System.out.println(" -a <address> Specify the address of ER1 RCC. Defaults to
127.0.0.1.");
System.out.println(" -p <port> The port number of the ER1 RCC. Defaults to 9000.");
System.out.println(" -q Quiet mode. Only errors are printed out.");
System.out.println(" -h This message.");
System.exit(0);
}
public void waitFor(String command)
{
boolean moveDone = false;
// Wait until the move command is done by continuously sending
// events command until "move done" is include in the response.
while (!moveDone) {
try {
Thread.sleep(500);
}
catch (Exception ex) {
System.out.println(ex.toString());
}
String recvMsg = sendCommand("events
// Check to see if "[command] done" is part of the response.
String doneString = command + " done";
moveDone = (recvMsg.indexOf(doneString) >= 0);
if (!moveDone) {
// Check for error.
String errorString = command + " error";
int errorIndex = recvMsg.indexOf(errorString);
moveDone = errorIndex >= 0;
if (moveDone && !_verbose) {
// print error message if in quiet mode. If not
// in quiet mode, error message is already printed.
System.out.print(recvMsg.substring(errorIndex));
}
}
}
}
public String sendCommand(String command)
{
if (_verbose) {
System.out.print("Sending command: " + command);
}
if (!sendString(command)) {