X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Farducontrol.h;h=40c7b3c6912d47247024c5ab28461bb497a6a7f1;hb=b4beace6f1d3e018dbe1495430d32f828d406229;hp=555280985767a7e37ea512607a0337359ac11618;hpb=1e655686513ef60e1972fc9ca9bcf7b434a09e40;p=r2c2.git diff --git a/source/libr2c2/arducontrol.h b/source/libr2c2/arducontrol.h index 5552809..40c7b3c 100644 --- a/source/libr2c2/arducontrol.h +++ b/source/libr2c2/arducontrol.h @@ -117,6 +117,7 @@ private: bool set(T v) { if(v==pending) return false; pending = v; ++serial; return true; } bool commit(unsigned short s) { if(s!=serial) return false; current = pending; return true; } + void rollback() { pending = current; ++serial; } operator T() const { return current; } }; @@ -173,6 +174,7 @@ private: unsigned address; unsigned bits; ControlledVariable state; + unsigned uncertain; unsigned target; Msp::Time::TimeDelta active_time; @@ -217,6 +219,7 @@ private: public: void push(const T &); bool pop(T &); + bool empty() const; }; class Task @@ -354,7 +357,7 @@ private: virtual void main(); void init_baud_rate(); bool get_work(PendingCommand &); - unsigned do_command(const PendingCommand &); + unsigned do_command(const PendingCommand &, const Msp::Time::TimeDelta &); unsigned process_reply(const char *, unsigned); }; @@ -369,6 +372,7 @@ private: Msp::FS::Path state_file; ControlledVariable power; + bool halted; LocomotiveMap locomotives; MfxInfoArray mfx_info; @@ -380,7 +384,7 @@ private: SensorMap sensors; - Msp::Mutex mutex; + Msp::Time::TimeDelta command_timeout; Queue command_queue; Queue completed_commands; RefreshTask refresh; @@ -399,7 +403,7 @@ public: virtual void set_power(bool); virtual bool get_power() const { return power; } virtual void halt(bool); - virtual bool is_halted() const { return false; } + virtual bool is_halted() const { return halted; } virtual const char *enumerate_protocols(unsigned) const; private: