@Override public M getValue() throws NotAvailableException { return unit.getData(); }
@Override public D getData() throws NotAvailableException { return responsibleInstance.getData(); }
@Override public void activate() throws CouldNotPerformException, InterruptedException { if (locationDataObserver == null) { throw new NotInitializedException(this); } active = true; locationDataProvider.addDataObserver(locationDataObserver); // start initial timeout presenceTimeout.start(); updateMotionState(locationDataProvider.getData().getMotionState()); }
@Override public void expired() { try { // if motion is still detected just restart the timeout. if (locationDataProvider.getData().getMotionState().getValue() == MotionState.State.MOTION) { GlobalCachedExecutorService.submit(() -> { try { presenceTimeout.restart(); } catch (final CouldNotPerformException ex) { ExceptionPrinter.printHistory("Could not setup presence timeout!", ex, logger); } }); return; } updatePresenceState(PresenceState.newBuilder().setValue(PresenceState.State.ABSENT)); } catch (CouldNotPerformException ex) { ExceptionPrinter.printHistory(new CouldNotPerformException("Could not notify absent by timer!", ex), logger); } } };