X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftimetable.h;fp=source%2Flibmarklin%2Ftimetable.h;h=39cff5ee6b2b14a077445521783ac2039630acd9;hb=a9180bc4bb7ff4c403e206cc2c785ff32544a0d6;hp=0000000000000000000000000000000000000000;hpb=f06c2b89a2601981aae84d0f971c07816dc1bab4;p=r2c2.git diff --git a/source/libmarklin/timetable.h b/source/libmarklin/timetable.h new file mode 100644 index 0000000..39cff5e --- /dev/null +++ b/source/libmarklin/timetable.h @@ -0,0 +1,76 @@ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#ifndef LIBMARKLIN_TIMETABLE_H_ +#define LIBMARKLIN_TIMETABLE_H_ + +#include +#include +#include +#include + +namespace Marklin { + +class Block; +class Train; + +class Timetable +{ +public: + class Loader: public Msp::DataFile::ObjectLoader + { + public: + Loader(Timetable &); + private: + void go_to(const std::string &); + void route(const std::string &); + void speed(int); + void travel(const std::string &); + void wait(unsigned); + }; + + enum RowType + { + GOTO, + TRAVEL, + WAIT, + SPEED, + ROUTE + }; + + struct Row + { + RowType type; + int intparam; + std::string strparam; + + Row(RowType, int); + Row(RowType, const std::string &); + }; + +private: + Train &train; + std::vector rows; + unsigned current_row; + bool executing; + Block *pending_block; + Msp::Time::TimeStamp wait_timeout; + +public: + Timetable(Train &); + + void tick(const Msp::Time::TimeStamp &); + void save(std::list &) const; +private: + Block &parse_location(const std::string &); + void sensor_event(unsigned, bool); + void train_arrived(); +}; + +} // namespace Marklin + +#endif