/** * Method returns the state source(s) result(s) (contains state value(s)) of the input blindState. * * @param blindState The BlindState. * @return state source(s) result(s) of the input state. */ private List<RdfNodeObject> blindStateSources(final BlindState blindState) { final List<RdfNodeObject> stateSources = new ArrayList<>(); final String blindMovementStateVal = blindState.getMovementState().toString(); stateSources.add(new RdfNodeObject(new ArrayList<String>() {{add(blindMovementStateVal);}}, false)); final String blindOpeningRationVal = "\"" + String.valueOf(blindState.getOpeningRatio()) + "\"^^NS:Percent"; stateSources.add(new RdfNodeObject(new ArrayList<String>() {{add(blindOpeningRationVal);}}, true)); return stateSources; }
@Override protected void updateDynamicComponents() { try { openingRatioBar.setValue((int) getProviderService().getBlindState().getOpeningRatio()); openingRatioBar.setString("Opening Ratio = " + openingRatioBar.getValue() + "%"); switch (getProviderService().getBlindState().getMovementState()) { case UP: movementStatePanel.setBackground(Color.GREEN.darker()); break; case DOWN: movementStatePanel.setBackground(Color.RED.darker()); break; case STOP: movementStatePanel.setBackground(Color.CYAN.darker()); break; case UNKNOWN: movementStatePanel.setBackground(Color.GRAY); break; default: break; } movementStateLabel.setText(getProviderService().getBlindState().getMovementState().name()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); } } }
openingRatioAverage += service.getBlindState().getOpeningRatio(); timestamp = Math.max(timestamp, service.getBlindState().getTimestamp().getTime());
static void verifyBlindState(final BlindState blindState) throws VerificationFailedException { try { if (!blindState.hasMovementState() && !blindState.hasOpeningRatio()) { throw new VerificationFailedException("MovementState and OpeningRatio not available!", new InvalidStateException(blindState.toString())); } if (blindState.hasOpeningRatio() && blindState.getOpeningRatio() < 0) { throw new VerificationFailedException("Opening ratio of blind state out of range with value[" + blindState.getOpeningRatio() + "]!", new InvalidStateException(blindState.toString())); } if (blindState.hasMovementState()) { switch (blindState.getMovementState()) { case UNKNOWN: throw new VerificationFailedException("MovementState unknown!", new InvalidStateException(blindState.toString())); default: break; } } } catch (final CouldNotPerformException ex) { throw new VerificationFailedException("BlindState not valid!", ex); } } }
/** * Get the brightness value. * * @param blindState the state to transform * @return the current brightness value */ public static Double transform(BlindState blindState) { return blindState.getOpeningRatio(); } }