From 6fdeadf1712dda9f6476d4c8c59324b840ccbfaf Mon Sep 17 00:00:00 2001 From: mrkraimer Date: Mon, 16 Oct 2017 10:00:22 -0400 Subject: [PATCH] pvAlarm, pvTimeStamp, pvControl, pvDisplay: only put to fields that have changed --- src/property/pv/timeStamp.h | 2 +- src/property/pvAlarm.cpp | 23 ++++++++++++++++++---- src/property/pvControl.cpp | 23 ++++++++++++++++++---- src/property/pvDisplay.cpp | 37 ++++++++++++++++++++++++++++++------ src/property/pvTimeStamp.cpp | 23 ++++++++++++++++++---- 5 files changed, 89 insertions(+), 19 deletions(-) diff --git a/src/property/pv/timeStamp.h b/src/property/pv/timeStamp.h index 5f46f3e..16e2ac8 100644 --- a/src/property/pv/timeStamp.h +++ b/src/property/pv/timeStamp.h @@ -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. diff --git a/src/property/pvAlarm.cpp b/src/property/pvAlarm.cpp index 92ce546..1361ec8 100644 --- a/src/property/pvAlarm.cpp +++ b/src/property/pvAlarm.cpp @@ -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; } }} diff --git a/src/property/pvControl.cpp b/src/property/pvControl.cpp index faeda86..f745b1a 100644 --- a/src/property/pvControl.cpp +++ b/src/property/pvControl.cpp @@ -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; } }} diff --git a/src/property/pvDisplay.cpp b/src/property/pvDisplay.cpp index fb3dc88..1205262 100644 --- a/src/property/pvDisplay.cpp +++ b/src/property/pvDisplay.cpp @@ -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; } }} diff --git a/src/property/pvTimeStamp.cpp b/src/property/pvTimeStamp.cpp index d67a31f..ec1c992 100644 --- a/src/property/pvTimeStamp.cpp +++ b/src/property/pvTimeStamp.cpp @@ -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; } }}