AIM
 All Classes Functions Variables Typedefs Enumerations
SleepTime Class Reference

#include <SleepTime.h>

Inheritance diagram for SleepTime:
AIM

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)
 
AIMoperator= (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 AIMgetDataSubscriber (std::string subscriber)
 
virtual std::string getName () const
 
virtual std::vector< AIMValuegetRequirements () 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< AIMDataAIMDataQueue
 
typedef std::queue< AIMValueAIMValueQueue
 
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< AIMValuerequirements
 
bool requirementsUpdated
 
std::map< std::string, AIM * > dataSubscribers
 
std::map< std::string, AIMValueproperties
 
InputDataQueue inputDataQueue
 
AIMDataQueue outputDataQueue
 

Detailed Description

SleepTime.h

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}}

Constructor & Destructor Documentation

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).

Member Function Documentation

void SleepTime::addData ( const AIMData data)
virtual

Add data

This method adds data to the input queue of the AI-module The AIMData object

Parameters
AIMDatadata The input data

Reimplemented from AIM.

void SleepTime::doTick ( )
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.

std::map< std::string, AIMValue > & SleepTime::getProperties ( )
virtual

Return the module and submodule properties

Reimplemented from AIM.

void SleepTime::setProperties ( const std::map< std::string, AIMValue > &  properties)
virtual

Set the module properties

Set the defined properties. Old property values will remain if no new values are specified for a property.

Parameters
mapproperties The properties to set

Set the properties for this module and for each submodule

Reimplemented from AIM.

AIMValue SleepTime::setProperty ( const std::string &  key,
AIMValue  value 
)
virtual

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.

Member Data Documentation

const std::string SleepTime::FEATURE_NORMALIZATION_MINMAX = "min max normalization"
static

Feature type for the normalization feature: min max

const std::string SleepTime::FEATURE_NORMALIZATION_STD = "standard score normalization"
static

Feature type for the normalization feature: standard score / z-score

const std::string SleepTime::MODULE_NAME = "sleep_time"
static

Name of the this module

const std::string SleepTime::PROP_ADAPTIVE_SAMPLING = "adaptive_sampling"
static

Property key for adaptive sampling

const std::string SleepTime::PROP_CARRY_DEVICE = "carry device property"
static

Property key of the carry device module

const std::string SleepTime::PROP_FEATURE_BUFFER = "feature buffer"
static

Property key for the feature buffer

const std::string SleepTime::PROP_FEATURE_NORMALIZATION = "normalization feature"
static

Property key for the normalization feature

property for the normalization feature

const std::string SleepTime::PROP_LAST_LOCATION_INDX = "last location index"
static

Property key for storing last location index

const std::string SleepTime::PROP_LEARN_END_TIME = "learn end time"
static

Property key for the end time of the learn sleep period

const std::string SleepTime::PROP_LEARN_RATE_NORM_CNT = "learn rate norm cnt"
static

Property key for the normalization count

const std::string SleepTime::PROP_LEARN_RATE_USE_NORM = "learn rate use norm"
static

Property key for using normalizaion for the learn rate

const std::string SleepTime::PROP_LEARN_START_TIME = "learn start time"
static

Property key for the learned sleep parameters Property key for the start time of the learn sleep period

const std::string SleepTime::PROP_LENGTH_START_SLEEP = "length start sleep"
static

Property key for the length of sleep start boolean

const std::string SleepTime::PROP_LOCATION_THRESHOLDS = "location based thresholds"
static

Property key for storing threshold per location

const std::string SleepTime::PROP_MAX_TRAVEL_DISTANCE = "max travel distance"
static

Property key for the max travel distance

const std::string SleepTime::PROP_NEXT_END_TIME = "next output time"
static

Property key for the next end time

const std::string SleepTime::PROP_NIGHTLY_SLEEP_START_HOUR = "nightly sleep start hour"
static

Property key for the nightly sleep start hour

const std::string SleepTime::PROP_NOISE_BUFFER = "noise buffer"
static

Property key for storing the noise values

const std::string SleepTime::PROP_NOISE_LEARN_PERCENTILE = "noise learn percentile"
static

Property key for storing the noise learn percentile

const std::string SleepTime::PROP_NOISE_LEARN_RATE = "noise learn rate"
static

Property key for storing the noise learn rate

const std::string SleepTime::PROP_NOISE_THRESHOLD = "noise threshold"
static

Property key for the noise threshold (on)

const std::string SleepTime::PROP_NOISE_THRESHOLD_OFF = "noise threshold off"
static

Property key for the noise threshold off (off/on)

const std::string SleepTime::PROP_ONLY_USE_ACC = "only use accelerometer"
static

Property key for the only using the accelerometer

const std::string SleepTime::PROP_POSITION_DISTANCE = "position distance property"
static

Property key of the position distance measure module

const std::string SleepTime::PROP_POSITION_FILTER = "position filter property"
static

Property key of the position filter module

const std::string SleepTime::PROP_SENSOREVENT_NOISE = "SensorEvent noise"
static

Property key of the sensor event module

const std::string SleepTime::PROP_SLEEP_LOCATION = "sleep location"
static

Property key for the sleep location value

const std::string SleepTime::PROP_SLEEP_PERIOD_END_TIME = "sleep period end time"
static

Property key for the end time for computing the sleep period

const std::string SleepTime::PROP_SLEEP_STARTED = "sleep started"
static

Property key for the sleep started boolean

const std::string SleepTime::PROP_TEST_SLEEP = "test sleep"
static

Property key for testing sleep against a dataset

const std::string SleepTime::PROP_TIME_WINDOW = "time window"
static

Property key for the time window

const std::string SleepTime::PROP_USE_CARRIED = "use carried"
static

Property key for the using the carried feature

const std::string SleepTime::PROP_USE_LEARNING = "use learning"
static

Property key for the using the learning feature

const std::string SleepTime::PROP_USE_LOCATION_BASED_THRESHOLDS = "use location based thresholds"
static

Property key for the using the location based thresholds feature

const std::string SleepTime::PROP_USE_LOUDNESS = "use loudness"
static

Property key for the using loudness feature

const std::string SleepTime::PROP_USE_NIGHTLY_SLEEP = "use nightly sleep"
static

Property key for the nightly sleep boolean

features to disable / enable

const std::string SleepTime::PROP_USE_NOISE_EVENT = "use noise event"
static

Property key for the using the noise event feature

const std::string SleepTime::PROP_USE_ON_OFF_THRESHOLDS = "use on off thresholds"
static

Property key for using on off thresholds

const std::string SleepTime::PROP_USE_TRAVELED = "use traveled"
static

Property key for the using the traveled feature

const std::string SleepTime::PROP_USE_TUCKIN = "use tuck in"
static

Property key for the using the tuck in feature

const std::string SleepTime::SENSOR_ACCELEROMETER_EVENT = "accelerometer event"
static

Input name of the accelerometer event sensor

const std::string SleepTime::SENSOR_CARRY_DEVICE = "carry_device"
static

Input name of the carry device sensor

const std::string SleepTime::SENSOR_NOISE_EVENT = "noise event"
static

Input name of the noise eventsensor

const std::string SleepTime::VERSION = "1.6.5"
static

Module version


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