Ctrl retcodes - move some to positive values

This commit is contained in:
2022-02-14 02:14:39 +03:00
parent b79d873629
commit 20bdbac8c5

View File

@@ -691,6 +691,12 @@ return false;
} }
//Main routine to control Item //Main routine to control Item
//Return values
// 1 complete
// 3 complete, no action, target reached
// -3 ignored
// -1 system error
// -4 invalid argument
int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion) int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
{ {
@@ -911,7 +917,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
status2Send |= SEND_COMMAND | SEND_IMMEDIATE; status2Send |= SEND_COMMAND | SEND_IMMEDIATE;
break; break;
default: default:
return -3; return 3;
} }
status2Send |= SEND_COMMAND; status2Send |= SEND_COMMAND;
break; break;
@@ -924,7 +930,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
break; break;
default: default:
debugSerial << F("XOFF skipped. Prev cmd:") << t <<endl; debugSerial << F("XOFF skipped. Prev cmd:") << t <<endl;
return -3; return 3;
} }
break; break;
@@ -940,7 +946,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
else else
{ {
debugSerial<<F("XON:Already Active\n"); debugSerial<<F("XON:Already Active\n");
return -3; return 3;
} }
break; break;
case CMD_HALT: case CMD_HALT:
@@ -954,7 +960,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
else else
{ {
debugSerial<<F("HALT:Already Inactive\n"); debugSerial<<F("HALT:Already Inactive\n");
return -3; return 3;
} }
break; break;
} }
@@ -981,7 +987,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
if (subitemCmd != prevCmd) if (subitemCmd != prevCmd)
{ {
debugSerial<<F("Ignored, channel cmd=")<<prevCmd<<endl; debugSerial<<F("Ignored, channel cmd=")<<prevCmd<<endl;
return -1; return -3;
} }
subItem=NULL; subItem=NULL;
} }
@@ -1007,7 +1013,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
status2Send |= SEND_COMMAND | SEND_IMMEDIATE; status2Send |= SEND_COMMAND | SEND_IMMEDIATE;
break; break;
default: default:
return -3; return 3;
} }
status2Send |= SEND_COMMAND; status2Send |= SEND_COMMAND;
break; break;
@@ -1021,7 +1027,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
break; break;
default: default:
debugSerial << F("XOFF skipped. Prev cmd:") << t <<endl; debugSerial << F("XOFF skipped. Prev cmd:") << t <<endl;
return -3; return 3;
} }
break; break;
@@ -1037,7 +1043,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
else else
{ {
debugSerial<<F("XON:Already Active\n"); debugSerial<<F("XON:Already Active\n");
return -3; return 3;
} }
break; break;
case CMD_HALT: case CMD_HALT:
@@ -1051,7 +1057,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
else else
{ {
debugSerial<<F("HALT:Already Inactive\n"); debugSerial<<F("HALT:Already Inactive\n");
return -3; return 3;
} }
break; break;
@@ -1062,7 +1068,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
break; break;
} }
if (getCmd() == CMD_HALT) return -3; //Halted, ignore OFF if (getCmd() == CMD_HALT) return 3; //Halted, ignore OFF
status2Send |= SEND_COMMAND | SEND_IMMEDIATE; status2Send |= SEND_COMMAND | SEND_IMMEDIATE;
toExecute=true; toExecute=true;
break; break;
@@ -1077,7 +1083,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
if (chActive) if (chActive)
{ {
debugSerial<<F("ON:Already Active\n"); debugSerial<<F("ON:Already Active\n");
return -3; return 3;
} }
//newly added. For climate commands need to restore previous temperature //newly added. For climate commands need to restore previous temperature
case CMD_AUTO: case CMD_AUTO:
@@ -2001,7 +2007,7 @@ int Item::checkModbusDimmer() {
short numpar = 0; short numpar = 0;
if ((itemArg->type != aJson_Array) || ((numpar = aJson.getArraySize(itemArg)) < 2)) { if ((itemArg->type != aJson_Array) || ((numpar = aJson.getArraySize(itemArg)) < 2)) {
debugSerial<<F("Illegal arguments\n"); debugSerial<<F("Illegal arguments\n");
return -3; return -4;
} }
modbusBusy = 1; modbusBusy = 1;