AIM
|
#include <SleepTime.h>
Public Member Functions | |
SleepTime (std::string name=MODULE_NAME) | |
void | doTick () |
virtual void | addData (const AIMData &data) |
AIMValue | setProperty (const std::string &key, AIMValue value) |
void | setProperties (const std::map< std::string, AIMValue > &properties) |
std::map< std::string, AIMValue > & | getProperties () |
Public Member Functions inherited from AIM | |
AIM (std::string name="") | |
AIM (const AIM &other) | |
AIM & | operator= (const AIM &rhs) |
virtual void | addDataSubscriber (const std::string &key, AIM *subscriber) |
virtual void | removeDataSubscriber (const std::string &key) |
virtual AIMValue | getProperty (std::string key) const |
virtual void | sendData () |
virtual std::string | exportProperties () |
virtual std::vector< std::pair < std::string, AIMValue > > | getOutputData (bool clear_output=false) |
virtual std::vector< std::pair < std::string, AIMValue > > | getInputData (bool clear_input=false) |
virtual AIM * | getDataSubscriber (std::string subscriber) |
virtual std::string | getName () const |
virtual std::vector< AIMValue > | getRequirements () const |
virtual bool | requirementsAreUpdated (bool reset=true) const |
Static Public Attributes | |
static const std::string | VERSION = "1.6.5" |
static const std::string | SENSOR_ACCELEROMETER_EVENT = "accelerometer event" |
static const std::string | SENSOR_NOISE_EVENT = "noise event" |
static const std::string | SENSOR_CARRY_DEVICE = "carry_device" |
static const std::string | PROP_SENSOREVENT_NOISE = "SensorEvent noise" |
static const std::string | PROP_CARRY_DEVICE = "carry device property" |
static const std::string | PROP_POSITION_FILTER = "position filter property" |
static const std::string | PROP_POSITION_DISTANCE = "position distance property" |
static const std::string | PROP_TIME_WINDOW = "time window" |
static const std::string | PROP_FEATURE_BUFFER = "feature buffer" |
static const std::string | PROP_SLEEP_PERIOD_END_TIME = "sleep period end time" |
static const std::string | PROP_NEXT_END_TIME = "next output time" |
static const std::string | PROP_NOISE_THRESHOLD = "noise threshold" |
static const std::string | PROP_NOISE_THRESHOLD_OFF = "noise threshold off" |
static const std::string | PROP_USE_NIGHTLY_SLEEP = "use nightly sleep" |
static const std::string | PROP_LENGTH_START_SLEEP = "length start sleep" |
static const std::string | PROP_ONLY_USE_ACC = "only use accelerometer" |
static const std::string | PROP_USE_TUCKIN = "use tuck in" |
static const std::string | PROP_MAX_TRAVEL_DISTANCE = "max travel distance" |
static const std::string | PROP_SLEEP_LOCATION = "sleep location" |
static const std::string | PROP_SLEEP_STARTED = "sleep started" |
static const std::string | PROP_FEATURE_NORMALIZATION = "normalization feature" |
static const std::string | FEATURE_NORMALIZATION_STD = "standard score normalization" |
static const std::string | FEATURE_NORMALIZATION_MINMAX = "min max normalization" |
static const std::string | PROP_USE_LOUDNESS = "use loudness" |
static const std::string | PROP_USE_NOISE_EVENT = "use noise event" |
static const std::string | PROP_USE_TRAVELED = "use traveled" |
static const std::string | PROP_USE_CARRIED = "use carried" |
static const std::string | PROP_USE_LOCATION_BASED_THRESHOLDS = "use location based thresholds" |
static const std::string | PROP_LEARN_START_TIME = "learn start time" |
static const std::string | PROP_LEARN_END_TIME = "learn end time" |
static const std::string | PROP_USE_LEARNING = "use learning" |
static const std::string | PROP_NOISE_BUFFER = "noise buffer" |
static const std::string | PROP_NOISE_LEARN_RATE = "noise learn rate" |
static const std::string | PROP_NOISE_LEARN_PERCENTILE = "noise learn percentile" |
static const std::string | PROP_LOCATION_THRESHOLDS = "location based thresholds" |
static const std::string | PROP_LAST_LOCATION_INDX = "last location index" |
static const std::string | PROP_TEST_SLEEP = "test sleep" |
static const std::string | PROP_USE_ON_OFF_THRESHOLDS = "use on off thresholds" |
static const std::string | PROP_LEARN_RATE_USE_NORM = "learn rate use norm" |
static const std::string | PROP_LEARN_RATE_NORM_CNT = "learn rate norm cnt" |
static const std::string | PROP_ADAPTIVE_SAMPLING = "adaptive_sampling" |
static const std::string | PROP_NIGHTLY_SLEEP_START_HOUR = "nightly sleep start hour" |
static const std::string | MODULE_NAME = "sleep_time" |
Static Public Attributes inherited from AIM | |
static const std::string | VERSION = AIM_VERSION |
Additional Inherited Members | |
Public Types inherited from AIM | |
typedef std::pair< std::string, AIMValue > | AIMData |
typedef std::queue< AIMData > | AIMDataQueue |
typedef std::queue< AIMValue > | AIMValueQueue |
typedef std::map< std::string, AIMValueQueue > | InputDataQueue |
Protected Member Functions inherited from AIM | |
void | setDataSubscribers (const std::map< std::string, AIM * > &subscribers) |
void | setInputDataQueue (const InputDataQueue &inputDataQueue) |
void | setOutputDataQueue (const AIMDataQueue &outputDataQueue) |
Protected Attributes inherited from AIM | |
std::string | name |
std::vector< AIMValue > | requirements |
bool | requirementsUpdated |
std::map< std::string, AIM * > | dataSubscribers |
std::map< std::string, AIMValue > | properties |
InputDataQueue | inputDataQueue |
AIMDataQueue | outputDataQueue |
Created on: August 23, 2013 Author: Ted Schmidt
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 PROP_ONLY_USE_ACC 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.
When the tuck in property is set to false the phone does not need to be put face down while sleeping. By default the property is true.
As AIMData input it needs the following 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
{"position":{"latitude", 4.112345, "longitude", 53.322134, "accuracy":100}}
SleepTime::SleepTime | ( | std::string | name = MODULE_NAME | ) |
SleepTime constructor
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).
|
virtual |
Add data
This method adds data to the input queue of the AI-module The AIMData object
AIMData | data The input data |
Reimplemented from AIM.
|
virtual |
Do an AIM tick
This method is called to tick the AI-module to do its processing. During this tick the AI module grabs it's input data, does its processing, and sends the data to its data receivers. This method can be used in combination with AIM priorities, to streamline the data flow and timers for timed AI modules.
Reimplemented from AIM.
|
virtual |
Return the module and submodule properties
Reimplemented from AIM.
|
virtual |
Set the module properties
Set the defined properties. Old property values will remain if no new values are specified for a property.
map | properties The properties to set |
Set the properties for this module and for each submodule
Reimplemented from AIM.
Set a property value
To set a property value for the sensor event module use the key PROP_SENSOREVENT_ACC.
Set the properties
Reimplemented from AIM.
|
static |
Feature type for the normalization feature: min max
|
static |
Feature type for the normalization feature: standard score / z-score
|
static |
Name of the this module
|
static |
Property key for adaptive sampling
|
static |
Property key of the carry device module
|
static |
Property key for the feature buffer
|
static |
Property key for the normalization feature
property for the normalization feature
|
static |
Property key for storing last location index
|
static |
Property key for the end time of the learn sleep period
|
static |
Property key for the normalization count
|
static |
Property key for using normalizaion for the learn rate
|
static |
Property key for the learned sleep parameters Property key for the start time of the learn sleep period
|
static |
Property key for the length of sleep start boolean
|
static |
Property key for storing threshold per location
|
static |
Property key for the max travel distance
|
static |
Property key for the next end time
|
static |
Property key for the nightly sleep start hour
|
static |
Property key for storing the noise values
|
static |
Property key for storing the noise learn percentile
|
static |
Property key for storing the noise learn rate
|
static |
Property key for the noise threshold (on)
|
static |
Property key for the noise threshold off (off/on)
|
static |
Property key for the only using the accelerometer
|
static |
Property key of the position distance measure module
|
static |
Property key of the position filter module
|
static |
Property key of the sensor event module
|
static |
Property key for the sleep location value
|
static |
Property key for the end time for computing the sleep period
|
static |
Property key for the sleep started boolean
|
static |
Property key for testing sleep against a dataset
|
static |
Property key for the time window
|
static |
Property key for the using the carried feature
|
static |
Property key for the using the learning feature
|
static |
Property key for the using the location based thresholds feature
|
static |
Property key for the using loudness feature
|
static |
Property key for the nightly sleep boolean
features to disable / enable
|
static |
Property key for the using the noise event feature
|
static |
Property key for using on off thresholds
|
static |
Property key for the using the traveled feature
|
static |
Property key for the using the tuck in feature
|
static |
Input name of the accelerometer event sensor
|
static |
Input name of the carry device sensor
|
static |
Input name of the noise eventsensor
|
static |
Module version