+ struct PendingCommand
+ {
+ Tag tag;
+ char command[15];
+ unsigned char length;
+ unsigned repeat_count;
+
+ PendingCommand();
+ PendingCommand(GeneralCommand);
+ PendingCommand(Locomotive &, Locomotive::Command, unsigned = 0);
+ PendingCommand(Accessory &, Accessory::Command, unsigned = 0);
+ };
+
+ class Task
+ {
+ protected:
+ Task() { }
+ public:
+ virtual ~Task() { }
+
+ virtual bool get_work(PendingCommand &) = 0;
+ virtual void process_reply(const char *, unsigned) { }
+ };
+
+ class RefreshTask: public Task
+ {
+ private:
+ ArduControl &control;
+ Locomotive *loco;
+ unsigned phase;
+
+ public:
+ RefreshTask(ArduControl &);
+
+ virtual bool get_work(PendingCommand &);
+ };
+
+ class S88Task: public Task
+ {
+ private:
+ ArduControl &control;
+ unsigned octets_remaining;
+
+ public:
+ S88Task(ArduControl &);
+
+ virtual bool get_work(PendingCommand &);
+ virtual void process_reply(const char *, unsigned);
+ };
+
+ class MfxAnnounceTask: public Task
+ {
+ private:
+ ArduControl &control;
+ Msp::Time::TimeStamp next;
+
+ public:
+ MfxAnnounceTask(ArduControl &);
+
+ virtual bool get_work(PendingCommand &);
+ };
+
+ class MfxSearchTask: public Task
+ {
+ private:
+ ArduControl &control;
+ Msp::Time::TimeStamp next;
+ unsigned size;
+ unsigned bits;
+ bool pending;
+
+ public:
+ MfxSearchTask(ArduControl &);
+
+ virtual bool get_work(PendingCommand &);
+ virtual void process_reply(const char *, unsigned);
+ };
+