Skip to content

Commit

Permalink
drop yaml export
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnrd committed Aug 21, 2024
1 parent ecd53db commit ae09ff1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 137 deletions.
7 changes: 0 additions & 7 deletions include/reactor-cpp/environment.hh
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,7 @@ public:
void sync_shutdown();
void async_shutdown();

// Debugging methods
void export_dependency_graph(const std::string& path);
void dump_to_yaml(const std::string& path);

static void dump_trigger_to_yaml(std::ofstream& yaml, const BaseAction& trigger);
static void dump_instance_to_yaml(std::ofstream& yaml, const Reactor& reactor);
static void dump_port_to_yaml(std::ofstream& yaml, const BasePort& port);
static void dump_reaction_to_yaml(std::ofstream& yaml, const Reaction& reaction);

[[nodiscard]] auto top_level_reactors() const noexcept -> const auto& { return top_level_reactors_; }
[[nodiscard]] auto phase() const noexcept -> Phase { return phase_; }
Expand Down
130 changes: 0 additions & 130 deletions lib/environment.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,134 +368,4 @@ auto Environment::startup(const TimePoint& start_time) -> std::thread {
});
}

void Environment::dump_trigger_to_yaml(std::ofstream& yaml, const BaseAction& trigger) {
yaml << " - name: " << trigger.name() << '\n';
if (dynamic_cast<const StartupTrigger*>(&trigger) != nullptr) {
yaml << " type: startup\n";
} else if (dynamic_cast<const ShutdownTrigger*>(&trigger) != nullptr) {
yaml << " type: shutdown\n";
} else if (dynamic_cast<const Timer*>(&trigger) != nullptr) {
yaml << " type: timer\n";
} else if (trigger.is_logical()) {
yaml << " type: logical action\n";
} else {
yaml << " type: physical action\n";
}
yaml << " trigger_of:\n";
for (auto* const reaction : trigger.triggers()) {
yaml << " - " << reaction->fqn() << '\n';
}
yaml << " effect_of:\n";
for (auto* const reaction : trigger.schedulers()) {
yaml << " - " << reaction->fqn() << '\n';
}
}

void Environment::dump_instance_to_yaml(std::ofstream& yaml, const Reactor& reactor) {
yaml << " " << reactor.fqn() << ":\n";
yaml << " name: " << reactor.name() << '\n';
if (reactor.is_top_level()) {
yaml << " container: null\n";
} else {
yaml << " container: " << reactor.container()->fqn() << '\n';
}
yaml << " reactor_instances:\n";
for (auto* const current_reactor : reactor.reactors()) {
yaml << " - " << current_reactor->fqn() << '\n';
}
yaml << " inputs:\n";
for (auto* const inputs : reactor.inputs()) {
dump_port_to_yaml(yaml, *inputs);
}
yaml << " outputs:\n";
for (auto* const outputs : reactor.outputs()) {
dump_port_to_yaml(yaml, *outputs);
}
yaml << " triggers:\n";
for (auto* const actions : reactor.actions()) {
dump_trigger_to_yaml(yaml, *actions);
}
yaml << " reactions:\n";
for (auto* const current_reaction : reactor.reactions()) {
dump_reaction_to_yaml(yaml, *current_reaction);
}

for (auto* const reactors : reactor.reactors()) {
dump_instance_to_yaml(yaml, *reactors);
}
}

void Environment::dump_port_to_yaml(std::ofstream& yaml, const BasePort& port) {
yaml << " " << port.name() << ":\n";
if (port.has_inward_binding()) {
yaml << " upstream_port: " << port.inward_binding()->fqn() << '\n';
} else {
yaml << " upstream_port: null\n";
}
yaml << " downstream_ports: \n";
for (auto* const outward_binding : port.outward_bindings()) {
yaml << " - " << outward_binding->fqn() << '\n';
}
yaml << " trigger_of:\n";
for (auto* const trigger : port.triggers()) {
yaml << " - " << trigger->fqn() << '\n';
}
yaml << " source_of:\n";
for (auto* const dependency : port.dependencies()) {
if (port.triggers().find(dependency) == port.triggers().end()) {
yaml << " - " << dependency->fqn() << '\n';
}
}
yaml << " effect_of: " << '\n';
for (auto* const antidepencency : port.anti_dependencies()) {
yaml << " - " << antidepencency->fqn() << '\n';
}
}

void Environment::dump_reaction_to_yaml(std::ofstream& yaml, const Reaction& reaction) {
yaml << " - name: " << reaction.name() << '\n';
yaml << " priority: " << reaction.priority() << '\n';
yaml << " level: " << reaction.index() << '\n';
yaml << " triggers:\n";
for (auto* const trigger : reaction.action_triggers()) {
yaml << " - " << trigger->fqn() << '\n';
}
for (auto* const trigger : reaction.port_triggers()) {
yaml << " - " << trigger->fqn() << '\n';
}
yaml << " sources:\n";
for (auto* dependency : reaction.dependencies()) {
if (reaction.port_triggers().find(dependency) == reaction.port_triggers().end()) {
yaml << " - " << dependency->fqn() << '\n';
}
}
yaml << " effects:\n";
for (auto* const antidependency : reaction.antidependencies()) {
yaml << " - " << antidependency->fqn() << '\n';
}
for (auto* const scheduable_action : reaction.scheduable_actions()) {
yaml << " - " << scheduable_action->fqn() << '\n';
}
}

void Environment::dump_to_yaml(const std::string& path) {
std::ofstream yaml(path);
yaml << "---\n";
yaml << "top_level_instances:\n";
for (const auto* reactors : top_level_reactors_) {
yaml << " - " << reactors->fqn() << '\n';
}
yaml << "all_reactor_instances:\n";
for (const auto* reactors : top_level_reactors_) {
dump_instance_to_yaml(yaml, *reactors);
}
yaml << "reaction_dependencies:\n";
for (auto& iterator : dependencies_) {
yaml << " - from: " << iterator.first->fqn() << '\n';
yaml << " - to: " << iterator.second->fqn() << '\n';
}

log_.info() << "Program structure was dumped to " << path;
}

} // namespace reactor

0 comments on commit ae09ff1

Please sign in to comment.