Exemplo n.º 1
0
  private void updateBinding() {
    if (openSprinkler != null) {
      openSprinkler.closeConnection();
    }

    if (mode == null) {
      return;
    }

    switch (mode) {
      case GPIO:
        openSprinkler = OpenSprinklerFactory.newGpioConnection();
        break;
      case HTTP:
        openSprinkler = OpenSprinklerFactory.newHttpConnection(url, password);
        break;
      default:
        throw new IllegalStateException(
            "Unknown OpenSprinkler mode: "
                + mode
                + "! Since it is checked while initialization already, this Exception should never be thrown!");
    }

    openSprinkler.setNumberOfStations(numberOfStations);

    logger.info(
        "OpenSprinkler binding running in "
            + mode
            + " mode"
            + (HTTP.equals(mode) ? " with url " + url : "")
            + ". Running with "
            + numberOfStations
            + " stations enabled and a refresh rate of "
            + refreshInterval
            + ".");
  }
Exemplo n.º 2
0
 public void deactivate() {
   // deallocate Resources here that are no longer needed and
   // should be reset when activating this binding again
   openSprinkler.closeConnection();
 }