X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/blobdiff_plain/989d0da7e93d155dde399bf3047ab6b4af550bb6..e4f66a8221e3f2156d89a7a358073863503b2564:/Server/src/plant.cpp diff --git a/Server/src/plant.cpp b/Server/src/plant.cpp index 49ad53a..69ce671 100644 --- a/Server/src/plant.cpp +++ b/Server/src/plant.cpp @@ -28,6 +28,9 @@ #include "plaqui/server/plant.h" #include #include +#include +#include +#include #ifdef DEBUG # include #endif // DEBUG @@ -50,12 +53,12 @@ Plant::~Plant(void) { } } -Plant::Plant(const string& filename): simulator(filename) { +Plant::Plant(const string& filename): simulator(filename), filename(filename) { #ifdef DEBUG cerr << __FILE__ << ": constructor. filename = " << filename << endl; #endif // DEBUG // TODO plant - simulator.add_pump("bomba1"); +/* simulator.add_pump("bomba1"); simulator.add_conduct("c"); simulator.add_conduct("c1"); simulator.add_drainage("d"); @@ -65,7 +68,7 @@ Plant::Plant(const string& filename): simulator(filename) { simulator.connect("c", "tanque", Model::IConector::OUT); simulator.connect("tanque", "c1", Model::IConector::OUT); simulator.connect("c1", "d", Model::IConector::OUT); - +*/ } void Plant::real_run(void) { @@ -83,8 +86,7 @@ void Plant::real_run(void) { } } -bool Plant::transmission_start(const string& host, - const Connection::Port& port) { +bool Plant::transmission_start(string& host, Connection::Port& port) { Glib::Mutex::Lock lock(transmissions_mutex); for (TransmitterList::iterator i = transmissions.begin(); i != transmissions.end(); i++) { @@ -117,6 +119,19 @@ bool Plant::transmission_stop(const string& host, return false; // No la encontrĂ³. } +const string Plant::get_xml(void) const { + ostringstream oss; + try { + ifstream ifs(filename.c_str()); + ifs >> noskipws; + copy(istream_iterator(ifs), istream_iterator(), + ostream_iterator(oss)); + } catch (...) { // TODO hacerlo mas selectivo? + return ""; + } + return oss.str(); +} + /* bool Plant::transmission_exists(const string& host, const Connection::Port& port) {