#include "plaqui/server/plant.h"
#include <glibmm/timer.h>
#include <sigc++/slot.h>
+#include <fstream>
+#include <iterator>
+#include <algorithm>
#ifdef DEBUG
# include <iostream>
#endif // DEBUG
}
}
-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");
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) {
}
}
-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++) {
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<char>(ifs), istream_iterator<char>(),
+ ostream_iterator<char>(oss));
+ } catch (...) { // TODO hacerlo mas selectivo?
+ return "";
+ }
+ return oss.str();
+}
+
/*
bool Plant::transmission_exists(const string& host,
const Connection::Port& port) {