]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Se leen bien los valores de punto flotante y la simulacion es mas coherente
authorRicardo Markiewicz <gazer.arg@gmail.com>
Wed, 3 Dec 2003 22:28:42 +0000 (22:28 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Wed, 3 Dec 2003 22:28:42 +0000 (22:28 +0000)
Client/src/principal.cpp

index db0dd1211b66d115ece2f3689c66398a17a8712e..c3c553ad6789086f91dd171a778779367aceea90 100644 (file)
@@ -812,10 +812,18 @@ void Principal::loadDrain(xmlNodePtr nodo)
        mapItems[name] = b;
 }
 
        mapItems[name] = b;
 }
 
-void Principal::read_status_xml(const std::string &frame)
+void Principal::read_status_xml(const std::string &_frame)
 {
        std::string item_name;
 {
        std::string item_name;
+       std::string frame = _frame;
        xmlDocPtr document;
        xmlDocPtr document;
+
+       // Cambio las , por . para evitar problemas de convercion 
+       for(int i=0; i<frame.size(); i++) {
+               if (frame[i] == ',') {
+                       frame[i] = '.';
+               }
+       }
        document = xmlParseMemory(frame.c_str(),frame.size());
        if (document == NULL) {
                txt_view->get_buffer()->insert(txt_view->get_buffer()->begin(), "ERROR : No se pudo leer el último frame!\n");
        document = xmlParseMemory(frame.c_str(),frame.size());
        if (document == NULL) {
                txt_view->get_buffer()->insert(txt_view->get_buffer()->begin(), "ERROR : No se pudo leer el último frame!\n");
@@ -836,6 +844,7 @@ void Principal::read_status_xml(const std::string &frame)
                                if (xmlStrcmp(items->name, BAD_CAST"float")==0) {
                                        tmp = get_float_from_xml(items->children);
                                        item_name = (char *)xmlGetProp(items, BAD_CAST"name");
                                if (xmlStrcmp(items->name, BAD_CAST"float")==0) {
                                        tmp = get_float_from_xml(items->children);
                                        item_name = (char *)xmlGetProp(items, BAD_CAST"name");
+                                       std::cout << item_name << " " << tmp << std::endl;
                                        mapItems[item_name]->set_actual_flow(tmp);
                                } else if (xmlStrcmp(items->name, BAD_CAST"exclusa")==0) {
                                        tmp_b = get_bool_from_xml(items->children);
                                        mapItems[item_name]->set_actual_flow(tmp);
                                } else if (xmlStrcmp(items->name, BAD_CAST"exclusa")==0) {
                                        tmp_b = get_bool_from_xml(items->children);
@@ -915,16 +924,21 @@ Gdk::Color Principal::get_rgb_from_xml(xmlNodePtr nodo)
 float Principal::get_float_from_xml(xmlNodePtr nodo)
 {
        float tmp = -1;
 float Principal::get_float_from_xml(xmlNodePtr nodo)
 {
        float tmp = -1;
+       std::string s;
        while (nodo != NULL) {
                if (nodo->type == XML_ELEMENT_NODE) {
                        if (xmlStrcmp(nodo->name, BAD_CAST"actual_flow")==0) {
        while (nodo != NULL) {
                if (nodo->type == XML_ELEMENT_NODE) {
                        if (xmlStrcmp(nodo->name, BAD_CAST"actual_flow")==0) {
-                               tmp = atof( (char *)XML_GET_CONTENT(nodo->children) );
+                               s = (char *)XML_GET_CONTENT(nodo->children);
                                break;
                        }
                }
                nodo = nodo->next;
        }
                                break;
                        }
                }
                nodo = nodo->next;
        }
+       std::stringstream ss;
+       ss << s;
+       ss >> tmp;
        if (tmp == INFINITO) tmp = 0;
        if (tmp == INFINITO) tmp = 0;
+
        return tmp;
 }
 
        return tmp;
 }