handle out of control limits better
This commit is contained in:
@ -92,15 +92,18 @@ bool ControlSupport::process()
|
|||||||
double limitLow = pvLimitLow->get();
|
double limitLow = pvLimitLow->get();
|
||||||
double limitHigh = pvLimitHigh->get();
|
double limitHigh = pvLimitHigh->get();
|
||||||
double minStep = pvMinStep->get();
|
double minStep = pvMinStep->get();
|
||||||
|
bool setValue = false;
|
||||||
if(limitHigh>limitLow) {
|
if(limitHigh>limitLow) {
|
||||||
if(value>limitHigh) value = limitHigh;
|
if(value>limitHigh) {value = limitHigh;setValue=true;}
|
||||||
if(value<limitLow) value = limitLow;
|
if(value<limitLow) {value = limitLow;setValue=true;}
|
||||||
}
|
}
|
||||||
|
if(setValue) convert->fromDouble(pvValue,value);
|
||||||
double diff = value - currentValue;
|
double diff = value - currentValue;
|
||||||
double outputValue = value;
|
double outputValue = value;
|
||||||
if(minStep>0.0) {
|
if(minStep>0.0) {
|
||||||
if(diff<0.0) {
|
if(diff<0.0) {
|
||||||
outputValue = currentValue - minStep;
|
outputValue = currentValue - minStep;
|
||||||
|
if(limitHigh>limitLow && outputValue<=limitLow) outputValue = limitLow;
|
||||||
isMinStep = true;
|
isMinStep = true;
|
||||||
if(outputValue<value) {
|
if(outputValue<value) {
|
||||||
outputValue = value;
|
outputValue = value;
|
||||||
@ -108,6 +111,7 @@ bool ControlSupport::process()
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outputValue = currentValue + minStep;
|
outputValue = currentValue + minStep;
|
||||||
|
if(limitHigh>limitLow && outputValue>=limitHigh) outputValue = limitHigh;
|
||||||
isMinStep = true;
|
isMinStep = true;
|
||||||
if(outputValue>value) {
|
if(outputValue>value) {
|
||||||
outputValue = value;
|
outputValue = value;
|
||||||
@ -115,11 +119,9 @@ bool ControlSupport::process()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(outputValue==currentValue) return false;
|
||||||
currentValue = outputValue;
|
currentValue = outputValue;
|
||||||
convert->fromDouble(pvOutputValue,outputValue);
|
convert->fromDouble(pvOutputValue,outputValue);
|
||||||
if(!isMinStep && (outputValue!=value)) {
|
|
||||||
convert->fromDouble(pvValue,value);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user