return i;
}
+ArduControl::MfxInfo *ArduControl::find_mfx_info(unsigned id)
+{
+ for(MfxInfoArray::iterator i=mfx_info.begin(); i!=mfx_info.end(); ++i)
+ if(i->id==id)
+ return &*i;
+ return 0;
+}
+
void ArduControl::remove_loco(unsigned id)
{
Locomotive &loco = get_item(locomotives, id);
if(size>32)
{
+ unsigned address = 0;
+ if(MfxInfo *existing = control.find_mfx_info(bits))
+ address = existing->address;
+ else
+ address = next_address++;
+
if(control.debug>=1)
- IO::print("Assigning MFX address %d to decoder %08X\n", next_address, bits);
+ IO::print("Assigning MFX address %d to decoder %08X\n", address, bits);
pending_info = new MfxInfo;
pending_info->protocol = "MFX";
- pending_info->address = next_address;
+ pending_info->address = address;
pending_info->name = format("%08X", bits);
pending_info->id = bits;
cmd.command[0] = MFX_ASSIGN_ADDRESS;
- cmd.command[1] = next_address>>8;
- cmd.command[2] = next_address;
+ cmd.command[1] = address>>8;
+ cmd.command[2] = address;
for(unsigned i=0; i<4; ++i)
cmd.command[3+i] = bits>>(24-i*8);
cmd.length = 7;
size = 0;
bits = 0;
misses = 0;
- ++next_address;
read_array = 0;
read_offset = 0;
virtual unsigned add_loco(unsigned, const std::string &, const VehicleType &);
private:
MfxInfoArray::iterator add_mfx_info(const MfxInfo &);
+ MfxInfo *find_mfx_info(unsigned);
public:
virtual void remove_loco(unsigned);
virtual void set_loco_speed(unsigned, unsigned);