X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnetwork%2Ftrain.cpp;h=4ba4df08870891e354c10c86489bc3c82a0290ac;hb=d06a1e1ab34e5ecb4bb7011d44298a0b5e6162be;hp=6a0c3a8b8fa99006c56275e9382618f05998b962;hpb=378f04522aa762729c0d5651fb60ad7e4d8ba9f3;p=r2c2.git diff --git a/source/network/train.cpp b/source/network/train.cpp index 6a0c3a8..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_vehicle(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