+ArduControl::PendingCommand::PendingCommand():
+ length(0),
+ repeat_count(1)
+{ }
+
+ArduControl::PendingCommand::PendingCommand(GeneralCommand cmd):
+ length(0),
+ repeat_count(1)
+{
+ tag.type = Tag::GENERAL;
+ tag.command = cmd;
+}
+
+ArduControl::PendingCommand::PendingCommand(Locomotive &loco, Locomotive::Command cmd, unsigned index):
+ repeat_count(8)
+{
+ tag.type = Tag::LOCOMOTIVE;
+ tag.command = cmd;
+ tag.id = loco.id;
+ if(cmd==Locomotive::SPEED)
+ {
+ tag.serial = loco.speed.serial;
+ length = loco.create_speed_dir_command(command);
+ }
+ else if(cmd==Locomotive::REVERSE)
+ {
+ tag.serial = loco.reverse.serial;
+ length = loco.create_speed_dir_command(command);
+ }
+ else if(cmd==Locomotive::FUNCTIONS)
+ {
+ tag.serial = loco.funcs.serial;
+ length = loco.create_speed_func_command(index, command);
+ }
+ else
+ throw invalid_argument("PendingCommand");
+}
+
+ArduControl::PendingCommand::PendingCommand(Accessory &acc, Accessory::Command cmd, unsigned index):
+ repeat_count(1)
+{
+ tag.type = Tag::ACCESSORY;
+ tag.command = cmd;
+ tag.id = acc.address;
+ if(cmd==Accessory::ACTIVATE || cmd==Accessory::DEACTIVATE)
+ {
+ tag.serial = acc.state.serial;
+ length = acc.create_state_command(index, (cmd==Accessory::ACTIVATE), command);
+ }
+ else
+ throw invalid_argument("PendingCommand");
+}
+
+
+ArduControl::RefreshTask::RefreshTask(ArduControl &c):