X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/63715b9ec8f3b126b4e495a4c4485cd68fd6973a..7e74b790d290cd7d776349503bb361c47933c01f:/Model/src/simulator.cpp diff --git a/Model/src/simulator.cpp b/Model/src/simulator.cpp index 2d763fe..3aeacd6 100644 --- a/Model/src/simulator.cpp +++ b/Model/src/simulator.cpp @@ -158,17 +158,27 @@ IConector *Simulator::find(const std::string &name) return NULL; } -bool Simulator::pump_deactivate(const std::string &name) +bool Simulator::set_open(const std::string &name, bool open) { // Busco el elemento, usando RTTI :-( - Pump *pump = dynamic_cast(find(name)); - - if (!pump) { - // Ups!, "name" no era un Pump!!! + IConector *tmp = find(name); + Pump *p; + Exclusa *e; + if ((p = dynamic_cast(tmp))) { + if (open) { + p->activate(); + } else { + p->deactivate(); + } + } else if ((e = dynamic_cast(tmp))) { + if (open) { + e->open(); + } else { + e->close(); + } + } else { return false; } - pump->deactivate(); - return true; } void Simulator::loadBomba(xmlNodePtr nodo)