]> git.llucax.com Git - z.facultad/75.42/plaqui.git/blobdiff - Model/src/simulator.cpp
Mini bugfix.
[z.facultad/75.42/plaqui.git] / Model / src / simulator.cpp
index 5095123e27710b01c17aae0e79477cb4a09134a7..6a85446bfa325e3130ad4c3ef1adc8ac0c92adb1 100644 (file)
@@ -539,6 +539,9 @@ std::string Simulator::get_state_as_xml()
        for(i2=items.begin(); i2!=items.end(); i2++)
                (*i2)->get_state_as_xml(out);
 
        for(i2=items.begin(); i2!=items.end(); i2++)
                (*i2)->get_state_as_xml(out);
 
+       std::list<LogicControl *>::iterator i3;
+       for(i3=control_lst.begin(); i3!=control_lst.end(); i3++)
+               (*i3)->get_state_as_xml(out);
        out << "</plantstatus>";
        return out.str();;
 }
        out << "</plantstatus>";
        return out.str();;
 }
@@ -594,7 +597,7 @@ void Simulator::connect_logic(LogicControl *current, xmlNodePtr nodo)
                if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
                        item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));
                        if (item != NULL) {
                if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) {
                        item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));
                        if (item != NULL) {
-                               if (dynamic_cast<Tank *>(item)) {
+                               if (dynamic_cast<Tank *>(item) != NULL) {
                                        std::string donde = (char *)xmlGetProp(nodo, BAD_CAST"id");
                                        if (donde == "inferior") {
                                                current->connect( item->get_logic_output(), IConector::IN );
                                        std::string donde = (char *)xmlGetProp(nodo, BAD_CAST"id");
                                        if (donde == "inferior") {
                                                current->connect( item->get_logic_output(), IConector::IN );
@@ -605,7 +608,13 @@ void Simulator::connect_logic(LogicControl *current, xmlNodePtr nodo)
                                        current->connect( item->get_logic_output(), IConector::IN );
                                }
                        } else {
                                        current->connect( item->get_logic_output(), IConector::IN );
                                }
                        } else {
-                               std::cout << "ERROR : Item no es tipo Control!!" << std::endl;
+                               LogicControl *logic = dynamic_cast<LogicControl *>(find_logic((char *)XML_GET_CONTENT(nodo->children)));
+                               /* Bien, si no era un control, debe ser una compuerta */
+                               if (logic != NULL) {
+                                       current->connect(logic, IConector::IN);
+                               } else {
+                                       std::cout << "ERROR : Item no es tipo Control ni tipo LogicControl ... esto si que esta todo malllll!!" << std::endl;
+                               }
                        }
                } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
                        item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));
                        }
                } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
                        item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));