X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Freply.cpp;h=1d7d536ba1dbb506c94289e23499b138bba44f86;hb=dcfa1e9503b7e97b61396d7458f0b2e5896779cd;hp=5a02df212897c4efd36a2261d4747d94da41617b;hpb=38fb8d56efde037a71c46a58bda314655e68ab6c;p=r2c2.git diff --git a/source/libmarklin/reply.cpp b/source/libmarklin/reply.cpp index 5a02df2..1d7d536 100644 --- a/source/libmarklin/reply.cpp +++ b/source/libmarklin/reply.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -108,6 +108,45 @@ Reply Reply::read(int fd, Cmd cmd) return result; } +Reply Reply::simulate(Cmd cmd) +{ + Reply result; + + if(cmd==CMD_STATUS) + { + result.data[0] = 0x80; + result.len = 1; + } + if(cmd==CMD_EVENT) + result.len = 1; + else if(cmd==CMD_TURNOUT) + ; + else if(cmd==CMD_TURNOUT_STATUS) + { + result.data[0] = 0x04; + result.len = 1; + } + else if(cmd==CMD_LOK) + ; + else if(cmd==CMD_LOK_STATUS) + { + result.data[1] = 0x20; + result.len = 3; + } + else if(cmd==CMD_SENSOR_PARAM_SET) + ; + else if(cmd==CMD_SENSOR_REPORT) + ; + else if(cmd==CMD_POWER_ON) + ; + else if(cmd==CMD_POWER_OFF) + ; + else + result.err = ERR_SYS_ERROR; + + return result; +} + ostream &operator<<(ostream &out, const Reply &reply) { out<