Service stores the state of the sensor and the date of last report from the sensor. Also it regularly runs a scheduled task to check the last report timestamp.
To decouple this service from notifiers - Spring application events are used.
We have 2 parameters for this routine:
Parameter
Description
Default value
checkRate
How often to check sensor state
30 seconds
sensorTimeout
If no reports were received during this amount of time - the sensor is considered unpowered
1 minute
Following describes the change between states:
let's consider initial state is on
if current state is on and scheduled task finds that time passed from last report is more that sensorTimeout, set state to off and emit event (in initial state, if there were no reports, bypass the check)
if current state is off and new report from the sensor is received, set state to on and emit event
if there is no state changes, do not emit events
Please see the following links to learn about Spring features needed:
Create first basic implementation of
SensorService
. See the design suggestion at https://github.com/kuzjka/lighthouse-community/wiki/Server-app-design-v0.1Service stores the state of the sensor and the date of last report from the sensor. Also it regularly runs a scheduled task to check the last report timestamp.
To decouple this service from notifiers - Spring application events are used.
We have 2 parameters for this routine:
Following describes the change between states:
Please see the following links to learn about Spring features needed:
Prefer annotation-based configuration for both of these features.