Skip to content

Commit

Permalink
NDPluginROIStat: Add the ability to clear the time series data withou…
Browse files Browse the repository at this point in the history
…t also starting acquisition.
  • Loading branch information
Matthew Pearson (mkp) committed Oct 29, 2024
1 parent 94414af commit b85ba4b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ADApp/Db/NDROIStat.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 18 additions & 3 deletions ADApp/pluginSrc/NDPluginROIStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion ADApp/pluginSrc/NDPluginROIStat.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ typedef enum {
TSEraseStart,
TSStart,
TSStop,
TSRead
TSRead,
TSErase
} NDPluginROIStatsTSControl_t;

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

int maxROIs_;
Expand All @@ -149,3 +151,5 @@ class NDPLUGIN_API NDPluginROIStat : public NDPluginDriver {
};

#endif //NDPluginROIStat_H


0 comments on commit b85ba4b

Please sign in to comment.