out_slots = 1;
active = true;
open = true;
- max_flow = 1;
+ max_flow = actual_flow = 0.0f;
}
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;
}
// 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_flow<max_flow)?actual_flow:max_flow;
+ } else {
+ tmp = 0.0f;
+ }
who->recieve_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: