coral
A C++ library for distributed co-simulation
Public Types | Public Member Functions | List of all members
coral::bus::ExecutionManager Class Reference

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::stringSlaveName (coral::model::SlaveID id) const
 Gets the name of the slave with the given ID.
 

Detailed Description

Manages and coordinates all participants in an execution.

Constructor & Destructor Documentation

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.

Parameters
[in]reactorThe coral::net::Reactor object used for communication.
[in]executionNameA (preferably unique) name for the execution.
[in]optionsConfiguration settings for the execution.

Member Function Documentation

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.

Parameters
[in]slaveConfigsA list of slave configuration change specifications, at most one entry per slave.
[in]commTimeoutThe communications timeout used to detect loss of communication with the slaves.
[in]onCompleteHandler callback which is called when the entire operation is complete.
[in]onSlaveCompleteHandler 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.

Parameters
[in]slavesToAddA 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]commTimeoutThe communications timeout used to detect loss of communication with the slaves.
[in]onCompleteHandler callback which is called when the entire operation is complete.
[in]onSlaveCompleteHandler 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.

The documentation for this class was generated from the following file: