GAMS
1.4.0
|
The basic controller that can be used to perform actions on platforms and algorithms. More...
#include <BaseController.h>
Public Member Functions | |
BaseController (madara::knowledge::KnowledgeBase &knowledge, const ControllerSettings &settings=ControllerSettings()) | |
Constructor. More... | |
virtual | ~BaseController () |
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... | |
void | configure (const ControllerSettings &settings) |
Configures the controller with initialization settings. More... | |
virtual int | execute (void) |
Defines the execute function(the E of MAPE). More... | |
algorithms::BaseAlgorithm * | get_algorithm (void) |
Gets the current algorithm. More... | |
madara::knowledge::KnowledgeBase * | get_kb (void) |
Gets the KB. More... | |
platforms::BasePlatform * | get_platform (void) |
Gets the current platform. More... | |
variables::Self * | get_self (void) |
Gets the Self. More... | |
variables::Sensors * | get_sensors (void) |
Gets the sensors map. More... | |
void | init_accent (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Adds an accent algorithm. More... | |
void | init_algorithm (algorithms::BaseAlgorithm *algorithm) |
Initializes the controller with a user-provided algorithm. More... | |
void | init_algorithm (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes an 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 (algorithms::BaseAlgorithm &algorithm) |
Initializes containers and knowledge base in an algorithm. More... | |
void | init_vars (const madara::knowledge::KnowledgeRecord::Integer &id=0, const madara::knowledge::KnowledgeRecord::Integer &agents=-1) |
Initializes global variable containers. More... | |
void | init_vars (const std::string &self_prefix, const groups::GroupBase *group) |
Initializes global variable containers. More... | |
void | init_vars (const std::string &self_prefix, const std::string &group_name="") |
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... | |
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, double max_runtime=-1, double send_period=-1.0) |
Runs iterations of the MAPE loop with specified periods. More... | |
int | run (void) |
Runs iterations of the MAPE loop with configured settings. 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... | |
void | save_checkpoint (void) |
Saves a checkpoint according to the configured settings. 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... | |
int | checkpoint_count_ |
keeps track of the checkpoints saved in the control loop 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... | |
ControllerSettings | settings_ |
Settings for controller management and qos. 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... | |
The basic controller that can be used to perform actions on platforms and algorithms.
Definition at line 87 of file BaseController.h.
gams::controllers::BaseController::BaseController | ( | madara::knowledge::KnowledgeBase & | knowledge, |
const ControllerSettings & | settings = ControllerSettings() |
||
) |
Constructor.
knowledge | The knowledge base to reference and mutate |
settings | an initial configuration for the controller |
|
virtual |
Destructor.
void gams::controllers::BaseController::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 BaseController.
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::BaseController::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 BaseController.
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::BaseController::clear_accents | ( | void | ) |
Clears all accent algorithms.
void gams::controllers::BaseController::configure | ( | const ControllerSettings & | settings | ) |
Configures the controller with initialization settings.
|
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::BaseController::get_algorithm | ( | void | ) |
Gets the current algorithm.
madara::knowledge::KnowledgeBase* gams::controllers::BaseController::get_kb | ( | void | ) |
Gets the KB.
platforms::BasePlatform* gams::controllers::BaseController::get_platform | ( | void | ) |
Gets the current platform.
variables::Self* gams::controllers::BaseController::get_self | ( | void | ) |
Gets the Self.
variables::Sensors* gams::controllers::BaseController::get_sensors | ( | void | ) |
Gets the sensors map.
void gams::controllers::BaseController::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::BaseController::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::BaseController::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::BaseController::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::BaseController::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::BaseController::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 |
void gams::controllers::BaseController::init_vars | ( | const madara::knowledge::KnowledgeRecord::Integer & | id = 0 , |
const madara::knowledge::KnowledgeRecord::Integer & | agents = -1 |
||
) |
Initializes global variable containers.
id | node identifier |
agents | number of total agents |
void gams::controllers::BaseController::init_vars | ( | const std::string & | self_prefix, |
const groups::GroupBase * | group | ||
) |
Initializes global variable containers.
self_prefix | the prefix of the agent in the knowledge base |
group | the group that should populate agents |
void gams::controllers::BaseController::init_vars | ( | const std::string & | self_prefix, |
const std::string & | group_name = "" |
||
) |
Initializes global variable containers.
self_prefix | the prefix of the agent in the knowledge base |
group_name | the name of the group that the agent listing should come from |
void gams::controllers::BaseController::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 |
|
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::BaseController::run | ( | double | loop_period, |
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. |
int gams::controllers::BaseController::run | ( | void | ) |
Runs iterations of the MAPE loop with configured settings.
|
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 167 of file BaseController.h.
int gams::controllers::BaseController::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.
void gams::controllers::BaseController::save_checkpoint | ( | void | ) |
Saves a checkpoint according to the configured settings.
|
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 365 of file BaseController.h.
|
protected |
Containers for agent-related variables.
Definition at line 374 of file BaseController.h.
|
protected |
Algorithm to perform.
Definition at line 368 of file BaseController.h.
|
protected |
Containers for algorithm information.
Definition at line 371 of file BaseController.h.
|
protected |
keeps track of the checkpoints saved in the control loop
Definition at line 398 of file BaseController.h.
|
protected |
Knowledge base.
Definition at line 377 of file BaseController.h.
|
protected |
Platform on which the controller is running.
Definition at line 380 of file BaseController.h.
|
protected |
Containers for platform information.
Definition at line 383 of file BaseController.h.
|
protected |
Containers for self-referencing variables.
Definition at line 386 of file BaseController.h.
|
protected |
Containers for sensor information.
Definition at line 389 of file BaseController.h.
|
protected |
Settings for controller management and qos.
Definition at line 395 of file BaseController.h.
|
protected |
Containers for swarm-related variables.
Definition at line 392 of file BaseController.h.