]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/locomotive.cpp
Add Id tags and copyright notices to files
[r2c2.git] / source / libmarklin / locomotive.cpp
index 0de0110f3cafd673ec55347ec3fb71c9e987cc74..87effa04e8e35175152bc5de2e88950532a5d55c 100644 (file)
@@ -1,3 +1,10 @@
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
 #include <msp/time/timer.h>
 #include <msp/time/units.h>
 #include "command.h"
@@ -10,7 +17,8 @@ using namespace Msp;
 
 namespace Marklin {
 
-Locomotive::Locomotive(Control &c, unsigned a):
+Locomotive::Locomotive(const LocoType &t, Control &c, unsigned a):
+       type(t),
        control(c),
        addr(a),
        speed(0),
@@ -56,6 +64,8 @@ void Locomotive::set_function(unsigned func, bool state)
                funcs&=~(1<<func);
 
        send_command(true);
+
+       signal_function_changed.emit(func, state);
 }
 
 void Locomotive::refresh_status()
@@ -105,6 +115,9 @@ void Locomotive::status_reply(Error err, const string &reply)
                funcs=(reply[1]&0xF)<<1;
                if(reply[1]&0x10)
                        funcs|=1;
+
+               for(unsigned i=0; i<5; ++i)
+                       signal_function_changed.emit(i, (funcs>>i)&1);
        }
 }