public static BlindState transform(final StopMoveHolder.StopMove stopMoveType) throws CouldNotTransformException { switch (stopMoveType) { case STOP: return BlindState.newBuilder().setMovementState(BlindState.MovementState.STOP).build(); case MOVE: return BlindState.newBuilder().setMovementState(BlindState.MovementState.UNKNOWN).build(); default: throw new CouldNotTransformException("Could not transform " + StopMoveHolder.StopMove.class.getName() + "! " + StopMoveHolder.StopMove.class.getSimpleName() + "[" + stopMoveType.name() + "] is unknown!"); } }
@Override public Future<ActionFuture> setBlindState(final BlindState state) throws CouldNotPerformException { logger.debug("Setting [" + getLabel() + "] to BlindState [" + state + "]"); try { Services.verifyOperationServiceState(state); } catch (VerificationFailedException ex) { return FutureProcessor.canceledFuture(ActionFuture.class, ex); } // stop before moving in any direction. switch (state.getMovementState()) { case DOWN: case UP: try { blindStateService.setBlindState(state.toBuilder().setMovementState(BlindState.MovementState.STOP).build()).get(1000, TimeUnit.MILLISECONDS); } catch (ExecutionException | TimeoutException | InterruptedException ex) { if (ex instanceof InterruptedException) { Thread.currentThread().interrupt(); } ExceptionPrinter.printHistory(new CouldNotPerformException("Could not stop before inverse blind movement.", ex), logger, LogLevel.WARN); // continue without stop } } return blindStateService.setBlindState(state); }
public static BlindState transform(final UpDownHolder.UpDown upDownType) throws CouldNotTransformException { switch (upDownType) { case DOWN: return BlindState.newBuilder().setMovementState(BlindState.MovementState.DOWN).build(); case UP: return BlindState.newBuilder().setMovementState(BlindState.MovementState.UP).build(); default: throw new CouldNotTransformException("Could not transform " + UpDownHolder.UpDown.class.getName() + "! " + UpDownHolder.UpDown.class.getSimpleName() + "[" + upDownType.name() + "] is unknown!"); } }
return TimestampProcessor.updateTimestamp(timestamp, BlindState.newBuilder().setMovementState(mostOccurrences).setOpeningRatio(openingRatioAverage), TimeUnit.MICROSECONDS, logger).build();
ResourceAllocationType.ResourceAllocation.Priority.EMERGENCY, locationRemote, BlindStateType.BlindState.newBuilder().setOpeningRatio(100.0).build(), UnitType.UNKNOWN, ServiceTemplateType.ServiceTemplate.ServiceType.BLIND_STATE_SERVICE,
break; return simulatedBlindState.build();
private void regulateShutterLevelDown() { try { ActionDescriptionType.ActionDescription.Builder actionDescriptionBuilder = getNewActionDescription(ActionAuthorityType.ActionAuthority.getDefaultInstance(), ResourceAllocationType.ResourceAllocation.Initiator.SYSTEM, 1000 * 30, ResourceAllocationType.ResourceAllocation.Policy.FIRST, ResourceAllocationType.ResourceAllocation.Priority.NORMAL, locationRemote, BlindStateType.BlindState.newBuilder().setMovementState(BlindStateType.BlindState.MovementState.DOWN).build(), UnitTemplateType.UnitTemplate.UnitType.UNKNOWN, ServiceTemplateType.ServiceTemplate.ServiceType.BLIND_STATE_SERVICE, MultiResourceAllocationStrategyType.MultiResourceAllocationStrategy.Strategy.AT_LEAST_ONE); actionRescheduleHelper.startActionRescheduleing(locationRemote.applyAction(actionDescriptionBuilder.build()).get().toBuilder()); } catch (CouldNotPerformException | InterruptedException | ExecutionException ex) { logger.error("Could not dim lights.", ex); } }
private void regulateShutterLevelUp() { try { ActionDescriptionType.ActionDescription.Builder actionDescriptionBuilder = getNewActionDescription(ActionAuthorityType.ActionAuthority.getDefaultInstance(), ResourceAllocationType.ResourceAllocation.Initiator.SYSTEM, 1000 * 30, ResourceAllocationType.ResourceAllocation.Policy.FIRST, ResourceAllocationType.ResourceAllocation.Priority.NORMAL, locationRemote, BlindStateType.BlindState.newBuilder().setMovementState(BlindStateType.BlindState.MovementState.UP).build(), UnitTemplateType.UnitTemplate.UnitType.UNKNOWN, ServiceTemplateType.ServiceTemplate.ServiceType.BLIND_STATE_SERVICE, MultiResourceAllocationStrategyType.MultiResourceAllocationStrategy.Strategy.AT_LEAST_ONE); actionRescheduleHelper.startActionRescheduleing(locationRemote.applyAction(actionDescriptionBuilder.build()).get().toBuilder()); } catch (CouldNotPerformException | InterruptedException | ExecutionException ex) { logger.error("Could not dim lights.", ex); } } }
public Future<ActionFuture> setBlindState(BlindState.MovementState movementState) throws CouldNotPerformException { return RollerShutterRemote.this.setBlindState(BlindState.newBuilder().setMovementState(movementState).build()); }
/** * Transform a number to a brightness state by setting the number as the brightness value. * * @param value the brightness value * @return the corresponding brightness state */ public static BlindState transform(final Double value) { BlindState.Builder state = BlindState.newBuilder(); state.setOpeningRatio(value); return state.build(); }