X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/be1908f8097dbbc871bfd7c55432de43d25647b7..dafb509182bac9b314202fe7dfaf58206da5ccbe:/Model/src/simulator.cpp diff --git a/Model/src/simulator.cpp b/Model/src/simulator.cpp index 72c59ca..b6a77d3 100644 --- a/Model/src/simulator.cpp +++ b/Model/src/simulator.cpp @@ -11,6 +11,7 @@ Simulator::Simulator(const std::string &filename) document = xmlParseFile(filename.c_str()); if (document == NULL) { is_load_ok = false; + std::cout << "Error cargando XML" << std::endl; return; } @@ -149,9 +150,11 @@ void Simulator::simulate() 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++) + for(i2=items.begin(); i2!=items.end(); i2++) + (*i2)->update(); + + for(i2=items.begin(); i2!=items.end(); i2++) (*i2)->simulate(); frame++; @@ -355,6 +358,7 @@ void Simulator::do_connections(xmlNodePtr nodo) continue; } // obtengo el items actual por su nombre + std::string s = (char *)xmlGetProp(nodo, BAD_CAST"nombre"); current_item = find((char *)xmlGetProp(nodo, BAD_CAST"nombre")); props = nodo->children; conector3 = conector2 = conector1 = NULL; @@ -397,11 +401,19 @@ void Simulator::do_connections(xmlNodePtr nodo) // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar to_connect = find((char *)XML_GET_CONTENT(conector1->children)); // y lo conecto - current_item->connect(to_connect, IConector::IN); + if (!current_item->connect(to_connect, IConector::IN)) { + std::cout << s << " Error al conectar1 ENTRADA = " << (char *)XML_GET_CONTENT(conector1->children) << std::endl; + } else { + std::cout << s << " ENTRADA1 = " << (char *)XML_GET_CONTENT(conector1->children) << std::endl; + } } else if (xmlStrcmp(conector1->name, BAD_CAST"salida") == 0) { // Era a salida, es casi lo mismo que arriba to_connect = find((char *)XML_GET_CONTENT(conector1->children)); - current_item->connect(to_connect, IConector::OUT); + if (!current_item->connect(to_connect, IConector::OUT)) { + std::cout << s << " Error al conectar2 SALIDA" << std::endl; + } else { + std::cout << s << " SALIDA1 = " << (char *)XML_GET_CONTENT(conector1->children) << std::endl; + } } } if (conector2 != NULL) { @@ -410,11 +422,17 @@ void Simulator::do_connections(xmlNodePtr nodo) // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar to_connect = find((char *)XML_GET_CONTENT(conector2->children)); // y lo conecto - current_item->connect(to_connect, IConector::IN); + if (!current_item->connect(to_connect, IConector::IN)) { + std::cout << s << " Error al conectar2 ENTRADA = " << (char *)XML_GET_CONTENT(conector2->children) << std::endl; + } else { + std::cout << s << " ENTRADA2 = " << (char *)XML_GET_CONTENT(conector2->children) << std::endl; + } } else if (xmlStrcmp(conector2->name, BAD_CAST"salida") == 0) { // Era a salida, es casi lo mismo que arriba to_connect = find((char *)XML_GET_CONTENT(conector2->children)); - current_item->connect(to_connect, IConector::OUT); + if (!current_item->connect(to_connect, IConector::OUT)) { + std::cout << s << " Error al conectar " << std::endl; + } } } if (conector3 != NULL) { @@ -423,11 +441,15 @@ void Simulator::do_connections(xmlNodePtr nodo) // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar to_connect = find((char *)XML_GET_CONTENT(conector3->children)); // y lo conecto - current_item->connect(to_connect, IConector::IN); + if (!current_item->connect(to_connect, IConector::IN)) { + std::cout << s << " Error al conectar " << std::endl; + } } else if (xmlStrcmp(conector3->name, BAD_CAST"salida") == 0) { // Era a salida, es casi lo mismo que arriba to_connect = find((char *)XML_GET_CONTENT(conector3->children)); - current_item->connect(to_connect, IConector::OUT); + if (!current_item->connect(to_connect, IConector::OUT)) { + std::cout << s << " Error al conectar " << std::endl; + } } } nodo = nodo->next;