Intellibox::Intellibox(const string &dev):
power(false),
+ halted(false),
update_sensors(false),
command_sent(false)
{
signal_power.emit(power);
}
+void Intellibox::halt(bool h)
+{
+ halted = h;
+ if(halted)
+ {
+ for(map<unsigned, Locomotive>::iterator i=locos.begin(); i!=locos.end(); ++i)
+ if(i->second.speed)
+ set_loco_speed(i->first, 0);
+ }
+
+ signal_halt.emit(halted);
+}
+
void Intellibox::add_loco(unsigned addr)
{
if(!locos.count(addr))
Locomotive &loco = locos[addr];
if(speed==loco.speed)
return;
+ if(speed && halted)
+ return;
loco.speed = speed;
loco_command(addr, speed, loco.reverse, loco.funcs|0x100);
unsigned char err;
read_all(&err, 1);
+ unsigned addr = queue.front().addr;
+ Turnout &turnout = turnouts[addr];
+
if(err==ERR_NO_ERROR)
{
- unsigned addr = queue.front().addr;
- Turnout &turnout = turnouts[addr];
turnout.state = turnout.pending;
if(turnout.active)
{
}
else if(err==ERR_NO_I2C_SPACE)
queue.push_back(queue.front());
+ else
+ turnout.pending = turnout.state;
}
else if(cmd==CMD_TURNOUT_STATUS)
{