X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetwork%2Ftrain.cpp;h=4ba4df08870891e354c10c86489bc3c82a0290ac;hb=f0aa8913aa1f4df37b87dcedbc257febb0e101a1;hp=5c4b457bad9bb3093edb962887d567798e6d8777;hpb=9ddcd066e37e4c72685817c042c30897786ece05;p=r2c2.git diff --git a/source/network/train.cpp b/source/network/train.cpp index 5c4b457..4ba4df0 100644 --- a/source/network/train.cpp +++ b/source/network/train.cpp @@ -1,20 +1,13 @@ -/* $Id$ - -This file is part of the MSP Märklin suite -Copyright © 2009 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #include "client.h" #include "train.h" using namespace std; -namespace Marklin { +namespace R2C2 { NetTrain::NetTrain(Client &c, const TrainInfoPacket &pkt): client(c), - loco_type(client.get_catalogue().get_locomotive(pkt.loco_type)), + loco_type(client.get_catalogue().get(pkt.loco_type)), address(pkt.address), name(pkt.name), functions(0) @@ -32,6 +25,12 @@ void NetTrain::set_control(const string &c, float v) client.send(pkt); } +float NetTrain::get_control(const string &c) const +{ + map::const_iterator i = controls.find(c); + return i!=controls.end() ? i->second : 0; +} + void NetTrain::set_function(unsigned i, bool set) { TrainFunctionPacket pkt; @@ -82,4 +81,4 @@ void NetTrain::process_packet(const TrainRoutePacket &pkt) signal_route_changed.emit(route); } -} // namespace Marklin +} // namespace R2C2