Skip to content

Commit

Permalink
Merge pull request #516 from mp49/master
Browse files Browse the repository at this point in the history
NDPluginROIStat: Clear the time series data without also starting acquisition
  • Loading branch information
MarkRivers authored Oct 29, 2024
2 parents 94414af + 0973ca5 commit 4346945
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 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


4 changes: 3 additions & 1 deletion docs/ADCore/NDPluginROIStat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4346945

Please sign in to comment.