X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/dfabbe2822ffdfb241105cff491b4331096e4af3..4f94fbe0a1d217c7410e5396aad365c85f1fc5af:/Model/src/simulator.cpp diff --git a/Model/src/simulator.cpp b/Model/src/simulator.cpp index f5c0114..7811d4e 100644 --- a/Model/src/simulator.cpp +++ b/Model/src/simulator.cpp @@ -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); + std::list::iterator i3; + for(i3=control_lst.begin(); i3!=control_lst.end(); i3++) + (*i3)->get_state_as_xml(out); out << ""; return out.str();; } @@ -574,7 +577,7 @@ void Simulator::do_logic_connetions(xmlNodePtr nodo) continue; } // obtengo el items actual por su nombre - if (xmlStrcmp(nodo->name, BAD_CAST"and") == 0) { + if ((xmlStrcmp(nodo->name, BAD_CAST"and") == 0) || (xmlStrcmp(nodo->name, BAD_CAST"not") == 0) || (xmlStrcmp(nodo->name, BAD_CAST"or") == 0)) { std::string s = (char *)xmlGetProp(nodo, BAD_CAST"nombre"); current = find_logic((char *)xmlGetProp(nodo, BAD_CAST"nombre")); connect_logic(current, nodo->children); @@ -594,7 +597,16 @@ void Simulator::connect_logic(LogicControl *current, xmlNodePtr nodo) if (xmlStrcmp(nodo->name, BAD_CAST"entrada") == 0) { item = dynamic_cast(find((char *)XML_GET_CONTENT(nodo->children))); if (item != NULL) { - current->connect( item->get_logic_output(), IConector::IN ); + if (dynamic_cast(item)) { + std::string donde = (char *)xmlGetProp(nodo, BAD_CAST"id"); + if (donde == "inferior") { + current->connect( item->get_logic_output(), IConector::IN ); + } else { + current->connect( item->get_logic_input(), IConector::IN ); + } + } else { + current->connect( item->get_logic_output(), IConector::IN ); + } } else { std::cout << "ERROR : Item no es tipo Control!!" << std::endl; } @@ -603,7 +615,13 @@ void Simulator::connect_logic(LogicControl *current, xmlNodePtr nodo) if (item != NULL) { item->get_logic_input()->connect( current, IConector::IN ); } else { - std::cout << "ERROR : Item no es tipo Control!!" << std::endl; + LogicControl *logic = dynamic_cast(find_logic((char *)XML_GET_CONTENT(nodo->children))); + /* Bien, si no era un control, debe ser una compuerta */ + if (logic != NULL) { + logic->connect(current, IConector::IN); + } else { + std::cout << "ERROR : Item no es tipo Control ni tipo LogicControl ... esto si que esta todo malllll!!" << std::endl; + } } }