Refactored beta

+Doxigen autogenerated docs
This commit is contained in:
2020-11-19 23:47:35 +03:00
parent 9fa9e0f481
commit 7bfe7ed330
601 changed files with 70469 additions and 72 deletions

View File

@@ -346,7 +346,7 @@ void Item::setVal(short n, int par) // Only store if VAL is array defined in c
void Item::setVal(long int par) // Only store if VAL is int (autogenerated or config-defined)
{
if (!itemVal || itemVal->type != aJson_Int) return;
debugSerial<<F(" Store ")<<F(" Val=")<<par<<endl;
//debugSerial<<F(" Store ")<<F(" Val=")<<par<<endl;
itemVal->valueint = par;
}
@@ -487,7 +487,7 @@ st.setSuffix(suffixCode);
while (payload && i < 3)
Par[i++] = getInt((char **) &payload);
switch(suffixCode)
switch(suffixCode)
{case S_HUE:
st.setH(Par[0]);
break;
@@ -497,10 +497,9 @@ st.setSuffix(suffixCode);
default:
switch (i) //Number of params
{
case 1: st.Percents(Par[0]);
case 1: st.Percents(Par[0]); //ToDo float
break;
case 2: st.setH(Par[0]);
st.setS(Par[0]);
case 2: st.HS(Par[0],Par[1]);
break;
case 3: st.HSV(Par[0],Par[1],Par[2]);
default:;
@@ -559,22 +558,27 @@ int Item::Ctrl(itemCmd cmd, char* subItem)
debugSerial<<F("RAM=")<<freeRam()<<F(" Item=")<<itemArr->name<<F(" Sub=")<<subItem<<F(" Suff=")<<suffixCode<<F(" Cmd=")<<cmd.getCmd()<<F(" Par=")<<cmd.toString(stringBuffer, sizeof(stringBuffer))<<endl;
if (!itemArr) return -1;
bool chActive = (isActive()>0);
bool toExecute = (chActive>0); // execute if channel is active now
if (itemType != CH_GROUP )
{
//Check if subitem is some sort of command
int subitemCmd = subitem2cmd(subItem);
if (subitemCmd && subitemCmd != getCmd())
short prevCmd = getCmd();
if (!prevCmd && chActive>0) prevCmd=CMD_ON;
if (subitemCmd && subitemCmd != prevCmd)
{
debugSerial<<F("Ignored, channel cmd=")<<getCmd()<<endl;
debugSerial<<F("Ignored, channel cmd=")<<prevCmd<<endl;
return -1;
}
}
else
// else
// Group channel
if (! operation) return -1;
// if (! operation) return -1;
bool chActive = (isActive()>0);
bool toExecute = (chActive>0); // execute if channel is active now
itemCmd st(ST_VOID,CMD_VOID);
@@ -674,19 +678,21 @@ int Item::Ctrl(itemCmd cmd, char* subItem)
{
case S_NOTFOUND: //For empty (universal) suffix - turn ON/OFF automatically
toExecute=true;
if (chActive>0 && !cmd.getPercents()) st.Cmd(CMD_OFF);
if (chActive==0 && cmd.getPercents()) st.Cmd(CMD_ON);
if (chActive>0 && !cmd.getInt()) st.Cmd(CMD_OFF);
if (chActive==0 && cmd.getInt()) st.Cmd(CMD_ON);
setCmd(st.getCmd());
SendStatus(SEND_COMMAND | SEND_DEFFERED);
// continue processing as SET
case S_SET:
if (itemType == CH_GROUP && cmd.isColor()) st.setArgType(ST_HSV);//Extend storage for group channel
st.assignFrom(cmd);
st.saveItem(this);
SendStatus(SEND_PARAMETERS | SEND_DEFFERED);
break;
case S_SAT:
if (itemType == CH_GROUP && cmd.isColor()) st.setArgType(ST_HSV);//Extend storage for group channel
if (st.setS(cmd.getS()))
{
st.saveItem(this);
@@ -695,6 +701,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem)
break;
case S_HUE:
if (itemType == CH_GROUP && cmd.isColor()) st.setArgType(ST_HSV);//Extend storage for group channel
if (st.setH(cmd.getH()))
{
st.saveItem(this);
@@ -778,7 +785,7 @@ else //Driver not found
switch (itemType) {
case CH_GROUP:
{
if (itemArg->type == aJson_Array) {
if (itemArg->type == aJson_Array && operation) {
aJsonObject *i = itemArg->child;
configLocked++;
while (i) {
@@ -832,13 +839,13 @@ switch (itemType) {
#ifndef MODBUS_DISABLE
case CH_MODBUS:
modbusDimmerSet(st.getPercents());
modbusDimmerSet(st);
break;
case CH_VC:
VacomSetFan(st.getPercents(), st.getCmd());
VacomSetFan(st);
break;
case CH_VCTEMP:
VacomSetHeat(st.getPercents(), st.getCmd());
VacomSetHeat(st);
break;
#endif
@@ -1005,14 +1012,18 @@ POLL 2101x10
*/
#ifndef MODBUS_DISABLE
int Item::modbusDimmerSet(uint16_t value)
int Item::modbusDimmerSet(itemCmd st)
{
switch (getCmd())
{
int value=st.getPercents();
int cmd=st.getCmd();
switch (cmd){
case CMD_OFF:
case CMD_HALT:
value=0;
break;
}
short numpar=0;
@@ -1041,7 +1052,18 @@ extern ModbusMaster node;
int Item::VacomSetFan(int8_t val, int8_t cmd) {
int Item::VacomSetFan(itemCmd st) {
int val=st.getPercents();
int cmd=st.getCmd();
switch (cmd){
case CMD_OFF:
case CMD_HALT:
val=0;
break;
}
uint8_t result;
int addr = getArg();
debugSerial<<F("VC#")<<addr<<F("=")<<val<<endl;
@@ -1074,9 +1096,14 @@ int Item::VacomSetFan(int8_t val, int8_t cmd) {
#define a 0.1842f
#define b -36.68f
int Item::VacomSetHeat(int8_t val, int8_t cmd) {
uint8_t result;
int addr;
///move to float todo
int Item::VacomSetHeat(itemCmd st)
{
int val=st.getPercents();
int cmd=st.getCmd();
uint8_t result;
int addr;
if (itemArg->type != aJson_String) return 0;
Item it(itemArg->valuestring);
@@ -1268,7 +1295,8 @@ boolean Item::checkModbusRetry() {
if (modbusBusy) return false;
// int cmd = getCmd();
if (getFlag(SEND_RETRY)) { // if last sending attempt of command was failed
int val = getVal();
itemCmd val(ST_VOID,CMD_VOID);
val.loadItem(this, true);
debugSerial<<F("Retrying dimmer CMD\n");
clearFlag(SEND_RETRY); // Clean retry flag
modbusDimmerSet(val);
@@ -1279,12 +1307,13 @@ return false;
boolean Item::checkVCRetry() {
if (modbusBusy) return false;
int cmd = getCmd();
//int cmd = getCmd();
if (getFlag(SEND_RETRY)) { // if last sending attempt of command was failed
int val = getVal();
itemCmd val(ST_VOID,CMD_VOID);
val.loadItem(this, true);
debugSerial<<F("Retrying VC CMD\n");
clearFlag(SEND_RETRY); // Clean retry flag
VacomSetFan(val,cmd);
VacomSetFan(val);
return true;
}
return false;
@@ -1292,12 +1321,13 @@ return false;
boolean Item::checkHeatRetry() {
if (modbusBusy) return false;
int cmd = getCmd();
//int cmd = getCmd();
if (getFlag(SEND_RETRY)) { // if last sending attempt of command was failed
int val = getVal();
itemCmd val(ST_VOID,CMD_VOID);
val.loadItem(this, true);
debugSerial<<F("Retrying VC temp CMD\n");
clearFlag(SEND_RETRY); // Clean retry flag
VacomSetHeat(val,cmd);
VacomSetHeat(val);
return true;
}
return false;