From 86153c20ca59eec5f1cbf25cdc2bc1fcb90fad2e Mon Sep 17 00:00:00 2001 From: Benjamin Bradnick Date: Wed, 19 Feb 2020 11:15:00 +0000 Subject: [PATCH] Now set ADAcquire parameter to 1 after detector acquisition has started --- andorApp/src/andorCCD.cpp | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 7efb253..cb32783 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -627,16 +627,18 @@ asynStatus AndorCCD::writeInt32(asynUser *pasynUser, epicsInt32 value) asynStatus status = asynSuccess; static const char *functionName = "writeInt32"; - //Set in param lib so the user sees a readback straight away. Save a backup in case of errors. + // Set in param lib so the user sees a readback straight away. Save a backup in case of errors. getIntegerParam(function, &oldValue); status = setIntegerParam(function, value); if (function == ADAcquire) { getIntegerParam(ADStatus, &adstatus); + // Temporarily set ADAcquire back to 0 until Acquisition is started by dataTask + status = setIntegerParam(ADAcquire, 0); if (value && (adstatus == ADStatusIdle)) { try { mAcquiringData = 1; - //We send an event at the bottom of this function. + // We send an event at the bottom of this function. } catch (const std::string &e) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: %s\n", @@ -724,9 +726,6 @@ asynStatus AndorCCD::writeInt32(asynUser *pasynUser, epicsInt32 value) status = ADDriver::writeInt32(pasynUser, value); } - //For a successful write, clear the error message. - setStringParam(AndorMessage, " "); - /* Do callbacks so higher layers see any changes */ callParamCallbacks(); @@ -737,18 +736,22 @@ asynStatus AndorCCD::writeInt32(asynUser *pasynUser, epicsInt32 value) asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, Sending dataEvent to dataTask ...\n", driverName, functionName); - //Also signal the data readout thread + // Also signal the data readout thread epicsEventSignal(dataEvent); } - if (status) + if (status) { asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%d\n", driverName, functionName, status, function, value); - else + } + else { asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%d\n", driverName, functionName, function, value); + /* For a successful write, clear the error message. */ + setStringParam(AndorMessage, " "); + } return status; } @@ -1479,7 +1482,7 @@ void AndorCCD::dataTask(void) epicsTimeStamp startTime; NDArray *pArray; int autoSave; - int readOutMode; + int readOutMode; static const char *functionName = "dataTask"; printf("%s:%s: Data thread started...\n", driverName, functionName); @@ -1515,13 +1518,16 @@ void AndorCCD::dataTask(void) driverName, functionName); checkStatus(StartAcquisition()); acquiring = 1; + asynPrint(pasynUserSelf, ASYN_TRACE_FLOW, + "%s:%s: Acquisition started\n", + driverName, functionName); } catch (const std::string &e) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: %s\n", driverName, functionName, e.c_str()); continue; } - //Read some parameters + // Read some parameters getIntegerParam(NDDataType, &itemp); dataType = (NDDataType_t)itemp; getIntegerParam(NDAutoSave, &autoSave); getIntegerParam(NDArrayCallbacks, &arrayCallbacks); @@ -1531,6 +1537,9 @@ void AndorCCD::dataTask(void) setIntegerParam(ADNumImagesCounter, 0); setIntegerParam(ADNumExposuresCounter, 0); callParamCallbacks(); + // Set ADAcquire to 1 + setIntegerParam(ADAcquire, 1); + callParamCallbacks(); } else { asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s:, Data thread is running but main thread thinks we are not acquiring.\n", @@ -1579,8 +1588,8 @@ void AndorCCD::dataTask(void) dims[0] = sizeX; dims[1] = sizeY; pArray = this->pNDArrayPool->alloc(nDims, dims, dataType, 0, NULL); - if (readOutMode == ARRandomTrack) - mMultiTrack.storeTrackAttributes(pArray->pAttributeList); + if (readOutMode == ARRandomTrack) + mMultiTrack.storeTrackAttributes(pArray->pAttributeList); // Read the oldest array // Is there still an image available? status = GetNumberNewImages(&firstImage, &lastImage);