X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/4c30f5939017e47c70f79df3a9f737d9ea743db5..025f50123cb4ffad9847ea588967314e6aec0567:/Model/src/splitter.cpp?ds=inline diff --git a/Model/src/splitter.cpp b/Model/src/splitter.cpp index 140bf7e..38742f6 100644 --- a/Model/src/splitter.cpp +++ b/Model/src/splitter.cpp @@ -10,6 +10,7 @@ Splitter::Splitter(const std::string &_name):Transport(_name) out_slots = 2; max_flow = actual_flow = 0.0f; updated = true; + out_on_zero = out_ready = 0; } Splitter::~Splitter() @@ -37,7 +38,8 @@ void Splitter::recieve_msg(int msg, IConector *who, void *data) if (max_flow < actual_flow) actual_flow = max_flow; - actual_flow /= 2.0f; + if (out_on_zero == 0) + actual_flow /= 2.0f; send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, &actual_flow); @@ -54,8 +56,22 @@ void Splitter::recieve_msg(int msg, IConector *who, void *data) std::cout << name << ":Split " << max << std::endl; #endif if (pos == OUT) { - if (max < actual_flow) actual_flow = max; - if (max_flow < actual_flow) actual_flow = max_flow; + if (max == 0) { + out_on_zero++; + switch (out_on_zero) { + case 1: + if (out_ready == 0) { + actual_flow = max_flow; + } + break; + case 2: + actual_flow = 0.0; + } + } else { + if (max < actual_flow) actual_flow = max; + if (max_flow < actual_flow) actual_flow = max_flow; + } + out_ready++; } else { if (((2*max) < actual_flow) && (max != 0)) actual_flow = 2*max; @@ -72,7 +88,7 @@ void Splitter::update(int dir) // Si ya me actualice, no lo tengo que hacer de nuevo if (updated) return; // Seteo mi actualizar en true para evitar entrar de nuevo - actual_flow = 99999; + actual_flow = INFINITO; updated = true; switch (dir) { case IN: @@ -94,5 +110,6 @@ void Splitter::simulate() #endif updated = false; color_updated = false; + out_on_zero = out_ready = 0; }