X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/950f83d0e71dc886fcf5be9889796c5b2a85fa4c..fb8d2fb83534b0ca76f81e6d107e38d002642a46:/Model/src/splitter.cpp?ds=sidebyside diff --git a/Model/src/splitter.cpp b/Model/src/splitter.cpp index 4d4497e..c3ce1b4 100644 --- a/Model/src/splitter.cpp +++ b/Model/src/splitter.cpp @@ -9,6 +9,7 @@ Splitter::Splitter(const std::string &_name):Transport(_name) in_slots = 1; out_slots = 2; max_flow = actual_flow = 0.0f; + updated = true; } Splitter::~Splitter() @@ -27,6 +28,9 @@ void Splitter::recieve_msg(int msg, IConector *who, void *data) switch (msg) { case MSG_QUERY_MAX_FLOW_OUT: { + if (updated) { + who->recieve_msg(MSG_RESPONSE_MAX_FLOW, this, &actual_flow); + } // Me preguntan por el flujo máximo. // Primero me actualizo, y luego respondo actual_flow = *((float *)data); @@ -46,7 +50,9 @@ void Splitter::recieve_msg(int msg, IConector *who, void *data) break; case MSG_RESPONSE_MAX_FLOW: { float max = *((float *)data); +#ifdef DEBUG 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; @@ -83,7 +89,14 @@ void Splitter::simulate() return; } + std::list::iterator i = in_list.begin(); + if (i != in_list.end()) { + PlantItem *o = (PlantItem *)(*i); + set_color( o->get_color() ); + } +#ifdef DEBUG std::cout << name << "::Flujo actual = " << actual_flow << std::endl; +#endif updated = false; }