]> git.tdb.fi Git - r2c2.git/blob - source/serial/serial.h
Halt all trains in various unexpected situations
[r2c2.git] / source / serial / serial.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef SERIAL_H_
9 #define SERIAL_H_
10
11 #include <msp/core/application.h>
12 #include <msp/io/serial.h>
13 #include "network/client.h"
14
15 class Serial: public Msp::Application
16 {
17 private:
18         Msp::IO::EventDispatcher event_disp;
19         Marklin::Catalogue catalogue;
20         Marklin::Client client;
21         Msp::IO::Serial serial_port;
22         Marklin::NetTrain *train;
23         bool reverse;
24         char rx_buf[3];
25         unsigned rx_fill;
26
27         static Msp::Application::RegApp<Serial> reg;
28
29 public:
30         Serial(int, char **);
31
32 private:
33         virtual void tick();
34         void train_added(Marklin::NetTrain &);
35         void error(const std::string &);
36         void set_train(Marklin::NetTrain *);
37         void next_train();
38         void prev_train();
39         void data_available();
40 };
41
42 #endif