class RefreshTask: public Task
{
private:
- ArduControl &control;
+ typedef std::list<Locomotive *> LocomotivePtrList;
+
+ LocomotivePtrList cycle;
+ LocomotivePtrList::iterator next;
+ unsigned round;
Locomotive *loco;
unsigned phase;
+ Msp::Mutex mutex;
public:
- RefreshTask(ArduControl &);
+ RefreshTask();
virtual bool get_work(PendingCommand &);
+
+ void add_loco(Locomotive &);
+ void remove_loco(Locomotive &);
+ private:
+ Locomotive *get_next_loco();
+ void advance();
};
class S88Task: public Task
{
private:
ArduControl &control;
+ unsigned n_octets;
unsigned octets_remaining;
public:
virtual bool get_work(PendingCommand &);
virtual void process_reply(const char *, unsigned);
+
+ void set_n_octets(unsigned);
+ void grow_n_octets(unsigned);
};
class MfxAnnounceTask: public Task
{
private:
- ArduControl &control;
+ unsigned serial;
Msp::Time::TimeStamp next;
public:
- MfxAnnounceTask(ArduControl &);
+ MfxAnnounceTask();
virtual bool get_work(PendingCommand &);
+
+ void set_serial(unsigned);
};
class MfxSearchTask: public Task
{
private:
ArduControl &control;
+ unsigned next_address;
Msp::Time::TimeStamp next;
unsigned size;
unsigned bits;
};
typedef std::map<unsigned, Locomotive> LocomotiveMap;
- typedef std::list<Locomotive *> LocomotivePtrList;
typedef std::map<unsigned, Accessory> AccessoryMap;
typedef std::list<Accessory *> AccessoryPtrList;
typedef std::map<unsigned, Sensor> SensorMap;
ControlledVariable<bool> power;
LocomotiveMap locomotives;
- LocomotivePtrList refresh_cycle;
- LocomotivePtrList::iterator next_refresh;
- unsigned refresh_counter;
AccessoryMap accessories;
AccessoryPtrList accessory_queue;
Accessory *active_accessory;
std::list<Tag> completed_commands;
SensorMap sensors;
- unsigned n_s88_octets;
-
- unsigned mfx_announce_serial;
- unsigned next_mfx_address;
Msp::Mutex mutex;
+ RefreshTask refresh;
+ S88Task s88;
+ MfxAnnounceTask mfx_announce;
+ MfxSearchTask mfx_search;
ControlThread thread;
static ProtocolInfo protocol_info[2];
virtual void set_loco_speed(unsigned, unsigned);
virtual void set_loco_reverse(unsigned, bool);
virtual void set_loco_function(unsigned, unsigned, bool);
-private:
- void add_loco_to_refresh(Locomotive &);
- void remove_loco_from_refresh(Locomotive &);
- Locomotive *get_loco_to_refresh();
- void advance_next_refresh();
-public:
virtual unsigned add_turnout(unsigned, const TrackType &);
virtual void remove_turnout(unsigned);
virtual void set_turnout(unsigned, unsigned);