namespace R2C2 {
-CentralStation::CentralStation(const string &host):
+CentralStation::CentralStation(const Options &opts):
socket(Net::INET),
pending_commands(0),
power(false),
accessories_synced(false),
sensors_synced(false)
{
- RefPtr<Net::SockAddr> addr = Net::resolve(host+":15471");
+ RefPtr<Net::SockAddr> addr = Net::resolve(opts.get<string>(string())+":15471");
socket.connect(*addr);
IO::print("Connected to central station at %s\n", addr->str());
}
}
-void CentralStation::add_loco(unsigned addr, const string &proto_name, const VehicleType &type)
+unsigned CentralStation::add_loco(unsigned addr, const string &proto_name, const VehicleType &type)
{
Protocol proto = map_protocol(proto_name);
}
else
command(format("request(%d, view, control, force)", id));
+
+ return addr;
}
void CentralStation::remove_loco(unsigned addr)
command(format("set(%d, func[%d, %d])", id, func, state));
}
-void CentralStation::add_turnout(unsigned addr, const TrackType &type)
+unsigned CentralStation::add_turnout(unsigned addr, const TrackType &type)
{
unsigned straight = type.get_paths();
bool left = false;
MagnetAccessory &turnout = add_accessory(addr, MagnetAccessory::TURNOUT, symbol);
turnout.bits = type.get_state_bits();
+
+ return addr;
}
void CentralStation::remove_turnout(unsigned addr)
return get_accessory_state(addr, MagnetAccessory::TURNOUT);
}
-void CentralStation::add_signal(unsigned addr, const SignalType &)
+unsigned CentralStation::add_signal(unsigned addr, const SignalType &)
{
add_accessory(addr, MagnetAccessory::SIGNAL, MagnetAccessory::SEMAPHORE_HOME);
+ return addr;
}
void CentralStation::remove_signal(unsigned addr)
signal_signal.emit(accessory.address, accessory.state);
}
-void CentralStation::add_sensor(unsigned addr)
+unsigned CentralStation::add_sensor(unsigned addr)
{
sensors.insert(SensorMap::value_type(addr, Sensor()));
if(addr>s88.size()*16)
command("create(26, add[0])");
}
+
+ return addr;
}
void CentralStation::remove_sensor(unsigned)