]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blob - Model/src/simulator.cpp
despues de estar como un pelotudo buscando el error, lo encontre, era un == ( yo...
[z.facultad/75.42/plaqui.git] / Model / src / simulator.cpp
1
2 #include "simulator.h"
3
4 using namespace PlaQui::Model;
5
6 Simulator::Simulator(const std::string &filename)
7 {
8         frame = 0;
9         /* Parseo de ejemplo de un XML desde archivo */
10         xmlDocPtr document;
11         document = xmlParseFile(filename.c_str());
12         if (document == NULL) {
13                 is_load_ok = false;
14                 std::cout << "Error cargando XML" << std::endl;
15                 return;
16         }
17
18         is_load_ok = true;
19
20         /* bien, el archivo se parseo bien! */
21         xmlNodePtr nodo, items;
22         nodo = document->children;
23
24         if (strcmp((char *)nodo->name, "planta") == 0) {
25                 items = nodo->children;
26                 while (items != NULL) {
27                         if (items->type == XML_ELEMENT_NODE) {
28                                 if (xmlStrcmp(items->name, BAD_CAST"bomba")==0) {
29                                         loadBomba(items);
30                                 } else if ((xmlStrcmp(items->name, BAD_CAST"tubo")==0)||(xmlStrcmp(items->name, BAD_CAST"codo")==0)) {
31                                         loadConduct(items);
32                                 } else if (xmlStrcmp(items->name, BAD_CAST"exclusa")==0) {
33                                         loadExclusa(items);
34                                 } else if (xmlStrcmp(items->name, BAD_CAST"tanque")==0) {
35                                         loadTank(items);
36                                 } else if (xmlStrcmp(items->name, BAD_CAST"empalme")==0) {
37                                         loadUnion(items);
38                                 } else if (xmlStrcmp(items->name, BAD_CAST"drenaje")==0) {
39                                         loadDrain(items);
40                                 } else if (xmlStrcmp(items->name, BAD_CAST"and")==0) {
41                                         loadAnd(items);
42                                 } else if (xmlStrcmp(items->name, BAD_CAST"or")==0) {
43                                         loadOr(items);
44                                 } else if (xmlStrcmp(items->name, BAD_CAST"not")==0) {
45                                         loadNot(items);
46                                 }
47                         }
48                         items = items->next;
49                 }
50                 // Bien, la planta esta cargada, conectemos todo!!
51                 do_connections(nodo->children);
52                 do_logic_connetions(nodo->children);
53         }
54         xmlFreeDoc(document);
55 }
56
57 Simulator::~Simulator()
58 {
59         std::list<PlantItem *>::iterator i = items.begin();
60         PlantItem *o;
61
62         while (i != items.end()) {
63                 o = (*i);
64                 items.remove(o);
65                 delete o;
66                 i = items.begin();
67         }
68 }
69
70 void Simulator::add_pump(const std::string &name, float max_flow, RGB color)
71 {
72         Pump *p = new Pump(name);
73         p->set_max_flow(max_flow);
74         p->set_color(color);
75         pump_lst.push_back(p);
76         items.push_back(p);
77 }
78
79 void Simulator::add_union(const std::string &name, float max_flow)
80 {
81         Union *u = new Union(name);
82         u->set_max_flow(max_flow);
83         union_lst.push_back(u);
84         items.push_back(u);
85 }
86
87 void Simulator::add_splitter(const std::string &name, float max_flow)
88 {
89         Splitter *p = new Splitter(name);
90         p->set_max_flow(max_flow);
91         split_lst.push_back(p);
92         items.push_back(p);
93 }
94
95 void Simulator::add_conduct(const std::string &name, float flujo)
96 {
97         Conduct *p = new Conduct(name);
98         p->set_max_flow(flujo);
99         conduct_lst.push_back(p);
100         items.push_back(p);
101 }
102
103 void Simulator::add_exclusa(const std::string &name, bool open)
104 {
105         Exclusa *p = new Exclusa(name);
106         if (!open)
107                 p->close();
108         exclusa_lst.push_back(p);
109         items.push_back(p);
110 }
111
112 void Simulator::add_tank(const std::string &name, float capacity, float initial, RGB color)
113 {
114         Tank *p = new Tank(name);
115         p->set_capacity(capacity);
116         p->set_max_flow(initial);
117         p->set_litros(initial);
118         p->set_color(color);
119         tank_lst.push_back(p);
120         items.push_back(p);
121 }
122
123 void Simulator::add_drainage(const std::string &name)
124 {
125         Drainage *p = new Drainage(name);
126         drainage_lst.push_back(p);
127         items.push_back(p);
128 }
129
130 bool Simulator::connect(const std::string &name1, const std::string &name2, int flag)
131 {
132         IConector *o1, *o2;
133         o1 = find(name1);
134         o2 = find(name2);
135
136         if ((o1 == NULL) || (o2 == NULL)) {
137                 // NO SE PUDO CONECTAR!, FALTAN ITEMS!!
138                 return false;
139         }
140
141         bool b;
142         if (flag == IConector::OUT) {
143                 b = o1->connect(o2, IConector::OUT);
144                 b = b && o2->connect(o1, IConector::IN);
145         } else {
146                 b = o1->connect(o2, IConector::IN);
147                 b = b && o2->connect(o1, IConector::OUT);
148         }
149         
150         return b;
151 }
152
153 void Simulator::simulate()
154 {
155         // Actualizo
156         std::list<Pump *>::iterator i1;
157         for(i1=pump_lst.begin(); i1!=pump_lst.end(); i1++)
158                 (*i1)->update();
159
160         std::list<PlantItem *>::iterator i2;
161         for(i2=items.begin(); i2!=items.end(); i2++) {
162                 (*i2)->update();
163                 (*i2)->update_color();
164         }
165         
166         for(i2=items.begin(); i2!=items.end(); i2++) 
167                 (*i2)->simulate();
168
169         frame++;
170 }
171
172 IConector *Simulator::find(const std::string &name)
173 {
174         // Busco el item, aca no me importa de que tipo es!
175         std::list<PlantItem *>::iterator i;
176         for(i=items.begin(); i!=items.end(); i++)
177                 if ((*i)->get_name() == name)
178                         return *i;
179         return NULL;
180 }
181
182 LogicControl *Simulator::find_logic(const std::string &name)
183 {
184         // Busco el item, aca no me importa de que tipo es!
185         std::list<LogicControl *>::iterator i;
186         for(i=control_lst.begin(); i!=control_lst.end(); i++)
187                 if ((*i)->get_name() == name)
188                         return *i;
189         return NULL;
190 }
191
192 bool Simulator::set_open(const std::string &name, bool open)
193 {
194         // Busco el elemento, usando RTTI :-(
195         IConector *tmp = find(name);
196         Pump *p;
197         Exclusa *e;
198         if ((p = dynamic_cast<Pump*>(tmp))) {
199                 if (open) {
200                         p->activate();
201                 } else {
202                         p->deactivate();
203                 }
204         } else if ((e = dynamic_cast<Exclusa*>(tmp))) {
205                 if (open) {
206                         e->open();
207                 } else {
208                         e->close();
209                 }
210         } else {
211                 return false;
212         }
213 }
214
215 void Simulator::loadBomba(xmlNodePtr nodo)
216 {
217         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
218         int orientacion=0, x, y;
219         RGB color;
220         float flujo;
221
222         nodo = nodo->children;
223         while (nodo != NULL) {
224                 if (nodo->type == XML_ELEMENT_NODE) {
225                         if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
226                                 orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
227                         } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
228                                 x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
229                         } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
230                                 y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
231                         } else if (xmlStrcmp(nodo->name, BAD_CAST"entrega") == 0) {
232                                 flujo = atof( (char *)XML_GET_CONTENT(nodo->children) );
233                         } else if (xmlStrcmp(nodo->name, BAD_CAST"color") == 0) {
234                                 color = loadRGB(nodo->children);
235                         }
236                 }
237                 nodo = nodo->next;
238         }
239
240         add_pump(name, flujo, color);
241 }
242
243 void Simulator::loadConduct(xmlNodePtr nodo)
244 {
245         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
246         int orientacion=0, x, y;
247         float flujo;
248
249         nodo = nodo->children;
250         while (nodo != NULL) {
251                 if (nodo->type == XML_ELEMENT_NODE) {
252                         if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
253                                 orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
254                         } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
255                                 x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
256                         } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
257                                 y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
258                         } else if (xmlStrcmp(nodo->name, BAD_CAST"caudal") == 0) {
259                                 flujo = atof( (char *)XML_GET_CONTENT(nodo->children) );
260                         }
261                         
262
263                 }
264                 nodo = nodo->next;
265         }
266
267         // listo, ya recolecte todos los datos, ahora creo el objeto!
268         add_conduct(name, flujo);
269 }
270
271 void Simulator::loadExclusa(xmlNodePtr nodo)
272 {
273         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
274         int orientacion=0, x, y;
275         std::string open;
276
277         nodo = nodo->children;
278         while (nodo != NULL) {
279                 if (nodo->type == XML_ELEMENT_NODE) {
280                         if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
281                                 orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
282                         } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
283                                 x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
284                         } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
285                                 y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
286                         } else if (xmlStrcmp(nodo->name, BAD_CAST"estado") == 0) {
287                                 open = (char *)XML_GET_CONTENT(nodo->children);
288                         }
289                 }
290                 nodo = nodo->next;
291         }
292
293         // listo, ya recolecte todos los datos, ahora creo el objeto!
294         add_exclusa(name, open == "1");
295 }
296
297 void Simulator::loadTank(xmlNodePtr nodo)
298 {
299         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
300         int orientacion=0, x, y;
301         float capacidad, inicial;
302         RGB color;
303
304         nodo = nodo->children;
305         while (nodo != NULL) {
306                 if (nodo->type == XML_ELEMENT_NODE) {
307                         if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
308                                 orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
309                         } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
310                                 x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
311                         } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
312                                 y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
313                         } else if (xmlStrcmp(nodo->name, BAD_CAST"capacidad") == 0) {
314                                 capacidad = atoi( (char *)XML_GET_CONTENT(nodo->children) );
315                         } else if (xmlStrcmp(nodo->name, BAD_CAST"inicial") == 0) {
316                                 inicial = atof( (char *)XML_GET_CONTENT(nodo->children) );
317                         } else if (xmlStrcmp(nodo->name, BAD_CAST"") == 0) {
318                                 color = loadRGB(nodo->children);
319                         }
320                 }
321                 nodo = nodo->next;
322         }
323
324         // listo, ya recolecte todos los datos, ahora creo el objeto!
325         add_tank(name, capacidad, inicial, color);
326 }
327
328 void Simulator::loadUnion(xmlNodePtr nodo)
329 {
330         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
331         int orientacion=0, x, y;
332         float flow;
333         std::string type;
334
335         nodo = nodo->children;
336         while (nodo != NULL) {
337                 if (nodo->type == XML_ELEMENT_NODE) {
338                         if (xmlStrcmp(nodo->name, BAD_CAST"orientacion") == 0) {
339                                 orientacion = atoi( (char *)XML_GET_CONTENT(nodo->children) );
340                         } else if (xmlStrcmp(nodo->name, BAD_CAST"x") == 0) {
341                                 x = atoi( (char *)XML_GET_CONTENT(nodo->children) );
342                         } else if (xmlStrcmp(nodo->name, BAD_CAST"y") == 0) {
343                                 y = atoi( (char *)XML_GET_CONTENT(nodo->children) );
344                         } else if (xmlStrcmp(nodo->name, BAD_CAST"caudal") == 0) {
345                                 flow = atof( (char *)XML_GET_CONTENT(nodo->children) );
346                         } else if (xmlStrcmp(nodo->name, BAD_CAST"tipo") == 0) {
347                                 type = (char *)XML_GET_CONTENT(nodo->children);
348                         }
349                 }
350                 nodo = nodo->next;
351         }
352
353         // listo, ya recolecte todos los datos, ahora creo el objeto!
354         if (type == "union")
355                 add_union(name, flow);
356         else
357                 add_splitter(name, flow);
358 }
359
360 void Simulator::loadDrain(xmlNodePtr nodo)
361 {
362         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
363
364         add_drainage(name);
365 }
366
367 void Simulator::loadNot(xmlNodePtr nodo)
368 {
369         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
370         std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id");
371         int orientacion=0, x, y;
372
373         nodo = nodo->children;
374         while (nodo != NULL) {
375                 if (nodo->type == XML_ELEMENT_NODE) {
376                         if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
377                                 //p->out_lines.push_back((char *)XML_GET_CONTENT(nodo->children));
378                         } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
379                                 //p->in_lines.push_back((char *)XML_GET_CONTENT(nodo->children));
380                         }
381                 }
382                 nodo = nodo->next;
383         }
384
385         Not *n = new Not();
386         n->set_name(name);
387         control_lst.push_back(n);
388 }
389
390 void Simulator::loadOr(xmlNodePtr nodo)
391 {
392         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
393         std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id");
394
395         nodo = nodo->children;
396         while (nodo != NULL) {
397                 if (nodo->type == XML_ELEMENT_NODE) {
398                         if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
399                                 //p->out_lines.push_back((char *)XML_GET_CONTENT(nodo->children));
400                         } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
401                                 //p->in_lines.push_back((char *)XML_GET_CONTENT(nodo->children));
402                         }
403                 }
404                 nodo = nodo->next;
405         }
406
407         Or *n = new Or();
408         n->set_name(name);
409         control_lst.push_back(n);
410 }
411
412 void Simulator::loadAnd(xmlNodePtr nodo)
413 {
414         std::string name = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
415         std::string id = (char *)xmlGetProp(nodo, BAD_CAST"id");
416         int orientacion=0, x, y;
417         
418         nodo = nodo->children;
419         while (nodo != NULL) {
420                 if (nodo->type == XML_ELEMENT_NODE) {
421                         if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
422                         //      p->out_lines.push_back((char *)XML_GET_CONTENT(nodo->children));
423                         } else if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
424                         //      p->in_lines.push_back((char *)XML_GET_CONTENT(nodo->children));
425                         }
426                 }
427                 nodo = nodo->next;
428         }
429
430         And *n = new And();
431         n->set_name(name);
432         control_lst.push_back(n);
433 }
434
435 void Simulator::do_connections(xmlNodePtr nodo)
436 {
437         // Intengo conectar los elementos :)
438         IConector *current_item, *to_connect;
439         xmlNodePtr props; // propiedades del item actual
440         xmlNodePtr conector1, conector2, conector3;
441
442         while (nodo != NULL) {
443                 if (nodo->type != XML_ELEMENT_NODE) {
444                         nodo = nodo->next;
445                         continue;
446                 }
447                 // obtengo el items actual por su nombre
448                 std::string s = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
449                 current_item = find((char *)xmlGetProp(nodo, BAD_CAST"nombre"));
450                 props = nodo->children;
451                 conector3 = conector2 = conector1 = NULL;
452                 while (props != NULL) {
453                         if (nodo->type == XML_ELEMENT_NODE) {
454                                 if (xmlStrcmp(props->name, BAD_CAST"conector") == 0) {
455                                         xmlNodePtr temp = props->children;
456                                         while ((temp != NULL) && (conector1 == NULL))
457                                                 if (temp->type == XML_ELEMENT_NODE) {
458                                                         conector1 = temp;
459                                                         temp = temp->next;
460                                                         break;
461                                                 } else {
462                                                         temp = temp->next;
463                                                 }
464                                         while ((temp != NULL) && (conector2 == NULL))
465                                                 if (temp->type == XML_ELEMENT_NODE) {
466                                                         conector2 = temp;
467                                                         temp = temp->next;
468                                                         break;
469                                                 } else {
470                                                         temp = temp->next;
471                                                 }
472                                         while ((temp != NULL) && (conector3 == NULL))
473                                                 if (temp->type == XML_ELEMENT_NODE) {
474                                                         conector3 = temp;
475                                                         temp = temp->next;
476                                                         break;
477                                                 } else {
478                                                         temp = temp->next;
479                                                 }
480                                 }
481                         }
482                         props = props->next;
483                 }
484                 // Bien, conector1 y 2 deberian estar apuntando a <entrada> y/o <salida>
485                 if (conector1 != NULL) {
486                         // si, aca hay un conector!, veamos cual es
487                         if (xmlStrcmp(conector1->name, BAD_CAST"entrada") == 0) {
488                                 // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar
489                                 to_connect = find((char *)XML_GET_CONTENT(conector1->children));
490                                 // y lo conecto
491                                 current_item->connect(to_connect, IConector::IN);
492                         } else if (xmlStrcmp(conector1->name, BAD_CAST"salida") == 0) {
493                                 // Era a salida, es casi lo mismo que arriba 
494                                 to_connect = find((char *)XML_GET_CONTENT(conector1->children));
495                                 current_item->connect(to_connect, IConector::OUT);
496                         }
497                 }
498                 if (conector2 != NULL) {
499                         // si, aca hay un conector!, veamos cual es
500                         if (xmlStrcmp(conector2->name, BAD_CAST"entrada") == 0) {
501                                 // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar
502                                 to_connect = find((char *)XML_GET_CONTENT(conector2->children));
503                                 // y lo conecto
504                                 current_item->connect(to_connect, IConector::IN);
505                         } else if (xmlStrcmp(conector2->name, BAD_CAST"salida") == 0) {
506                                 // Era a salida, es casi lo mismo que arriba 
507                                 to_connect = find((char *)XML_GET_CONTENT(conector2->children));
508                                 current_item->connect(to_connect, IConector::OUT);
509                         }
510                 }
511                 if (conector3 != NULL) {
512                         // si, aca hay un conector!, veamos cual es
513                         if (xmlStrcmp(conector3->name, BAD_CAST"entrada") == 0) {
514                                 // bien, es a la entrada!, obtengo el item al cual lo tengo que conectar
515                                 to_connect = find((char *)XML_GET_CONTENT(conector3->children));
516                                 // y lo conecto
517                                 current_item->connect(to_connect, IConector::IN);
518                         } else if (xmlStrcmp(conector3->name, BAD_CAST"salida") == 0) {
519                                 // Era a salida, es casi lo mismo que arriba 
520                                 to_connect = find((char *)XML_GET_CONTENT(conector3->children));
521                                 current_item->connect(to_connect, IConector::OUT);
522                         }
523                 }
524                 nodo = nodo->next;
525         }
526         // Fin de las conexiones
527 }
528
529 std::string Simulator::get_state_as_xml()
530 {
531         std::stringstream out;
532
533         // XML Header
534         out << "<?xml version=\"1.0\" ?>" << std::endl;
535
536         out << "<plantstatus frame=\"" << frame << "\">" << std::endl;
537         
538         std::list<PlantItem *>::iterator i2;
539         for(i2=items.begin(); i2!=items.end(); i2++)
540                 (*i2)->get_state_as_xml(out);
541
542         out << "</plantstatus>";
543         return out.str();;
544 }
545
546 RGB Simulator::loadRGB(xmlNodePtr nodo)
547 {
548         unsigned long r,g,b;
549         while (nodo != NULL) {
550                 if (nodo->type == XML_ELEMENT_NODE) {
551                         if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0)
552                                 r = atoi( (char *)XML_GET_CONTENT(nodo->children) );
553                         if (xmlStrcmp(nodo->name, BAD_CAST"verde")==0)
554                                 g = atoi( (char *)XML_GET_CONTENT(nodo->children) );
555                         if (xmlStrcmp(nodo->name, BAD_CAST"azul")==0)
556                                 b = atoi( (char *)XML_GET_CONTENT(nodo->children) );
557                 }
558                 nodo = nodo->next;
559         }
560         r = static_cast<unsigned long>(255 * (r / 65535.0f));
561         g = static_cast<unsigned long>(255 * (g / 65535.0f));
562         b = static_cast<unsigned long>(255 * (b / 65535.0f));
563
564         return RGB(r,g,b);
565 }
566
567 void Simulator::do_logic_connetions(xmlNodePtr nodo)
568 {
569         LogicControl *current;
570
571         while (nodo != NULL) {
572                 if (nodo->type != XML_ELEMENT_NODE) {
573                         nodo = nodo->next;
574                         continue;
575                 }
576                 // obtengo el items actual por su nombre
577                 if (xmlStrcmp(nodo->name, BAD_CAST"and") == 0) {
578                         std::string s = (char *)xmlGetProp(nodo, BAD_CAST"nombre");
579                         current = find_logic((char *)xmlGetProp(nodo, BAD_CAST"nombre"));
580                         connect_logic(current, nodo->children);
581                 }
582                 nodo = nodo->next;
583         }
584 }
585
586 void Simulator::connect_logic(LogicControl *current, xmlNodePtr nodo)
587 {
588         Control *item;
589         while (nodo != NULL) {
590                 if (nodo->type != XML_ELEMENT_NODE) {
591                         nodo = nodo->next;
592                         continue;
593                 }
594                 if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
595                         item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));
596                         if (item != NULL) {
597                                 current->connect( item->get_logic_output(), IConector::IN );
598                         } else {
599                                 std::cout << "ERROR : Item no es tipo Control!!" << std::endl;
600                         }
601                 } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
602                         item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));
603                         if (item != NULL) {
604                                 item->get_logic_input()->connect( current, IConector::IN );
605                         } else {
606                                 std::cout << "ERROR : Item no es tipo Control!!" << std::endl;
607                         }
608                 }
609
610                 nodo = nodo->next;
611         }
612 }
613