@Override protected void updateDynamicComponents() { try { switch (getProviderService().getStandbyState().getValue()) { case STANDBY: standbyStatusLabel.setForeground(Color.LIGHT_GRAY); standbyStatePanel.setBackground(Color.BLUE.brighter()); standbyButton.setText("Wakeup"); break; case RUNNING: standbyStatusLabel.setForeground(Color.BLACK); standbyStatePanel.setBackground(Color.GREEN.darker()); standbyButton.setText("Activate Standby"); break; case UNKNOWN: standbyStatusLabel.setForeground(Color.BLACK); standbyStatePanel.setBackground(Color.ORANGE.darker()); standbyButton.setText("Activate Standby"); break; default: throw new InvalidStateException("State[" + getProviderService().getStandbyState().getValue() + "] is unknown."); } standbyStatusLabel.setText("Current StandbyState = " + StringProcessor.transformUpperCaseToCamelCase(getProviderService().getStandbyState().getValue().name())); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(ex, logger); } } }
@Override public Future<ActionFuture> setStandbyState(final StandbyState standbyState) { logger.info("Standby[" + standbyState.getValue() + "]" + this); return GlobalScheduledExecutorService.submit(() -> { try (ClosableDataBuilder<LocationData.Builder> dataBuilder = getDataBuilder(this)) { switch (getStandbyState().getValue()) { case UNKNOWN: case RUNNING: switch (standbyState.getValue()) { case STANDBY: for(LocationRemote childLocation : getChildLocationList(false)) { switch (standbyState.getValue()) { case RUNNING: standbyController.wakeup();
@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); }
private void standbyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_standbyButtonActionPerformed try { switch (getProviderService().getStandbyState().getValue()) { case STANDBY: notifyActionProcessing(getOperationService().setStandbyState(RUNNING)); break; case RUNNING: case UNKNOWN: notifyActionProcessing(getOperationService().setStandbyState(STANDBY)); break; default: throw new InvalidStateException("State[" + getProviderService().getStandbyState().getValue().name() + "] is unknown."); } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not set standby state!", ex), logger); } }//GEN-LAST:event_standbyButtonActionPerformed
@Override public StandbyState getStandbyState(final UnitType unitType) throws NotAvailableException { StandbyState.State standbyValue = StandbyState.State.STANDBY; long timestamp = 0; for (StandbyStateOperationService service : getServices(unitType)) { if (!((UnitRemote) service).isDataAvailable()) { continue; } if (service.getStandbyState().getValue() == StandbyState.State.RUNNING) { standbyValue = StandbyState.State.RUNNING; } timestamp = Math.max(timestamp, service.getStandbyState().getTimestamp().getTime()); } return TimestampProcessor.updateTimestamp(timestamp, StandbyState.newBuilder().setValue(standbyValue), TimeUnit.MICROSECONDS, logger).build(); } }
public default Future<ActionFuture> setStandbyState(final StandbyState.State standbyState) throws CouldNotPerformException { return setStandbyState(StandbyState.newBuilder().setValue(standbyState).build()); } }
/** * Method returns the state source(s) result(s) (contains state value(s)) of the input standbyState. * * @param standbyState The StandbyState. * @return state source(s) result(s) of the input state. */ private List<RdfNodeObject> standbyStateSources(final StandbyState standbyState) { final List<RdfNodeObject> stateSources = new ArrayList<>(); final String standbyStateVal = standbyState.getValue().toString(); stateSources.add(new RdfNodeObject(new ArrayList<String>() {{add(standbyStateVal);}}, false)); return stateSources; }