public String waitForPassword(int timeout, String username) throws TimeoutException {
    while (!initiated) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ex) {
      }
    }

    String password = "";
    try {
      // send a message to the robot
      String response = robotSocketServer.sendMessageAndWaitForResponse("waitForPassword");
      if (!response.startsWith("password is ")) {
        System.err.println(
            "waitForPassword RECEIVED MESSAGE DIFFERENT THAN \"password is ...\": " + response);
        System.exit(1);
      }
      password = response.substring(12, response.length());
      System.out.println("Received: " + response + "   Password is " + password);
    } catch (SocketTimeoutException ex) {
      System.err.println("waitForPassword EXCEPTION!");
      ex.printStackTrace();
      System.exit(1);
    }
    return password;
  }
  public void openTray(int trayNum) {
    while (!initiated) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ex) {
      }
    }

    try {
      // send a message to the robot
      String response = robotSocketServer.sendMessageAndWaitForResponse("openTray " + trayNum);
      if (!response.startsWith("closedTray")) {
        System.err.println("openTray RECEIVED MESSAGE DIFFERENT THAN \"closedTray\": " + response);
        System.exit(1);
      }
    } catch (SocketTimeoutException ex) {
      System.err.println("openTray EXCEPTION!");
      ex.printStackTrace();
      System.exit(1);
    }
  }
  public void ringBuzzer() {
    while (!initiated) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ex) {
      }
    }

    try {
      // send a message to the robot
      String response = robotSocketServer.sendMessageAndWaitForResponse("ringBuzzer");
      if (!response.equals("ringBuzzer done")) {
        System.err.println(
            "ringBuzzer RECEIVED MESSAGE DIFFERENT THAN \"ringBuzzer done\": " + response);
        System.exit(1);
      }
    } catch (SocketTimeoutException ex) {
      System.err.println("ringBuzzer EXCEPTION!");
      ex.printStackTrace();
      System.exit(1);
    }
  }
  public void moveRobotToNextPoint() {
    while (!initiated) {
      try {
        Thread.sleep(100);
      } catch (InterruptedException ex) {
      }
    }

    try {
      // send a message to the robot
      String response = robotSocketServer.sendMessageAndWaitForResponse("move robot to next point");
      if (!response.equals("next point found")) {
        System.err.println(
            "moveRobotToNextPoint RECEIVED MESSAGE DIFFERENT THAN \"next point found\": "
                + response);
        System.exit(1);
      }
      System.out.println("Robot arrived to the next point");
    } catch (SocketTimeoutException ex) {
      System.err.println("moveRobotToNextPoint EXCEPTION!");
      ex.printStackTrace();
      System.exit(1);
    }
  }