- while (!stop) {
- simulator_mutex.lock();
- simulator.simulate();
- simulator_mutex.unlock();
- transmissions_mutex.lock();
- for (TransmitterList::iterator i = transmissions.begin();
- i != transmissions.end(); i++) {
- (*i)->send(simulator.get_state_as_xml());
+ unsigned wait;
+ while (!stop()) {
+ if (paused) { // Si está pausada, espera un tiempo sin simular.
+ Glib::usleep(DEFAULT_WAIT_TIME);
+ } else { // Si está andando, simula y manda estado.
+ 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(plantstatus);
+ }
+ transmissions_mutex.unlock();
+ wait_time_mutex.lock();
+ wait = wait_time;
+ wait_time_mutex.unlock();
+ Glib::usleep(wait);