|
GAMS
1.2.2
|
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::BaseAlgorithm * | get_algorithm (void) |
| Gets the current algorithm. More... | |
| platforms::BasePlatform * | get_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::BaseAlgorithm * | algorithm_ |
| Algorithm to perform. More... | |
| variables::Algorithms | algorithms_ |
| Containers for algorithm information. More... | |
| madara::knowledge::KnowledgeBase & | knowledge_ |
| Knowledge base. More... | |
| platforms::BasePlatform * | platform_ |
| 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... | |
A controller that has the capability of starting many different threads.
Definition at line 83 of file Multicontroller.h.
| gams::controllers::Multicontroller::Multicontroller | ( | madara::knowledge::KnowledgeBase & | knowledge | ) |
Constructor.
| knowledge | The knowledge base to reference and mutate |
|
virtual |
Destructor.
| 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.
| aliases | the named aliases for the factory. All aliases will be converted to lower case |
| factory | the 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.
| aliases | the named aliases for the factory. All aliases will be converted to lower case |
| factory | the factory for creating a platform |
|
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 |
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.
| platforms::BasePlatform* gams::controllers::Multicontroller::get_platform | ( | void | ) |
Gets the current platform.
| void gams::controllers::Multicontroller::init_accent | ( | const std::string & | algorithm, |
| const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
| ) |
Adds an accent algorithm.
| algorithm | the name of the accent algorithm to add |
| args | vector 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.
| algorithm | the name of the algorithm to run |
| args | vector 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.
| algorithm | the algorithm to use |
| void gams::controllers::Multicontroller::init_platform | ( | const std::string & | platform, |
| const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
| ) |
Initializes the platform.
| platform | the name of the platform the controller is using |
| args | vector 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.
| platform | the 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.
| id | node identifier |
| processes | processes |
| 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.
| platform | the 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.
| algorithm | the algorithm to initialize |
|
virtual |
Defines the monitor function (the M of MAPE).
This function should return a 0 unless the MAPE loop should stop.
|
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.
| loop_period | time (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_runtime | maximum total runtime to execute the MAPE loops |
| send_period | time (in seconds) between sending data. If send_period <= 0, send period will use the loop period. |
|
inline |
Runs iterations of the MAPE loop with specified hertz.
| loop_hz | the intended hz at which the loop should execute. anything non-negative is valid. 0hz is treated as as infinite hertz |
| max_runtime | maximum total runtime to execute the MAPE loops |
| send_hz | the intended hz at which updates should be sent. If non-positive, loop_hz is used. |
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.
|
private |
Code shared between run and run_once.
|
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.
|
protected |
Accents on the primary algorithm.
Definition at line 307 of file Multicontroller.h.
|
protected |
Containers for agent-related variables.
Definition at line 316 of file Multicontroller.h.
|
protected |
Algorithm to perform.
Definition at line 310 of file Multicontroller.h.
|
protected |
Containers for algorithm information.
Definition at line 313 of file Multicontroller.h.
|
protected |
Knowledge base.
Definition at line 319 of file Multicontroller.h.
|
protected |
Platform on which the controller is running.
Definition at line 322 of file Multicontroller.h.
|
protected |
Containers for platform information.
Definition at line 325 of file Multicontroller.h.
|
protected |
Containers for self-referencing variables.
Definition at line 328 of file Multicontroller.h.
|
protected |
Containers for sensor information.
Definition at line 331 of file Multicontroller.h.
|
protected |
Containers for swarm-related variables.
Definition at line 334 of file Multicontroller.h.