X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/24ac99bd21e4562a6ae028e0a84d8c09da07058b..bd2c5ebb465f2265d618feefb66479e5259dcfaa:/Model/src/exclusa.cpp diff --git a/Model/src/exclusa.cpp b/Model/src/exclusa.cpp index 89554f8..8e56006 100644 --- a/Model/src/exclusa.cpp +++ b/Model/src/exclusa.cpp @@ -12,14 +12,22 @@ Exclusa::Exclusa(const std::string &_name):Control(_name) input = new ByPass(); output = new ByPass(); ((ByPass *)output)->set_control(this); + updated = false; } Exclusa::~Exclusa() { + delete input; + delete output; } void Exclusa::update(int dir) { + std::list::iterator i = in_list.begin(); + if (i != in_list.end()) { + PlantItem *o = (PlantItem *)(*i); + set_color( o->get_color() ); + } // Primero me fijo si la entrada esta operando, es decir // si hay alguien conectado para automatizar. if (input->is_operational()) { @@ -31,18 +39,18 @@ void Exclusa::update(int dir) void Exclusa::simulate() { - std::list::iterator i = in_list.begin(); - if (i != in_list.end()) { - PlantItem *o = (PlantItem *)(*i); - set_color( o->get_color() ); - } +#ifdef DEBUG std::cout << name << ": " << ((is_open)?"Abierta":"Cerrada") << std::endl; +#endif } void Exclusa::recieve_msg(int msg, IConector *who, void *data) { switch (msg) { case MSG_QUERY_MAX_FLOW_OUT: + if (updated) { + who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &temp); + } temp = *((float *)data); if (!is_open) temp = 0; send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &temp);