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 + + diff --git a/docs/ADCore/NDPluginROIStat.rst b/docs/ADCore/NDPluginROIStat.rst index abc6cccd4..cce518de7 100644 --- a/docs/ADCore/NDPluginROIStat.rst +++ b/docs/ADCore/NDPluginROIStat.rst @@ -93,7 +93,9 @@ tables. ROISTAT_TS_CURRENT_POINT. Used to restart collection after a Stop operation. |br| **Stop**: Stops times-series data collection. Performs callbacks on all time-series waveform records. |br| - **Read**: Performs callbacks on all time-series waveform records, updating the values. + **Read**: Performs callbacks on all time-series waveform records, updating the values. |br| + **Erase**: Clears all time-series arrays, sets ROISTAT_TS_CURRENT_POINT=0, and performs + callbacks on all time-series waveform records. - ROISTAT_TS_CONTROL - $(P)$(R)TSControl - mbbo