AIM
 All Classes Functions Variables Typedefs Enumerations
SleepTimeEstimate Class Reference

#include <SleepTimeEstimate.h>

Inheritance diagram for SleepTimeEstimate:
AIM

Public Member Functions

 SleepTimeEstimate (std::string name=MODULE_NAME)
 
void doTick ()
 
- 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 setProperty (const std::string &key, AIMValue value)
 
virtual AIMValue getProperty (std::string key) const
 
virtual void sendData ()
 
virtual void addData (const AIMData &data)
 
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 const std::map
< std::string, AIMValue > & 
getProperties ()
 
virtual std::string getName () const
 
virtual std::vector< AIMValuegetRequirements () const
 
virtual bool requirementsAreUpdated (bool reset=true) const
 
virtual void setProperties (const std::map< std::string, AIMValue > &properties)
 

Static Public Attributes

static const std::string VERSION = "1.0"
 
static const std::string MODULE_NAME = "sleep_time_estimate"
 
static const std::string FIELD_SLEEP_TIME = "sleepTime"
 
static const std::string FIELD_START_DATE = "start_date"
 
static const std::string FIELD_END_DATE = "end_date"
 
static const std::string FIELD_HISTORY_BASED = "history_based"
 
static const std::string PROP_SLEEP_TIME_AVERAGE = "sleep_time_average"
 
static const std::string PROP_SLEEP_TIME_COUNT = "sleep_time_count"
 
static const std::string PROP_SLEEP_TIME_HISTORY = "sleep_time_history"
 
static const std::string PROP_POPULATION_SLEEP_TIME = "population_sleep_time"
 
static const std::string PROP_POPULATION_START_TIME = "population_start_time"
 
static const std::string PROP_POPULATION_END_TIME = "population_end_time"
 
static const std::string PROP_SLEEP_END_TIME = "sleep_end_time"
 
static const std::string PROP_MAX_SLEEP_DURATION = "max_sleep_duration"
 
static const std::string PROP_MIN_SLEEP_DURATION = "min_sleep_duration"
 
static const std::string PROP_GOAL_SLEEP_TIME_COUNT = "goal_sleep_time_count"
 
static const std::string PROP_ESTIMATE_RETURN_TIME = "estimate_return_time"
 
static const std::string PROP_ESTIMATE_RETURN_MIN_CNT = "estimate_return_min_cnt"
 
static const std::string PROP_ESTIMATE_NOISE = "estimate_noise"
 
static const std::string PROP_SLEEP_TIME_WEIGHTED_AVERAGE = "sleep_time_weighted_average"
 
- 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

SleepTimeEstimate.h

Created on: Dec 17, 2014 Author: Ted Schmidt

This module gives a sleep estimate based on the observed values of the sleep_time module.
When the sleep_time module continuously returns 0 minutes of sleep during sleep period, this module will return an estimate based on the population and the sleep history of the user.
An estimate will only be calculated when:

  • the time is past PROP_ESTIMATE_RETURN_TIME and before PROP_SLEEP_END_TIME
  • it has at least PROP_ESTIMATE_RETURN_MIN_CNT sleep_time measurements
  • the latest sleep_time measurement was 0
  • the first sleep_time measurement was before PROP_SLEEP_END_TIME
    This module returns a value with the format:
    * {"sleepTime":8.5, "start_date":1377242482, "end_date": 1377242482, "history_based"=1}
    Where the boolean field "history_based", indicates whether the current values are based on the population and history, or coming directly from the sleep_time module. The start_date will always be at or after the date of the first sleep_time measurement
    This module expects the input of the sleep_time sensor:
    {"sleepTime":8.5, "start_date":1377242482, "end_date": 1377242482}

Constructor & Destructor Documentation

SleepTimeEstimate::SleepTimeEstimate ( std::string  name = MODULE_NAME)

SleepTimeEstimate constructor

The SleepTimeEstimate module will be initialized with the following properties, these can be altered via setProperty:
PROP_POPULATION_SLEEP_TIME = 8 hours
PROP_POPULATION_START_TIME = 23.5 o'clock
PROP_POPULATION_END_TIME = 7 o'clock
PROP_MIN_SLEEP_DURATION = 4 hours
PROP_GOAL_SLEEP_TIME_COUNT = 14 nights
PROP_ESTIMATE_RETURN_TIME = 6 o'clock
PROP_ESTIMATE_RETURN_MIN_CNT = 48 samples (4 hours every 5 minutes a sample)
PROP_SLEEP_END_TIME = 12 o'clock
PROP_MAX_SLEEP_DURATION = 14 hours
PROP_ESTIMATE_NOISE = 0.5 hours

Member Function Documentation

void SleepTimeEstimate::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.

Member Data Documentation

const std::string SleepTimeEstimate::FIELD_END_DATE = "end_date"
static

sleep_time module field name end_date

const std::string SleepTimeEstimate::FIELD_HISTORY_BASED = "history_based"
static

sleep_time_estimate module field names

const std::string SleepTimeEstimate::FIELD_SLEEP_TIME = "sleepTime"
static

sleep_time module field name sleepTime

const std::string SleepTimeEstimate::FIELD_START_DATE = "start_date"
static

sleep_time module field name start_date

const std::string SleepTimeEstimate::MODULE_NAME = "sleep_time_estimate"
static

Name of the this module

const std::string SleepTimeEstimate::PROP_ESTIMATE_NOISE = "estimate_noise"
static

The property name for the maximum amount of noise in hours added/subtracted from the sleepTime estimate

const std::string SleepTimeEstimate::PROP_ESTIMATE_RETURN_MIN_CNT = "estimate_return_min_cnt"
static

The property name for the min amount of data points after which it starts returning an estimate

const std::string SleepTimeEstimate::PROP_ESTIMATE_RETURN_TIME = "estimate_return_time"
static

The property name for the hour at which it starts returning an estimate

const std::string SleepTimeEstimate::PROP_GOAL_SLEEP_TIME_COUNT = "goal_sleep_time_count"
static

The property name for the goal value for the amount of values needed to have the sleep time estimation totally based on the users average

const std::string SleepTimeEstimate::PROP_MAX_SLEEP_DURATION = "max_sleep_duration"
static

The property name for maximum sleep duration, start time - end time of the sleep period of the sleep_time module

const std::string SleepTimeEstimate::PROP_MIN_SLEEP_DURATION = "min_sleep_duration"
static

The property name for the minimum sleep time duration needed before the value is used for the average sleep calculation

const std::string SleepTimeEstimate::PROP_POPULATION_END_TIME = "population_end_time"
static

The property name for the sleep population value for the end time in hours

const std::string SleepTimeEstimate::PROP_POPULATION_SLEEP_TIME = "population_sleep_time"
static

The property name for the sleep population value for the amount of sleep in hours

const std::string SleepTimeEstimate::PROP_POPULATION_START_TIME = "population_start_time"
static

The property name for the sleep population value for the start time in hours

const std::string SleepTimeEstimate::PROP_SLEEP_END_TIME = "sleep_end_time"
static

The property name for the end time for calculating the sleep period as set in the sleep_time module

const std::string SleepTimeEstimate::PROP_SLEEP_TIME_AVERAGE = "sleep_time_average"
static

user specific sleep_time structured average value

const std::string SleepTimeEstimate::PROP_SLEEP_TIME_COUNT = "sleep_time_count"
static

user specific average sample count

const std::string SleepTimeEstimate::PROP_SLEEP_TIME_HISTORY = "sleep_time_history"
static

The property name for the sleep time value cache for the last night

const std::string SleepTimeEstimate::PROP_SLEEP_TIME_WEIGHTED_AVERAGE = "sleep_time_weighted_average"
static

The property name for the weighted sleep time average based on the population and user average with added noise

const std::string SleepTimeEstimate::VERSION = "1.0"
static

Module version


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