X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/5885f9816965f487fd852a9ea46bbc580c48d317..db48e71a89861a755974c45ea7e7fd5d52de8afa:/Model/src/bomb.cpp diff --git a/Model/src/bomb.cpp b/Model/src/bomb.cpp index 9bae0a5..b9159a6 100644 --- a/Model/src/bomb.cpp +++ b/Model/src/bomb.cpp @@ -10,7 +10,7 @@ Bomb::Bomb(const std::string &_name):Source(_name) out_slots = 1; active = true; open = true; - max_flow = 1; + max_flow = actual_flow = 0.0f; } Bomb::~Bomb() @@ -20,13 +20,15 @@ Bomb::~Bomb() void Bomb::update() { if (updated) return; + actual_flow = 99999; updated = true; send_msg(OUT, MSG_QUERY_MAX_FLOW); } void Bomb::simulate() { - std::cout << name << "::Flujo entregado = " << (active && open)?max_flow:0; + std::cout << name << "::Flujo actual = " << ((active && open)?actual_flow:0) \ + << " de " << max_flow; std::cout << ((active && open)?" (funcionando)":" (apagada)") << std::endl; } @@ -46,12 +48,18 @@ void Bomb::recieve_msg(int msg, IConector *who, void *data) // Me preguntan por el flujo máximo. // Primero me actualizo, y luego respondo update(); - float tmp = (active && open)?max_flow:0; + float tmp; + if (active && open) { + tmp = (actual_flowrecieve_msg(MSG_RESPONSE_MAX_FLOW, this, &tmp); } break; case MSG_RESPONSE_MAX_FLOW: { - max_flow = *((float *)data); + float tmp = *((float *)data); + if (tmp < actual_flow) actual_flow = tmp; } break; default: