Exemplo n.º 1
0
 public void register(int event, Listener<SerialPortToRobot> listener) {
   Signal<SerialPortToRobot> signal = signals.get(event);
   if (signal == null) {
     signal = new Signal<SerialPortToRobot>();
     signals.put(event, signal);
   }
   signal.connect(listener);
 }
Exemplo n.º 2
0
  @SuppressWarnings("unused")
  @Override
  public synchronized void serialEvent(SerialPortEvent event) {
    if (event.getEventType() == SerialPortEvent.DATA_AVAILABLE) updateAvailable();
    Signal<SerialPortToRobot> signal = signals.get(event.getEventType());
    if (signal != null) signal.fire(this);
    if (!DebugSignals) return;
    switch (event.getEventType()) {
      case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
        System.out.println("Event received: outputBufferEmpty");
        break;

      case SerialPortEvent.DATA_AVAILABLE:
        System.out.println("Event received: dataAvailable");
        break;

      case SerialPortEvent.BI:
        System.out.println("Event received: breakInterrupt");
        break;

      case SerialPortEvent.CD:
        System.out.println("Event received: carrierDetect");
        break;

      case SerialPortEvent.CTS:
        System.out.println("Event received: clearToSend");
        break;

      case SerialPortEvent.DSR:
        System.out.println("Event received: dataSetReady");
        break;

      case SerialPortEvent.FE:
        System.out.println("Event received: framingError");
        break;

      case SerialPortEvent.OE:
        System.out.println("Event received: overrunError");
        break;

      case SerialPortEvent.PE:
        System.out.println("Event received: parityError");
        break;
      case SerialPortEvent.RI:
        System.out.println("Event received: ringIndicator");
        break;
      default:
        System.out.println("Event received: unknown");
    }
  }
Exemplo n.º 3
0
 public void close() {
   // Produce a SEG FAULT
   // serialStreams.close();
   if (isClosed) return;
   isClosed = true;
   onClosed.fire(this);
 }