From 05ea0319773b27e97bd4c8ddc199e28e8b75e343 Mon Sep 17 00:00:00 2001 From: Andrey Date: Sun, 28 Jan 2024 12:05:10 +0300 Subject: [PATCH] PID out, less logs, GET cfg fix, mbus concurr wrte --- lighthub/item.cpp | 2 +- lighthub/itemCmd.cpp | 4 ++-- lighthub/main.cpp | 5 +++-- lighthub/main.h | 3 ++- lighthub/modules/out_modbus.cpp | 24 +++++++++++++++++------- lighthub/modules/out_pid.cpp | 24 +++++++++++++++--------- 6 files changed, 40 insertions(+), 22 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index 0c868d9..5a9e5aa 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -327,7 +327,7 @@ void Item::setCmd(uint8_t cmdValue) { { itemCmd->type = aJson_Int; itemCmd->valueint = cmdValue & CMD_MASK | itemCmd->valueint & (FLAG_MASK); // Preserve special bits - debugSerial<setVal(param.asInt32); item->setSubtype(cmd.itemArgType); } - debugSerial<type) { case aJson_Int: //register/coil/.. number - debugSerial<valueint<valueint<valueint>= registerFrom) && (defMappingObj->valueint<=registerTo)) { mappedParam = findRegister(defMappingObj->valueint,defMappingObj->valueint-registerFrom,regType,registerFrom,registerTo,false,&submitRecurrentOut); @@ -351,7 +351,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin break; case aJson_String: // parameter name - debugSerial<valuestring<valuestring<type ==aJson_Object) { //Searching item param for nested mapping @@ -364,7 +364,7 @@ itemCmd out_Modbus::findRegister(uint16_t registerNum, uint16_t posInBuffer, uin aJsonObject *lastMeasured = aJson.getObjectItem(itemParObj,"@S"); if (lastMeasured && lastMeasured->type ==aJson_Int) { - debugSerial<valueint<valueint<parameters,defMappingObj->valuestring); if (templateParObj) @@ -550,7 +550,7 @@ return itemCmd(); int registerTo=aJson.getArrayItem(reg, 1)->valueint; if (readModbus(registerFrom,regType,registerTo-registerFrom+1)) - { debugSerial<valueint<valueint<type ==aJson_Object) lineInitialized=true; initLine(); } - debugSerial<<"MBUS: SEND "<itemArr->name<<" "; - switch (sendModbus(execObj->name,outValue->valueint,outValue->subtype)) + + int sendRes; + int savedValue; + do + { + savedValue = outValue->valueint; + debugSerial<<"MBUS: SEND "<itemArr->name<<" "; + sendRes = sendModbus(execObj->name,outValue->valueint,outValue->subtype); + } + while (savedValue != outValue->valueint); //repeat sending if target value changed while we're waited for mbus responce + + switch (sendRes) { case 1: //success execObj->subtype&=~ MB_NEED_SEND; diff --git a/lighthub/modules/out_pid.cpp b/lighthub/modules/out_pid.cpp index 59bdb18..58cda5b 100644 --- a/lighthub/modules/out_pid.cpp +++ b/lighthub/modules/out_pid.cpp @@ -334,32 +334,38 @@ case S_CTRL: switch (command) { case CMD_OFF: - //value.Percents255(0); - + if (isNotRetainingStatus()) executeCommand(oCmd,-1,itemCmd().Cmd(CMD_DISABLE)); // Not actually disable, just inform depended systems, that no autoreg now (for pannels indication) + executeCommand(oCmd,-1,value); + item->SendStatus(FLAG_FLAGS); + return 1; case CMD_ON: case CMD_HEAT: case CMD_COOL: case CMD_AUTO: case CMD_FAN: case CMD_DRY: - - executeCommand(oCmd,-1,value); executeCommand(oCmd,-1,itemCmd().Cmd((item->getFlag(FLAG_DISABLED))?CMD_DISABLE:CMD_ENABLE)); + executeCommand(oCmd,-1,value); item->SendStatus(FLAG_FLAGS); return 1; case CMD_ENABLE: - //item->setCmd(CMD_ENABLE); - //item->SendStatus(FLAG_COMMAND); + if (isNotRetainingStatus()) + { + item->setCmd(CMD_ON); + item->SendStatus(FLAG_COMMAND); + } item->setFlag(FLAG_ACTION_NEEDED); - executeCommand(oCmd,-1,value); + executeCommand(oCmd,-1,value); + if (isActive()) executeCommand(oCmd,-1,itemCmd().Cmd((CMD_ON))); + + store->prevOut=-2.0; return 1; case CMD_DISABLE: - //item->setCmd(CMD_DISABLE); - //item->SendStatus(FLAG_COMMAND); executeCommand(oCmd,-1,value); + if (!isActive()) executeCommand(oCmd,-1,itemCmd().Cmd((CMD_OFF))); return 1; /* case CMD_OFF: