From db48e71a89861a755974c45ea7e7fd5d52de8afa Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Thu, 23 Oct 2003 19:57:22 +0000 Subject: [PATCH] - 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 --- Constructor/constructor.cpp | 7 +------ Model/include/source.h | 4 ++++ Model/src/bomb.cpp | 16 ++++++++++++---- Model/src/main.cpp | 1 + docs/clases.dia | Bin 4161 -> 4166 bytes 5 files changed, 18 insertions(+), 10 deletions(-) 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 d05f6f79ecfad75ad405dce018d60732b65a1b6c..8ac71763db207fed6ed11b5b777c56787d4f9715 100644 GIT binary patch literal 4166 zcmV-M5V`LkiwFP!000001MOXHZ{s!+{@!09xIjM~vWzI|wQja((`!*+uPwT}pNhg@ zEXH9gi(b9#ZVtu$_9G?P$$Di)lxbT@X3-{gN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