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<Pump *>(find(name));
-
- if (!pump) {
- // Ups!, "name" no era un Pump!!!
+ IConector *tmp = find(name);
+ Pump *p;
+ Exclusa *e;
+ if ((p = dynamic_cast<Pump*>(tmp))) {
+ if (open) {
+ p->activate();
+ } else {
+ p->deactivate();
+ }
+ } else if ((e = dynamic_cast<Exclusa*>(tmp))) {
+ if (open) {
+ e->open();
+ } else {
+ e->close();
+ }
+ } else {
return false;
}
- pump->deactivate();
- return true;
}
void Simulator::loadBomba(xmlNodePtr nodo)