pvAlarm, pvTimeStamp, pvControl, pvDisplay: only put to fields that have changed

This commit is contained in:
mrkraimer
2017-10-16 10:00:22 -04:00
parent a88d491012
commit 6fdeadf171
5 changed files with 89 additions and 19 deletions

View File

@@ -98,7 +98,7 @@ public:
* Set userTag.
* @param userTag application specific.
*/
void setUserTag(int userTag) {this->userTag = userTag;}
void setUserTag(int32 userTag) {this->userTag = userTag;}
/**
* Set time fields in timeStamp.
* Result will be normalized.

View File

@@ -72,10 +72,25 @@ bool PVAlarm::set(Alarm const & alarm)
throw std::logic_error(notAttached);
}
if(pvSeverity->isImmutable() || pvMessage->isImmutable()) return false;
pvSeverity->put(alarm.getSeverity());
pvStatus->put(alarm.getStatus());
pvMessage->put(alarm.getMessage());
return true;
Alarm current;
get(current);
bool returnValue = false;
if(current.getSeverity()!=alarm.getSeverity())
{
pvSeverity->put(alarm.getSeverity());
returnValue = true;
}
if(current.getStatus()!=alarm.getStatus())
{
pvStatus->put(alarm.getStatus());
returnValue = true;
}
if(current.getMessage()!=alarm.getMessage())
{
pvMessage->put(alarm.getMessage());
returnValue = true;
}
return returnValue;
}
}}

View File

@@ -70,10 +70,25 @@ bool PVControl::set(Control const & control)
throw std::logic_error(notAttached);
}
if(pvLow->isImmutable() || pvHigh->isImmutable() || pvMinStep->isImmutable()) return false;
pvLow->put(control.getLow());
pvHigh->put(control.getHigh());
pvMinStep->put(control.getMinStep());
return true;
Control current;
get(current);
bool returnValue = false;
if(current.getLow()!=control.getLow())
{
pvLow->put(control.getLow());
returnValue = true;
}
if(current.getHigh()!=control.getHigh())
{
pvHigh->put(control.getHigh());
returnValue = true;
}
if(current.getMinStep()!=control.getMinStep())
{
pvMinStep->put(control.getMinStep());
returnValue = true;
}
return returnValue;
}
}}

View File

@@ -85,13 +85,38 @@ bool PVDisplay::set(Display const & display)
}
if(pvDescription->isImmutable() || pvFormat->isImmutable()) return false;
if(pvUnits->isImmutable() || pvLow->isImmutable() || pvHigh->isImmutable())
{
return false;
pvDescription->put(display.getDescription());
pvFormat->put(display.getFormat());
pvUnits->put(display.getUnits());
pvLow->put(display.getLow());
pvHigh->put(display.getHigh());
return true;
}
Display current;
get(current);
bool returnValue = false;
if(current.getDescription()!=display.getDescription())
{
pvDescription->put(display.getDescription());
returnValue = true;
}
if(current.getFormat()!=display.getFormat())
{
pvFormat->put(display.getFormat());
returnValue = true;
}
if(current.getUnits()!=display.getUnits())
{
pvUnits->put(display.getUnits());
returnValue = true;
}
if(current.getLow()!=display.getLow())
{
pvLow->put(display.getLow());
returnValue = true;
}
if(current.getHigh()!=display.getHigh())
{
pvHigh->put(display.getHigh());
returnValue = true;
}
return returnValue;
}
}}

View File

@@ -73,10 +73,25 @@ bool PVTimeStamp::set(TimeStamp const & timeStamp)
throw std::logic_error(notAttached);
}
if(pvSecs->isImmutable() || pvNano->isImmutable()) return false;
pvSecs->put(timeStamp.getSecondsPastEpoch());
pvUserTag->put(timeStamp.getUserTag());
pvNano->put(timeStamp.getNanoseconds());
return true;
TimeStamp current;
get(current);
bool returnValue = false;
if(current.getSecondsPastEpoch()!=timeStamp.getSecondsPastEpoch())
{
pvSecs->put(timeStamp.getSecondsPastEpoch());
returnValue = true;
}
if(current.getNanoseconds()!=timeStamp.getNanoseconds())
{
pvNano->put(timeStamp.getNanoseconds());
returnValue = true;
}
if(current.getUserTag()!=timeStamp.getUserTag())
{
pvUserTag->put(timeStamp.getUserTag());
returnValue = true;
}
return returnValue;
}
}}