Skip to content
Open
Changes from all commits
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
26 changes: 14 additions & 12 deletions isisdaeApp/src/isisdaeDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1811,14 +1811,14 @@ void isisdaeDriver::pollerThread4()
int arrayCallbacks;
NDArray *pImage;
double acquireTime, acquirePeriod, delay, updateTime;
epicsTimeStamp startTime, endTime;
double elapsedTime, maxval;
epicsTime startTime, endUpdateTime, endTime; // these hold monotonic time
epicsTimeStamp startTimeTS;
double elapsedTime, maxval, loop_delay(1.0);
std::vector<int> old_acquiring(maxAddr, 0);
std::vector<epicsTimeStamp> last_update(maxAddr);
std::vector<epicsTime> last_update(maxAddr);
long totalCntsDiff, maxSpecCntsDiff;

registerStructuredExceptionHandler();
memset(&(last_update[0]), 0, maxAddr * sizeof(epicsTimeStamp));
while(true)
{
all_acquiring = all_enable = 0;
Expand Down Expand Up @@ -1847,17 +1847,19 @@ void isisdaeDriver::pollerThread4()
old_acquiring[i] = acquiring;
}
setIntegerParam(i, ADStatus, ADStatusAcquire);
epicsTimeGetCurrent(&startTime);
getIntegerParam(i, ADImageMode, &imageMode);

/* Get the exposure parameters */
getDoubleParam(i, ADAcquireTime, &acquireTime); // not really used

startTime = epicsTime::getMonotonic();
setShutter(i, ADShutterOpen);
callParamCallbacks(i, i);

/* Update the image */
epicsTimeGetCurrent(&startTimeTS);
status = computeImage(i, maxval, totalCntsDiff, maxSpecCntsDiff, data_mode);
endUpdateTime = epicsTime::getMonotonic();

// if (status) continue;

Expand Down Expand Up @@ -1888,7 +1890,7 @@ void isisdaeDriver::pollerThread4()

/* Put the frame number and time stamp into the buffer */
pImage->uniqueId = imageCounter;
pImage->timeStamp = startTime.secPastEpoch + startTime.nsec / 1.e9;
pImage->timeStamp = startTimeTS.secPastEpoch + startTimeTS.nsec / 1.e9;
updateTimeStamp(&pImage->epicsTS);

/* Get any attributes that have been defined for this driver */
Expand All @@ -1903,9 +1905,10 @@ void isisdaeDriver::pollerThread4()
"%s:%s: calling imageData callback addr %d\n", driverName, functionName, i);
doCallbacksGenericPointer(pImage, NDArrayData, i);
}
epicsTimeGetCurrent(&endTime);
elapsedTime = epicsTimeDiffInSeconds(&endTime, &startTime);
updateTime = epicsTimeDiffInSeconds(&endTime, &(last_update[i]));
endTime = epicsTime::getMonotonic();
elapsedTime = endTime - startTime;
updateTime = endUpdateTime - last_update[i];
last_update[i] = endUpdateTime;
if (updateTime > 0.0)
{
setDoubleParam(i, P_integralsUpdateRate, 1.0 / updateTime);
Expand All @@ -1919,7 +1922,6 @@ void isisdaeDriver::pollerThread4()
setDoubleParam(i, P_integralsSpecCountRate, 0.0);
}
setDoubleParam(i, P_integralsSpecMax, maxval);
last_update[i] = endTime;
/* Call the callbacks to update any changes */
callParamCallbacks(i, i);
/* sleep for the acquire period minus elapsed time. */
Expand All @@ -1946,11 +1948,11 @@ void isisdaeDriver::pollerThread4()
}
if (all_enable == 0 || all_acquiring == 0)
{
epicsThreadSleep(1.0);
epicsThreadSleep(loop_delay);
}
else
{
epicsThreadSleep(1.0);
epicsThreadSleep(loop_delay);
}
}
}
Expand Down