AIM
 All Classes Functions Variables Typedefs Enumerations
CoachingEngine::ShiftWorkCoach Class Reference

#include <ShiftWorkCoach.h>

Inheritance diagram for CoachingEngine::ShiftWorkCoach:
CoachingEngine::Coach AIM

Public Types

enum  SHIFT {
  FREE, MORNING, DAY, EVENING,
  NIGHT
}
 
- Public Types inherited from CoachingEngine::Coach
enum  Type {
  PHYSICAL_ACTIVITY, MENTAL_RESILIENCE, SLEEP_DURATION, JETLAG,
  SHIFTWORK, CALIBRATION, NONE, BIORHYTHM
}
 
enum  InitializationType { MANUAL_GOAL, POPULATION_GOAL, PERSONAL_GOAL }
 
enum  Status { UNINITIALIZED, GOAL_INITIALIZED, READY, PAUSED }
 
- 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
 

Public Member Functions

 ShiftWorkCoach (std::string name="shift_work_coach")
 
virtual void setGoal (InitializationType type, const AIMValue &init, bool dynamic=true)
 
virtual const std::map
< std::string, AIMValue > & 
getProperties ()
 
virtual void setProperties (const std::map< std::string, AIMValue > &properties)
 
virtual std::vector
< TaskDescription
getFutureTasks (double start, double end)
 
- Public Member Functions inherited from CoachingEngine::Coach
 Coach (const Coach &other)
 
Coachoperator= (const Coach &rhs)
 
void addData (const AIMData &data)
 
void doTick ()
 
std::vector< AIMValuegetRequirements () const
 
bool requirementsAreUpdated (bool reset) const
 
virtual AIMValue getGoal () const
 
virtual std::vector
< TaskDescription
getCurrentTasks () const
 
virtual Status getStatus () const
 
virtual Type getType ()
 
virtual std::map< std::string,
AIMValue
getMemberDataAsProperties () const
 
virtual void pause (double time)
 
virtual void resume (double time)
 
virtual TaskDescription setTaskValueManually (std::string taskType, double taskStartDate, const AIMValue &data)
 
- 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 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
 

Static Public Attributes

static const std::string PROP_BED_TIME = "bed_time"
 
static const std::string PROP_NORMAL_BED_TIME = "normal_bed_time"
 
static const std::string PROP_WAKEUP_TIME = "wakeup_time"
 
static const std::string PROP_NORMAL_WAKEUP_TIME = "normal_wakeup_time"
 
static const std::string PROP_PLANNED_TASKS = "planned_tasks"
 
static const std::string PROP_PROGRAM_FINISHED_DATE = "program_finished_date"
 
static const std::string PROP_SCHEDULE = "schedule"
 
static const std::string PROP_WORK_START_DATE = "work_start_date"
 
static const std::string PROP_WORK_END_DATE = "work_end_date"
 
static const std::string PROP_CORE_BODY_LOW = "core_body_low"
 
- Static Public Attributes inherited from CoachingEngine::Coach
static const std::string PROP_COMPLETED_TASKS = "completed_tasks"
 
static const std::string PROP_ACTIVE_TASKS = "active_tasks"
 
static const std::string PROP_STATUS = "status"
 
static const std::string PROP_GOAL = "goal"
 
static const std::string PROP_BASELINE = "baseline"
 
static const std::string PROP_DYNAMIC_COACH = "dynamic_coach"
 
static const std::string PROP_GOAL_TYPE = "goal_type"
 
static const std::string PROP_START_DATE = "start_date"
 
static const std::string PROP_END_DATE = "end_date"
 
static const std::string PROP_TOTAL_DAYS = "total_days"
 
static const std::string PROP_GAIN = "gain"
 
static const std::string PROP_CURRENT_TIME = "clock"
 
static const std::string PROP_START_PAUSE = "start_pause"
 
static const std::string OUTPUT_FIELD_COACH_TYPE = "coach_type"
 
static const std::string PROP_PAUSED_SECONDS = "paused_seconds"
 
- Static Public Attributes inherited from AIM
static const std::string VERSION = AIM_VERSION
 

Protected Member Functions

virtual void processDateValue (const std::string &sensor, const AIMValue &dateValue)
 
virtual void startPlannedTasks ()
 
virtual std::vector
< ShiftWorkTask * > 
getMorningShiftTasks (double start_date, double end_date, std::map< std::string, AIMValue > &stateProperties)
 
virtual std::vector
< ShiftWorkTask * > 
getDayShiftTasks (double start_date, double end_date, std::map< std::string, AIMValue > &stateProperties)
 
virtual std::vector
< ShiftWorkTask * > 
getEveningShiftTasks (double start_date, double end_date, std::map< std::string, AIMValue > &stateProperties)
 
virtual std::vector
< ShiftWorkTask * > 
getNightShiftTasks (double start_date, double end_date, std::map< std::string, AIMValue > &stateProperties)
 
virtual std::vector
< ShiftWorkTask * > 
getFreeShiftTasks (double start_date, double end_date, std::map< std::string, AIMValue > &stateProperties)
 
virtual std::vector
< ShiftWorkTask * > 
getShiftTasks (double start_date, double end_date, std::map< std::string, AIMValue > &stateProperties)
 
virtual std::vector
< ShiftWorkTask * > 
getBiorhythmTasks (double coreBodyLowDate)
 
virtual void createNewPlan ()
 
virtual double getNextToBedDate (double time, double bed_time)
 
virtual double getNextOutBedDate (double time, double out_bed_time, double to_bed_date=0)
 
virtual double addHoursToBedTime (double bed_time, double hours)
 
virtual double getStartOfDay (double time)
 
virtual void setBedTimes (double bedTime, double wakeUpTime, std::map< std::string, AIMValue > &stateProperties)
 
virtual ShiftWorkTaskcreatShiftWorkTask (Task::Type taskType, double taskStartTime, double taskEndTime, double triggerTime=0.0/0.0, double targetStartTime=0.0/0.0, double targetEndTime=0.0/0.0)
 
SHIFT getShift (double start_date, double end_date)
 
void getBedTimes (double start_date, double end_date, double &bedTime, double &wakeUpTime)
 
- Protected Member Functions inherited from CoachingEngine::Coach
 Coach (Type coachType, std::string name="coach")
 
virtual void addActiveTask (Task &task)
 
virtual void removeActiveTask (Task *task)
 
virtual double calculateTargetValue (int week, double goalValue, double lastValue, double speed=(2.0/3.0))
 
virtual int getWeek (double date)
 
virtual double calculateGoal (std::string taskType, double currentValue, int weeksLeft)
 
virtual void decreaseGain (std::string taskType)
 
virtual void increaseGain (std::string taskType)
 
virtual void handleCompletedTask (Task *task)
 
virtual bool checkAndHandleNewWeek ()
 
virtual double calculateAverage (std::string taskType, double startDate, double endDate, int min_values=1, int nr_values=-1)
 
virtual void createNewTask (std::string taskType)
 
virtual std::pair< double, double > calculateTaskPeriod (double currentTime, std::string taskType="")
 
virtual void removeRoutesForTask (Task *task)
 
virtual TaskgetTask (TaskDescription::Type type)
 
- 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)
 

Additional Inherited Members

- Protected Types inherited from CoachingEngine::Coach
typedef std::map< std::string,
std::unordered_set< Task * > > 
SensorRoutes
 
- Protected Attributes inherited from CoachingEngine::Coach
const Type type
 
Status status
 
std::vector< Task * > activeTasks
 
std::vector< Task * > completedTasks
 
SensorRoutes routes
 
AIMValue goal
 
AIMValue baseline
 
Clock clock
 
bool dynamicCoach
 
InitializationType goalType
 
double end_date
 
double start_date
 
int total_days
 
AIMValue gain
 
- 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

Implementation of the shift work coach. This coach coaches a user based on it's working schedule

Member Function Documentation

void CoachingEngine::ShiftWorkCoach::getBedTimes ( double  start_date,
double  end_date,
double &  bedTime,
double &  wakeUpTime 
)
protected

Get the bed times based on the work start_date and end_date It does a lookup for the which shift should be selected, and calculates the corresponding bed times

std::vector< TaskDescription > CoachingEngine::ShiftWorkCoach::getFutureTasks ( double  start,
double  end 
)
virtual

Return planned tasks for the specified time range.

Parameters
startStart date as Unix timestmap for the range to get planned tasks for,
endEnd date as Unix timestamp for the range to get planned tasks for.
Returns
A list of the tasks planned for the specified period.

Reimplemented from CoachingEngine::Coach.

double CoachingEngine::ShiftWorkCoach::getNextToBedDate ( double  time,
double  bed_time 
)
protectedvirtual

Returns the epoch time in seconds for the next to bed or out bed time

const std::map< std::string, AIMValue > & CoachingEngine::ShiftWorkCoach::getProperties ( )
virtual

get the properties of the coach

Reimplemented from CoachingEngine::Coach.

ShiftWorkCoach::SHIFT CoachingEngine::ShiftWorkCoach::getShift ( double  start_date,
double  end_date 
)
protected

selects the shift type based on the start and end work times

void CoachingEngine::ShiftWorkCoach::processDateValue ( const std::string &  sensor,
const AIMValue dateValue 
)
protectedvirtual

Called with the sensor and a date/value tuple.

Reimplemented from CoachingEngine::Coach.

void CoachingEngine::ShiftWorkCoach::setBedTimes ( double  bedTime,
double  wakeUpTime,
std::map< std::string, AIMValue > &  stateProperties 
)
protectedvirtual

Set the latest to bed and wake up hours, based on the latest bedTime and wakeUpTime epoch times

void CoachingEngine::ShiftWorkCoach::setGoal ( InitializationType  type,
const AIMValue init,
bool  dynamic = true 
)
virtual

Set the goal for the coach.

A coach can be initialized with a specific type. With a corresponding init value.

MANUAL_GOAL: init = {{"goal",{"Task.TYPE", "value"}}}

PERSONAL_GOAL: init = {{"goal",{"Task.TYPE", "value"}}, {"baseline",{"Task.TYPE", "value"}}, {"days",84}}

POPULATION_GOAL: init = {{"goal",{"Task.TYPE", "value"}}, {"baseline",{"Task.TYPE", "value"}}, {"days",84}}

Parameters
typeThe InitializationType of the coach
initThe AIMValue map with initialization data
dynamicUpdate the goal based on the progress

Reimplemented from CoachingEngine::Coach.

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

set the properties of the coach

Reimplemented from CoachingEngine::Coach.

Member Data Documentation

const string CoachingEngine::ShiftWorkCoach::PROP_BED_TIME = "bed_time"
static

Current bed time in hours

const string CoachingEngine::ShiftWorkCoach::PROP_CORE_BODY_LOW = "core_body_low"
static

The time of the low core body

const string CoachingEngine::ShiftWorkCoach::PROP_NORMAL_BED_TIME = "normal_bed_time"
static

Normal bed time in hours

const string CoachingEngine::ShiftWorkCoach::PROP_NORMAL_WAKEUP_TIME = "normal_wakeup_time"
static

Normal wake up time in hours

const string CoachingEngine::ShiftWorkCoach::PROP_PLANNED_TASKS = "planned_tasks"
static

Hour difference in hours

const string CoachingEngine::ShiftWorkCoach::PROP_PROGRAM_FINISHED_DATE = "program_finished_date"
static

End date of the program

const string CoachingEngine::ShiftWorkCoach::PROP_SCHEDULE = "schedule"
static

The work schedule This consists of a vector with AIMValues with a start_date and end_date in epoch secods

const string CoachingEngine::ShiftWorkCoach::PROP_WAKEUP_TIME = "wakeup_time"
static

Current wake up time in hours

const string CoachingEngine::ShiftWorkCoach::PROP_WORK_END_DATE = "work_end_date"
static

Key for the end date of the work schedule map value

const string CoachingEngine::ShiftWorkCoach::PROP_WORK_START_DATE = "work_start_date"
static

Key for the start date of the work schedule map value


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