From cafdb587ee6e195e5a917cea7570c2ea7e22a003 Mon Sep 17 00:00:00 2001 From: Ricardo Markiewicz Date: Thu, 20 Nov 2003 02:00:12 +0000 Subject: [PATCH] Se agrega XML para otros items (no todos ya implementados en el cliente). Empiecen a debbuggear :-) ... tambien habria que poner algun valor distinto de 0 en el modelo de ejemplo, es muy aburrido como esta :-) --- Client/src/principal.cpp | 10 ++++++---- Model/include/conduct.h | 2 -- Model/include/exclusa.h | 1 + Model/include/plantitem.h | 3 ++- Model/include/pump.h | 1 + Model/include/tank.h | 1 + Model/src/conduct.cpp | 6 ------ Model/src/exclusa.cpp | 11 +++++++++++ Model/src/plantitem.cpp | 6 ++++++ Model/src/pump.cpp | 11 +++++++++++ Model/src/tank.cpp | 8 ++++++++ 11 files changed, 47 insertions(+), 13 deletions(-) diff --git a/Client/src/principal.cpp b/Client/src/principal.cpp index 2973543..76680bd 100644 --- a/Client/src/principal.cpp +++ b/Client/src/principal.cpp @@ -487,14 +487,16 @@ void Principal::read_status_xml(const std::string &frame) 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; } diff --git a/Model/include/conduct.h b/Model/include/conduct.h index edf23fd..306c92a 100644 --- a/Model/include/conduct.h +++ b/Model/include/conduct.h @@ -27,8 +27,6 @@ public: 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") {} diff --git a/Model/include/exclusa.h b/Model/include/exclusa.h index d0c1f22..818ccb4 100644 --- a/Model/include/exclusa.h +++ b/Model/include/exclusa.h @@ -24,6 +24,7 @@ public: void open() { is_open = true; } void close() { is_open = false; } + void get_state_as_xml(std::stringstream &out); protected: bool is_open; float temp; diff --git a/Model/include/plantitem.h b/Model/include/plantitem.h index 5c3e762..2cfb5b6 100644 --- a/Model/include/plantitem.h +++ b/Model/include/plantitem.h @@ -6,6 +6,7 @@ #include #include "iconector.h" #include "rgb.h" +#include namespace PlaQui { @@ -70,7 +71,7 @@ public: /// 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 diff --git a/Model/include/pump.h b/Model/include/pump.h index b51edbf..b8b12f0 100644 --- a/Model/include/pump.h +++ b/Model/include/pump.h @@ -42,6 +42,7 @@ public: 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 diff --git a/Model/include/tank.h b/Model/include/tank.h index 0495404..652955b 100644 --- a/Model/include/tank.h +++ b/Model/include/tank.h @@ -32,6 +32,7 @@ public: 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 diff --git a/Model/src/conduct.cpp b/Model/src/conduct.cpp index 02fe3a6..b196eec 100644 --- a/Model/src/conduct.cpp +++ b/Model/src/conduct.cpp @@ -75,10 +75,4 @@ void Conduct::simulate() updated = false; } -void Conduct::get_state_as_xml(std::stringstream &out) -{ - out << "\t" << std::endl; - out << "\t\t" << actual_flow << "" << std::endl; - out << "\t" << std::endl; -} diff --git a/Model/src/exclusa.cpp b/Model/src/exclusa.cpp index 34b2fab..8e64bc3 100644 --- a/Model/src/exclusa.cpp +++ b/Model/src/exclusa.cpp @@ -50,3 +50,14 @@ void Exclusa::recieve_msg(int msg, IConector *who, void *data) } } +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" << std::endl; + out << "\t\t" << ((is_open)?"true":"false") << "" << std::endl; + out << "\t" << std::endl; +} + diff --git a/Model/src/plantitem.cpp b/Model/src/plantitem.cpp index 1ce56f8..efca4c1 100644 --- a/Model/src/plantitem.cpp +++ b/Model/src/plantitem.cpp @@ -31,3 +31,9 @@ void PlantItem::recieve_msg(int msg, IConector *who, void *data) } } +void PlantItem::get_state_as_xml(std::stringstream &out) +{ + out << "\t" << std::endl; + out << "\t\t" << actual_flow << "" << std::endl; + out << "\t" << std::endl; +} diff --git a/Model/src/pump.cpp b/Model/src/pump.cpp index 7f1ace4..9c2a9b4 100644 --- a/Model/src/pump.cpp +++ b/Model/src/pump.cpp @@ -74,3 +74,14 @@ void Pump::recieve_msg(int msg, IConector *who, void *data) } +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" << std::endl; + out << "\t\t" << ((open&&active)?"true":"false") << "" << std::endl; + out << "\t" << std::endl; +} + diff --git a/Model/src/tank.cpp b/Model/src/tank.cpp index f21a2e8..e951254 100644 --- a/Model/src/tank.cpp +++ b/Model/src/tank.cpp @@ -66,3 +66,11 @@ void Tank::recieve_msg(int msg, IConector *who, void *data) } } +void Tank::get_state_as_xml(std::stringstream &out) +{ + // El tanque no emite flujo actual! + out << "\t" << std::endl; + out << "\t\t" << capacity << "" << std::endl; + out << "\t\t" << litros << "" << std::endl; + out << "\t" << std::endl; +} -- 2.43.0