@Override public Future<ActionFuture> setUserPresenceState(UserPresenceState userPresenceState) throws CouldNotPerformException { try (ClosableDataBuilder<Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setUserPresenceState(userPresenceState); } catch (CouldNotPerformException | NullPointerException ex) { throw new CouldNotPerformException("Could not set user presence state to [" + userPresenceState + "] for " + this + "!", ex); } return CompletableFuture.completedFuture(null); } }
/** * {@inheritDoc} * * @param consumer {@inheritDoc} * @return {@inheritDoc} */ @Override public ClosableDataBuilder<MB> getDataBuilder(final Object consumer, final boolean notifyChange) { return new ClosableDataBuilder<>(getBuilderSetup(), consumer, notifyChange); }
@Override public Future<ActionFuture> setEmphasisState(EmphasisState emphasisState) throws CouldNotPerformException { logger.debug("Apply emphasisState Update[" + emphasisState + "] for " + this + "."); try (ClosableDataBuilder<AgentData.Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setEmphasisState(emphasisState); } catch (Exception ex) { throw new CouldNotPerformException("Could not apply emphasisState Update[" + emphasisState + "] for " + this + "!", ex); } CompletableFuture<ActionFuture> completableFuture = new CompletableFuture<>(); completableFuture.complete(ActionFuture.getDefaultInstance()); return completableFuture; }
/** * {@inheritDoc} * * @param consumer {@inheritDoc} * @return {@inheritDoc} */ @Override public ClosableDataBuilder<MB> getDataBuilder(final Object consumer) { return new ClosableDataBuilder<>(getBuilderSetup(), consumer); }
@Override public Future<ActionFuture> setUserActivityState(UserActivityState UserActivityState) throws CouldNotPerformException { try (ClosableDataBuilder<UserData.Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setUserActivityState(UserActivityState); } catch (CouldNotPerformException | NullPointerException ex) { throw new CouldNotPerformException("Could not set user activity to [" + UserActivityState + "] for " + this + "!", ex); } return CompletableFuture.completedFuture(null); }
@Override public Future<ActionFuture> setUserPresenceState(UserPresenceState userPresenceState) throws CouldNotPerformException { try (ClosableDataBuilder<UserData.Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setUserPresenceState(userPresenceState); } catch (CouldNotPerformException | NullPointerException ex) { throw new CouldNotPerformException("Could not set user presence state to [" + userPresenceState + "] for " + this + "!", ex); } return CompletableFuture.completedFuture(null); }
public void updateBrightnessStateProvider(final BrightnessState value) throws CouldNotPerformException { logger.debug("Apply brightnessState Update[" + value + "] for " + this + "."); try (ClosableDataBuilder<BrightnessSensorData.Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setBrightnessState(value); } catch (Exception ex) { throw new CouldNotPerformException("Could not apply brightnessState Update[" + value + "] for " + this + "!", ex); } }
public void updateIlluminanceStateProvider(final IlluminanceState illuminanceState) throws CouldNotPerformException { logger.debug("Apply illuminanceState Update[" + illuminanceState + "] for " + this + "."); try (ClosableDataBuilder<BrightnessSensorData.Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setIlluminanceState(illuminanceState); } catch (Exception ex) { throw new CouldNotPerformException("Could not apply illuminanceState Update[" + illuminanceState + "] for " + this + "!", ex); } }
@Override public void update(Observable<PresenceState> source, PresenceState data) throws Exception { try (ClosableDataBuilder<LocationData.Builder> dataBuilder = getDataBuilder(this)) { LOGGER.debug("Set " + this + " presence to [" + data.getValue() + "]"); dataBuilder.getInternalBuilder().setPresenceState(data); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not apply presense state change!", ex); } } });
@Override public void expired() { try (ClosableDataBuilder<ButtonData.Builder> dataBuilder = getDataBuilder(this)) { dataBuilder.getInternalBuilder().setButtonState(BUTTON_STATE_RELEASED); } catch (Exception ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not reset button state!", ex), logger); } } };
private <B extends GeneratedMessage.Builder> B registerUnitBuilder(final UnitConfig unitConfig) throws CouldNotPerformException { try (ClosableDataBuilder<DB> dataBuilder = getDataBuilder(this, isActive())) { DB builder = dataBuilder.getInternalBuilder(); Class builderClass = builder.getClass(); String unitTypeName = StringProcessor.transformUpperCaseToCamelCase(unitConfig.getType().name());
private void updateUnitData() throws InterruptedException { try (ClosableDataBuilder<LocationDataType.LocationData.Builder> dataBuilder = getDataBuilder(this)) { serviceRemoteManager.updateBuilderWithAvailableServiceStates(dataBuilder.getInternalBuilder(), getDataClass(), getSupportedServiceTypes()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not update current status!", ex), LOGGER, LogLevel.WARN); } }
private void updateUnitData() throws InterruptedException { try (ClosableDataBuilder<UnitGroupData.Builder> dataBuilder = getDataBuilder(this)) { serviceRemoteManager.updateBuilderWithAvailableServiceStates(dataBuilder.getInternalBuilder(), getDataClass(), getSupportedServiceTypes()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not update current status!", ex), LOGGER, LogLevel.WARN); } }
private void setRequestedState() throws CouldNotPerformException { try (ClosableDataBuilder dataBuilder = unit.getDataBuilder(this)) { // set the responsible action for the service attribute Message.Builder serviceStateBuilder = serviceAttribute.toBuilder(); Descriptors.FieldDescriptor fieldDescriptor = ProtoBufFieldProcessor.getFieldDescriptor(serviceStateBuilder, Service.RESPONSIBLE_ACTION_FIELD_NAME); serviceStateBuilder.setField(fieldDescriptor, actionDescriptionBuilder.build()); // set the updated service attribute as requested state in the unit data builder Services.invokeServiceMethod(serviceDescription.getType(), serviceDescription.getPattern(), ServiceTempus.REQUESTED, dataBuilder.getInternalBuilder(), serviceStateBuilder); } }
Descriptors.FieldDescriptor findFieldByName = dataBuilder.getInternalBuilder().getDescriptorForType().findFieldByName(FIELD_ACTIVATION_STATE); if (findFieldByName == null) { throw new NotAvailableException("Field[" + FIELD_ACTIVATION_STATE + "] does not exist for type " + dataBuilder.getClass().getName()); dataBuilder.getInternalBuilder().setField(findFieldByName, activation);
dataBuilder.getInternalBuilder().setStandbyState(standbyState); childLocation.setStandbyState(State.RUNNING).get(); dataBuilder.getInternalBuilder().setStandbyState(standbyState); case STANDBY:
dataBuilder.getInternalBuilder().setWindowState(TimestampProcessor.updateTimestamp(timestamp, dataBuilder.getInternalBuilder().getWindowStateBuilder().setValue(windowState), logger).build()); } catch (Exception ex) { throw new CouldNotPerformException("Could not apply brightness data change!", ex);
dataBuilder.getInternalBuilder().setDoorState(TimestampProcessor.updateTimestamp(timestamp, dataBuilder.getInternalBuilder().getDoorStateBuilder().setValue(doorState), logger).build()); } catch (Exception ex) { throw new CouldNotPerformException("Could not apply brightness data change!", ex);
@Override public void init(final UnitConfig config) throws InitializationException, InterruptedException { LOGGER.debug("Init location [" + config.getLabel() + "]"); try { Registries.getUnitRegistry().waitForData(); } catch (CouldNotPerformException ex) { throw new InitializationException(this, ex); } super.init(config); // do not notify because not activated yet try (ClosableDataBuilder<LocationData.Builder> dataBuilder = getDataBuilder(this, false)) { dataBuilder.getInternalBuilder().setStandbyState(StandbyState.newBuilder().setValue(StandbyState.State.RUNNING).build()); } catch (Exception ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not apply initial standby service states!", ex), LOGGER, LogLevel.WARN); } presenceDetector.init(this); standbyController.init(this); }
DB internalBuilder = dataBuilder.getInternalBuilder();