10 #ifndef CORAL_BUS_SLAVE_CONTROLLER_HPP 11 #define CORAL_BUS_SLAVE_CONTROLLER_HPP 16 #include <system_error> 19 #include "coral/config.h" 91 ConnectHandler onComplete,
92 int maxConnectionAttempts = 3);
121 typedef
std::function<
void(const
std::error_code&, const
coral::model::SlaveDescription&)>
133 std::chrono::milliseconds timeout,
151 const
std::vector<
coral::model::VariableSetting>& settings,
152 std::chrono::milliseconds timeout,
153 SetVariablesHandler onComplete);
170 const
std::vector<
coral::net::Endpoint>& peers,
171 std::chrono::milliseconds timeout,
172 SetPeersHandler onComplete);
193 std::chrono::milliseconds timeout,
194 ResendVarsHandler onComplete);
217 std::chrono::milliseconds timeout,
218 StepHandler onComplete);
233 std::chrono::milliseconds timeout,
234 AcceptStepHandler onComplete);
247 SlaveController& operator=(SlaveController&&);
258 #endif // header guard Defines the coral::bus::SlaveSetup class.
void SetPeers(const std::vector< coral::net::Endpoint > &peers, std::chrono::milliseconds timeout, SetPeersHandler onComplete)
Sets or resets the list of peers to which the slave should be connected for the purpose of subscribin...
A class which is used for controlling one slave in an execution.
Definition: slave_controller.hpp:34
Contains the coral::net::Reactor class and related functionality.
A handle for a pending connection to a slave.
Definition: slave_control_messenger.hpp:63
Main module header for coral::net.
~SlaveController()
Destructor.
void Close()
Closes the connection to the slave and cancels all pending operations.
void AcceptStep(std::chrono::milliseconds timeout, AcceptStepHandler onComplete)
Tells the slave that the time step is accepted and it should update its inputs with results from othe...
Configuration data which is sent to each slave as they are added to the simulation.
Definition: slave_setup.hpp:27
VoidHandler ConnectHandler
Completion handler type for the constructor.
Definition: slave_controller.hpp:45
Defines the coral::bus::ISlaveControlMessenger interface and the two related functions ConnectToSlave...
void ResendVars(std::chrono::milliseconds timeout, ResendVarsHandler onComplete)
Makes the slave send all variable values and then wait to receive values for all connected input vari...
std::function< void(const std::error_code &)> VoidHandler
Basic completion handler type without any arguments aside from an error code.
Definition: slave_controller.hpp:41
std::int32_t StepID
A number that uniquely identifies a time step in an execution.
Definition: model.hpp:34
void Terminate()
Terminates the slave and cancels all pending operations.
Definition: variable_io.hpp:28
SlaveState
The various states a slave may be in.
Definition: slave_control_messenger.hpp:41
void Step(coral::model::StepID stepID, coral::model::TimePoint currentT, coral::model::TimeDuration deltaT, std::chrono::milliseconds timeout, StepHandler onComplete)
Makes the slave perform a time step.
double TimeDuration
The type used to specify (simulation) time durations.
Definition: model.hpp:56
An interface for classes that implement various versions of the master/slave communication protocol...
Definition: slave_control_messenger.hpp:141
SlaveController(coral::net::Reactor &reactor, const coral::net::SlaveLocator &slaveLocator, coral::model::SlaveID slaveID, const std::string &slaveName, const SlaveSetup &setup, std::chrono::milliseconds timeout, ConnectHandler onComplete, int maxConnectionAttempts=3)
Constructor.
An implementation of the reactor pattern.
Definition: reactor.hpp:41
Class which represents the network location(s) of a slave.
Definition: net.hpp:292
void SetVariables(const std::vector< coral::model::VariableSetting > &settings, std::chrono::milliseconds timeout, SetVariablesHandler onComplete)
Sets the values of, or connects, one or more of the slave's variables.
Main module header for coral::model.
double TimePoint
The type used to specify (simulation) time points.
Definition: model.hpp:42
SlaveState State() const CORAL_NOEXCEPT
Returns the current state of the slave.
void GetDescription(std::chrono::milliseconds timeout, GetDescriptionHandler onComplete)
Requests a description of the slave.