diff --git a/ADApp/Db/NDROIStat.template b/ADApp/Db/NDROIStat.template index 88057ec39..e5961c286 100644 --- a/ADApp/Db/NDROIStat.template +++ b/ADApp/Db/NDROIStat.template @@ -43,7 +43,9 @@ record(mbbo, "$(P)$(R)TSControl") field(TWVL, "2") field(TWST, "Stop") field(THVL, "3") - field(THST, "Read") + field(THST, "Read") + field(FRVL, "4") + field(FRST, "Erase") } # This record periodically pokes the TSControl record with 3 to read the time series diff --git a/ADApp/pluginSrc/NDPluginROIStat.cpp b/ADApp/pluginSrc/NDPluginROIStat.cpp index dec3c4571..15cfef20f 100644 --- a/ADApp/pluginSrc/NDPluginROIStat.cpp +++ b/ADApp/pluginSrc/NDPluginROIStat.cpp @@ -361,10 +361,8 @@ asynStatus NDPluginROIStat::writeInt32(asynUser *pasynUser, epicsInt32 value) } else if (function == NDPluginROIStatTSControl) { switch (value) { case TSEraseStart: - currentTSPoint_ = 0; - setIntegerParam(NDPluginROIStatTSCurrentPoint, currentTSPoint_); + clearTimeSeries(); setIntegerParam(NDPluginROIStatTSAcquiring, 1); - memset(timeSeries_, 0, maxROIs_*MAX_TIME_SERIES_TYPES*numTSPoints_*sizeof(double)); break; case TSStart: if (currentTSPoint_ < numTSPoints_) { @@ -378,6 +376,10 @@ asynStatus NDPluginROIStat::writeInt32(asynUser *pasynUser, epicsInt32 value) case TSRead: doTimeSeriesCallbacks(); break; + case TSErase: + clearTimeSeries(); + doTimeSeriesCallbacks(); + break; } } else if (function < FIRST_NDPLUGIN_ROISTAT_PARAM) { stat = (NDPluginDriver::writeInt32(pasynUser, value) == asynSuccess) && stat; @@ -432,6 +434,19 @@ asynStatus NDPluginROIStat::clear(epicsUInt32 roi) return status; } +/** + * Reset the time series data. + * This is meant to be called in writeInt32. + */ +void NDPluginROIStat::clearTimeSeries() +{ + currentTSPoint_ = 0; + setIntegerParam(NDPluginROIStatTSCurrentPoint, currentTSPoint_); + if (timeSeries_) { + memset(timeSeries_, 0, maxROIs_*MAX_TIME_SERIES_TYPES*numTSPoints_*sizeof(double)); + } +} + void NDPluginROIStat::doTimeSeriesCallbacks() { double *pData; diff --git a/ADApp/pluginSrc/NDPluginROIStat.h b/ADApp/pluginSrc/NDPluginROIStat.h index 495550bbf..99c754aaf 100644 --- a/ADApp/pluginSrc/NDPluginROIStat.h +++ b/ADApp/pluginSrc/NDPluginROIStat.h @@ -62,7 +62,8 @@ typedef enum { TSEraseStart, TSStart, TSStop, - TSRead + TSRead, + TSErase } NDPluginROIStatsTSControl_t; /** Structure defining a Region-Of-Interest and Stats */ @@ -140,6 +141,7 @@ class NDPLUGIN_API NDPluginROIStat : public NDPluginDriver { template asynStatus doComputeStatisticsT(NDArray *pArray, NDROI_t *pROI); asynStatus doComputeStatistics(NDArray *pArray, NDROI_t *pStats); asynStatus clear(epicsUInt32 roi); + void clearTimeSeries(); void doTimeSeriesCallbacks(); int maxROIs_; @@ -149,3 +151,5 @@ class NDPLUGIN_API NDPluginROIStat : public NDPluginDriver { }; #endif //NDPluginROIStat_H + +