1 #include <msp/core/maputils.h>
2 #include <msp/datafile/writer.h>
3 #include <msp/fs/redirectedpath.h>
4 #include <msp/fs/stat.h>
5 #include <msp/io/print.h>
6 #include <msp/time/utils.h>
7 #include "arducontrol.h"
15 ArduControl::ProtocolInfo ArduControl::protocol_info[2] =
18 { 0x3FFF, 126, 15 } // MFX
21 ArduControl::ArduControl(const Options &opts):
22 serial(opts.get<string>(string(), "ttyUSB0")),
23 debug(opts.get<unsigned>("debug")),
24 state_file("arducontrol.state"),
31 if(FS::exists(state_file))
32 DataFile::load(*this, state_file.str());
34 unsigned max_address = 0;
35 for(MfxInfoArray::const_iterator i=mfx_info.begin(); i!=mfx_info.end(); ++i)
36 max_address = max(max_address, i->address);
37 mfx_search.set_next_address(max_address+1);
40 cmd.command[0] = READ_POWER_STATE;
42 command_queue.push(cmd);
44 cmd.command[0] = MFX_SET_STATION_ID;
50 command_queue.push(cmd);
53 ArduControl::~ArduControl()
58 void ArduControl::set_power(bool p)
62 PendingCommand cmd(POWER);
63 cmd.tag.serial = power.serial;
64 cmd.command[0] = (p ? POWER_ON : POWER_OFF);
66 command_queue.push(cmd);
70 void ArduControl::halt(bool)
74 const char *ArduControl::enumerate_protocols(unsigned i) const
84 ArduControl::Protocol ArduControl::map_protocol(const string &proto_name)
88 else if(proto_name=="MFX")
91 throw invalid_argument("ArduControl::map_protocol");
94 unsigned ArduControl::get_protocol_speed_steps(const string &proto_name) const
96 return protocol_info[map_protocol(proto_name)].max_speed;
99 const Driver::DetectedLocomotive *ArduControl::enumerate_detected_locos(unsigned i) const
101 if(i>=mfx_info.size())
107 unsigned ArduControl::add_loco(unsigned addr, const string &proto_name, const VehicleType &)
110 throw invalid_argument("ArduControl::add_loco");
112 Protocol proto = map_protocol(proto_name);
113 if(addr>protocol_info[proto].max_address)
114 throw invalid_argument("ArduControl::add_loco");
116 Locomotive loco(proto, addr);
117 insert_unique(locomotives, loco.id, loco);
122 ArduControl::MfxInfoArray::iterator ArduControl::add_mfx_info(const MfxInfo &info)
124 MfxInfoArray::iterator i;
125 for(i=mfx_info.begin(); (i!=mfx_info.end() && i->id!=info.id); ++i) ;
126 if(i==mfx_info.end())
128 mfx_info.push_back(info);
129 i = --mfx_info.end();
136 void ArduControl::remove_loco(unsigned id)
138 Locomotive &loco = get_item(locomotives, id);
139 refresh.remove_loco(loco);
140 locomotives.erase(id);
143 void ArduControl::set_loco_speed(unsigned id, unsigned speed)
145 Locomotive &loco = get_item(locomotives, id);
146 if(speed>protocol_info[loco.proto].max_speed)
147 throw invalid_argument("ArduControl::set_loco_speed");
149 if(loco.speed.set(speed))
151 PendingCommand cmd(loco, Locomotive::SPEED);
152 command_queue.push(cmd);
154 refresh.add_loco(loco);
158 void ArduControl::set_loco_reverse(unsigned id, bool rev)
160 Locomotive &loco = get_item(locomotives, id);
161 if(loco.reverse.set(rev))
163 PendingCommand cmd(loco, Locomotive::REVERSE);
164 command_queue.push(cmd);
166 refresh.add_loco(loco);
170 void ArduControl::set_loco_function(unsigned id, unsigned func, bool state)
172 Locomotive &loco = get_item(locomotives, id);
173 if(func>protocol_info[loco.proto].max_func)
174 throw invalid_argument("ArduControl::set_loco_function");
176 unsigned mask = 1<<func;
177 if(loco.funcs.set((loco.funcs&~mask)|(mask*state)))
179 if(func>0 || loco.proto!=MM)
181 PendingCommand cmd(loco, Locomotive::FUNCTIONS, func);
182 command_queue.push(cmd);
185 refresh.add_loco(loco);
189 unsigned ArduControl::add_turnout(unsigned addr, const TrackType &type)
191 if(!addr || !type.is_turnout())
192 throw invalid_argument("ArduControl::add_turnout");
194 return add_accessory(Accessory::TURNOUT, addr, type.get_state_bits());
197 void ArduControl::remove_turnout(unsigned addr)
199 remove_accessory(Accessory::TURNOUT, addr);
202 void ArduControl::set_turnout(unsigned addr, unsigned state)
204 set_accessory(Accessory::TURNOUT, addr, state);
207 unsigned ArduControl::get_turnout(unsigned addr) const
209 return get_accessory(Accessory::TURNOUT, addr);
212 unsigned ArduControl::add_signal(unsigned addr, const SignalType &)
214 return add_accessory(Accessory::SIGNAL, addr, 1);
217 void ArduControl::remove_signal(unsigned addr)
219 remove_accessory(Accessory::SIGNAL, addr);
222 void ArduControl::set_signal(unsigned addr, unsigned state)
224 set_accessory(Accessory::SIGNAL, addr, state);
227 unsigned ArduControl::get_signal(unsigned addr) const
229 return get_accessory(Accessory::SIGNAL, addr);
232 unsigned ArduControl::add_accessory(Accessory::Kind kind, unsigned addr, unsigned bits)
234 AccessoryMap::iterator i = accessories.lower_bound(addr);
235 AccessoryMap::iterator j = accessories.upper_bound(addr+bits-1);
237 throw key_error(addr);
238 if(i!=accessories.begin())
241 if(i->first+i->second.bits>addr)
242 throw key_error(addr);
245 insert_unique(accessories, addr, Accessory(kind, addr, bits));
249 void ArduControl::remove_accessory(Accessory::Kind kind, unsigned addr)
251 Accessory &acc = get_item(accessories, addr);
253 throw key_error(addr);
254 accessories.erase(addr);
257 void ArduControl::set_accessory(Accessory::Kind kind, unsigned addr, unsigned state)
259 Accessory &acc = get_item(accessories, addr);
261 throw key_error(addr);
263 if(state!=acc.target)
266 accessory_queue.push_back(&acc);
270 unsigned ArduControl::get_accessory(Accessory::Kind kind, unsigned addr) const
272 const Accessory &acc = get_item(accessories, addr);
274 throw key_error(addr);
278 unsigned ArduControl::add_sensor(unsigned addr)
281 throw invalid_argument("ArduControl::add_sensor");
283 insert_unique(sensors, addr, Sensor(addr));
284 s88.grow_n_octets((addr+7)/8);
289 void ArduControl::remove_sensor(unsigned addr)
291 remove_existing(sensors, addr);
292 // TODO update s88.n_octets
295 bool ArduControl::get_sensor(unsigned addr) const
297 return get_item(sensors, addr).state;
300 void ArduControl::tick()
303 while(completed_commands.pop(tag))
305 if(tag.type==Tag::GENERAL)
307 if(tag.command==POWER)
309 if(power.commit(tag.serial))
310 signal_power.emit(power.current);
312 else if(tag.command==NEW_LOCO)
315 if(mfx_search.pop_info(info))
317 MfxInfoArray::iterator i = add_mfx_info(info);
319 signal_locomotive_detected.emit(*i);
323 else if(tag.type==Tag::LOCOMOTIVE)
325 LocomotiveMap::iterator i = locomotives.find(tag.id);
326 if(i==locomotives.end())
329 Locomotive &loco = i->second;
330 if(tag.command==Locomotive::SPEED)
332 if(loco.speed.commit(tag.serial))
333 signal_loco_speed.emit(loco.id, loco.speed, loco.reverse);
335 else if(tag.command==Locomotive::REVERSE)
337 if(loco.reverse.commit(tag.serial))
338 signal_loco_speed.emit(loco.id, loco.speed, loco.reverse);
340 else if(tag.command==Locomotive::FUNCTIONS)
342 unsigned old = loco.funcs;
343 if(loco.funcs.commit(tag.serial))
345 unsigned changed = old^loco.funcs;
346 for(unsigned j=0; changed>>j; ++j)
348 signal_loco_function.emit(loco.id, j, (loco.funcs>>j)&1);
352 else if(tag.type==Tag::ACCESSORY)
354 AccessoryMap::iterator i = accessories.find(tag.id);
355 if(i==accessories.end())
358 Accessory &acc = i->second;
359 if(tag.command==Accessory::ACTIVATE)
360 off_timeout = Time::now()+acc.active_time;
361 else if(tag.command==Accessory::DEACTIVATE)
363 if(acc.state.commit(tag.serial))
365 if(acc.state==acc.target)
367 if(acc.kind==Accessory::TURNOUT)
368 signal_turnout.emit(acc.address, acc.state);
369 else if(acc.kind==Accessory::SIGNAL)
370 signal_signal.emit(acc.address, acc.state);
372 if(&acc==active_accessory)
373 active_accessory = 0;
377 else if(tag.type==Tag::SENSOR)
379 SensorMap::iterator i = sensors.find(tag.id);
383 Sensor &sensor = i->second;
384 if(tag.command==Sensor::STATE)
386 if(sensor.state.commit(tag.serial))
387 signal_sensor.emit(sensor.address, sensor.state);
392 while(!active_accessory && !accessory_queue.empty())
394 Accessory &acc = *accessory_queue.front();
396 if(acc.state!=acc.target)
398 active_accessory = &acc;
400 unsigned changes = acc.state^acc.target;
401 unsigned lowest_bit = changes&~(changes-1);
403 for(i=0; (lowest_bit>>i)>1; ++i) ;
405 acc.state.set(acc.state^lowest_bit);
406 PendingCommand cmd(acc, Accessory::ACTIVATE, i);
407 command_queue.push(cmd);
410 accessory_queue.pop_front();
413 if(active_accessory && off_timeout)
415 Time::TimeStamp t = Time::now();
418 off_timeout = Time::TimeStamp();
419 PendingCommand cmd(*active_accessory, Accessory::DEACTIVATE, active_index);
420 command_queue.push(cmd);
425 void ArduControl::flush()
429 void ArduControl::save_state() const
431 FS::RedirectedPath tmp_file(state_file);
432 IO::BufferedFile out(tmp_file.str(), IO::M_WRITE);
433 DataFile::Writer writer(out);
435 writer.write((DataFile::Statement("mfx_announce_serial"), mfx_announce.get_serial()));
436 for(MfxInfoArray::const_iterator i=mfx_info.begin(); i!=mfx_info.end(); ++i)
438 DataFile::Statement st("mfx_locomotive");
440 st.sub.push_back((DataFile::Statement("address"), i->address));
441 st.sub.push_back((DataFile::Statement("name"), i->name));
447 ArduControl::Tag::Tag():
455 ArduControl::Locomotive::Locomotive(Protocol p, unsigned a):
465 unsigned ArduControl::Locomotive::create_speed_dir_command(char *buffer) const
469 buffer[0] = MOTOROLA_SPEED_DIRECTION;
471 buffer[2] = funcs.pending&1;
472 buffer[3] = speed.pending+reverse.pending*0x80;
477 buffer[0] = MFX_SPEED;
478 buffer[1] = address>>8;
480 buffer[3] = speed.pending+reverse.pending*0x80;
487 unsigned ArduControl::Locomotive::create_speed_func_command(unsigned f, char *buffer) const
492 throw invalid_argument("Locomotive::create_speed_func_command");
494 buffer[0] = MOTOROLA_SPEED_FUNCTION;
496 buffer[2] = (f<<4)|(((funcs.pending>>f)&1)<<1)|(funcs.pending&1);
497 buffer[3] = speed.pending;
502 bool f16 = (funcs.pending>0xFF);
503 buffer[0] = (f16 ? MFX_SPEED_FUNCS16 : MFX_SPEED_FUNCS8);
504 buffer[1] = address>>8;
506 buffer[3] = speed.pending+reverse.pending*0x80;
509 buffer[4] = funcs.pending>>8;
510 buffer[5] = funcs.pending;
515 buffer[4] = funcs.pending;
524 ArduControl::Accessory::Accessory(Kind k, unsigned a, unsigned b):
529 active_time(500*Time::msec)
532 unsigned ArduControl::Accessory::create_state_command(unsigned b, bool c, char *buffer) const
535 throw invalid_argument("Accessory::create_state_command");
537 unsigned a = (address+b+3)*2;
538 if(!((state.pending>>b)&1))
540 buffer[0] = MOTOROLA_SOLENOID;
542 buffer[2] = ((a&7)<<4)|c;
547 ArduControl::Sensor::Sensor(unsigned a):
553 ArduControl::PendingCommand::PendingCommand():
558 ArduControl::PendingCommand::PendingCommand(GeneralCommand cmd):
562 tag.type = Tag::GENERAL;
566 ArduControl::PendingCommand::PendingCommand(Locomotive &loco, Locomotive::Command cmd, unsigned index):
569 tag.type = Tag::LOCOMOTIVE;
572 if(cmd==Locomotive::SPEED)
574 tag.serial = loco.speed.serial;
575 length = loco.create_speed_dir_command(command);
577 else if(cmd==Locomotive::REVERSE)
579 tag.serial = loco.reverse.serial;
580 length = loco.create_speed_dir_command(command);
582 else if(cmd==Locomotive::FUNCTIONS)
584 tag.serial = loco.funcs.serial;
585 length = loco.create_speed_func_command(index, command);
588 throw invalid_argument("PendingCommand");
591 ArduControl::PendingCommand::PendingCommand(Accessory &acc, Accessory::Command cmd, unsigned index):
594 tag.type = Tag::ACCESSORY;
596 tag.id = acc.address;
597 if(cmd==Accessory::ACTIVATE || cmd==Accessory::DEACTIVATE)
599 tag.serial = acc.state.serial;
600 length = acc.create_state_command(index, (cmd==Accessory::ACTIVATE), command);
603 throw invalid_argument("PendingCommand");
608 void ArduControl::Queue<T>::push(const T &item)
610 MutexLock lock(mutex);
611 items.push_back(item);
615 bool ArduControl::Queue<T>::pop(T &item)
617 MutexLock lock(mutex);
621 item = items.front();
627 ArduControl::RefreshTask::RefreshTask():
634 bool ArduControl::RefreshTask::get_work(PendingCommand &cmd)
636 if(loco && loco->proto==MM && phase==0)
638 cmd.length = loco->create_speed_func_command(round%4+1, cmd.command);
639 cmd.repeat_count = 2;
644 loco = get_next_loco();
651 cmd.length = loco->create_speed_dir_command(cmd.command);
652 cmd.repeat_count = 2;
654 else if(loco->proto==MFX)
655 cmd.length = loco->create_speed_func_command(0, cmd.command);
662 void ArduControl::RefreshTask::add_loco(Locomotive &l)
664 MutexLock lock(mutex);
668 LocomotivePtrList::iterator oldest = cycle.begin();
669 for(LocomotivePtrList::iterator i=cycle.begin(); ++i!=cycle.end(); )
670 if((*i)->last_change_age>(*oldest)->last_change_age)
676 if(next==cycle.end())
677 next = cycle.begin();
680 void ArduControl::RefreshTask::remove_loco(Locomotive &l)
682 MutexLock lock(mutex);
683 for(LocomotivePtrList::iterator i=cycle.begin(); i!=cycle.end(); ++i)
698 ArduControl::Locomotive *ArduControl::RefreshTask::get_next_loco()
700 MutexLock lock(mutex);
704 Locomotive *l = *next;
709 void ArduControl::RefreshTask::advance()
712 if(next==cycle.end())
720 ArduControl::S88Task::S88Task(ArduControl &c):
727 bool ArduControl::S88Task::get_work(PendingCommand &cmd)
734 if(octets_remaining || !n_octets)
737 octets_remaining = n_octets;
738 cmd.command[0] = S88_READ;
739 cmd.command[1] = octets_remaining;
747 void ArduControl::S88Task::process_reply(const char *reply, unsigned length)
749 unsigned char type = reply[0];
750 if(type==S88_DATA && length>2)
752 unsigned offset = static_cast<unsigned char>(reply[1]);
753 unsigned count = length-2;
755 SensorMap::iterator begin = control.sensors.lower_bound(offset*8+1);
756 SensorMap::iterator end = control.sensors.upper_bound((offset+count)*8);
757 for(SensorMap::iterator i=begin; i!=end; ++i)
759 unsigned bit_index = i->first-1-offset*8;
760 bool state = (reply[2+bit_index/8]>>(7-bit_index%8))&1;
761 i->second.state.set(state);
764 tag.type = Tag::SENSOR;
765 tag.command = Sensor::STATE;
766 tag.serial = i->second.state.serial;
768 control.completed_commands.push(tag);
771 if(count>octets_remaining)
772 octets_remaining = 0;
774 octets_remaining -= count;
778 void ArduControl::S88Task::set_n_octets(unsigned n)
783 void ArduControl::S88Task::grow_n_octets(unsigned n)
790 ArduControl::MfxAnnounceTask::MfxAnnounceTask():
794 bool ArduControl::MfxAnnounceTask::get_work(PendingCommand &cmd)
796 Time::TimeStamp t = Time::now();
800 cmd.command[0] = MFX_ANNOUNCE;
801 cmd.command[1] = serial>>8;
802 cmd.command[2] = serial;
804 next = t+400*Time::msec;
809 void ArduControl::MfxAnnounceTask::set_serial(unsigned s)
815 ArduControl::MfxSearchTask::MfxSearchTask(ArduControl &c):
823 bool ArduControl::MfxSearchTask::get_work(PendingCommand &cmd)
828 IO::print("Assigning MFX address %d to decoder %08X\n", next_address, bits);
831 info.protocol = "MFX";
832 info.address = next_address;
833 info.name = format("%08X", bits);
837 cmd.command[0] = MFX_ASSIGN_ADDRESS;
838 cmd.command[1] = next_address>>8;
839 cmd.command[2] = next_address;
840 for(unsigned i=0; i<4; ++i)
841 cmd.command[3+i] = bits>>(24-i*8);
844 cmd.tag.type = Tag::GENERAL;
845 cmd.tag.command = NEW_LOCO;
855 Time::TimeStamp t = Time::now();
859 cmd.command[0] = MFX_SEARCH;
860 for(unsigned i=0; i<4; ++i)
861 cmd.command[1+i] = bits>>(24-i*8);
862 cmd.command[5] = size;
865 next = t+200*Time::msec;
868 IO::print("Search %08X/%d\n", bits, size);
873 void ArduControl::MfxSearchTask::process_reply(const char *reply, unsigned length)
875 unsigned char type = reply[0];
876 if(type==MFX_SEARCH_FEEDBACK && length==2)
883 else if(size>0 && misses<6)
886 bits ^= 1<<(32-size);
890 next = Time::now()+2*Time::sec;
898 void ArduControl::MfxSearchTask::set_next_address(unsigned a)
903 bool ArduControl::MfxSearchTask::pop_info(MfxInfo &info)
905 return queue.pop(info);
909 ArduControl::MonitorTask::MonitorTask():
917 bool ArduControl::MonitorTask::get_work(PendingCommand &cmd)
919 Time::TimeStamp t = Time::now();
924 cmd.command[0] = READ_INPUT_VOLTAGE;
926 cmd.command[0] = READ_TRACK_CURRENT;
929 next_poll = t+200*Time::msec;
930 next_type = (next_type+1)%5;
935 void ArduControl::MonitorTask::process_reply(const char *reply, unsigned length)
937 unsigned char type = reply[0];
938 if(type==INPUT_VOLTAGE && length==3)
939 voltage = ((static_cast<unsigned char>(reply[1])<<8) | static_cast<unsigned char>(reply[2]))/1000.0f;
940 else if(type==TRACK_CURRENT && length==5)
942 current = ((static_cast<unsigned char>(reply[1])<<8) | static_cast<unsigned char>(reply[2]))/1000.0f;
943 float peak = ((static_cast<unsigned char>(reply[3])<<8) | static_cast<unsigned char>(reply[4]))/1000.0f;
944 peak_level = max(peak_level, peak);
945 base_level = min(base_level, current);
949 void ArduControl::MonitorTask::reset_peak()
951 base_level = current;
952 peak_level = current;
956 ArduControl::ControlThread::ControlThread(ArduControl &c):
960 tasks.push_back(&control.monitor);
961 tasks.push_back(&control.mfx_announce);
962 tasks.push_back(&control.mfx_search);
963 tasks.push_back(&control.s88);
964 tasks.push_back(&control.refresh);
969 void ArduControl::ControlThread::exit()
975 void ArduControl::ControlThread::main()
985 for(unsigned i=0; (success && i<cmd.repeat_count); ++i)
986 success = (do_command(cmd)==COMMAND_OK);
987 if(success && cmd.tag)
988 control.completed_commands.push(cmd.tag);
991 Time::sleep(10*Time::msec);
995 void ArduControl::ControlThread::init_baud_rate()
997 static unsigned rates[] = { 57600, 9600, 19200, 38400, 0 };
999 control.serial.set_data_bits(8);
1000 control.serial.set_parity(IO::Serial::NONE);
1001 control.serial.set_stop_bits(1);
1002 for(unsigned i=0; rates[i]; ++i)
1004 control.serial.set_baud_rate(rates[i]);
1005 control.serial.put('\xFF');
1006 if(IO::poll(control.serial, IO::P_INPUT, 500*Time::msec))
1008 int c = control.serial.get();
1019 if(control.debug>=1)
1020 IO::print("ArduControl detection failed\n");
1025 if(control.debug>=1)
1026 IO::print("ArduControl detected at %d bits/s\n", rate);
1031 cmd.command[0] = SET_BAUD_RATE;
1032 cmd.command[1] = rates[0]>>8;
1033 cmd.command[2] = rates[0];
1035 if(do_command(cmd)==COMMAND_OK)
1037 control.serial.set_baud_rate(rates[0]);
1038 Time::sleep(Time::sec);
1039 if(do_command(cmd)==COMMAND_OK)
1041 if(control.debug>=1)
1042 IO::print("Rate changed to %d bits/s\n", rates[0]);
1048 bool ArduControl::ControlThread::get_work(PendingCommand &cmd)
1050 if(control.command_queue.pop(cmd))
1053 for(vector<Task *>::iterator i=tasks.begin(); i!=tasks.end(); ++i)
1054 if((*i)->get_work(cmd))
1057 // As fallback, send an idle packet for the MM protocol
1058 cmd.command[0] = MOTOROLA_SPEED;
1059 cmd.command[1] = 80;
1067 unsigned ArduControl::ControlThread::do_command(const PendingCommand &cmd)
1069 if(control.debug>=2)
1072 for(unsigned i=0; i<cmd.length; ++i)
1073 cmd_hex += format(" %02X", static_cast<unsigned char>(cmd.command[i]));
1074 IO::print("< %02X%s\n", cmd.length^0xFF, cmd_hex);
1077 control.serial.put(cmd.length^0xFF);
1078 control.serial.write(cmd.command, cmd.length);
1080 unsigned result = 0;
1085 got_data = IO::poll(control.serial, IO::P_INPUT, Time::zero);
1087 got_data = IO::poll(control.serial, IO::P_INPUT);
1092 unsigned rlength = control.serial.get()^0xFF;
1095 IO::print("Invalid length %02X\n", rlength);
1102 pos += control.serial.read(reply+pos, rlength-pos);
1104 if(control.debug>=2)
1107 for(unsigned i=0; i<rlength; ++i)
1108 reply_hex += format(" %02X", static_cast<unsigned char>(reply[i]));
1109 IO::print("> %02X%s\n", rlength^0xFF, reply_hex);
1112 unsigned r = process_reply(reply, rlength);
1120 unsigned ArduControl::ControlThread::process_reply(const char *reply, unsigned rlength)
1122 unsigned char type = reply[0];
1123 if((type&0xE0)==0x80)
1125 if(type!=COMMAND_OK)
1126 IO::print("Error %02X\n", type);
1129 else if(type==POWER_STATE && rlength==2)
1131 control.power.set(reply[1]);
1134 tag.type = Tag::GENERAL;
1135 tag.command = POWER;
1136 tag.serial = control.power.serial;
1137 control.completed_commands.push(tag);
1141 for(vector<Task *>::iterator i=tasks.begin(); i!=tasks.end(); ++i)
1142 (*i)->process_reply(reply, rlength);
1149 ArduControl::Loader::Loader(ArduControl &c):
1150 DataFile::ObjectLoader<ArduControl>(c)
1152 add("mfx_announce_serial", &Loader::mfx_announce_serial);
1153 add("mfx_locomotive", &Loader::mfx_locomotive);
1156 void ArduControl::Loader::mfx_announce_serial(unsigned s)
1158 obj.mfx_announce.set_serial(s);
1161 void ArduControl::Loader::mfx_locomotive(unsigned id)
1165 info.protocol = "MFX";
1167 obj.add_mfx_info(info);
1171 ArduControl::MfxInfo::Loader::Loader(MfxInfo &i):
1172 DataFile::ObjectLoader<MfxInfo>(i)
1174 add("address", static_cast<unsigned MfxInfo::*>(&MfxInfo::address));
1175 add("name", static_cast<string MfxInfo::*>(&MfxInfo::name));