]> git.tdb.fi Git - r2c2.git/commitdiff
Support dual-address locomotives with extra functions on the second address
authorMikko Rasa <tdb@tdb.fi>
Sun, 13 Dec 2009 16:51:04 +0000 (16:51 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 13 Dec 2009 16:51:04 +0000 (16:51 +0000)
locos.dat
source/libmarklin/locomotive.cpp
source/libmarklin/locotype.cpp
source/libmarklin/locotype.h

index 211daf49457327b8c2e05eb0d6efbc4f7fb936fd..f923d45d219b4678549a74cf2282ae22f1b95e42 100644 (file)
--- a/locos.dat
+++ b/locos.dat
@@ -7,7 +7,7 @@ locomotive 37844
        function 1 "smke";
        function 2 "tlx";
        function 3 "sfx";
-       //function 5 "whst";
+       function 5 "whst";
 };
 
 locomotive 33961
index 2df46a0d7fae67429c6ddea6be63da3e81c9f6eb..5fe5ca5f863d07ca489cdea2bae773eb46ba9d8e 100644 (file)
@@ -11,6 +11,7 @@ Distributed under the GPL
 #include "constants.h"
 #include "control.h"
 #include "locomotive.h"
+#include "locotype.h"
 #include "reply.h"
 
 using namespace std;
@@ -105,6 +106,18 @@ void Locomotive::send_command(bool setf)
                                data[3] |= (1<<i);
        }
        control.command(CMD_LOK, data, 4);
+
+       if(setf && type.get_max_function()>4)
+       {
+               if(!++data[0])
+                       ++data[1];
+               data[2] = 0;
+               data[3] = 0xA0;
+               for(unsigned i=0; i<4; ++i)
+                       if((funcs>>i)&32)
+                               data[3] |= (1<<i);
+               control.command(CMD_LOK, data, 4);
+       }
 }
 
 void Locomotive::status_reply(const Reply &reply)
index 6dcd6ae302920757072eee25c0fb5d00eb168ed6..7a1becf35ac5152db6d926a1c73673ed271ea895 100644 (file)
@@ -15,6 +15,13 @@ LocoType::LocoType(unsigned an):
        art_nr(an)
 { }
 
+unsigned LocoType::get_max_function() const
+{
+       if(funcs.empty())
+               return 0;
+       return (--funcs.end())->first;
+}
+
 
 LocoType::Loader::Loader(LocoType &lt):
        Msp::DataFile::BasicLoader<LocoType>(lt)
index 7509eca1c991078d98235ef2bd842cefda8a3374..5fd34d8c32f20d56d043075e7fa5dfd9d72ed985 100644 (file)
@@ -32,6 +32,7 @@ public:
        LocoType(unsigned);
        unsigned get_article_number() const { return art_nr; }
        const std::string &get_name() const { return name; }
+       unsigned get_max_function() const;
        const std::map<unsigned, std::string> &get_functions() const { return funcs; }
 };