private void verifyCondition() { try { if (locationRemote.getData().getPresenceState().getValue().equals(PresenceState.State.PRESENT) && (connectionRemote.getDoorState().getValue().equals(DoorState.State.OPEN) || connectionRemote.getWindowState().getValue().equals(WindowState.State.OPEN))) { notifyChange(TimestampProcessor.updateTimestampWithCurrentTime(ActivationState.newBuilder().setValue(ActivationState.State.ACTIVE).build())); } else { notifyChange(TimestampProcessor.updateTimestampWithCurrentTime(ActivationState.newBuilder().setValue(ActivationState.State.DEACTIVE).build())); } } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not verify trigger state " + this, ex, LoggerFactory.getLogger(getClass())); } } }
public void triggerPresenceChange(LocationDataType.LocationData data) throws InterruptedException { synchronized (standbySync) { if (data.getPresenceState().getValue().equals(PresenceStateType.PresenceState.State.PRESENT) && timeout.isActive()) { timeout.cancel(); try { locationRemote.setStandbyState(State.RUNNING); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify motion state change!", ex), logger); } } else if (data.getPresenceState().getValue().equals(PresenceStateType.PresenceState.State.ABSENT) && !timeout.isActive()) { try { timeout.start(); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not schedule presence timeout!", ex), logger); } } } } }
@Override default PresenceState getPresenceState() throws NotAvailableException { try { return getData().getPresenceState(); } catch (CouldNotPerformException ex) { throw new NotAvailableException("PresenceState", ex); } }
public PersonLightProviderAgent() throws InstantiationException, CouldNotPerformException, InterruptedException { super(PersonLightProviderAgent.class); locationObserver = (final Observable<LocationDataType.LocationData> source, LocationDataType.LocationData data) -> { try { notifyPresenceStateChanged(data.getPresenceState()); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify presence state change!", ex), logger); } }; }