coral
A C++ library for distributed co-simulation
execution.hpp
Go to the documentation of this file.
1 
10 #ifndef CORAL_MASTER_EXECUTION_HPP
11 #define CORAL_MASTER_EXECUTION_HPP
12 
13 #include <chrono>
14 #include <future>
15 #include <iterator>
16 #include <memory>
17 #include <string>
18 #include <vector>
19 
20 #include <coral/config.h>
22 #include <coral/model.hpp>
23 #include <coral/net.hpp>
24 
25 
26 namespace coral
27 {
28 namespace master
29 {
30 
31 
33 enum class StepResult
34 {
36  failed = 0,
37 
39  completed = 1
40 };
41 
42 
58 struct AddedSlave
59 {
62 
72 
75 
78 
80  AddedSlave() CORAL_NOEXCEPT { }
81 
84  : locator{std::move(locator_)}, name(std::move(name_))
85  { }
86 };
87 
88 
105 {
112 
115 
118 
120  SlaveConfig() CORAL_NOEXCEPT { }
121 
124  coral::model::SlaveID slaveID_,
126  : slaveID(slaveID_)
127  , variableSettings(std::move(variableSettings_))
128  { }
129 };
130 
131 
132 
142 {
143 public:
153  explicit Execution(
154  const std::string& executionName,
155  const ExecutionOptions& options = ExecutionOptions{});
156 
158  ~Execution() CORAL_NOEXCEPT;
159 
160  Execution(const Execution&) = delete;
161  Execution& operator=(const Execution&) = delete;
162 
164  Execution(Execution&&) CORAL_NOEXCEPT;
165 
167  Execution& operator=(Execution&&) CORAL_NOEXCEPT;
168 
195  void Reconstitute(
196  std::vector<AddedSlave>& slavesToAdd,
197  std::chrono::milliseconds commTimeout);
198 
226  void Reconfigure(
227  std::vector<SlaveConfig>& slaveConfigs,
228  std::chrono::milliseconds commTimeout);
229 
273  StepResult Step(
277 
290  void AcceptStep(std::chrono::milliseconds timeout);
291 
298  void Terminate();
299 
300 private:
301  class Private;
302  std::unique_ptr<Private> m_private;
303 };
304 
305 
306 }} //namespace
307 #endif // header guard
std::error_code error
[Output] The error reported by the slave, if any.
Definition: execution.hpp:117
Creates and controls an execution.
Definition: execution.hpp:141
std::error_code error
[Output] The error reported by the slave, if any.
Definition: execution.hpp:77
AddedSlave(coral::net::SlaveLocator locator_, std::string name_)
Constructor which sets the locator and name fields.
Definition: execution.hpp:83
Main module header for coral::net.
SlaveConfig(coral::model::SlaveID slaveID_, std::vector< coral::model::VariableSetting > variableSettings_)
Constructor which sets the slaveID and variableSettings fields.
Definition: execution.hpp:123
STL namespace.
STL class.
Configuration options for an execution.
STL class.
AddedSlave() CORAL_NOEXCEPT
Default constructor.
Definition: execution.hpp:80
coral::net::SlaveLocator locator
[Input] Information about the slave&#39;s network location.
Definition: execution.hpp:61
Definition: variable_io.hpp:28
T move(T...args)
std::vector< coral::model::VariableSetting > variableSettings
[Input] The variable value/connection changes.
Definition: execution.hpp:114
double TimeDuration
The type used to specify (simulation) time durations.
Definition: model.hpp:56
Configuration options for an execution.
Definition: execution_options.hpp:29
Specifies a slave which is to be added to an execution.
Definition: execution.hpp:58
StepResult
Constants used to indicate the result of Execution::Step()
Definition: execution.hpp:33
const SlaveID INVALID_SLAVE_ID
An invalid slave identifier.
Definition: model.hpp:64
Class which represents the network location(s) of a slave.
Definition: net.hpp:292
std::string name
[Input] A name for the slave, unique in the execution.
Definition: execution.hpp:71
Main module header for coral::model.
SlaveConfig() CORAL_NOEXCEPT
Default constructor.
Definition: execution.hpp:120
Specifies variable values and connection changes for a single slave.
Definition: execution.hpp:104