diff --git a/lighthub/item.cpp b/lighthub/item.cpp index f7ba6e0..1fc962a 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -496,13 +496,56 @@ int Item::Ctrl(short cmd, short n, int *Parameters, boolean send, int suffixCode } - if (driver) + if (driver) //New style modular code { - int res = driver->Ctrl(cmd, n, Parameters, send, suffixCode, subItem); - setCmd(cmd); + int res = -1; + switch (cmd) + { + case CMD_XON: + if (!chActive>0) //if channel was'nt active before CMD_XON + { + debugSerial<Ctrl(CMD_ON, n, Parameters, send, suffixCode, subItem); + setCmd(CMD_XON); + } + else + { //cmd = CMD_ON; + debugSerial<0) //if channel was active before CMD_HALT + { + res = driver->Ctrl(CMD_OFF, n, Parameters, send, suffixCode, subItem); + setCmd(CMD_HALT); + return res; + } + else + { + debugSerial<Ctrl(cmd, n, Parameters, send, suffixCode, subItem); + setCmd(CMD_OFF); + } + else + { + debugSerial<Ctrl(cmd, n, Parameters, send, suffixCode, subItem); + setCmd(cmd); + } return res; } - // Legacy code + // Legacy monolite core code bool toExecute = (chActive>0); //if channel is already active - unconditionally propogate changes switch (cmd) { case 0: // old style SET - with turning ON