return type;
}
else if(type==POWER_STATE && rlength==2)
+ set_power(reply[1]);
+ else if(type==OVERCURRENT)
{
- control.power.set(reply[1]);
-
- Tag tag;
- tag.type = Tag::GENERAL;
- tag.command = POWER;
- tag.serial = control.power.serial;
- control.completed_commands.push(tag);
+ set_power(false);
+ IO::print("Overcurrent detected!\n");
}
else
{
return 0;
}
+void ArduControl::ControlThread::set_power(bool p)
+{
+ control.power.set(p);
+
+ Tag tag;
+ tag.type = Tag::GENERAL;
+ tag.command = POWER;
+ tag.serial = control.power.serial;
+ control.completed_commands.push(tag);
+}
+
ArduControl::Loader::Loader(ArduControl &c):
DataFile::ObjectLoader<ArduControl>(c)
bool get_work(PendingCommand &);
unsigned do_command(const PendingCommand &, const Msp::Time::TimeDelta &);
unsigned process_reply(const char *, unsigned);
+ void set_power(bool);
};
typedef std::map<unsigned, Locomotive> LocomotiveMap;