AIM
 All Classes Functions Variables Typedefs Enumerations
AIM Class Reference

#include <AIM.h>

Inheritance diagram for AIM:
CarryDevice CoachingEngine::Coach CoachingEngine::Task ExampleModule FallDetector GeoFencing LocationTrace Loudness MotionFeatures NaiveBayesClassifierModule PhysicalActivity PositionDistanceMeasure PositionFilter SensorEvent SitStand SleepTime SleepTimeEstimate StepCounter TimeActive TimeCarried TopLocations

Public Types

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

 AIM (std::string name="")
 
 AIM (const AIM &other)
 
AIMoperator= (const AIM &rhs)
 
virtual void doTick ()
 
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 = AIM_VERSION
 

Protected Member Functions

void setDataSubscribers (const std::map< std::string, AIM * > &subscribers)
 
void setInputDataQueue (const InputDataQueue &inputDataQueue)
 
void setOutputDataQueue (const AIMDataQueue &outputDataQueue)
 

Protected Attributes

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

AIM.h

Created on: Feb 4, 2013 Author: Ted Schmidt

This header file defines the structure of an AI module.
From this base class more specific types of AI modules can be created like: pre-processor, feature-selector, classifier.

** Input **\n
The input data of an AI-Module is a key-value pair object.\n
The input values are stored in a queue for each key via addData(AIMData data).\n

** Process **\n
An AI-Module does its processing when the function doTick() is called\n
It can add its output to the outputDataQueue which is a queue of AIMData\n

** Output **\n
The output of an AI-Module is sent to the subscribers of an AI-Module in the method sendData().\n
Subscribers can be added by adding an AIM object pointer via addDataSubscriber(string& key, AIM* subscriber).\n
The output data is of type AIMData and can have different underlying data types. A JSON representation of this data can\n
be requested with toJSONValue method.\n

** Properties **\n
The properties of an AI-module can be set, get and exported in JSON format with the methods: setProperty, getProperty\n
and exportProperties\n

Member Typedef Documentation

typedef std::pair<std::string, AIMValue> AIM::AIMData

Preliminary data types

typedef std::queue<AIMData> AIM::AIMDataQueue

The data queue for AIM result data

typedef std::queue<AIMValue> AIM::AIMValueQueue

The value queue for AIM input data

typedef std::map<std::string, AIMValueQueue> AIM::InputDataQueue

An input data queue for every input source

Constructor & Destructor Documentation

AIM::AIM ( std::string  name = "")

Construct the aim module.

Parameters
nameOptional name of the module. The output of the module uses this name. If not specified the default name of the module will be used.

Member Function Documentation

void AIM::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 in SleepTime, TopLocations, CarryDevice, CoachingEngine::Coach, TimeCarried, TimeActive, and PhysicalActivity.

virtual void AIM::addDataSubscriber ( const std::string &  key,
AIM subscriber 
)
inlinevirtual

Add data receiver callback function

This method adds a callback function pointer to the list of data receivers. When the AI module has new data the data receiver function is called with AIMData as parameter

Parameters
AIMDataReceiverreceiver The function pointer data receiver
virtual void AIM::doTick ( )
inlinevirtual

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 in SleepTime, TopLocations, SleepTimeEstimate, SensorEvent, CarryDevice, CoachingEngine::Coach, CoachingEngine::Task, TimeCarried, PositionDistanceMeasure, GeoFencing, TimeActive, FallDetector, PhysicalActivity, LocationTrace, PositionFilter, Loudness, SitStand, ExampleModule, MotionFeatures, StepCounter, and NaiveBayesClassifierModule.

std::string AIM::exportProperties ( )
virtual

Export properties

This method exports the properties of the AI-module in JSON format.

Returns
string The export string in JSON format

Reimplemented in PhysicalActivity.

virtual AIM* AIM::getDataSubscriber ( std::string  subscriber)
inlinevirtual

Get a data subscriber

This method return a data subscriber

Parameters
stringThe data subscriber key
Returns
AIM* The data subscriber
std::vector< std::pair< std::string, AIMValue > > AIM::getInputData ( bool  clear_input = false)
virtual

Get the input data

This method returns the input data queue

Parameters
boolclear_input Clears the input buffer if set to true
Returns
vector<AIMData> The data vector with input data
virtual std::string AIM::getName ( ) const
inlinevirtual

Return the module name.

std::vector< std::pair< std::string, AIMValue > > AIM::getOutputData ( bool  clear_output = false)
virtual

Get the output data

This method returns the output data queue

Parameters
boolclear_ouput Clears the output buffer if set to true
Returns
vector<AIMData> The data vector with output data
virtual const std::map<std::string, AIMValue>& AIM::getProperties ( )
inlinevirtual

TODO: create function import properties

  • read the properties from a JSON string (easier to call setProperty from Java/IOS)

Reimplemented in SleepTime, CoachingEngine::Coach, TopLocations, CarryDevice, CoachingEngine::Task, CoachingEngine::JetLagCoach, CoachingEngine::ShiftWorkCoach, and CoachingEngine::BiorhythmCoach.

virtual AIMValue AIM::getProperty ( std::string  key) const
inlinevirtual

Get Property

This method returns the value of a property

Parameters
stringkey The key of the property
Returns
AIMValue The value of the property
std::vector< AIMValue > AIM::getRequirements ( ) const
virtual

Get the requirements of the module.

Returns
vector<AIMValue> The list of requirements.

Reimplemented in TopLocations, CoachingEngine::Coach, TimeCarried, CoachingEngine::Task, and TimeActive.

virtual void AIM::removeDataSubscriber ( const std::string &  key)
inlinevirtual

Remove data receiver callback function

This method removes a callback function pointer from the list of data receivers.

Parameters
AIMDataReceiverreceiver The function pointer data receiver
bool AIM::requirementsAreUpdated ( bool  reset = true) const
virtual

Return wether the requirements have been updated since the last call to this function.

Parameters
resetIf false, don't reset wether the requirements have been updated.
Returns
true if the requirements are updated since the last call to this function, otherwise false.

Reimplemented in TopLocations, CoachingEngine::Coach, TimeCarried, CoachingEngine::Task, and TimeActive.

void AIM::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

Reimplemented in SleepTime, CoachingEngine::Coach, TopLocations, CarryDevice, CoachingEngine::Task, LocationTrace, GeoFencing, CoachingEngine::CalibrationCoach, CoachingEngine::JetLagCoach, CoachingEngine::ShiftWorkCoach, CoachingEngine::BiorhythmCoach, PhysicalActivity, and NaiveBayesClassifierModule.

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

Set property

This method sets the value of a property. An AIMValue response value is returned and it can have the type EMPTY if no response data is present.

Parameters
stringkey The key of the property
AIMValuevalue The value of the property
Returns
AIMValue An optional response value.

Reimplemented in SleepTime, TopLocations, CarryDevice, SensorEvent, LocationTrace, CoachingEngine::JetLagCoach, GeoFencing, PhysicalActivity, and NaiveBayesClassifierModule.


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