X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/0aacdcf95cf6d4f33a2201160d472ab84148d52b..5950ea0ec0352497042b368ba4e2d7d977391225:/Model/src/exclusa.cpp?ds=inline diff --git a/Model/src/exclusa.cpp b/Model/src/exclusa.cpp index 34b2fab..4253507 100644 --- a/Model/src/exclusa.cpp +++ b/Model/src/exclusa.cpp @@ -12,14 +12,19 @@ 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) { + if (updated) return; + // Primero me fijo si la entrada esta operando, es decir // si hay alguien conectado para automatizar. if (input->is_operational()) { @@ -27,26 +32,47 @@ void Exclusa::update(int dir) // mi estado is_open = input->get_output(); } + actual_flow = temp = INFINITO; } void Exclusa::simulate() { +#ifdef DEBUG std::cout << name << ": " << ((is_open)?"Abierta":"Cerrada") << std::endl; +#endif + + updated = false; + color_updated = false; } void Exclusa::recieve_msg(int msg, IConector *who, void *data) { switch (msg) { case MSG_QUERY_MAX_FLOW_OUT: - temp = *((float *)data); + if (updated) { + who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &temp); + } + actual_flow = temp = *((float *)data); + if (!is_open) actual_flow = temp = 0; + updated = true; send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &temp); who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &temp); break; case MSG_RESPONSE_MAX_FLOW: - temp = *((float *)data); + if (is_open) + actual_flow = temp = *((float *)data); break; default: Control::recieve_msg(msg, who, data); } } +void Exclusa::get_state_as_xml(std::stringstream &out) +{ + PlantItem::get_state_as_xml(out); + out << "\t" << std::endl; + out << "\t\t" << ((is_open)?"true":"false") << "" << std::endl; + out << "\t" << std::endl; + temp = actual_flow = INFINITO; +} +