debug(opts.get<unsigned>("debug")),
state_file("arducontrol.state"),
power(false),
+ halted(false),
active_accessory(0),
s88(*this),
mfx_search(*this),
}
}
-void ArduControl::halt(bool)
+void ArduControl::halt(bool h)
{
+ if(h==halted)
+ return;
+
+ halted = h;
+ if(halted)
+ {
+ for(LocomotiveMap::const_iterator i=locomotives.begin(); i!=locomotives.end(); ++i)
+ set_loco_speed(i->first, 0);
+ }
+
+ signal_halt.emit(halted);
}
const char *ArduControl::enumerate_protocols(unsigned i) const
if(speed>protocol_info[loco.proto].max_speed)
throw invalid_argument("ArduControl::set_loco_speed");
+ if(speed && halted)
+ return;
+
if(loco.speed.set(speed))
{
PendingCommand cmd(loco, Locomotive::SPEED);
}
}
- while(!active_accessory && !accessory_queue.empty())
+ while(power && !active_accessory && !accessory_queue.empty())
{
Accessory &acc = *accessory_queue.front();
void ArduControl::flush()
{
+ while(!command_queue.empty() || !accessory_queue.empty())
+ tick();
}
void ArduControl::save_state() const
return true;
}
+template<typename T>
+bool ArduControl::Queue<T>::empty() const
+{
+ return items.empty();
+}
+
ArduControl::RefreshTask::RefreshTask():
next(cycle.end()),