54 #ifndef _GAMS_BASE_CONTROLLER_H_
55 #define _GAMS_BASE_CONTROLLER_H_
72 #include "madara/knowledge/containers/String.h"
73 #include "madara/knowledge/containers/Vector.h"
153 int run(
double loop_period,
154 double max_runtime = -1,
155 double send_period = -1.0);
168 double max_runtime = -1,
169 double send_hz = -1.0)
171 double loop_rate, send_rate;
178 loop_rate = 1.0 / loop_hz;
182 send_rate = loop_rate;
185 send_rate = 1.0 / send_hz;
187 return run(loop_rate, max_runtime, send_rate);
202 const madara::knowledge::KnowledgeMap & args =
203 madara::knowledge::KnowledgeMap());
219 const std::vector <std::string> & aliases,
231 const std::vector <std::string> & aliases,
240 const madara::knowledge::KnowledgeMap & args = madara::knowledge::KnowledgeMap());
256 const madara::knowledge::KnowledgeMap & args =
257 madara::knowledge::KnowledgeMap());
277 void init_algorithm(jobject algorithm);
283 void init_platform(jobject platform);
291 void init_vars(
const madara::knowledge::KnowledgeRecord::Integer &
id = 0,
292 const madara::knowledge::KnowledgeRecord::Integer & agents = -1);
301 const std::string & group_name =
"");
349 madara::knowledge::KnowledgeBase *
get_kb(
void);
Copyright(c) 2014-2018 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2017 Carnegie Mellon University.
Copyright(c) 2016 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Copyright(c) 2014 Carnegie Mellon University.
Base class for algorithm factories that classes derived from.
The base class that algorithms in GAMS use.
The basic controller that can be used to perform actions on platforms and algorithms.
int run_once(void)
Runs a single iteration of the MAPE loop Always sends updates after the iteration.
variables::Self * get_self(void)
Gets the Self.
void init_platform(platforms::BasePlatform *platform)
Initializes the controller with a user-provided platform.
virtual int monitor(void)
Defines the monitor function(the M of MAPE).
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.
BaseController(madara::knowledge::KnowledgeBase &knowledge, const ControllerSettings &settings=ControllerSettings())
Constructor.
void init_algorithm(const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap())
Initializes an algorithm.
void save_checkpoint(void)
Saves a checkpoint according to the configured settings.
virtual int plan(void)
Defines the plan function(the P of MAPE).
int run_once_(void)
Code shared between run and run_once.
int run(double loop_period, double max_runtime=-1, double send_period=-1.0)
Runs iterations of the MAPE loop with specified periods.
int run(void)
Runs iterations of the MAPE loop with configured settings.
algorithms::BaseAlgorithm * get_algorithm(void)
Gets the current algorithm.
void init_platform(const std::string &platform, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap())
Initializes the platform.
void add_platform_factory(const std::vector< std::string > &aliases, platforms::PlatformFactory *factory)
Adds an aliased platform factory.
ControllerSettings settings_
Settings for controller management and qos.
platforms::BasePlatform * get_platform(void)
Gets the current platform.
platforms::BasePlatform * platform_
Platform on which the controller is running.
virtual ~BaseController()
Destructor.
algorithms::Algorithms accents_
Accents on the primary algorithm.
variables::Platforms platforms_
Containers for platform information.
void init_vars(platforms::BasePlatform &platform)
Initializes containers and knowledge base in a platform This is usually the first thing a developer s...
madara::knowledge::KnowledgeBase & knowledge_
Knowledge base.
variables::Agents agents_
Containers for agent-related variables.
void init_accent(const std::string &algorithm, const madara::knowledge::KnowledgeMap &args=madara::knowledge::KnowledgeMap())
Adds an accent algorithm.
variables::Self self_
Containers for self-referencing variables.
variables::Sensors sensors_
Containers for sensor information.
algorithms::BaseAlgorithm * algorithm_
Algorithm to perform.
variables::Sensors * get_sensors(void)
Gets the sensors map.
variables::Swarm swarm_
Containers for swarm-related variables.
void init_vars(const madara::knowledge::KnowledgeRecord::Integer &id=0, const madara::knowledge::KnowledgeRecord::Integer &agents=-1)
Initializes global variable containers.
void init_vars(const std::string &self_prefix, const std::string &group_name="")
Initializes global variable containers.
virtual int analyze(void)
Defines the analyze function(the A of MAPE).
void configure(const ControllerSettings &settings)
Configures the controller with initialization settings.
int checkpoint_count_
keeps track of the checkpoints saved in the control loop
void init_vars(const std::string &self_prefix, const groups::GroupBase *group)
Initializes global variable containers.
void add_algorithm_factory(const std::vector< std::string > &aliases, algorithms::AlgorithmFactory *factory)
Adds an aliased algorithm factory.
virtual int execute(void)
Defines the execute function(the E of MAPE).
void clear_accents(void)
Clears all accent algorithms.
void init_vars(algorithms::BaseAlgorithm &algorithm)
Initializes containers and knowledge base in an algorithm.
void init_algorithm(algorithms::BaseAlgorithm *algorithm)
Initializes the controller with a user-provided algorithm.
variables::Algorithms algorithms_
Containers for algorithm information.
virtual int system_analyze(void)
Analyzes the system to determine if platform or algorithm changes are necessary.
madara::knowledge::KnowledgeBase * get_kb(void)
Gets the KB.
Settings used for initializing GAMS controllers.
Base class for a group of agents.
A container for self referencing information.
A container for swarm information.
std::vector< BaseAlgorithm * > Algorithms
std::map< std::string, PlatformStatus > Platforms
a map of sensor names to the sensor information
std::map< std::string, AlgorithmStatus > Algorithms
a map of sensor names to the sensor information
std::map< std::string, Sensor * > Sensors
a map of sensor names to the sensor information
std::vector< Agent > Agents
An array of agent knowledge.
Contains all GAMS-related tools, classes and code.