AIM
|
#include <TimeCarried.h>
Public Member Functions | |
TimeCarried (std::string name="time_carried") | |
void | doTick () |
virtual void | addData (const AIMData &data) |
std::vector< AIMValue > | getRequirements () const |
bool | requirementsAreUpdated (bool reset=true) const |
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 | 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 AIM * | getDataSubscriber (std::string subscriber) |
virtual const std::map < std::string, AIMValue > & | getProperties () |
virtual std::string | getName () const |
virtual void | setProperties (const std::map< std::string, AIMValue > &properties) |
Static Public Attributes | |
static const std::string | PROPERTY_TOTAL = "total" |
static const std::string | PROPERTY_RESET_PERIOD = "reset_period" |
static const std::string | PROPERTY_RESET_DATE = "reset_date" |
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 |
The TimeCarried module registers how much time a user has been carrying the device. It accumulates in real-time the number of seconds the user has been carrying the device since the last reset. The time can be manually reset, or a periodic reset can be used, e.g. to reset every day at 00:00.
Output:
The number of seconds the user has been carrying the device since the last reset. Between resets this value is monotonically non-decreasing. Each time an input is received, the module produces an output. The output is a DataPoint with the value being a double.
Input:
As AIMData input it needs the key:values
{"accelerometer":{"value":{"x-axis":9.81, "y-axis":0.1, "z-axis":9.81}, "date":12345678.11}} float acceleration value
{"accelerometer_burst":{"value":{"header": "x,y,z","hz": 50,"values": [[9.81,0.1,9.81],[9.80,0,9.80]]}, "date":12345678.11}} float acceleration values
{"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 in 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
Properties:
The properties PROPERTY_RESET_DATE and PROPERTY_RESET_PERIOD can be used to set a periodic reset. The PROPERTY_RESET_DATE is the unix timestamp at which resets are aligned, and the PROPERTY_RESET_PERIOD is the period in seconds at which the reset is performed.
The property PROPERTY_TOTAL is the current value of the total time that the user was carrying the device. This property can be adjusted, e.g. to manually reset.
|
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 |
Get the requirements of the module.
Reimplemented from AIM.
|
virtual |
Return wether the requirements have been updated since the last call to this function.
reset | If false, don't reset wether the requirements have been updated. |
Reimplemented from AIM.
|
static |
The periodic reset interval.
|
static |
The date (in unix time) to align the periodic reset with.
|
static |
The current total time carried.