From 1977f2e514c49ae6bdf411be9b08bc59be554a60 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Mon, 17 Nov 2003 00:14:50 +0000 Subject: [PATCH] =?utf8?q?=20*=20Simulador=20=3D=3D>=20Simulator=20fixed?= =?utf8?q?=20=20*=20El=20simulador=20levanta=20una=20planta=20de=20un=20XM?= =?utf8?q?L=20(no=20va=20a=20funcionar=20hasta=20que=20el=20XML=20=20=20?= =?utf8?q?=20este=20completo,=20con=20conexiones=20y=20todo)=20=20*=20Mode?= =?utf8?q?l=20:=20verifica=20en=20el=20configure=20que=20exista=20la=20lib?= =?utf8?q?xml2=20=20*=20Cambios=20de=20cara=20en=20el=20Cliente,=20se=20es?= =?utf8?q?cuchan=20las=20se=C3=B1ales=20"conected"=20y=20=20=20=20"finishe?= =?utf8?q?d"?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Client/include/principal.h | 4 + Client/src/client.glade | 388 +++++++++++++++++---- Client/src/principal.cpp | 50 ++- Model/configure.in | 3 + Model/include/{simulador.h => simulator.h} | 15 +- Model/src/Makefile.am | 2 +- Model/src/main.cpp | 20 +- Model/src/simulador.cpp | 135 ------- Model/src/simulator.cpp | 303 ++++++++++++++++ 9 files changed, 681 insertions(+), 239 deletions(-) rename Model/include/{simulador.h => simulator.h} (83%) delete mode 100644 Model/src/simulador.cpp create mode 100644 Model/src/simulator.cpp diff --git a/Client/include/principal.h b/Client/include/principal.h index f18735c..a6daef3 100644 --- a/Client/include/principal.h +++ b/Client/include/principal.h @@ -39,6 +39,8 @@ protected: Gtk::Entry *txt_target, *txt_command, *txt_args; Gtk::TextView *txt_view; Gtk::Fixed *work_place; + Gtk::Label *lbl_nombre, *lbl_color, *lbl_flujo; + Gtk::Image *ico_conected; // Callbacks del menu y la barra virtual void on_mnu_file_exit(); @@ -51,6 +53,8 @@ protected: virtual bool on_item_clicked(GdkEventButton *, ViewItem *); // Callbacks para las conexiones + void on_conexion_connected(); + void on_conexion_finished(); void on_conexion_ok(); void on_conexion_error(unsigned code); }; diff --git a/Client/src/client.glade b/Client/src/client.glade index abd0e25..f83c0cf 100644 --- a/Client/src/client.glade +++ b/Client/src/client.glade @@ -41,7 +41,7 @@ - + True gtk-execute 1 @@ -54,6 +54,27 @@ + + + True + _Desconectar + True + + + + + True + gtk-stop + 1 + 0.5 + 0.5 + 0 + 0 + + + + + True @@ -90,7 +111,7 @@ - + True gtk-properties 1 @@ -133,7 +154,7 @@ - + True gtk-dialog-info 1 @@ -158,48 +179,78 @@ - + True - GTK_SHADOW_OUT - GTK_POS_LEFT - GTK_POS_TOP + False + 0 - + True - GTK_ORIENTATION_HORIZONTAL - GTK_TOOLBAR_BOTH - True + GTK_SHADOW_OUT + GTK_POS_LEFT + GTK_POS_TOP - + True - Conectar - True - gtk-execute - - + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_BOTH + True - - - True - Desconectar - True - - + + + True + Conectar + True + gtk-execute + + - - - True - gtk-quit - True - True + + + True + Desconectar + True + + + + + + True + gtk-quit + True + True + + + True + + - - True - + + 0 + True + True + + + + + + True + gtk-no + 3 + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + @@ -452,57 +503,258 @@ - + True - 0 - 0.5 - GTK_SHADOW_ETCHED_IN + False + 0 - + True - True - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT + 0 + 0.5 + GTK_SHADOW_ETCHED_IN - + True - True - True - GTK_JUSTIFY_LEFT - GTK_WRAP_NONE - True - 0 - 0 - 0 - 0 - 0 - 0 - + 3 + 2 + False + 0 + 0 + + + + True + Nombre : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Flujo Actual : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Color : + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + ... + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + ... + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 1 + 2 + fill + + + + + + + True + ... + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 2 + 3 + fill + + + + + + + + + True + Propiedades : + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + label_item + + + 0 + False + True + - + True - Propiedades - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + + + + True + Log : + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + - label_item + 0 + True + True diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index 4250709..0538736 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -19,7 +19,9 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & 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); @@ -32,6 +34,7 @@ Principal::Principal(BaseObjectType *co, const Glib::RefPtr & 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)); @@ -52,29 +55,31 @@ Principal::~Principal() 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(); } @@ -123,11 +128,25 @@ void Principal::on_mnu_help_about() 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"); @@ -194,18 +213,10 @@ void Principal::on_mnu_prop() } 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) @@ -233,6 +244,8 @@ 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) @@ -261,7 +274,7 @@ 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) @@ -289,6 +302,8 @@ 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) @@ -316,6 +331,8 @@ 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) @@ -343,6 +360,8 @@ 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) @@ -370,4 +389,7 @@ 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; } + diff --git a/Model/configure.in b/Model/configure.in index db25a8f..05d0532 100644 --- a/Model/configure.in +++ b/Model/configure.in @@ -9,6 +9,9 @@ AC_PROG_CXX AM_PROG_CC_STDC AC_HEADER_STDC +PKG_CHECK_MODULES(PACKAGE, + xml2 >= 0.15.0 ) + AC_SUBST(PACKAGE_CFLAGS) AC_SUBST(PACKAGE_LIBS) diff --git a/Model/include/simulador.h b/Model/include/simulator.h similarity index 83% rename from Model/include/simulador.h rename to Model/include/simulator.h index 8f5713c..8fe8dab 100644 --- a/Model/include/simulador.h +++ b/Model/include/simulator.h @@ -13,14 +13,15 @@ #include "exclusa.h" #include "drainage.h" #include "iconector.h" +#include "libxml/parser.h" namespace PlaQui { namespace Model { -class Simulador { +class Simulator { public: - Simulador(); - ~Simulador(); + Simulator(const std::string &filename); + ~Simulator(); void add_pump(const std::string &name); void add_union(const std::string &name); @@ -62,6 +63,14 @@ protected: // Utilidades IConector *find(const std::string &name); + + // Carga del XML + void loadBomba(xmlNodePtr nodo); + void loadCodo(xmlNodePtr nodo); + void loadConduct(xmlNodePtr nodo); + void loadExclusa(xmlNodePtr nodo); + void loadTank(xmlNodePtr nodo); + void loadUnion(xmlNodePtr nodo); }; } diff --git a/Model/src/Makefile.am b/Model/src/Makefile.am index b848189..f687afc 100644 --- a/Model/src/Makefile.am +++ b/Model/src/Makefile.am @@ -6,7 +6,7 @@ INCLUDES = \ bin_PROGRAMS = plaqui-model -plaqui_model_SOURCES = main.cpp conduct.cpp control.cpp drainage.cpp drain.cpp exclusa.cpp iconector.cpp plantitem.cpp pump.cpp source.cpp splitter.cpp tank.cpp transport.cpp union.cpp simulador.cpp +plaqui_model_SOURCES = main.cpp conduct.cpp control.cpp drainage.cpp drain.cpp exclusa.cpp iconector.cpp plantitem.cpp pump.cpp source.cpp splitter.cpp tank.cpp transport.cpp union.cpp simulator.cpp plaqui_model_LDADD = @PACKAGE_LIBS@ diff --git a/Model/src/main.cpp b/Model/src/main.cpp index ab4f7f6..1151dcf 100644 --- a/Model/src/main.cpp +++ b/Model/src/main.cpp @@ -9,34 +9,18 @@ #include "exclusa.h" #include #include -#include "simulador.h" +#include "simulator.h" using namespace std; using namespace PlaQui::Model; int main(int argc, char *argv[]) { - Simulador *sim = new Simulador(); - - sim->add_pump("bomba1"); - sim->add_conduct("c"); - sim->add_conduct("c1"); - sim->add_drainage("d"); - sim->add_tank("tanque"); - - sim->connect("bomba1", "c", IConector::OUT); - sim->connect("c", "tanque", IConector::OUT); - sim->connect("tanque", "c1", IConector::OUT); - sim->connect("c1", "d", IConector::OUT); + Simulator *sim = new Simulator(argv[1]); int i=0; while (i<10) { sim->simulate(); - if (i == 4) { - if (!sim->pump_deactivate("bomba1")) { - std::cout << "c no es pump :-)" << std::endl; - } - } i++; } diff --git a/Model/src/simulador.cpp b/Model/src/simulador.cpp deleted file mode 100644 index 9128711..0000000 --- a/Model/src/simulador.cpp +++ /dev/null @@ -1,135 +0,0 @@ - -#include "simulador.h" - -using namespace PlaQui::Model; - -Simulador::Simulador() -{ -} - -Simulador::~Simulador() -{ - // FIXME REMOVER TODOOOOOO -} - -void Simulador::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 Simulador::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 Simulador::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 Simulador::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 Simulador::add_exclusa(const std::string &name) -{ - Exclusa *p = new Exclusa(name); - // FIXME no va!! - exclusa_lst.push_back(p); - items.push_back(p); -} - -void Simulador::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 Simulador::add_drainage(const std::string &name) -{ - Drainage *p = new Drainage(name); - // FIXME no va!! - drainage_lst.push_back(p); - items.push_back(p); -} - -bool Simulador::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 Simulador::simulate() -{ - // Actualizo - std::list::iterator i1; - for(i1=pump_lst.begin(); i1!=pump_lst.end(); i1++) - (*i1)->update(); - - // Simulo! - std::list::iterator i2; - for(i2=items.begin(); i2!=items.end(); i2++) - (*i2)->simulate(); -} - -IConector *Simulador::find(const std::string &name) -{ - // Busco el item, aca no me importa de que tipo es! - std::list::iterator i; - for(i=items.begin(); i!=items.end(); i++) - if ((*i)->get_name() == name) - return *i; - return NULL; -} - -bool Simulador::pump_deactivate(const std::string &name) -{ - // Busco el elemento, usando RTTI :-( - Pump *pump = dynamic_cast(find(name)); - - if (!pump) { - // Ups!, "name" no era un Pump!!! - return false; - } - pump->deactivate(); - return true; -} - diff --git a/Model/src/simulator.cpp b/Model/src/simulator.cpp new file mode 100644 index 0000000..c5eb381 --- /dev/null +++ b/Model/src/simulator.cpp @@ -0,0 +1,303 @@ + +#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::iterator i1; + for(i1=pump_lst.begin(); i1!=pump_lst.end(); i1++) + (*i1)->update(); + + // Simulo! + std::list::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::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(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); +} + -- 2.43.0