コード例 #1
0
  public static synchronized void send(String command) throws ComInterruptException {
    if (!isConnected()) {
      disconnect();
      throw new ComInterruptException("Not connected !");
    }
    // No command
    if (command.trim().equals("")) {
      return;
    }

    while ((I().internal_isbusy() || initThread.isAlive()) && isConnected()) {
      try {
        Communication.class.wait();
      } catch (InterruptedException ex) {
        throw new ComInterruptException("Interrupt!");
      }
    }
    if (!isConnected()) {
      throw new ComInterruptException("Not connected !");
    }

    doSendEvent(command);

    try {
      I().internal_send(command);
    } catch (MyException ex) {
      Logger.getLogger(Communication.class.getName()).log(Level.SEVERE, null, ex);
      resetAll();
      doChangedEvent(ex.getMessage());
      throw new ComInterruptException(ex.getMessage());
    }
  }
コード例 #2
0
  private static synchronized void receive(String[] lines) {
    // remove emty lines
    ArrayList<String> l = new ArrayList<>();
    for (String s : lines) if (!s.equals("")) l.add(s);
    lines = l.toArray(new String[0]);

    doResiveEvent(lines);

    for (String line : lines) {
      try {
        I().internal_receive(line);
      } catch (MyException ex) {
        Logger.getLogger(Communication.class.getName()).log(Level.SEVERE, null, ex);
        resetAll();
        doChangedEvent(ex.getMessage());
        return;
      }

      Double val = I().internal_ZEndStopHit(line);
      if (val != null) {
        doEnstopHitEvent(val);
      }
    }
  }