coral
A C++ library for distributed co-simulation
|
Manages and coordinates all participants in an execution. More...
#include "coral/bus/execution_manager.hpp"
Inherits noncopyable.
Public Types | |
typedef std::function< void(const std::error_code &)> | ReconstituteHandler |
Completion handler type for Reconstitute(). | |
typedef std::function< void(const std::error_code &, coral::model::SlaveID, std::size_t)> | SlaveReconstituteHandler |
Per-slave completion handler type for Reconstitute() | |
typedef std::function< void(const std::error_code &)> | ReconfigureHandler |
Completion handler type for Reconfigure(). | |
typedef std::function< void(const std::error_code &, coral::model::SlaveID, std::size_t)> | SlaveReconfigureHandler |
Per-slave completion handler type for Reconfigure() | |
typedef std::function< void(const std::error_code &)> | StepHandler |
Completion handler type for the Step() function. | |
typedef std::function< void(const std::error_code &, coral::model::SlaveID)> | SlaveStepHandler |
Completion handler type for the Step() function of individual slaves. | |
typedef std::function< void(const std::error_code &)> | AcceptStepHandler |
Completion handler type for the AcceptStep() function. | |
typedef std::function< void(const std::error_code &, coral::model::SlaveID)> | SlaveAcceptStepHandler |
Completion handler type for the AcceptStep() function of individual slaves. | |
Public Member Functions | |
ExecutionManager (coral::net::Reactor &reactor, const std::string &executionName, const coral::master::ExecutionOptions &options=coral::master::ExecutionOptions{}) | |
Constructs an object which manages an execution. More... | |
void | Reconstitute (const std::vector< AddedSlave > &slavesToAdd, std::chrono::milliseconds commTimeout, ReconstituteHandler onComplete, SlaveReconstituteHandler onSlaveComplete=SlaveReconstituteHandler{}) |
Adds new slaves to the execution. More... | |
void | Reconfigure (const std::vector< SlaveConfig > &slaveConfigs, std::chrono::milliseconds commTimeout, ReconfigureHandler onComplete, SlaveReconfigureHandler onSlaveComplete=SlaveReconfigureHandler{}) |
Sets the values of and/or connects variables. More... | |
void | Step (coral::model::TimeDuration stepSize, std::chrono::milliseconds timeout, StepHandler onComplete, SlaveStepHandler onSlaveStepComplete=nullptr) |
Steps the simulation forward. | |
void | AcceptStep (std::chrono::milliseconds timeout, AcceptStepHandler onComplete, SlaveAcceptStepHandler onSlaveAcceptStepComplete=nullptr) |
Informs the slaves that the step is accepted. | |
void | Terminate () |
Terminates the entire execution and all associated slaves. | |
const std::string & | SlaveName (coral::model::SlaveID id) const |
Gets the name of the slave with the given ID. | |
Manages and coordinates all participants in an execution.
coral::bus::ExecutionManager::ExecutionManager | ( | coral::net::Reactor & | reactor, |
const std::string & | executionName, | ||
const coral::master::ExecutionOptions & | options = coral::master::ExecutionOptions{} |
||
) |
Constructs an object which manages an execution.
[in] | reactor | The coral::net::Reactor object used for communication. |
[in] | executionName | A (preferably unique) name for the execution. |
[in] | options | Configuration settings for the execution. |
void coral::bus::ExecutionManager::Reconfigure | ( | const std::vector< SlaveConfig > & | slaveConfigs, |
std::chrono::milliseconds | commTimeout, | ||
ReconfigureHandler | onComplete, | ||
SlaveReconfigureHandler | onSlaveComplete = SlaveReconfigureHandler{} |
||
) |
Sets the values of and/or connects variables.
When a connection is made between an output variable and an input variable, or such a connection is to be broken, this is specified in the SlaveConfig
object for the slave which owns the input variable.
[in] | slaveConfigs | A list of slave configuration change specifications, at most one entry per slave. |
[in] | commTimeout | The communications timeout used to detect loss of communication with the slaves. |
[in] | onComplete | Handler callback which is called when the entire operation is complete. |
[in] | onSlaveComplete | Handler callback which is called once for each slave, and which receives an error code in case of error. It also receives the slave ID and a size_t variable which contains the slave's index in the slavesToAdd vector. |
void coral::bus::ExecutionManager::Reconstitute | ( | const std::vector< AddedSlave > & | slavesToAdd, |
std::chrono::milliseconds | commTimeout, | ||
ReconstituteHandler | onComplete, | ||
SlaveReconstituteHandler | onSlaveComplete = SlaveReconstituteHandler{} |
||
) |
Adds new slaves to the execution.
The naming of this function reflects the fact that, in a future version, it is intended to also support removing slaves from an execution, and not just adding.
[in] | slavesToAdd | A list of slaves to add. If empty, onComplete is called immediately and the function returns without doing anything else. Contains information about the slaves on output. |
[in] | commTimeout | The communications timeout used to detect loss of communication with the slaves. |
[in] | onComplete | Handler callback which is called when the entire operation is complete. |
[in] | onSlaveComplete | Handler callback which is called once for each slave, and which receives the slave's assigned ID number (or an error code, in case the operation failed). It also receives a size_t variable which contains the slave's index in the slavesToAdd vector. |