Ejemplo n.º 1
0
  public int getSemaphoreStatus() {
    int res = -1;

    if (connection.isConnected()) {
      int red =
          connection.readRegister(
              MEMORY_AREA_30, PlcConstants.SEMAPHORE_RED_REGISTER, PlcConstants.SEMAPHORE_RED_BIT);
      int yellow =
          connection.readRegister(
              MEMORY_AREA_30,
              PlcConstants.SEMAPHORE_YELLOW_REGISTER,
              PlcConstants.SEMAPHORE_YELLOW_BIT);
      int green =
          connection.readRegister(
              MEMORY_AREA_30,
              PlcConstants.SEMAPHORE_GREEN_REGISTER,
              PlcConstants.SEMAPHORE_GREEN_BIT);

      res = 0;
      res |= (red * Semaphore.RED.getValue());
      res |= (yellow * Semaphore.YELLOW.getValue());
      res |= (green * Semaphore.GREEN.getValue());
    }

    return res;
  }
Ejemplo n.º 2
0
  public int getStatus() {
    int res = -1;

    if (connection.isConnected()) {
      res = connection.readRegister(MEMORY_AREA_B2, Register.STATUS_BITS.getValue());
    }

    return res;
  }
Ejemplo n.º 3
0
  public int getTrackPosition() {
    int res = -1;

    if (connection.isConnected()) {
      int up =
          connection.readRegister(
              MEMORY_AREA_30, PlcConstants.TRACK_POS_UP_REGISTER, PlcConstants.TRACK_POS_UP_BIT);
      int down =
          connection.readRegister(
              MEMORY_AREA_30,
              PlcConstants.TRACK_POS_DOWN_REGISTER,
              PlcConstants.TRACK_POS_DOWN_BIT);

      if (up != 0) {
        res = 1;
      } else if (down != 0) {
        res = 2;
      }
    }

    return res;
  }