X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fcentralstation.h;h=6fe26f61e6b94802c5f74eb2501430d02552c805;hb=f730acd5fa2b4f0d0185770ff7950ab814aec47c;hp=ce5253b1abe97f44a16e582ee3b133b20d33b589;hpb=e61a3ee0847b957152d98ba5945e42325821c357;p=r2c2.git diff --git a/source/libr2c2/centralstation.h b/source/libr2c2/centralstation.h index ce5253b..6fe26f6 100644 --- a/source/libr2c2/centralstation.h +++ b/source/libr2c2/centralstation.h @@ -1,10 +1,3 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_CENTRALSTATION_H_ #define LIBR2C2_CENTRALSTATION_H_ @@ -30,7 +23,7 @@ private: struct Message { - typedef std::map AttribMap; + typedef std::multimap AttribMap; typedef std::map ObjectMap; Tag header; @@ -68,42 +61,52 @@ private: unsigned address; unsigned speed; bool reverse; + unsigned func_mask; unsigned funcs; bool control; Locomotive(); }; - struct Turnout + struct MagnetAccessory { + enum Type + { + TURNOUT, + SIGNAL + }; + enum Symbol { - LEFT, - RIGHT, - THREEWAY, - DOUBLESLIP + TURNOUT_LEFT = 0, + TURNOUT_RIGHT = 1, + TURNOUT_THREEWAY = 2, + TURNOUT_DOUBLESLIP = 3, + SEMAPHORE_HOME = 5, + TURNOUT_CURVED_LEFT = 21, + TURNOUT_CURVED_RIGHT = 22 }; unsigned address; - unsigned symbol; + Type type; + Symbol symbol; unsigned state; unsigned bits; bool synced; - Turnout(); + MagnetAccessory(); }; struct Sensor { bool state; - Msp::Time::TimeStamp off_timeout; Sensor(); }; typedef std::map AddressMap; typedef std::map LocoMap; - typedef std::map TurnoutMap; + typedef std::map AccessoryMap; typedef std::map SensorMap; Msp::Net::StreamSocket socket; @@ -115,9 +118,9 @@ private: LocoMap locos; AddressMap loco_addr; bool locos_synced; - TurnoutMap turnouts; - AddressMap turnout_addr; - bool turnouts_synced; + AccessoryMap accessories; + AddressMap accessory_addr; + bool accessories_synced; SensorMap sensors; std::vector s88; bool sensors_synced; @@ -143,6 +146,17 @@ public: virtual void set_turnout(unsigned, unsigned); virtual unsigned get_turnout(unsigned) const; + virtual void add_signal(unsigned, const SignalType &); + virtual void set_signal(unsigned, unsigned); + virtual unsigned get_signal(unsigned) const; + +private: + MagnetAccessory &add_accessory(unsigned, MagnetAccessory::Type, MagnetAccessory::Symbol); + void set_accessory_state(unsigned, MagnetAccessory::Type, unsigned); + unsigned get_accessory_state(unsigned, MagnetAccessory::Type) const; + void accessory_state_changed(const MagnetAccessory &) const; + +public: virtual void add_sensor(unsigned); virtual void set_sensor(unsigned, bool) { } virtual bool get_sensor(unsigned) const;