#include "plaqui/server/plant.h"
#include <glibmm/timer.h>
-#include <sigc++/slot.h>
+#include <sigc++/class_slot.h>
#include <fstream>
#ifdef DEBUG
# include <iostream>
while (!stop) {
simulator_mutex.lock();
simulator.simulate();
+ string plantstatus = simulator.get_state_as_xml();
simulator_mutex.unlock();
transmissions_mutex.lock();
for (TransmitterList::iterator i = transmissions.begin();
i != transmissions.end(); i++) {
- (*i)->send(simulator.get_state_as_xml());
+ (*i)->send(plantstatus);
}
transmissions_mutex.unlock();
Glib::usleep(1000000);
// return false;
}
transmissions.push_back(trans);
+ trans->signal_finished().connect(SigC::bind<Transmitter*>(
+ SigC::slot_class(*this, &Plant::on_transmission_finished),
+ trans));
trans->run();
host = trans->get_host();
port = trans->get_port();
bool Plant::transmission_stop(const string& host,
const Connection::Port& port) {
#ifdef DEBUG
- cerr << __FILE__ << "(" << __LINE__ << ")"
- << ": transmission_stop(host = " << host <<
- ", port = " << port << ")." << endl;
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": transmission_stop(host = " << host <<
+ ", port = " << port << ")." << endl;
#endif // DEBUG
Glib::Mutex::Lock lock(transmissions_mutex);
for (TransmitterList::iterator i = transmissions.begin();
return false; // No la encontró.
}
+void Plant::on_transmission_finished(Transmitter* transmission) {
+#ifdef DEBUG
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": on_transmission_finished(transmission = "
+ << transmission << ")" << endl;
+#endif // DEBUG
+ Glib::Mutex::Lock lock(transmissions_mutex);
+ transmissions.remove(transmission);
+#ifdef DEBUG
+ cerr << __FILE__ << "(" << __LINE__ << ")"
+ << ": lista de conexiones" << endl;
+ for (TransmitterList::const_iterator i = transmissions.begin();
+ i != transmissions.end(); i++) {
+ cerr << "\t " << *i << endl;
+ }
+#endif // DEBUG
+}
+
bool Plant::set_open(const std::string& element, bool open) {
#ifdef DEBUG
cerr << __FILE__ << "(" << __LINE__ << ")"