mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
PID & Modbus fine tuning
This commit is contained in:
@@ -340,7 +340,13 @@ int out_Modbus::findRegister(int registerNum, int posInBuffer, int regType)
|
|||||||
{
|
{
|
||||||
debugSerial<<F("Ignored - equal with setted val")<<endl;
|
debugSerial<<F("Ignored - equal with setted val")<<endl;
|
||||||
}
|
}
|
||||||
else executeCommand(execObj, -1, mappedParam);
|
else
|
||||||
|
{
|
||||||
|
executeCommand(execObj, -1, mappedParam);
|
||||||
|
// if param updated by device and no new value queued to send - update @V to avoid "Ignored - equal with setted val"
|
||||||
|
if (settedValue && !(execObj->subtype & MB_NEED_SEND))
|
||||||
|
settedValue->valueint=param;
|
||||||
|
}
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -593,13 +599,14 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
aJsonObject *execObj = aJson.getObjectItem(itemParametersObj,suffixStr);
|
aJsonObject *execObj = aJson.getObjectItem(itemParametersObj,suffixStr);
|
||||||
if (execObj && execObj->type == aJson_Object)
|
if (execObj && execObj->type == aJson_Object)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
aJsonObject *polledValue = aJson.getObjectItem(execObj,"@S");
|
aJsonObject *polledValue = aJson.getObjectItem(execObj,"@S");
|
||||||
if (polledValue && polledValue->type == aJson_Int && (polledValue->valueint == Value))
|
if (polledValue && polledValue->type == aJson_Int && (polledValue->valueint == Value))
|
||||||
{
|
{
|
||||||
debugSerial<<F("Ignored - not changed")<<endl;
|
debugSerial<<F("Ignored - not changed")<<endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else */
|
||||||
{ //Schedule update
|
{ //Schedule update
|
||||||
execObj->subtype |= MB_NEED_SEND;
|
execObj->subtype |= MB_NEED_SEND;
|
||||||
|
|
||||||
@@ -608,7 +615,6 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
{
|
{
|
||||||
outValue->valueint=Value;
|
outValue->valueint=Value;
|
||||||
outValue->subtype =regType & 0xF;
|
outValue->subtype =regType & 0xF;
|
||||||
if (outValue->type == aJson_Int) polledValue->valueint=Value; //to pevent suppressing to change back to previously polled value if this occurs before next polling
|
|
||||||
}
|
}
|
||||||
else //No container to store value yet
|
else //No container to store value yet
|
||||||
// If no @V in config - creating with INT type - normal behavior - no supress in-to-out
|
// If no @V in config - creating with INT type - normal behavior - no supress in-to-out
|
||||||
@@ -618,6 +624,10 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
outValue = aJson.getObjectItem(execObj,"@V");
|
outValue = aJson.getObjectItem(execObj,"@V");
|
||||||
if (outValue) outValue->subtype =regType & 0xF;
|
if (outValue) outValue->subtype =regType & 0xF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aJsonObject *polledValue = aJson.getObjectItem(execObj,"@S");
|
||||||
|
if (polledValue && outValue->type == aJson_Int) polledValue->valueint=Value; //to pevent suppressing to change back to previously polled value if this occurs before next polling
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,16 +213,17 @@ int out_pid::getAlarmVal()
|
|||||||
aJsonObject * param;
|
aJsonObject * param;
|
||||||
switch (aJson.getArraySize(kPIDObj))
|
switch (aJson.getArraySize(kPIDObj))
|
||||||
{
|
{
|
||||||
case 7: //kP,kI,kD, alarmTO, alarmVal, outMin, outMax
|
case 8: //kP,kI,kD,dT, alarmTO, alarmVal, outMin, outMax
|
||||||
case 6: //kP,kI,kD, alarmTO, alarmVal, outMin
|
case 7: //kP,kI,kD,dT, alarmTO, alarmVal, outMin
|
||||||
case 5: //kP,kI,kD, alarmTO, alarmVal
|
case 6: //kP,kI,kD,dT,alarmTO, alarmVal
|
||||||
param = aJson.getArrayItem(kPIDObj, 4);
|
param = aJson.getArrayItem(kPIDObj, 5);
|
||||||
alarmValDefined=true;
|
alarmValDefined=true;
|
||||||
if (param->type == aJson_Float) outAlarm=param->valuefloat;
|
if (param->type == aJson_Float) outAlarm=param->valuefloat;
|
||||||
else if (param->type == aJson_Int) outAlarm=param->valueint;
|
else if (param->type == aJson_Int) outAlarm=param->valueint;
|
||||||
else alarmValDefined=false;
|
else alarmValDefined=false;
|
||||||
|
|
||||||
case 4: //kP,kI,kD, alarmTO
|
case 5: //kP,kI,kD,dT, alarmTO
|
||||||
|
case 4: //kP,kI,kD,dT
|
||||||
case 3: //kP,kI,kD
|
case 3: //kP,kI,kD
|
||||||
case 2: //kP,kI
|
case 2: //kP,kI
|
||||||
case 1: //kP
|
case 1: //kP
|
||||||
@@ -234,7 +235,7 @@ int out_pid::getAlarmVal()
|
|||||||
{
|
{
|
||||||
if (!alarmValDefined) outAlarm = 0.;
|
if (!alarmValDefined) outAlarm = 0.;
|
||||||
}
|
}
|
||||||
else if (!alarmValDefined) outAlarm = .255;
|
else if (!alarmValDefined) outAlarm = 255.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return outAlarm;
|
return outAlarm;
|
||||||
|
|||||||
Reference in New Issue
Block a user