From: Ricardo Markiewicz Date: Thu, 23 Oct 2003 19:57:22 +0000 (+0000) Subject: - Se corrige la bomba para que tenga mas informacion sobre el flujo maximo y X-Git-Tag: svn_import~371 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/db48e71a89861a755974c45ea7e7fd5d52de8afa?ds=inline - Se corrige la bomba para que tenga mas informacion sobre el flujo maximo y actual. - El ejemplo es completamente funcional y si se cambia algun valor los flujos siguen dando bien actualizados :-) - Se pone al dia el diagrama de clases --- diff --git a/Constructor/constructor.cpp b/Constructor/constructor.cpp index 449e7c3..98f6ab9 100644 --- a/Constructor/constructor.cpp +++ b/Constructor/constructor.cpp @@ -82,12 +82,7 @@ void Constructor::on_item_drag_begin(const Glib::RefPtr& conte void Constructor::on_item_drag_data_get(const Glib::RefPtr& context, GtkSelectionData* selection_data, guint info, guint time) { - if ( strcmp((const char *)selection_data->data,"item_codo.png")==0) - gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_codo.png", 13); - if ( strcmp((const char *)selection_data->data,"item_canio.png")==0) - gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_canio.png", 14); - if ( strcmp((const char *)selection_data->data,"item_y.png")==0) - gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_y.png", 10); + gtk_selection_data_set (selection_data, selection_data->target, 10, (const guchar*)"item_codo.png", 13); } void Constructor::on_item_drop_drag_received(const Glib::RefPtr& context, int x, int y, GtkSelectionData* selection_data, guint info, guint time) diff --git a/Model/include/source.h b/Model/include/source.h index 48a9a12..41a7266 100644 --- a/Model/include/source.h +++ b/Model/include/source.h @@ -17,8 +17,12 @@ public: virtual bool get_output(); virtual void simulate(); + float get_actual_flow() { return actual_flow; } + float get_max_flow() { return max_flow; } + void set_max_flow(float _f) { max_flow = _f; } protected: float max_flow; + float actual_flow; private: Source(const Source &):Control("null") {} Source &operator = (const Source &) { return *this; } 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: diff --git a/Model/src/main.cpp b/Model/src/main.cpp index 2b4e5a9..237e158 100644 --- a/Model/src/main.cpp +++ b/Model/src/main.cpp @@ -15,6 +15,7 @@ int main(int argc, char *argv[]) Conduct *canio2; bomba = new Bomb("bomba"); + bomba->set_max_flow(3); canio1 = new Conduct("cond_1"); canio1->set_max_flow(10); canio2 = new Conduct("cond_2"); diff --git a/docs/clases.dia b/docs/clases.dia index d05f6f7..8ac7176 100644 Binary files a/docs/clases.dia and b/docs/clases.dia differ