@@ -368,134 +368,4 @@ auto Environment::startup(const TimePoint& start_time) -> std::thread {
368
368
});
369
369
}
370
370
371
- void Environment::dump_trigger_to_yaml (std::ofstream& yaml, const BaseAction& trigger) {
372
- yaml << " - name: " << trigger.name () << ' \n ' ;
373
- if (dynamic_cast <const StartupTrigger*>(&trigger) != nullptr ) {
374
- yaml << " type: startup\n " ;
375
- } else if (dynamic_cast <const ShutdownTrigger*>(&trigger) != nullptr ) {
376
- yaml << " type: shutdown\n " ;
377
- } else if (dynamic_cast <const Timer*>(&trigger) != nullptr ) {
378
- yaml << " type: timer\n " ;
379
- } else if (trigger.is_logical ()) {
380
- yaml << " type: logical action\n " ;
381
- } else {
382
- yaml << " type: physical action\n " ;
383
- }
384
- yaml << " trigger_of:\n " ;
385
- for (auto * const reaction : trigger.triggers ()) {
386
- yaml << " - " << reaction->fqn () << ' \n ' ;
387
- }
388
- yaml << " effect_of:\n " ;
389
- for (auto * const reaction : trigger.schedulers ()) {
390
- yaml << " - " << reaction->fqn () << ' \n ' ;
391
- }
392
- }
393
-
394
- void Environment::dump_instance_to_yaml (std::ofstream& yaml, const Reactor& reactor) {
395
- yaml << " " << reactor.fqn () << " :\n " ;
396
- yaml << " name: " << reactor.name () << ' \n ' ;
397
- if (reactor.is_top_level ()) {
398
- yaml << " container: null\n " ;
399
- } else {
400
- yaml << " container: " << reactor.container ()->fqn () << ' \n ' ;
401
- }
402
- yaml << " reactor_instances:\n " ;
403
- for (auto * const current_reactor : reactor.reactors ()) {
404
- yaml << " - " << current_reactor->fqn () << ' \n ' ;
405
- }
406
- yaml << " inputs:\n " ;
407
- for (auto * const inputs : reactor.inputs ()) {
408
- dump_port_to_yaml (yaml, *inputs);
409
- }
410
- yaml << " outputs:\n " ;
411
- for (auto * const outputs : reactor.outputs ()) {
412
- dump_port_to_yaml (yaml, *outputs);
413
- }
414
- yaml << " triggers:\n " ;
415
- for (auto * const actions : reactor.actions ()) {
416
- dump_trigger_to_yaml (yaml, *actions);
417
- }
418
- yaml << " reactions:\n " ;
419
- for (auto * const current_reaction : reactor.reactions ()) {
420
- dump_reaction_to_yaml (yaml, *current_reaction);
421
- }
422
-
423
- for (auto * const reactors : reactor.reactors ()) {
424
- dump_instance_to_yaml (yaml, *reactors);
425
- }
426
- }
427
-
428
- void Environment::dump_port_to_yaml (std::ofstream& yaml, const BasePort& port) {
429
- yaml << " " << port.name () << " :\n " ;
430
- if (port.has_inward_binding ()) {
431
- yaml << " upstream_port: " << port.inward_binding ()->fqn () << ' \n ' ;
432
- } else {
433
- yaml << " upstream_port: null\n " ;
434
- }
435
- yaml << " downstream_ports: \n " ;
436
- for (auto * const outward_binding : port.outward_bindings ()) {
437
- yaml << " - " << outward_binding->fqn () << ' \n ' ;
438
- }
439
- yaml << " trigger_of:\n " ;
440
- for (auto * const trigger : port.triggers ()) {
441
- yaml << " - " << trigger->fqn () << ' \n ' ;
442
- }
443
- yaml << " source_of:\n " ;
444
- for (auto * const dependency : port.dependencies ()) {
445
- if (port.triggers ().find (dependency) == port.triggers ().end ()) {
446
- yaml << " - " << dependency->fqn () << ' \n ' ;
447
- }
448
- }
449
- yaml << " effect_of: " << ' \n ' ;
450
- for (auto * const antidepencency : port.anti_dependencies ()) {
451
- yaml << " - " << antidepencency->fqn () << ' \n ' ;
452
- }
453
- }
454
-
455
- void Environment::dump_reaction_to_yaml (std::ofstream& yaml, const Reaction& reaction) {
456
- yaml << " - name: " << reaction.name () << ' \n ' ;
457
- yaml << " priority: " << reaction.priority () << ' \n ' ;
458
- yaml << " level: " << reaction.index () << ' \n ' ;
459
- yaml << " triggers:\n " ;
460
- for (auto * const trigger : reaction.action_triggers ()) {
461
- yaml << " - " << trigger->fqn () << ' \n ' ;
462
- }
463
- for (auto * const trigger : reaction.port_triggers ()) {
464
- yaml << " - " << trigger->fqn () << ' \n ' ;
465
- }
466
- yaml << " sources:\n " ;
467
- for (auto * dependency : reaction.dependencies ()) {
468
- if (reaction.port_triggers ().find (dependency) == reaction.port_triggers ().end ()) {
469
- yaml << " - " << dependency->fqn () << ' \n ' ;
470
- }
471
- }
472
- yaml << " effects:\n " ;
473
- for (auto * const antidependency : reaction.antidependencies ()) {
474
- yaml << " - " << antidependency->fqn () << ' \n ' ;
475
- }
476
- for (auto * const scheduable_action : reaction.scheduable_actions ()) {
477
- yaml << " - " << scheduable_action->fqn () << ' \n ' ;
478
- }
479
- }
480
-
481
- void Environment::dump_to_yaml (const std::string& path) {
482
- std::ofstream yaml (path);
483
- yaml << " ---\n " ;
484
- yaml << " top_level_instances:\n " ;
485
- for (const auto * reactors : top_level_reactors_) {
486
- yaml << " - " << reactors->fqn () << ' \n ' ;
487
- }
488
- yaml << " all_reactor_instances:\n " ;
489
- for (const auto * reactors : top_level_reactors_) {
490
- dump_instance_to_yaml (yaml, *reactors);
491
- }
492
- yaml << " reaction_dependencies:\n " ;
493
- for (auto & iterator : dependencies_) {
494
- yaml << " - from: " << iterator.first ->fqn () << ' \n ' ;
495
- yaml << " - to: " << iterator.second ->fqn () << ' \n ' ;
496
- }
497
-
498
- log_.info () << " Program structure was dumped to " << path;
499
- }
500
-
501
371
} // namespace reactor
0 commit comments