@Override public void activate() throws InterruptedException, CouldNotPerformException { super.activate(); synchronized (buttonObserverLock) { buttonRemoteSet.stream().forEach((button) -> { button.addDataObserver(buttonObserver); }); } }
@Override public void disable() throws CouldNotPerformException, InterruptedException { try { synchronized (enablingLock) { cancelExecution(); enabled = false; setActivationState(ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).build()).get(); deactivate(); } } catch (ExecutionException ex) { throw new CouldNotPerformException("Could not disable " + this, ex); } }
public ActivationState getActivationState() throws NotAvailableException { return (ActivationState) getDataField(FIELD_ACTIVATION_STATE); }
if (activation.getValue() == getActivationState().getValue()) { return CompletableFuture.completedFuture(null); if (isExecuting()) { return CompletableFuture.completedFuture(null); execute(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not execute [" + getLabel() + "]", ex), logger); if (isExecuting()) { cancelExecution(); stop(); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); applyDataUpdate(activation.toBuilder().setTimestamp(TimestampProcessor.getCurrentTimestamp()).build(), ServiceType.ACTIVATION_STATE_SERVICE); } catch (CouldNotPerformException ex) { throw new CouldNotPerformException("Could not " + StringProcessor.transformUpperCaseToCamelCase(activation.getValue().name()) + " " + this, ex);
@Override public void enable() throws CouldNotPerformException, InterruptedException { try { synchronized (enablingLock) { enabled = true; activate(); if (detectAutostart()) { setActivationState(ActivationState.newBuilder().setValue(ActivationState.State.ACTIVE).build()).get(); } else { setActivationState(ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).build()).get(); } } } catch (ExecutionException ex) { throw new CouldNotPerformException("Could not enable " + this, ex); } }
@Override public void deactivate() throws InterruptedException, CouldNotPerformException { logger.debug("deactivate " + getConfig().getLabel()); synchronized (buttonObserverLock) { buttonRemoteSet.stream().forEach((button) -> { button.removeDataObserver(buttonObserver); }); } super.deactivate(); }
@Override public UnitConfig applyConfigUpdate(UnitConfig config) throws CouldNotPerformException, InterruptedException { config = super.applyConfigUpdate(config);