+RGB Simulator::loadRGB(xmlNodePtr nodo)
+{
+ unsigned long r,g,b;
+ while (nodo != NULL) {
+ if (nodo->type == XML_ELEMENT_NODE) {
+ if (xmlStrcmp(nodo->name, BAD_CAST"rojo")==0)
+ r = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ if (xmlStrcmp(nodo->name, BAD_CAST"verde")==0)
+ g = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ if (xmlStrcmp(nodo->name, BAD_CAST"azul")==0)
+ b = atoi( (char *)XML_GET_CONTENT(nodo->children) );
+ }
+ nodo = nodo->next;
+ }
+ r = static_cast<unsigned long>(255 * (r / 65535.0f));
+ g = static_cast<unsigned long>(255 * (g / 65535.0f));
+ b = static_cast<unsigned long>(255 * (b / 65535.0f));
+
+ return RGB(r,g,b);
+}
+
+void Simulator::do_logic_connetions(xmlNodePtr nodo)
+{
+ LogicControl *current;
+
+ while (nodo != NULL) {
+ if (nodo->type != XML_ELEMENT_NODE) {
+ nodo = nodo->next;
+ continue;
+ }
+ // obtengo el items actual por su nombre
+ 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);
+ }
+ nodo = nodo->next;
+ }
+}
+
+void Simulator::connect_logic(LogicControl *current, xmlNodePtr nodo)
+{
+ Control *item;
+ while (nodo != NULL) {
+ if (nodo->type != XML_ELEMENT_NODE) {
+ nodo = nodo->next;
+ continue;
+ }
+ 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)) {
+ 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;
+ }
+ } else if (xmlStrcmp(nodo->name, BAD_CAST"salida") == 0) {
+ item = dynamic_cast<Control *>(find((char *)XML_GET_CONTENT(nodo->children)));
+ if (item != NULL) {
+ item->get_logic_input()->connect( current, IConector::IN );
+ } else {
+ std::cout << "ERROR : Item no es tipo Control!!" << std::endl;
+ }
+ }
+
+ nodo = nodo->next;
+ }
+}
+