]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/locomotive.cpp
Major code refactoring:
[r2c2.git] / source / libmarklin / locomotive.cpp
index ecacea19a833af43f918823523951740d9a0e69c..fe236a515f0fa783dbbb0f1e92022c9b86eb0ebb 100644 (file)
@@ -17,7 +17,7 @@ Locomotive::Locomotive(Control &c, unsigned a):
        reverse(false),
        funcs(0)
 {
-       control.add_locomotive(this);
+       control.add_locomotive(*this);
 
        refresh_status();
 }
@@ -27,6 +27,8 @@ void Locomotive::set_speed(unsigned spd)
        speed=min(spd, 14U);
 
        send_command(false);
+
+       signal_speed_changed.emit(speed);
 }
 
 void Locomotive::set_reverse(bool rev)
@@ -36,7 +38,7 @@ void Locomotive::set_reverse(bool rev)
 
        if(speed)
        {
-               (new Time::Timer((500+speed*150)*Time::msec))->signal_timeout.connect(sigc::mem_fun(this, &Locomotive::reverse_timeout));
+               control.set_timer((500+speed*150)*Time::msec).signal_timeout.connect(sigc::mem_fun(this, &Locomotive::reverse_timeout));
                set_speed(0);
        }
        else
@@ -62,7 +64,7 @@ void Locomotive::refresh_status()
        cmd[0]=CMD_LOK_STATUS;
        cmd[1]=addr&0xFF;
        cmd[2]=(addr>>8)&0xFF;
-       control.command(string(cmd,3)).signal_done.connect(sigc::mem_fun(this,&Locomotive::status_reply));
+       control.command(string(cmd, 3)).signal_done.connect(sigc::mem_fun(this, &Locomotive::status_reply));
 }
 
 void Locomotive::send_command(bool setf)