AIM
|
#include <AIM.h>
Public Types | |
typedef std::pair< std::string, AIMValue > | AIMData |
typedef std::queue< AIMData > | AIMDataQueue |
typedef std::queue< AIMValue > | AIMValueQueue |
typedef std::map< std::string, AIMValueQueue > | InputDataQueue |
Public Member Functions | |
AIM (std::string name="") | |
AIM (const AIM &other) | |
AIM & | operator= (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 AIM * | getDataSubscriber (std::string subscriber) |
virtual const std::map < std::string, AIMValue > & | getProperties () |
virtual std::string | getName () const |
virtual std::vector< AIMValue > | getRequirements () 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< AIMValue > | requirements |
bool | requirementsUpdated |
std::map< std::string, AIM * > | dataSubscribers |
std::map< std::string, AIMValue > | properties |
InputDataQueue | inputDataQueue |
AIMDataQueue | outputDataQueue |
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
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
AIM::AIM | ( | std::string | name = "" | ) |
Construct the aim module.
name | Optional name of the module. The output of the module uses this name. If not specified the default name of the module will be used. |
|
virtual |
Add data
This method adds data to the input queue of the AI-module The AIMData object
AIMData | data The input data |
Reimplemented in SleepTime, TopLocations, CarryDevice, CoachingEngine::Coach, TimeCarried, TimeActive, and PhysicalActivity.
|
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
AIMDataReceiver | receiver The function pointer data receiver |
|
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.
|
virtual |
Export properties
This method exports the properties of the AI-module in JSON format.
Reimplemented in PhysicalActivity.
|
inlinevirtual |
Get a data subscriber
This method return a data subscriber
string | The data subscriber key |
|
virtual |
Get the input data
This method returns the input data queue
bool | clear_input Clears the input buffer if set to true |
|
inlinevirtual |
Return the module name.
|
virtual |
Get the output data
This method returns the output data queue
bool | clear_ouput Clears the output buffer if set to true |
|
inlinevirtual |
TODO: create function import properties
Reimplemented in SleepTime, CoachingEngine::Coach, TopLocations, CarryDevice, CoachingEngine::Task, CoachingEngine::JetLagCoach, CoachingEngine::ShiftWorkCoach, and CoachingEngine::BiorhythmCoach.
|
inlinevirtual |
Get Property
This method returns the value of a property
string | key The key of the property |
|
virtual |
Get the requirements of the module.
Reimplemented in TopLocations, CoachingEngine::Coach, TimeCarried, CoachingEngine::Task, and TimeActive.
|
inlinevirtual |
Remove data receiver callback function
This method removes a callback function pointer from the list of data receivers.
AIMDataReceiver | receiver The function pointer data receiver |
|
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 in TopLocations, CoachingEngine::Coach, TimeCarried, CoachingEngine::Task, and TimeActive.
|
virtual |
Set the module properties
Set the defined properties. Old property values will remain if no new values are specified for a property.
map | properties 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.
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.
string | key The key of the property |
AIMValue | value The value of the property |
Reimplemented in SleepTime, TopLocations, CarryDevice, SensorEvent, LocationTrace, CoachingEngine::JetLagCoach, GeoFencing, PhysicalActivity, and NaiveBayesClassifierModule.