Empiecen a debbuggear :-) ... tambien habria que poner algun valor distinto de 0
en el modelo de ejemplo, es muy aburrido como esta :-)
std::cout << "LEGO EL XML!" << std::endl;
items = nodo->children;
while (items != NULL) {
- tmp = -1;
if (items->type == XML_ELEMENT_NODE) {
- if (xmlStrcmp(items->name, BAD_CAST"conduct")==0) {
+ tmp = -1;
+ item_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 << "CONDUCT :: " << item_name << " -> " << tmp << std::endl;
- mapItems[item_name]->set_actual_flow(tmp);
}
+
+ if (item_name != "")
+ mapItems[item_name]->set_actual_flow(tmp);
}
items = items->next;
}
virtual void recieve_msg(int msg, IConector *who, void *data);
virtual void update(int dir=OUT);
virtual void simulate();
-
- virtual void get_state_as_xml(std::stringstream &out);
protected:
private:
Conduct():Transport("null") {}
void open() { is_open = true; }
void close() { is_open = false; }
+ void get_state_as_xml(std::stringstream &out);
protected:
bool is_open;
float temp;
#include <string>
#include "iconector.h"
#include "rgb.h"
+#include <sstream>
namespace PlaQui {
/// Retorna el flujo actual que maneja el objeto.
float get_actual_flow() { return actual_flow; }
- virtual void get_state_as_xml(std::stringstream &out) { }
+ virtual void get_state_as_xml(std::stringstream &out);
protected:
RGB fluid_color;
// es de solo lectura
void activate() { active = true; }
/// Desactiva la bomba
void deactivate() { active = false; }
+ void get_state_as_xml(std::stringstream &out);
protected:
/** Define si la bomba esta abierta o no. Esto lo maneja la logica de
* control
virtual void simulate();
void set_litros(float l) { litros = l; }
+ void get_state_as_xml(std::stringstream &out);
protected:
float litros; ///< cantidad de líquido actual
float actual_in_flow; ///< flujo máximo a la entrada
updated = false;
}
-void Conduct::get_state_as_xml(std::stringstream &out)
-{
- out << "\t<conduct name=\"" << name << "\">" << std::endl;
- out << "\t\t<actual_flow>" << actual_flow << "</actual_flow>" << std::endl;
- out << "\t</conduct>" << std::endl;
-}
}
}
+void Exclusa::get_state_as_xml(std::stringstream &out)
+{
+ // Datos comunes
+ // hack to avoid output problems :-)
+ actual_flow = temp;
+ PlantItem::get_state_as_xml(out);
+ out << "\t<exclusa name=\"" << name << "\">" << std::endl;
+ out << "\t\t<active>" << ((is_open)?"true":"false") << "</active>" << std::endl;
+ out << "\t</exclusa>" << std::endl;
+}
+
}
}
+void PlantItem::get_state_as_xml(std::stringstream &out)
+{
+ out << "\t<float name=\"" << name << "\">" << std::endl;
+ out << "\t\t<actual_flow>" << actual_flow << "</actual_flow>" << std::endl;
+ out << "\t</float>" << std::endl;
+}
}
+void Pump::get_state_as_xml(std::stringstream &out)
+{
+ // Saco el item basico por XML
+ PlantItem::get_state_as_xml(out);
+
+ // Saco lo importante de este item
+ out << "\t<pump name=\"" << name << "\">" << std::endl;
+ out << "\t\t<active>" << ((open&&active)?"true":"false") << "</active>" << std::endl;
+ out << "\t</pump>" << std::endl;
+}
+
}
}
+void Tank::get_state_as_xml(std::stringstream &out)
+{
+ // El tanque no emite flujo actual!
+ out << "\t<tank name=\"" << name << "\">" << std::endl;
+ out << "\t\t<capacity>" << capacity << "</capacity>" << std::endl;
+ out << "\t\t<litros>" << litros << "</litros>" << std::endl;
+ out << "\t</tank>" << std::endl;
+}