@@ -67,6 +67,26 @@ void Environment::optimize() {
67
67
optimized_graph_ = graph_;
68
68
}
69
69
70
+ void recursive_construct (Reactor* container) {
71
+ container->construct ();
72
+ for (auto * reactor : container->reactors ()) {
73
+ recursive_construct (reactor);
74
+ }
75
+ }
76
+
77
+ void Environment::construct () {
78
+ // phase_ = Phase::Assembly;
79
+
80
+ log::Info () << " Start Contruction of reactors" ;
81
+ for (auto * reactor : top_level_reactors_) {
82
+ recursive_construct (reactor);
83
+ }
84
+
85
+ for (auto * env : contained_environments_) {
86
+ env->construct ();
87
+ }
88
+ }
89
+
70
90
void recursive_assemble (Reactor* container) {
71
91
container->assemble ();
72
92
for (auto * reactor : container->reactors ()) {
@@ -80,7 +100,7 @@ void Environment::assemble() { // NOLINT(readability-function-cognitive-complexi
80
100
// constructing all the reactors
81
101
// this mainly tell the reactors that they should connect their ports and actions not ports and ports
82
102
83
- log::Debug () << " start assembly of reactors" ;
103
+ log::Info () << " start assembly of reactors" ;
84
104
for (auto * reactor : top_level_reactors_) {
85
105
recursive_assemble (reactor);
86
106
}
@@ -112,6 +132,8 @@ void Environment::assemble() { // NOLINT(readability-function-cognitive-complexi
112
132
source_port->add_outward_binding (destination_port);
113
133
log::Debug () << " from: " << source_port->fqn () << " (" << source_port << " )"
114
134
<< " --> to: " << destination_port->fqn () << " (" << destination_port << " )" ;
135
+ reactor::validate (source_port != destination_port,
136
+ " Self wiring detected; from " + source_port->fqn () + " --> " + destination_port->fqn ());
115
137
}
116
138
} else {
117
139
if (properties.type_ == ConnectionType::Enclaved || properties.type_ == ConnectionType::PhysicalEnclaved ||
@@ -221,6 +243,8 @@ void Environment::export_dependency_graph(const std::string& path) {
221
243
std::ofstream dot;
222
244
dot.open (path);
223
245
246
+ dependency_graph_and_indexes ();
247
+
224
248
// sort all reactions_ by their index
225
249
std::map<unsigned int , std::vector<Reaction*>> reactions_by_index;
226
250
for (auto * reaction : reactions_) {
@@ -317,7 +341,7 @@ auto Environment::startup() -> std::thread {
317
341
return startup (get_physical_time ());
318
342
}
319
343
320
- auto Environment::startup ( const TimePoint& start_time) -> std::thread {
344
+ void Environment::dependency_graph_and_indexes () {
321
345
validate (this ->phase () == Phase::Assembly, " startup() may only be called during assembly phase!" );
322
346
323
347
log::Debug () << " Building the Dependency-Graph" ;
@@ -327,7 +351,17 @@ auto Environment::startup(const TimePoint& start_time) -> std::thread {
327
351
328
352
calculate_indexes ();
329
353
330
- log_.debug () << " Starting the execution" ;
354
+ phase_ = Phase::Indexing;
355
+ }
356
+
357
+ auto Environment::startup (const TimePoint& start_time) -> std::thread {
358
+ if (phase_ == Phase::Assembly) {
359
+ dependency_graph_and_indexes ();
360
+ }
361
+
362
+ validate (this ->phase () == Phase::Indexing, " startup() may only be called during Indexing phase!" );
363
+
364
+ log_.info () << " Starting the execution" ;
331
365
phase_ = Phase::Startup;
332
366
333
367
this ->start_tag_ = Tag::from_physical_time (start_time);
0 commit comments