GAMS
1.4.0
|
A controller that has the capability of managing multiple controllers. More...
#include <HiveController.h>
Public Member Functions | |
HiveController () | |
Default constructor. More... | |
HiveController (madara::knowledge::Hive &hive, size_t init_id=0, size_t num_controllers=1, const ControllerSettings &settings=ControllerSettings()) | |
Constructor. More... | |
virtual | ~HiveController () |
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... | |
void | add_transports (const madara::transport::QoSTransportSettings &source_settings) |
Add transports to the knowledge bases that are being used by each controller. More... | |
void | clear_accents (size_t controller_index=0) |
Clears all accent algorithms. More... | |
void | clear_knowledge (void) |
Clears all controller knowledge bases. More... | |
void | evaluate (const std::string &logic, const madara::knowledge::EvalSettings &settings=madara::knowledge::EvalSettings::DELAY) |
Evaluates a karl logic across all controllers and knowledge bases. More... | |
void | evaluate (size_t controller_index, const std::string &logic, const madara::knowledge::EvalSettings &settings=madara::knowledge::EvalSettings::DELAY) |
Evaluates a karl logic across all controllers and knowledge bases. More... | |
algorithms::BaseAlgorithm * | get_algorithm (size_t controller_index=0) |
Gets the current algorithm at the controller index. More... | |
madara::knowledge::KnowledgeBase | get_kb (size_t controller_index) |
Returns the kb that is being used by the internal controller. More... | |
size_t | get_num_controllers (void) |
Returns the number of controllers being managed. More... | |
platforms::BasePlatform * | get_platform (size_t controller_index=0) |
Gets the current platform at the controller index. More... | |
void | init_accent (const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes all managed controllers with an accent algorithm. More... | |
void | init_accent (size_t controller_index, 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 all managed controllers with an algorithm. More... | |
void | init_algorithm (size_t controller_index, algorithms::BaseAlgorithm *algorithm) |
Initializes the controller with a user-provided algorithm. More... | |
void | init_algorithm (size_t controller_index, const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes a specific controller with an algorithm. More... | |
void | init_platform (const std::string &platform, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes all managed controllers with the platform. More... | |
void | init_platform (size_t controller_index, const std::string &platform, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap()) |
Initializes the platform. More... | |
void | init_platform (size_t controller_index, 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 (size_t controller_index, algorithms::BaseAlgorithm &algorithm) |
Initializes containers and knowledge base in an algorithm. More... | |
void | init_vars (size_t controller_index, 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 | refresh_vars (bool init_non_self_vars=false) |
Calls init_vars for each controller. More... | |
void | resize (size_t init_id, size_t num_controllers, bool init_non_self_vars=false) |
Resizes the number of controllers and knowledge bases. 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 | set_hive (madara::knowledge::Hive &hive) |
Sets the hive to control a portion of. More... | |
Protected Attributes | |
std::vector< BaseController * > | controllers_ |
Controllers that need to be instrumented. More... | |
madara::knowledge::Hive * | hive_ |
Pointer to a hive mind managed by parent. More... | |
size_t | offset_ |
the starting id within offsets and transports More... | |
ControllerSettings | settings_ |
Settings for controller management and qos. More... | |
A controller that has the capability of managing multiple controllers.
Definition at line 85 of file HiveController.h.
gams::controllers::HiveController::HiveController | ( | ) |
Default constructor.
gams::controllers::HiveController::HiveController | ( | madara::knowledge::Hive & | hive, |
size_t | init_id = 0 , |
||
size_t | num_controllers = 1 , |
||
const ControllerSettings & | settings = ControllerSettings() |
||
) |
Constructor.
hive | linked knowledge bases to control |
init_id | initial id of the controlled hive |
num_controllers | number of sequential controllers to manage |
settings | settings to use |
|
virtual |
Destructor.
void gams::controllers::HiveController::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 HiveController.
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::HiveController::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 HiveController.
aliases | the named aliases for the factory. All aliases will be converted to lower case |
factory | the factory for creating a platform |
void gams::controllers::HiveController::add_transports | ( | const madara::transport::QoSTransportSettings & | source_settings | ) |
Add transports to the knowledge bases that are being used by each controller.
If multicast or broadcast transports, the hosts are simply copied. If using unicast-based connections, then the first host in the settings is used and ports are added in an ascending order for each subsequent KB. This latter functionality is meant to aid in the expected use case of the HiveController managing colocated agents that need to communicate with each other. Note that you should resize the HiveController to the appropriate number of controllers BEFORE calling this function. Changes made here are not retroactive for all future resizes.
source_settings | base transport settings to copy from |
void gams::controllers::HiveController::clear_accents | ( | size_t | controller_index = 0 | ) |
Clears all accent algorithms.
controller_index | the index of the managed controllers |
void gams::controllers::HiveController::clear_knowledge | ( | void | ) |
Clears all controller knowledge bases.
void gams::controllers::HiveController::evaluate | ( | const std::string & | logic, |
const madara::knowledge::EvalSettings & | settings = madara::knowledge::EvalSettings::DELAY |
||
) |
Evaluates a karl logic across all controllers and knowledge bases.
logic | karl logic to evaluate |
settings | evaluation settings for the logic evaluation |
void gams::controllers::HiveController::evaluate | ( | size_t | controller_index, |
const std::string & | logic, | ||
const madara::knowledge::EvalSettings & | settings = madara::knowledge::EvalSettings::DELAY |
||
) |
Evaluates a karl logic across all controllers and knowledge bases.
controller_index | the index of the managed controllers |
logic | karl logic to evaluate |
settings | evaluation settings for the logic evaluation |
algorithms::BaseAlgorithm* gams::controllers::HiveController::get_algorithm | ( | size_t | controller_index = 0 | ) |
Gets the current algorithm at the controller index.
controller_index | the index of the managed controllers |
madara::knowledge::KnowledgeBase gams::controllers::HiveController::get_kb | ( | size_t | controller_index | ) |
Returns the kb that is being used by the internal controller.
controller_index | the index of the managed controllers |
size_t gams::controllers::HiveController::get_num_controllers | ( | void | ) |
Returns the number of controllers being managed.
platforms::BasePlatform* gams::controllers::HiveController::get_platform | ( | size_t | controller_index = 0 | ) |
Gets the current platform at the controller index.
controller_index | the index of the managed controllers |
void gams::controllers::HiveController::init_accent | ( | const std::string & | algorithm, |
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes all managed controllers with an accent algorithm.
algorithm | the name of the accent algorithm to add |
args | vector of knowledge record arguments |
void gams::controllers::HiveController::init_accent | ( | size_t | controller_index, |
const std::string & | algorithm, | ||
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Adds an accent algorithm.
controller_index | the index of the managed controllers |
algorithm | the name of the accent algorithm to add |
args | vector of knowledge record arguments |
void gams::controllers::HiveController::init_algorithm | ( | const std::string & | algorithm, |
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes all managed controllers with an algorithm.
algorithm | the name of the algorithm to run |
args | vector of knowledge record arguments |
void gams::controllers::HiveController::init_algorithm | ( | size_t | controller_index, |
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.
controller_index | the index of the managed controllers |
algorithm | the algorithm to use |
void gams::controllers::HiveController::init_algorithm | ( | size_t | controller_index, |
const std::string & | algorithm, | ||
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes a specific controller with an algorithm.
controller_index | the index of the managed controllers |
algorithm | the name of the algorithm to run |
args | vector of knowledge record arguments |
void gams::controllers::HiveController::init_platform | ( | const std::string & | platform, |
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes all managed controllers with the platform.
platform | the name of the platform the controller is using |
args | vector of knowledge record arguments |
void gams::controllers::HiveController::init_platform | ( | size_t | controller_index, |
const std::string & | platform, | ||
const madara::knowledge::KnowledgeMap & | args = madara::knowledge::KnowledgeMap() |
||
) |
Initializes the platform.
controller_index | the index of the managed controllers |
platform | the name of the platform the controller is using |
args | vector of knowledge record arguments |
void gams::controllers::HiveController::init_platform | ( | size_t | controller_index, |
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.
controller_index | the index of the managed controllers |
platform | the platform to use |
void gams::controllers::HiveController::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::HiveController::init_vars | ( | size_t | controller_index, |
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.
controller_index | the index of the managed controllers |
algorithm | the algorithm to initialize |
void gams::controllers::HiveController::init_vars | ( | size_t | controller_index, |
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.
controller_index | the index of the managed controllers |
platform | the platform to initialize |
void gams::controllers::HiveController::refresh_vars | ( | bool | init_non_self_vars = false | ) |
Calls init_vars for each controller.
Useful after clearing knowledge to repopulate the self identifying variables
init_non_self_vars | if true, populate agent vars for swarm, which is very memory expensive with 400+ |
void gams::controllers::HiveController::resize | ( | size_t | init_id, |
size_t | num_controllers, | ||
bool | init_non_self_vars = false |
||
) |
Resizes the number of controllers and knowledge bases.
init_id | initial id of the controlled hive |
num_controllers | the number of controllers to manage |
init_non_self_vars | if true, populate agent vars for swarm, which is very memory expensive with 400+ |
int gams::controllers::HiveController::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::HiveController::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 397 of file HiveController.h.
int gams::controllers::HiveController::run_once | ( | void | ) |
Runs a single iteration of the MAPE loop Always sends updates after the iteration.
|
inline |
Sets the hive to control a portion of.
hive | the hive to control |
Definition at line 367 of file HiveController.h.
|
protected |
Controllers that need to be instrumented.
Definition at line 426 of file HiveController.h.
|
protected |
Pointer to a hive mind managed by parent.
Definition at line 429 of file HiveController.h.
|
protected |
the starting id within offsets and transports
Definition at line 423 of file HiveController.h.
|
protected |
Settings for controller management and qos.
Definition at line 432 of file HiveController.h.