X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/a8803d96a8a33195ae9234b5e6ea84d7eefa0fd9..cc77948bedbd851e009ad3b8a421dea93c3ceeff:/Model/src/conduct.cpp?ds=sidebyside diff --git a/Model/src/conduct.cpp b/Model/src/conduct.cpp index 02fe3a6..e4a89d0 100644 --- a/Model/src/conduct.cpp +++ b/Model/src/conduct.cpp @@ -5,12 +5,13 @@ using namespace PlaQui::Model; Conduct::Conduct(const std::string &_name):Transport(_name) { - max_flow = actual_flow = 0.0f; + max_flow = 0.0f; // Inicio los parametros de conectores in_slots = 1; out_slots = 1; - actual_flow = 9999; + actual_flow = 99999; + updated = false; } Conduct::~Conduct() @@ -21,18 +22,19 @@ void Conduct::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 + updated = true; float tmp = *((float *)data); - // update(); actual_flow = (actual_flow>max_flow)?max_flow:actual_flow; actual_flow = (actual_flowrecieve_msg(MSG_RESPONSE_MAX_FLOW, this, &actual_flow); - updated = true; } break; case MSG_RESPONSE_MAX_FLOW: { @@ -51,34 +53,34 @@ void Conduct::recieve_msg(int msg, IConector *who, void *data) void Conduct::update(int dir) { // Si ya me actualice, no lo tengo que hacer de nuevo - if (updated) return; + if (updated) { + std::list::iterator i = in_list.begin(); + if (i != in_list.end()) { + PlantItem *o = (PlantItem *)(*i); + set_color( o->get_color() ); + } + return; + } // Seteo mi actualizar en true para evitar entrar de nuevo actual_flow = 99999; updated = true; - switch (dir) { - case IN: - send_msg(IN, MSG_QUERY_MAX_FLOW_IN, (void *)&max_flow); - break; - case OUT: - send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, (void *)&max_flow); - } + actual_flow = max_flow; + send_msg(OUT, MSG_QUERY_MAX_FLOW_OUT, (void *)&actual_flow); } void Conduct::simulate() { if (!updated) { +#ifdef DEBUG std::cout << name << "::sin actualizar!" << std::endl; +#endif return; } - std::cout << name << "::Flujo actual = " << actual_flow << std::endl; +#ifdef DEBUG + std::cout << name << "::Flujo actual = " << actual_flow << " de " << max_flow << std::endl; +#endif updated = false; } -void Conduct::get_state_as_xml(std::stringstream &out) -{ - out << "\t" << std::endl; - out << "\t\t" << actual_flow << "" << std::endl; - out << "\t" << std::endl; -}