<signal name="activate" handler="on_mnu_conectar_activate" last_modification_time="Thu, 16 Oct 2003 00:50:14 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image4">
+ <widget class="GtkImage" id="image11">
<property name="visible">True</property>
<property name="stock">gtk-execute</property>
<property name="icon_size">1</property>
</widget>
</child>
+ <child>
+ <widget class="GtkImageMenuItem" id="mnu_file_disconnect">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Desconectar</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_mnu_file_disconnect_activate" last_modification_time="Sun, 16 Nov 2003 22:40:50 GMT"/>
+
+ <child internal-child="image">
+ <widget class="GtkImage" id="image12">
+ <property name="visible">True</property>
+ <property name="stock">gtk-stop</property>
+ <property name="icon_size">1</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
<child>
<widget class="GtkMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
<signal name="activate" handler="on_propiedades1_activate" last_modification_time="Thu, 16 Oct 2003 01:17:27 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image5">
+ <widget class="GtkImage" id="image13">
<property name="visible">True</property>
<property name="stock">gtk-properties</property>
<property name="icon_size">1</property>
<signal name="activate" handler="on_mnu_help_about_activate" last_modification_time="Thu, 16 Oct 2003 18:02:46 GMT"/>
<child internal-child="image">
- <widget class="GtkImage" id="image6">
+ <widget class="GtkImage" id="image14">
<property name="visible">True</property>
<property name="stock">gtk-dialog-info</property>
<property name="icon_size">1</property>
</child>
<child>
- <widget class="GtkHandleBox" id="handlebox1">
+ <widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
- <property name="shadow_type">GTK_SHADOW_OUT</property>
- <property name="handle_position">GTK_POS_LEFT</property>
- <property name="snap_edge">GTK_POS_TOP</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
<child>
- <widget class="GtkToolbar" id="toolbar1">
+ <widget class="GtkHandleBox" id="handlebox1">
<property name="visible">True</property>
- <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
- <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
- <property name="tooltips">True</property>
+ <property name="shadow_type">GTK_SHADOW_OUT</property>
+ <property name="handle_position">GTK_POS_LEFT</property>
+ <property name="snap_edge">GTK_POS_TOP</property>
<child>
- <widget class="button" id="bar_connect">
+ <widget class="GtkToolbar" id="toolbar1">
<property name="visible">True</property>
- <property name="label" translatable="yes">Conectar</property>
- <property name="use_underline">True</property>
- <property name="stock_pixmap">gtk-execute</property>
- </widget>
- </child>
+ <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+ <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
+ <property name="tooltips">True</property>
- <child>
- <widget class="button" id="bar_disconect">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Desconectar</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
+ <child>
+ <widget class="button" id="bar_connect">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Conectar</property>
+ <property name="use_underline">True</property>
+ <property name="stock_pixmap">gtk-execute</property>
+ </widget>
+ </child>
- <child>
- <widget class="button" id="bar_exit">
- <property name="visible">True</property>
- <property name="label">gtk-quit</property>
- <property name="use_stock">True</property>
- <property name="new_group">True</property>
+ <child>
+ <widget class="button" id="bar_disconect">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Desconectar</property>
+ <property name="use_underline">True</property>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="button" id="bar_exit">
+ <property name="visible">True</property>
+ <property name="label">gtk-quit</property>
+ <property name="use_stock">True</property>
+ <property name="new_group">True</property>
+ </widget>
+ <packing>
+ <property name="new_group">True</property>
+ </packing>
+ </child>
</widget>
- <packing>
- <property name="new_group">True</property>
- </packing>
</child>
</widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkImage" id="ico_conected">
+ <property name="visible">True</property>
+ <property name="stock">gtk-no</property>
+ <property name="icon_size">3</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
</child>
</widget>
<packing>
</child>
<child>
- <widget class="GtkFrame" id="frame3">
+ <widget class="GtkVBox" id="vbox3">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="label_yalign">0.5</property>
- <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
<child>
- <widget class="GtkScrolledWindow" id="scrolledwindow3">
+ <widget class="GtkFrame" id="frame3">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0.5</property>
+ <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<child>
- <widget class="GtkTextView" id="txt_view">
+ <widget class="GtkTable" id="table3">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="justification">GTK_JUSTIFY_LEFT</property>
- <property name="wrap_mode">GTK_WRAP_NONE</property>
- <property name="cursor_visible">True</property>
- <property name="pixels_above_lines">0</property>
- <property name="pixels_below_lines">0</property>
- <property name="pixels_inside_wrap">0</property>
- <property name="left_margin">0</property>
- <property name="right_margin">0</property>
- <property name="indent">0</property>
- <property name="text" translatable="yes"></property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="homogeneous">False</property>
+ <property name="row_spacing">0</property>
+ <property name="column_spacing">0</property>
+
+ <child>
+ <widget class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Nombre : </property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label20">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Flujo Actual : </property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label21">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Color : </property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="right_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lbl_nombre">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="bottom_attach">1</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lbl_flujo">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="lbl_color">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">...</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">fill</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label17">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Propiedades :</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
</widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
</child>
</widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
</child>
<child>
- <widget class="GtkLabel" id="label3">
+ <widget class="GtkFrame" id="frame4">
<property name="visible">True</property>
- <property name="label" translatable="yes">Propiedades</property>
- <property name="use_underline">False</property>
- <property name="use_markup">False</property>
- <property name="justify">GTK_JUSTIFY_LEFT</property>
- <property name="wrap">False</property>
- <property name="selectable">False</property>
- <property name="xalign">0.5</property>
- <property name="yalign">0.5</property>
- <property name="xpad">0</property>
- <property name="ypad">0</property>
+ <property name="label_xalign">0</property>
+ <property name="label_yalign">0.5</property>
+ <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
+ <property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTextView" id="txt_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="editable">True</property>
+ <property name="justification">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap_mode">GTK_WRAP_NONE</property>
+ <property name="cursor_visible">True</property>
+ <property name="pixels_above_lines">0</property>
+ <property name="pixels_below_lines">0</property>
+ <property name="pixels_inside_wrap">0</property>
+ <property name="left_margin">0</property>
+ <property name="right_margin">0</property>
+ <property name="indent">0</property>
+ <property name="text" translatable="yes"></property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label18">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Log : </property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
</widget>
<packing>
- <property name="type">label_item</property>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
</packing>
</child>
</widget>
txt_view = 0;
txt_target = txt_command = txt_args = 0;
work_place = 0;
+ lbl_nombre = lbl_color = lbl_flujo = 0;
+ rg->get_widget("lbl_nombre", lbl_nombre);
rg->get_widget("mnu_file_connect", conect);
rg->get_widget("mnu_file_exit", exit);
rg->get_widget("mnu_help_about", about);
rg->get_widget("txt_args", txt_args);
rg->get_widget("bar_connect", bar_connect);
rg->get_widget("work_place", work_place);
+ rg->get_widget("ico_conected", ico_conected);
dlg_conectar->get_ok_button()->signal_clicked().connect( SigC::slot(*this, &Principal::on_dlg_connect_ok) );
mnu_prop->signal_activate().connect( SigC::slot(*this, &Principal::on_mnu_prop));
void Principal::on_dlg_connect_ok()
{
if (conexion == NULL) {
- std::cout << "Conectando ..." << std::endl;
// Creo la conexion
try {
conexion = new PlaQui::Server::ControlClient(dlg_conectar->get_server_name(), dlg_conectar->get_server_port());
}
catch (...) {
txt_view->get_buffer()->insert_at_cursor("NO SE PUDO CREAR OBJETO\n");
+ delete conexion;
+ conexion == NULL;
return;
}
// Conecto las señales
conexion->signal_ok_received().connect( SigC::slot(*this, &Principal::on_conexion_ok) );
conexion->signal_error_received().connect( SigC::slot(*this, &Principal::on_conexion_error) );
+ conexion->signal_connected().connect( SigC::slot(*this, &Principal::on_conexion_connected) );
+ conexion->signal_finished().connect( SigC::slot(*this, &Principal::on_conexion_finished) );
// Lanzo la conexion!
- //
try {
conexion->run();
}
catch (...) {
- txt_view->get_buffer()->insert_at_cursor("no se puede correr ->run()!!!\n");
+ txt_view->get_buffer()->insert_at_cursor("no se puede correr conexion->run()!!!\n");
}
} else {
- std::cout << "Ya estas conectado" << std::endl;
+ txt_view->get_buffer()->insert_at_cursor("YA ESTAS CONECTADO\n");
}
dlg_conectar->hide();
}
bool Principal::on_item_clicked(GdkEventButton *e, ViewItem *i)
{
- txt_view->get_buffer()->insert_at_cursor("Item : ");
+ lbl_nombre->set_text(i->get_name());
+ txt_view->get_buffer()->insert_at_cursor("Selecciono ");
txt_view->get_buffer()->insert_at_cursor(i->get_name());
txt_view->get_buffer()->insert_at_cursor("\n");
}
+void Principal::on_conexion_connected()
+{
+ txt_view->get_buffer()->insert_at_cursor("CONNECTED\n");
+ ico_conected->set( Gtk::Stock::YES , Gtk::IconSize(Gtk::ICON_SIZE_LARGE_TOOLBAR));
+}
+
+void Principal::on_conexion_finished()
+{
+ txt_view->get_buffer()->insert_at_cursor("HANG UP\n");
+ ico_conected->set( Gtk::Stock::NO , Gtk::IconSize(Gtk::ICON_SIZE_LARGE_TOOLBAR));
+ conexion = NULL;
+}
+
void Principal::on_conexion_ok()
{
txt_view->get_buffer()->insert_at_cursor("El server dice que ta' todo ok!\n");
} else if (xmlStrcmp(items->name, BAD_CAST"empalme")==0) {
loadUnion(items);
}
-
-
-
}
items = items->next;
}
- } else {
- printf("NO ES UNA PLANTA\n");
}
-
-
- printf("Fin parseo!!\n");
}
void Principal::loadBomba(xmlNodePtr nodo)
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
+ // los agrego al hash
+ mapItems[name] = b;
}
void Principal::loadCodo(xmlNodePtr nodo)
work_place->put(*b, x, y);
b->show();
// los agrego al hash
- //mapItems.insert(name, b);
+ mapItems[name] = b;
}
void Principal::loadConduct(xmlNodePtr nodo)
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
+ // los agrego al hash
+ mapItems[name] = b;
}
void Principal::loadExclusa(xmlNodePtr nodo)
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
+ // los agrego al hash
+ mapItems[name] = b;
}
void Principal::loadTank(xmlNodePtr nodo)
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
+ // los agrego al hash
+ mapItems[name] = b;
}
void Principal::loadUnion(xmlNodePtr nodo)
b->set_position(x,y);
work_place->put(*b, x, y);
b->show();
+ // los agrego al hash
+ mapItems[name] = b;
}
+
--- /dev/null
+
+#include "simulator.h"
+
+using namespace PlaQui::Model;
+
+Simulator::Simulator(const std::string &filename)
+{
+ /* Parseo de ejemplo de un XML desde archivo */
+ xmlDocPtr document;
+ document = xmlParseFile(filename.c_str());
+ if (document == NULL) {
+ return;
+ }
+
+ /* bien, el archivo se parseo bien! */
+ xmlNodePtr nodo, items;
+ nodo = document->children;
+
+ if (strcmp((char *)nodo->name, "planta") == 0) {
+ items = nodo->children;
+ while (items != NULL) {
+ if (items->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(items->name, BAD_CAST"bomba")==0) {
+ loadBomba(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"codo")==0) {
+ loadCodo(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"tubo")==0) {
+ loadConduct(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"exclusa")==0) {
+ loadExclusa(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"tanque")==0) {
+ loadTank(items);
+ } else if (xmlStrcmp(items->name, BAD_CAST"empalme")==0) {
+ loadUnion(items);
+ }
+ }
+ items = items->next;
+ }
+ }
+}
+
+Simulator::~Simulator()
+{
+ // FIXME REMOVER TODOOOOOO
+}
+
+void Simulator::add_pump(const std::string &name)
+{
+ Pump *p = new Pump(name);
+ // FIXME no va!!
+ p->set_max_flow(5);
+ pump_lst.push_back(p);
+ items.push_back(p);
+}
+
+void Simulator::add_union(const std::string &name)
+{
+ Union *u = new Union(name);
+ // FIXME no va!!
+ u->set_max_flow(5);
+ union_lst.push_back(u);
+ items.push_back(u);
+}
+
+void Simulator::add_splitter(const std::string &name)
+{
+ Splitter *p = new Splitter(name);
+ // FIXME no va!!
+ p->set_max_flow(5);
+ split_lst.push_back(p);
+ items.push_back(p);
+}
+
+void Simulator::add_conduct(const std::string &name)
+{
+ Conduct *p = new Conduct(name);
+ // FIXME no va!!
+ p->set_max_flow(5);
+ conduct_lst.push_back(p);
+ items.push_back(p);
+}
+
+void Simulator::add_exclusa(const std::string &name)
+{
+ Exclusa *p = new Exclusa(name);
+ // FIXME no va!!
+ exclusa_lst.push_back(p);
+ items.push_back(p);
+}
+
+void Simulator::add_tank(const std::string &name)
+{
+ Tank *p = new Tank(name);
+ p->set_capacity(100);
+ p->set_max_flow(10);
+ p->set_litros(10);
+ tank_lst.push_back(p);
+ items.push_back(p);
+}
+
+void Simulator::add_drainage(const std::string &name)
+{
+ Drainage *p = new Drainage(name);
+ // FIXME no va!!
+ drainage_lst.push_back(p);
+ items.push_back(p);
+}
+
+bool Simulator::connect(const std::string &name1, const std::string &name2, int flag)
+{
+ IConector *o1, *o2;
+ o1 = find(name1);
+ o2 = find(name2);
+
+ if ((o1 == NULL) || (o2 == NULL)) {
+ // NO SE PUDO CONECTAR!, FALTAN ITEMS!!
+ return false;
+ }
+
+ bool b;
+ if (flag == IConector::OUT) {
+ b = o1->connect(o2, IConector::OUT);
+ b = b && o2->connect(o1, IConector::IN);
+ } else {
+ b = o1->connect(o2, IConector::IN);
+ b = b && o2->connect(o1, IConector::OUT);
+ }
+
+ return b;
+}
+
+void Simulator::simulate()
+{
+ // Actualizo
+ std::list<Pump *>::iterator i1;
+ for(i1=pump_lst.begin(); i1!=pump_lst.end(); i1++)
+ (*i1)->update();
+
+ // Simulo!
+ std::list<PlantItem *>::iterator i2;
+ for(i2=items.begin(); i2!=items.end(); i2++)
+ (*i2)->simulate();
+}
+
+IConector *Simulator::find(const std::string &name)
+{
+ // Busco el item, aca no me importa de que tipo es!
+ std::list<PlantItem *>::iterator i;
+ for(i=items.begin(); i!=items.end(); i++)
+ if ((*i)->get_name() == name)
+ return *i;
+ return NULL;
+}
+
+bool Simulator::pump_deactivate(const std::string &name)
+{
+ // Busco el elemento, usando RTTI :-(
+ Pump *pump = dynamic_cast<Pump *>(find(name));
+
+ if (!pump) {
+ // Ups!, "name" no era un Pump!!!
+ return false;
+ }
+ pump->deactivate();
+ return true;
+}
+
+void Simulator::loadBomba(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ int orientacion=0, x, y;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ add_pump(name);
+}
+
+void Simulator::loadCodo(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ int orientacion=0, x, y;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ add_conduct(name);
+}
+
+void Simulator::loadConduct(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ int orientacion=0, x, y;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ add_conduct(name);
+}
+
+void Simulator::loadExclusa(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ int orientacion=0, x, y;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ add_exclusa(name);
+}
+
+void Simulator::loadTank(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ int orientacion=0, x, y;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ add_tank(name);
+}
+
+void Simulator::loadUnion(xmlNodePtr nodo)
+{
+ std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
+ int orientacion=0, x, y;
+
+ nodo = nodo->children;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
+ orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
+ x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
+ y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ }
+ nodo = nodo->next;
+ }
+
+ // listo, ya recolecte todos los datos, ahora creo el objeto!
+ add_union(name);
+}
+