X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/f031c89fa8a00ea12ff7290569ec507f44402458..6f70c17ffefd6150b68ac0f64a8116e730437408:/Model/src/pump.cpp?ds=inline diff --git a/Model/src/pump.cpp b/Model/src/pump.cpp index 78d4dcd..fb355a0 100644 --- a/Model/src/pump.cpp +++ b/Model/src/pump.cpp @@ -11,6 +11,9 @@ Pump::Pump(const std::string &_name):Source(_name),Control(_name) active = true; open = true; max_flow = actual_flow = 0.0f; + input = new ByPass(); + output = new ByPass(); + ((ByPass *)output)->set_control(this); } Pump::~Pump() @@ -20,18 +23,19 @@ Pump::~Pump() void Pump::update(int dir) { if (updated) return; + // Me fijo si me tengo que apagar automaticamente + open = input->get_output(); if (active && open) 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; std::cout << ((active && open)?" (funcionando)":" (apagada)") << std::endl; updated = false; } @@ -48,18 +52,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; @@ -69,3 +64,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; +} +