X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/f7e6ba4976cdafcb4aa3e39b03539d5a3d12f6a4..fb8d2fb83534b0ca76f81e6d107e38d002642a46:/Model/src/pump.cpp diff --git a/Model/src/pump.cpp b/Model/src/pump.cpp index 7f1ace4..d42bc58 100644 --- a/Model/src/pump.cpp +++ b/Model/src/pump.cpp @@ -18,6 +18,8 @@ Pump::Pump(const std::string &_name):Source(_name),Control(_name) Pump::~Pump() { + delete input; + delete output; } void Pump::update(int dir) @@ -29,15 +31,16 @@ void Pump::update(int dir) actual_flow = max_flow; else actual_flow = 0; - updated = true; + send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, (void *)&actual_flow); + updated = true; } void Pump::simulate() { - std::cout << name << "::Flujo actual = " << ((active && open)?actual_flow:0) \ - << " de " << max_flow; +#ifdef DEBUG std::cout << ((active && open)?" (funcionando)":" (apagada)") << std::endl; +#endif updated = false; } @@ -53,18 +56,9 @@ bool Pump::get_output() void Pump::recieve_msg(int msg, IConector *who, void *data) { switch (msg) { - case MSG_QUERY_MAX_FLOW_OUT: { - // Me preguntan por el flujo máximo. - // Primero me actualizo, y luego respondo - // TODO la bomba nunca deberia ser consultada,pues el flujo sale ella - /* update(); - float tmp; - tmp = (actual_flowrecieve_msg(MSG_RESPONSE_MAX_FLOW, this, &tmp);*/ - } - break; case MSG_RESPONSE_MAX_FLOW: { float tmp = *((float *)data); + if (max_flow < tmp) tmp = max_flow; if (tmp < actual_flow) actual_flow = tmp; } break; @@ -74,3 +68,14 @@ void Pump::recieve_msg(int msg, IConector *who, void *data) } +void Pump::get_state_as_xml(std::stringstream &out) +{ + // Saco el item basico por XML + PlantItem::get_state_as_xml(out); + + // Saco lo importante de este item + out << "\t" << std::endl; + out << "\t\t" << ((open&&active)?"true":"false") << "" << std::endl; + out << "\t" << std::endl; +} +