]> git.tdb.fi Git - r2c2.git/blobdiff - source/serial/serial.cpp
Move block reservation signal serialization to Layout
[r2c2.git] / source / serial / serial.cpp
index 27667521e1eb07cba7d3ba81545d6f70c847a72f..50f53bd7aff9b77ef4c40c01685d1a946893ebc3 100644 (file)
@@ -1,10 +1,3 @@
-/* $Id$
-
-This file is part of the MSP Märklin suite
-Copyright © 2010  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #include <msp/net/resolve.h>
 #include "serial.h"
 
@@ -12,14 +5,13 @@ Distributed under the GPL
 
 using namespace std;
 using namespace Msp;
-using namespace Marklin;
+using namespace R2C2;
        
-Application::RegApp<Serial> Serial::reg;
-
 Serial::Serial(int, char **argv):
        client(catalogue),
        serial_port(argv[2]),
        train(0),
+       reverse(false),
        rx_fill(0)
 {
        DataFile::load(catalogue, "locos.dat");
@@ -97,7 +89,8 @@ void Serial::data_available()
                else if(c=='R')
                {
                        IO::print("Reverse\n");
-                       train->set_reverse(!train->get_reverse());
+                       reverse = !reverse;
+                       train->set_control("speed", 0);
                }
                else if(c=='N')
                        next_train();
@@ -121,9 +114,10 @@ void Serial::data_available()
                }
                else if(rx_buf[0]=='S' && rx_fill==3)
                {
-                       unsigned speed = (rx_buf[1]-'0')*10+(rx_buf[2]-'0');
-                       IO::print("Set speed %d\n", speed);
-                       train->set_speed(speed);
+                       // XXX The firmware is still coded for speed step based control
+                       float speed = ((rx_buf[1]-'0')*10+(rx_buf[2]-'0'))*10/3.6*catalogue.get_scale();
+                       IO::print("Set speed %g\n", speed);
+                       train->set_control("speed", speed);
                        rx_fill = 0;
                }
        }