GAMS  1.2.2
gams::controllers::Multicontroller Class Reference

A controller that has the capability of starting many different threads. More...

#include <Multicontroller.h>

Public Member Functions

 Multicontroller (madara::knowledge::KnowledgeBase &knowledge)
 Constructor. More...
 
virtual ~Multicontroller ()
 Destructor. More...
 
void add_algorithm_factory (const std::vector< std::string > &aliases, algorithms::AlgorithmFactory *factory)
 Adds an aliased algorithm factory. More...
 
void add_platform_factory (const std::vector< std::string > &aliases, platforms::PlatformFactory *factory)
 Adds an aliased platform factory. More...
 
virtual int analyze (void)
 Defines the analyze function (the A of MAPE). More...
 
void clear_accents (void)
 Clears all accent algorithms. More...
 
virtual int execute (void)
 Defines the execute function (the E of MAPE). More...
 
algorithms::BaseAlgorithmget_algorithm (void)
 Gets the current algorithm. More...
 
platforms::BasePlatformget_platform (void)
 Gets the current platform. More...
 
void init_accent (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap())
 Adds an accent algorithm. More...
 
void init_algorithm (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap())
 Initializes an algorithm. More...
 
void init_algorithm (algorithms::BaseAlgorithm *algorithm)
 Initializes the controller with a user-provided algorithm. More...
 
void init_platform (const std::string &platform, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap())
 Initializes the platform. More...
 
void init_platform (platforms::BasePlatform *platform)
 Initializes the controller with a user-provided platform. More...
 
void init_vars (const madara::knowledge::KnowledgeRecord::Integer &id=0, const madara::knowledge::KnowledgeRecord::Integer &processes=-1)
 Initializes global variable containers. More...
 
void init_vars (platforms::BasePlatform &platform)
 Initializes containers and knowledge base in a platform This is usually the first thing a developer should do with a user-defined platform. More...
 
void init_vars (algorithms::BaseAlgorithm &algorithm)
 Initializes containers and knowledge base in an algorithm. More...
 
virtual int monitor (void)
 Defines the monitor function (the M of MAPE). More...
 
virtual int plan (void)
 Defines the plan function (the P of MAPE). More...
 
int run (double loop_period=0.0, double max_runtime=-1, double send_period=-1.0)
 Runs iterations of the MAPE loop with specified periods. More...
 
int run_hz (double loop_hz=0.0, double max_runtime=-1, double send_hz=-1.0)
 Runs iterations of the MAPE loop with specified hertz. More...
 
int run_once (void)
 Runs a single iteration of the MAPE loop Always sends updates after the iteration. More...
 
virtual int system_analyze (void)
 Analyzes the system to determine if platform or algorithm changes are necessary. More...
 

Protected Attributes

algorithms::Algorithms accents_
 Accents on the primary algorithm. More...
 
variables::Agents agents_
 Containers for agent-related variables. More...
 
algorithms::BaseAlgorithmalgorithm_
 Algorithm to perform. More...
 
variables::Algorithms algorithms_
 Containers for algorithm information. More...
 
madara::knowledge::KnowledgeBase & knowledge_
 Knowledge base. More...
 
platforms::BasePlatformplatform_
 Platform on which the controller is running. More...
 
variables::Platforms platforms_
 Containers for platform information. More...
 
variables::Self self_
 Containers for self-referencing variables. More...
 
variables::Sensors sensors_
 Containers for sensor information. More...
 
variables::Swarm swarm_
 Containers for swarm-related variables. More...
 

Private Member Functions

int run_once_ (void)
 Code shared between run and run_once. More...
 

Detailed Description

A controller that has the capability of starting many different threads.

Definition at line 83 of file Multicontroller.h.

Constructor & Destructor Documentation

gams::controllers::Multicontroller::Multicontroller ( madara::knowledge::KnowledgeBase &  knowledge)

Constructor.

Parameters
knowledgeThe knowledge base to reference and mutate
virtual gams::controllers::Multicontroller::~Multicontroller ( )
virtual

Destructor.

Member Function Documentation

void gams::controllers::Multicontroller::add_algorithm_factory ( const std::vector< std::string > &  aliases,
algorithms::AlgorithmFactory factory 
)

Adds an aliased algorithm factory.

This factory will be initialized with all appropriate variables in the AlgorithmFactory class by the Multicontroller.

Parameters
aliasesthe named aliases for the factory. All aliases will be converted to lower case
factorythe factory for creating an algorithm
void gams::controllers::Multicontroller::add_platform_factory ( const std::vector< std::string > &  aliases,
platforms::PlatformFactory factory 
)

Adds an aliased platform factory.

This factory will be initialized with all appropriate variables in the PlatformFactory class by the Multicontroller.

Parameters
aliasesthe named aliases for the factory. All aliases will be converted to lower case
factorythe factory for creating a platform
virtual int gams::controllers::Multicontroller::analyze ( void  )
virtual

Defines the analyze function (the A of MAPE).

This function should return a 0 unless the MAPE loop should stop.

void gams::controllers::Multicontroller::clear_accents ( void  )

Clears all accent algorithms.

virtual int gams::controllers::Multicontroller::execute ( void  )
virtual

Defines the execute function (the E of MAPE).

This function should return a 0 unless the MAPE loop should stop.

algorithms::BaseAlgorithm* gams::controllers::Multicontroller::get_algorithm ( void  )

Gets the current algorithm.

Returns
the algorithm
platforms::BasePlatform* gams::controllers::Multicontroller::get_platform ( void  )

Gets the current platform.

Returns
the platform
void gams::controllers::Multicontroller::init_accent ( const std::string &  algorithm,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Adds an accent algorithm.

Parameters
algorithmthe name of the accent algorithm to add
argsvector of knowledge record arguments
void gams::controllers::Multicontroller::init_algorithm ( const std::string &  algorithm,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Initializes an algorithm.

Parameters
algorithmthe name of the algorithm to run
argsvector of knowledge record arguments
void gams::controllers::Multicontroller::init_algorithm ( algorithms::BaseAlgorithm algorithm)

Initializes the controller with a user-provided algorithm.

This algorithm's memory will be maintained by the controller. DO NOT DELETE THIS POINTER.

Parameters
algorithmthe algorithm to use
void gams::controllers::Multicontroller::init_platform ( const std::string &  platform,
const madara::knowledge::KnowledgeMap &  args = madara::knowledge::KnowledgeMap() 
)

Initializes the platform.

Parameters
platformthe name of the platform the controller is using
argsvector of knowledge record arguments
void gams::controllers::Multicontroller::init_platform ( platforms::BasePlatform platform)

Initializes the controller with a user-provided platform.

This platform's memory will be maintained by the controller. DO NOT DELETE THIS POINTER.

Parameters
platformthe platform to use
void gams::controllers::Multicontroller::init_vars ( const madara::knowledge::KnowledgeRecord::Integer &  id = 0,
const madara::knowledge::KnowledgeRecord::Integer &  processes = -1 
)

Initializes global variable containers.

Parameters
idnode identifier
processesprocesses
void gams::controllers::Multicontroller::init_vars ( platforms::BasePlatform platform)

Initializes containers and knowledge base in a platform This is usually the first thing a developer should do with a user-defined platform.

Parameters
platformthe platform to initialize
void gams::controllers::Multicontroller::init_vars ( algorithms::BaseAlgorithm algorithm)

Initializes containers and knowledge base in an algorithm.

This is usually the first thing a developer should do with a user-defined algorithm.

Parameters
algorithmthe algorithm to initialize
virtual int gams::controllers::Multicontroller::monitor ( void  )
virtual

Defines the monitor function (the M of MAPE).

This function should return a 0 unless the MAPE loop should stop.

virtual int gams::controllers::Multicontroller::plan ( void  )
virtual

Defines the plan function (the P of MAPE).

This function should return a 0 unless the MAPE loop should stop.

int gams::controllers::Multicontroller::run ( double  loop_period = 0.0,
double  max_runtime = -1,
double  send_period = -1.0 
)

Runs iterations of the MAPE loop with specified periods.

Parameters
loop_periodtime (in seconds) between executions of the loop. 0 period is meant to run loop iterations as fast as possible. Negative loop periods are invalid.
max_runtimemaximum total runtime to execute the MAPE loops
send_periodtime (in seconds) between sending data. If send_period <= 0, send period will use the loop period.
Returns
the result of the MAPE loop
int gams::controllers::Multicontroller::run_hz ( double  loop_hz = 0.0,
double  max_runtime = -1,
double  send_hz = -1.0 
)
inline

Runs iterations of the MAPE loop with specified hertz.

Parameters
loop_hzthe intended hz at which the loop should execute. anything non-negative is valid. 0hz is treated as as infinite hertz
max_runtimemaximum total runtime to execute the MAPE loops
send_hzthe intended hz at which updates should be sent. If non-positive, loop_hz is used.
Returns
the result of the MAPE loop

Definition at line 161 of file Multicontroller.h.

int gams::controllers::Multicontroller::run_once ( void  )

Runs a single iteration of the MAPE loop Always sends updates after the iteration.

Returns
the result of the MAPE loop iteration
int gams::controllers::Multicontroller::run_once_ ( void  )
private

Code shared between run and run_once.

virtual int gams::controllers::Multicontroller::system_analyze ( void  )
virtual

Analyzes the system to determine if platform or algorithm changes are necessary.

This function should return a 0 unless the MAPE loop should stop.

Member Data Documentation

algorithms::Algorithms gams::controllers::Multicontroller::accents_
protected

Accents on the primary algorithm.

Definition at line 307 of file Multicontroller.h.

variables::Agents gams::controllers::Multicontroller::agents_
protected

Containers for agent-related variables.

Definition at line 316 of file Multicontroller.h.

algorithms::BaseAlgorithm* gams::controllers::Multicontroller::algorithm_
protected

Algorithm to perform.

Definition at line 310 of file Multicontroller.h.

variables::Algorithms gams::controllers::Multicontroller::algorithms_
protected

Containers for algorithm information.

Definition at line 313 of file Multicontroller.h.

madara::knowledge::KnowledgeBase& gams::controllers::Multicontroller::knowledge_
protected

Knowledge base.

Definition at line 319 of file Multicontroller.h.

platforms::BasePlatform* gams::controllers::Multicontroller::platform_
protected

Platform on which the controller is running.

Definition at line 322 of file Multicontroller.h.

variables::Platforms gams::controllers::Multicontroller::platforms_
protected

Containers for platform information.

Definition at line 325 of file Multicontroller.h.

variables::Self gams::controllers::Multicontroller::self_
protected

Containers for self-referencing variables.

Definition at line 328 of file Multicontroller.h.

variables::Sensors gams::controllers::Multicontroller::sensors_
protected

Containers for sensor information.

Definition at line 331 of file Multicontroller.h.

variables::Swarm gams::controllers::Multicontroller::swarm_
protected

Containers for swarm-related variables.

Definition at line 334 of file Multicontroller.h.


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