X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fturnout.cpp;h=efa98bb5a7b5c49dd62800de0c878091fcda6747;hb=38fb8d56efde037a71c46a58bda314655e68ab6c;hp=3e6e10dcc69f0d37c3148b3abf7506c3fadb6f35;hpb=449fb5de95ddb2ac9da4bd72a1c12150505d5549;p=r2c2.git diff --git a/source/libmarklin/turnout.cpp b/source/libmarklin/turnout.cpp index 3e6e10d..efa98bb 100644 --- a/source/libmarklin/turnout.cpp +++ b/source/libmarklin/turnout.cpp @@ -28,13 +28,13 @@ Turnout::Turnout(Control &c, unsigned a, bool d): control.signal_turnout_event.connect(sigc::mem_fun(this, &Turnout::turnout_event)); unsigned char data[2]; - data[0]=addr&0xFF; - data[1]=(addr>>8)&0xFF; + data[0] = addr&0xFF; + data[1] = (addr>>8)&0xFF; control.command(CMD_TURNOUT_STATUS, data, 2).signal_done.connect(sigc::bind(sigc::mem_fun(this, &Turnout::status_reply), false)); if(dual) { - data[0]=(addr+1)&0xFF; - data[1]=((addr+1)>>8)&0xFF; + data[0] = (addr+1)&0xFF; + data[1] = ((addr+1)>>8)&0xFF; control.command(CMD_TURNOUT_STATUS, data, 2).signal_done.connect(sigc::bind(sigc::mem_fun(this, &Turnout::status_reply), true)); } } @@ -43,7 +43,7 @@ void Turnout::set_route(unsigned r) { signal_route_changing.emit(r); - route=r; + route = r; command(true); control.set_timer(200*Time::msec).signal_timeout.connect(sigc::mem_fun(this, &Turnout::switch_timeout)); @@ -53,13 +53,13 @@ void Turnout::set_route(unsigned r) void Turnout::command(bool on) { unsigned char data[2]; - data[0]=addr&0xFF; - data[1]=((addr>>8)&0x7) | (on ? 0x40 : 0) | (route&1 ? 0 : 0x80); + data[0] = addr&0xFF; + data[1] = ((addr>>8)&0x7) | (on ? 0x40 : 0) | (route&1 ? 0 : 0x80); control.command(CMD_TURNOUT, data, 2); if(dual) { - data[0]=(addr+1)&0xFF; - data[1]=(((addr+1)>>8)&0x7) | (on ? 0x40 : 0) | (route&2 ? 0 : 0x80); + data[0] = (addr+1)&0xFF; + data[1] = (((addr+1)>>8)&0x7) | (on ? 0x40 : 0) | (route&2 ? 0 : 0x80); control.command(CMD_TURNOUT, data, 2); } } @@ -68,9 +68,9 @@ void Turnout::status_reply(const Reply &reply, bool high) { if(reply.get_error()==ERR_NO_ERROR) { - bool v=!(reply.get_data()[0]&0x04); - unsigned b=(high?2:1); - route=(route&~b)|(v?b:0); + bool v = !(reply.get_data()[0]&0x04); + unsigned b = (high?2:1); + route = (route&~b)|(v?b:0); signal_route_changed.emit(route); } } @@ -86,12 +86,12 @@ void Turnout::turnout_event(unsigned a, bool r) { if(a==addr && r!=(route&1)) { - route=(route&2)|(r?1:0); + route = (route&2)|(r?1:0); signal_route_changed.emit(route); } else if(dual && a==addr+1 && r!=((route>>1)&1)) { - route=(route&1)|(r?2:0); + route = (route&1)|(r?2:0); signal_route_changed.emit(route); } }