Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NDPluginROIStat: Clear the time series data without also starting acquisition #516

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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


Loading