Cortex Android
 All Classes Namespaces Functions Variables
nl.sense_os.cortex.SleepTimeSensor Class Reference
Inheritance diagram for nl.sense_os.cortex.SleepTimeSensor:

Public Member Functions

 SleepTimeSensor (String name, SensePlatform sensePlatform)
 
 SleepTimeSensor (SensePlatform sensePlatform)
 
String getName ()
 
void setInterval (double interval)
 
void setTimeWindow (double time_window)
 
void setEventThreshold (double threshold)
 
void setSleepEndTime (int hour)
 
void setComputeNightlySleep (boolean nightly_sleep)
 
void reCalibrate ()
 
void setAdaptiveSampling (boolean adaptive)
 
void onNewData (SensorDataPoint dataPoint)
 

Protected Member Functions

void setup ()
 

Detailed Description

This is wrapper class for the Sleep Time Module
This module recognizes when and how long a person sleeps in a day.

This module returns a value with the format:
{"sleepTime":8.5, "start_date":1377242482, "end_date": 1377242482}
When the nightly sleep property is set, sleep is calculated from 22:00
By default the nightly sleep property is set to true. Only after learning the threshold values the nightly sleep can be turned off.
By default the use only accelerometer is set to false, if this is set to true then only accelerometer input is used and the phone needs to be put face down when sleeping.
As AIMData input it needs the key:values
{"noise":{"value":45, "date":12345678.11}} double noise value
{"accelerometer":{"value":{"x-axis":9.81, "y-axis":0.1, "z-axis":9.81}, "date":12345678.11}} float, acceleration value
{"light":{"value":{"lux":11}, "date":12345678.11}} integer, lux
{"screen activity":{"value":{"screen":"on"}, "date":12345678.11}} string, can either be on or off
{"proximity":{"value":0.06, "date":12345678.11}} integer, meters
{"call state":{"value":{"state":"idle"}, "date":12345678.11}} string, can either be calling, ringing, idle, dialing
{"battery":{"value":{"status":"charging ac"}, "date":12345678.11}} string, can either be charging ac, charging usb, discharging, full

This DataProcessor requires the following sensors/settings:
SensorNames.NOISE
SensorNames.ACCELEROMETER
SensorNames.SCREEN_ACTIVITY
SensorNames.CALL_STATE
Motion sensing enabled
PhoneState sensing enabled
Ambience sensing enabled

Author
Ted Schmidt ted@s.nosp@m.ense.nosp@m.-os.n.nosp@m.l

Copyright (c) 2013 Sense Observation Systems BV. All rights reserved.

Constructor & Destructor Documentation

nl.sense_os.cortex.SleepTimeSensor.SleepTimeSensor ( String  name,
SensePlatform  sensePlatform 
)

SleepTime constructor

A SleepTime data producer will be registered at the Sense Service
under the name supplied with this constructor.
To receive data from this DataProducer, subscription should be done at the Sense Service with the given name.
The DataProcessor persists its state based on the supplied name.
Re-creating a SleepTime DataProducer with the same name will load its previous settings.
By default the time window (PROP_TIME_WINDOW) of the module is set to 5 minutes for computing an output.
The time window for the noise sensor event module is set to 5 minutes and with a variance threshold of 0.04.
The threshold for the maximum noise value (PROP_NOISE_THRESHOLD) for sleep is set to 50 dB.
The carry device module used has a time window which is 0.9 x the time window of this module for alignment.
The motion variance threshold for carry device is adjusted to 0.008, and when only using the accelerometer to 0.0035.
The end time for computing sleep PROP_SLEEP_PERIOD_END_TIME, is set to 12, which is 12PM.
The module computes sleep from 22:00 until 12:00 (PROP_SLEEP_PERIOD_END_TIME) when PROP_USE_NIGHTLY_SLEEP is set to true, which is the default.
The tuck in feature is used by default (PROP_USE_TUCKIN) when the device is put face down during sleep for more than 3 hours.
The start of sleep is set when a sleep period of more than PROP_LENGTH_START_SLEEP = 25 minutes is found (60 minutes when PROP_ONLY_USE_ACC is true).

Parameters
sensePlatformThe SensePlatform
nameThe name of the data processor. Should be unique.
nl.sense_os.cortex.SleepTimeSensor.SleepTimeSensor ( SensePlatform  sensePlatform)

SleepTime constructor

A SleepTime data producer will be registered at the Sense Service

See Also
SleepTimeSensor(String name, SensePlatform sensePlatform
Parameters
sensePlatformThe SensePlatform

Member Function Documentation

String nl.sense_os.cortex.SleepTimeSensor.getName ( )

Get the name of the DataProcessor

Returns
The name of the module
void nl.sense_os.cortex.SleepTimeSensor.onNewData ( SensorDataPoint  dataPoint)

On new data

This method receives data from the sensors to which the DataProcessor is subscribed

Parameters
dataPointThe SensorDataPoint coming from the subscribed sensor
void nl.sense_os.cortex.SleepTimeSensor.reCalibrate ( )

Re-calibrate the module

This method removes the learned lowest variance for noise sensor.

void nl.sense_os.cortex.SleepTimeSensor.setAdaptiveSampling ( boolean  adaptive)

Enable/disable adaptive sampling

This function enables or disables the adaptive sampling for the sleep time sensor.
When adaptive sampling is enabled and the default compute nightly sleep is set to true then it will disable all the sensors when not needed.
Otherwise all the needed sensors will be enabled.
N.B. This function is only working in combination with the CoachingEngine.

Parameters
adaptiveThe boolean to toggle the adaptive sampling.
void nl.sense_os.cortex.SleepTimeSensor.setComputeNightlySleep ( boolean  nightly_sleep)

Set compute the nightly sleep

This method sets whether to only compute the nightly sleep or not (from 22:00 until sleep end time 12:00)

Parameters
nightly_sleepboolean Set to compute nightly sleep only.
void nl.sense_os.cortex.SleepTimeSensor.setEventThreshold ( double  threshold)

Set the event threshold

This method sets the threshold for when a change in sensor data is seen as noise or as an event.
The default 0.04 = 4% higher then noise

Parameters
thresholddouble threshold value between 0-1
void nl.sense_os.cortex.SleepTimeSensor.setInterval ( double  interval)

Set the interval

This method sets the interval at which to do the sleep classification.
The default is 5 minutes.
Setting the interval will reset the time window.

Parameters
intervalin seconds
void nl.sense_os.cortex.SleepTimeSensor.setSleepEndTime ( int  hour)

Set the sleep end time

This method sets the maximum end time for computing the sleep period The default 12 (12:00 PM)

Parameters
hourinteger The end time for computing sleep
void nl.sense_os.cortex.SleepTimeSensor.setTimeWindow ( double  time_window)

Set the time window

This method sets the time window used for auto calibrating the noise sensor.
The default value is 10% larger than the interval.
Setting the interval will reset the time window.

Parameters
time_windowdouble The time window used for calibration
void nl.sense_os.cortex.SleepTimeSensor.setup ( )
protected

Setup the sensor

This method sets the input sensor and the initial settings


The documentation for this class was generated from the following file: