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 {
35  failed = 0,
36  completed = 1
37 };
38 
39 
54 struct AddedSlave
55 {
58 
61 
64 
67 
69  AddedSlave() CORAL_NOEXCEPT { }
70 
73  : locator{std::move(locator_)}, name(std::move(name_))
74  { }
75 };
76 
77 
92 {
95 
98 
101 
103  SlaveConfig() CORAL_NOEXCEPT { }
104 
107  coral::model::SlaveID slaveID_,
109  : slaveID(slaveID_)
110  , variableSettings(std::move(variableSettings_))
111  { }
112 };
113 
114 
115 
123 {
124 public:
133  explicit Execution(
134  const std::string& executionName,
135  const ExecutionOptions& options = ExecutionOptions{});
136 
138  ~Execution() CORAL_NOEXCEPT;
139 
140  Execution(const Execution&) = delete;
141  Execution& operator=(const Execution&) = delete;
142 
144  Execution(Execution&&) CORAL_NOEXCEPT;
145 
147  Execution& operator=(Execution&&) CORAL_NOEXCEPT;
148 
172  void Reconstitute(
173  std::vector<AddedSlave>& slavesToAdd,
174  std::chrono::milliseconds commTimeout);
175 
199  void Reconfigure(
200  std::vector<SlaveConfig>& slaveConfigs,
201  std::chrono::milliseconds commTimeout);
202 
238  StepResult Step(
242 
261  void AcceptStep(std::chrono::milliseconds timeout);
262 
273  void Terminate();
274 
275 private:
276  class Private;
277  std::unique_ptr<Private> m_private;
278 };
279 
280 
281 }} //namespace
282 #endif // header guard
std::error_code error
[Output] The error reported by the slave, if any
Definition: execution.hpp:100
Master execution controller.
Definition: execution.hpp:122
std::error_code error
[Output] The error reported by the slave, if any
Definition: execution.hpp:66
AddedSlave(coral::net::SlaveLocator locator_, std::string name_)
Constructor which sets the locator and name fields.
Definition: execution.hpp:72
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:106
STL namespace.
STL class.
Configuration options for an execution.
STL class.
AddedSlave() CORAL_NOEXCEPT
Default constructor.
Definition: execution.hpp:69
coral::net::SlaveLocator locator
[Input] The slave&#39;s network location
Definition: execution.hpp:57
Definition: variable_io.hpp:28
T move(T...args)
std::vector< coral::model::VariableSetting > variableSettings
[Input] The variable value/connection changes
Definition: execution.hpp:97
double TimeDuration
The type used to specify (simulation) time durations.
Definition: model.hpp:56
Used in Execution::Reconstitute() to specify a slave which should be added to the simulation...
Definition: execution.hpp:54
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:60
Main module header for coral::model.
SlaveConfig() CORAL_NOEXCEPT
Default constructor.
Definition: execution.hpp:103
Used in Execution::Reconfigure() to specify variable value and connection changes.
Definition: execution.hpp:91