Skip to content

Commit b85ba4b

Browse files
author
Matthew Pearson (mkp)
committed
NDPluginROIStat: Add the ability to clear the time series data without also starting acquisition.
1 parent 94414af commit b85ba4b

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

ADApp/Db/NDROIStat.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ record(mbbo, "$(P)$(R)TSControl")
4343
field(TWVL, "2")
4444
field(TWST, "Stop")
4545
field(THVL, "3")
46-
field(THST, "Read")
46+
field(THST, "Read")
47+
field(FRVL, "4")
48+
field(FRST, "Erase")
4749
}
4850

4951
# This record periodically pokes the TSControl record with 3 to read the time series

ADApp/pluginSrc/NDPluginROIStat.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,8 @@ asynStatus NDPluginROIStat::writeInt32(asynUser *pasynUser, epicsInt32 value)
361361
} else if (function == NDPluginROIStatTSControl) {
362362
switch (value) {
363363
case TSEraseStart:
364-
currentTSPoint_ = 0;
365-
setIntegerParam(NDPluginROIStatTSCurrentPoint, currentTSPoint_);
364+
clearTimeSeries();
366365
setIntegerParam(NDPluginROIStatTSAcquiring, 1);
367-
memset(timeSeries_, 0, maxROIs_*MAX_TIME_SERIES_TYPES*numTSPoints_*sizeof(double));
368366
break;
369367
case TSStart:
370368
if (currentTSPoint_ < numTSPoints_) {
@@ -378,6 +376,10 @@ asynStatus NDPluginROIStat::writeInt32(asynUser *pasynUser, epicsInt32 value)
378376
case TSRead:
379377
doTimeSeriesCallbacks();
380378
break;
379+
case TSErase:
380+
clearTimeSeries();
381+
doTimeSeriesCallbacks();
382+
break;
381383
}
382384
} else if (function < FIRST_NDPLUGIN_ROISTAT_PARAM) {
383385
stat = (NDPluginDriver::writeInt32(pasynUser, value) == asynSuccess) && stat;
@@ -432,6 +434,19 @@ asynStatus NDPluginROIStat::clear(epicsUInt32 roi)
432434
return status;
433435
}
434436

437+
/**
438+
* Reset the time series data.
439+
* This is meant to be called in writeInt32.
440+
*/
441+
void NDPluginROIStat::clearTimeSeries()
442+
{
443+
currentTSPoint_ = 0;
444+
setIntegerParam(NDPluginROIStatTSCurrentPoint, currentTSPoint_);
445+
if (timeSeries_) {
446+
memset(timeSeries_, 0, maxROIs_*MAX_TIME_SERIES_TYPES*numTSPoints_*sizeof(double));
447+
}
448+
}
449+
435450
void NDPluginROIStat::doTimeSeriesCallbacks()
436451
{
437452
double *pData;

ADApp/pluginSrc/NDPluginROIStat.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ typedef enum {
6262
TSEraseStart,
6363
TSStart,
6464
TSStop,
65-
TSRead
65+
TSRead,
66+
TSErase
6667
} NDPluginROIStatsTSControl_t;
6768

6869
/** Structure defining a Region-Of-Interest and Stats */
@@ -140,6 +141,7 @@ class NDPLUGIN_API NDPluginROIStat : public NDPluginDriver {
140141
template <typename epicsType> asynStatus doComputeStatisticsT(NDArray *pArray, NDROI_t *pROI);
141142
asynStatus doComputeStatistics(NDArray *pArray, NDROI_t *pStats);
142143
asynStatus clear(epicsUInt32 roi);
144+
void clearTimeSeries();
143145
void doTimeSeriesCallbacks();
144146

145147
int maxROIs_;
@@ -149,3 +151,5 @@ class NDPLUGIN_API NDPluginROIStat : public NDPluginDriver {
149151
};
150152

151153
#endif //NDPluginROIStat_H
154+
155+

0 commit comments

Comments
 (0)