/* $Id$
This file is part of the MSP Märklin suite
-Copyright © 2007-2008 Mikkosoft Productions, Mikko Rasa
+Copyright © 2007-2009 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
if(serial_fd>=0)
queue.front().send(serial_fd);
else
+ {
+ Reply reply = Reply::simulate(queue.front().get_command());
+ queue.front().signal_done.emit(reply);
queue.erase(queue.begin());
+ }
}
}
command(CMD_EVENT_TURNOUT).signal_done.connect(sigc::mem_fun(this, &Control::turnout_event_done));
if(data[0]&0x04)
command(CMD_EVENT_SENSOR).signal_done.connect(sigc::mem_fun(this, &Control::sensor_event_done));
- if(data[1]&0x40)
+ if((data[0]&0x80) && (data[1]&0x40))
command(CMD_STATUS).signal_done.connect(sigc::mem_fun(this, &Control::status_done));
}
/* $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
*/
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<<reply.err;
/* $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
*/
const unsigned char *get_data() const { return data; }
static Reply read(int, Cmd);
+ static Reply simulate(Cmd);
friend std::ostream &operator<<(std::ostream &, const Reply &);
};