From 440176e7c0e9c52541a86f332beb71aa086ea642 Mon Sep 17 00:00:00 2001 From: Mark Rivers Date: Fri, 24 Feb 2023 16:06:47 -0600 Subject: [PATCH 1/7] Wait for the status thread to set ADStatus to something other than ADStatusAcquire in the dataTask before finishing an acquisition --- andorApp/src/andorCCD.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index d06801ee..2f993b10 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -1686,7 +1686,13 @@ void AndorCCD::dataTask(void) // Now clear main thread flag mAcquiringData = 0; setIntegerParam(ADAcquire, 0); - //setIntegerParam(ADStatus, 0); //Dont set this as the status thread sets it. + // Wait for the status thread to set ADStatus to something other than ADStatusAcquire + while (1) { + epicsInt32 acquireStatus; + getIntegerParam(ADStatus, &acquireStatus); + if (acquireStatus != ADStatusAcquire) break; + epicsThreadSleep(0.01); + } /* Call the callbacks to update any changes */ callParamCallbacks(); From 71ba531999c42f84b3942b430bf80e0ffad4a3ed Mon Sep 17 00:00:00 2001 From: Mark Rivers Date: Tue, 28 Feb 2023 09:02:22 -0600 Subject: [PATCH 2/7] Fix logic waiting for camera actually being done --- andorApp/src/andorCCD.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 2f993b10..da70eedd 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -1686,11 +1686,13 @@ void AndorCCD::dataTask(void) // Now clear main thread flag mAcquiringData = 0; setIntegerParam(ADAcquire, 0); - // Wait for the status thread to set ADStatus to something other than ADStatusAcquire + // Wait for detector to actually stop acquiring while (1) { - epicsInt32 acquireStatus; - getIntegerParam(ADStatus, &acquireStatus); - if (acquireStatus != ADStatusAcquire) break; + int value; + unsigned int uvalue; + checkStatus(GetStatus(&value)); + uvalue = static_cast(value); + if (uvalue != ASAcquiring) break; epicsThreadSleep(0.01); } From d88206e027a923abd9de8f3e21d612b0e4b81287 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Wed, 1 Mar 2023 14:05:11 +0000 Subject: [PATCH 3/7] wait for the ADStatus to change, allow other threads to change --- andorApp/src/andorCCD.cpp | 63 ++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index da70eedd..346f39e2 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -901,25 +901,25 @@ void AndorCCD::setupTrackDefn(int minX, int sizeX, int binX) setIntegerParam(NDArraySizeY, mMultiTrack.DataHeight()); for (size_t TrackNo = 0; TrackNo < mMultiTrack.size(); TrackNo++) { - /* - Each track must be defined by a group of six integers. - - The top and bottom positions of the tracks. - - The left and right positions for the area of interest within each track - - The horizontal and vertical binning for each track. */ - /* - Andor use 1-based exclusive co-ordinates. - e.g. from SDK manual: - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 */ - TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; - TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. - TrackDefn[TrackNo * 6 + 2] = minX + 1; - TrackDefn[TrackNo * 6 + 3] = minX + sizeX; - TrackDefn[TrackNo * 6 + 4] = binX; - TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); + /* + Each track must be defined by a group of six integers. + - The top and bottom positions of the tracks. + - The left and right positions for the area of interest within each track + - The horizontal and vertical binning for each track. */ + /* + Andor use 1-based exclusive co-ordinates. + e.g. from SDK manual: + 1 2 1 1024 1 1 + 3 4 1 1024 1 1 + 5 6 1 1024 1 1 + 7 8 1 1024 1 1 + 9 10 1 1024 1 1 */ + TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; + TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. + TrackDefn[TrackNo * 6 + 2] = minX + 1; + TrackDefn[TrackNo * 6 + 3] = minX + sizeX; + TrackDefn[TrackNo * 6 + 4] = binX; + TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); } checkStatus(SetCustomTrackHBin(binX)); checkStatus(SetComplexImage(int(TrackDefn.size() / ValuesPerTrack), &TrackDefn[0])); @@ -1409,8 +1409,8 @@ asynStatus AndorCCD::setupAcquisition() driverName, functionName, verticalShiftPeriod); checkStatus(SetVSSpeed(verticalShiftPeriod)); - if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) - { + if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) + { asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, SetVSAmplitude(%d)\n", driverName, functionName, verticalShiftAmplitude); @@ -1683,19 +1683,22 @@ void AndorCCD::dataTask(void) ADDriver::setShutter(ADShutterClosed); } - // Now clear main thread flag - mAcquiringData = 0; - setIntegerParam(ADAcquire, 0); - // Wait for detector to actually stop acquiring + + // Wait for the status thread to set ADStatus to something other than Acquiring while (1) { - int value; - unsigned int uvalue; - checkStatus(GetStatus(&value)); - uvalue = static_cast(value); - if (uvalue != ASAcquiring) break; + epicsInt32 acquireStatus; + getIntegerParam(ADStatus,&acquireStatus); + if (acquireStatus!=ADStatusAcquire) break; + // Allow other threads to update ADStatusAcquire + this->unlock(); epicsThreadSleep(0.01); + this->lock(); } + // Now clear main thread flag. W + mAcquiringData = 0; + setIntegerParam(ADAcquire, 0); + /* Call the callbacks to update any changes */ callParamCallbacks(); } // End of loop From 262f15bd879a343f920f3450596ace63b25a346f Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 2 Mar 2023 16:27:54 +0000 Subject: [PATCH 4/7] undoing --- andorApp/src/andorCCD.cpp | 59 ++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 346f39e2..2f993b10 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -901,25 +901,25 @@ void AndorCCD::setupTrackDefn(int minX, int sizeX, int binX) setIntegerParam(NDArraySizeY, mMultiTrack.DataHeight()); for (size_t TrackNo = 0; TrackNo < mMultiTrack.size(); TrackNo++) { - /* - Each track must be defined by a group of six integers. - - The top and bottom positions of the tracks. - - The left and right positions for the area of interest within each track - - The horizontal and vertical binning for each track. */ - /* - Andor use 1-based exclusive co-ordinates. - e.g. from SDK manual: - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 */ - TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; - TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. - TrackDefn[TrackNo * 6 + 2] = minX + 1; - TrackDefn[TrackNo * 6 + 3] = minX + sizeX; - TrackDefn[TrackNo * 6 + 4] = binX; - TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); + /* + Each track must be defined by a group of six integers. + - The top and bottom positions of the tracks. + - The left and right positions for the area of interest within each track + - The horizontal and vertical binning for each track. */ + /* + Andor use 1-based exclusive co-ordinates. + e.g. from SDK manual: + 1 2 1 1024 1 1 + 3 4 1 1024 1 1 + 5 6 1 1024 1 1 + 7 8 1 1024 1 1 + 9 10 1 1024 1 1 */ + TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; + TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. + TrackDefn[TrackNo * 6 + 2] = minX + 1; + TrackDefn[TrackNo * 6 + 3] = minX + sizeX; + TrackDefn[TrackNo * 6 + 4] = binX; + TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); } checkStatus(SetCustomTrackHBin(binX)); checkStatus(SetComplexImage(int(TrackDefn.size() / ValuesPerTrack), &TrackDefn[0])); @@ -1409,8 +1409,8 @@ asynStatus AndorCCD::setupAcquisition() driverName, functionName, verticalShiftPeriod); checkStatus(SetVSSpeed(verticalShiftPeriod)); - if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) - { + if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) + { asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, SetVSAmplitude(%d)\n", driverName, functionName, verticalShiftAmplitude); @@ -1683,22 +1683,17 @@ void AndorCCD::dataTask(void) ADDriver::setShutter(ADShutterClosed); } - - // Wait for the status thread to set ADStatus to something other than Acquiring + // Now clear main thread flag + mAcquiringData = 0; + setIntegerParam(ADAcquire, 0); + // Wait for the status thread to set ADStatus to something other than ADStatusAcquire while (1) { epicsInt32 acquireStatus; - getIntegerParam(ADStatus,&acquireStatus); - if (acquireStatus!=ADStatusAcquire) break; - // Allow other threads to update ADStatusAcquire - this->unlock(); + getIntegerParam(ADStatus, &acquireStatus); + if (acquireStatus != ADStatusAcquire) break; epicsThreadSleep(0.01); - this->lock(); } - // Now clear main thread flag. W - mAcquiringData = 0; - setIntegerParam(ADAcquire, 0); - /* Call the callbacks to update any changes */ callParamCallbacks(); } // End of loop From 7c55466343e97c5546775cb8d59e1cc105321fcc Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 2 Mar 2023 16:29:22 +0000 Subject: [PATCH 5/7] changed line endings --- andorApp/src/andorCCD.cpp | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 2f993b10..1015144a 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -901,25 +901,25 @@ void AndorCCD::setupTrackDefn(int minX, int sizeX, int binX) setIntegerParam(NDArraySizeY, mMultiTrack.DataHeight()); for (size_t TrackNo = 0; TrackNo < mMultiTrack.size(); TrackNo++) { - /* - Each track must be defined by a group of six integers. - - The top and bottom positions of the tracks. - - The left and right positions for the area of interest within each track - - The horizontal and vertical binning for each track. */ - /* - Andor use 1-based exclusive co-ordinates. - e.g. from SDK manual: - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 */ - TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; - TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. - TrackDefn[TrackNo * 6 + 2] = minX + 1; - TrackDefn[TrackNo * 6 + 3] = minX + sizeX; - TrackDefn[TrackNo * 6 + 4] = binX; - TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); + /* + Each track must be defined by a group of six integers. + - The top and bottom positions of the tracks. + - The left and right positions for the area of interest within each track + - The horizontal and vertical binning for each track. */ + /* + Andor use 1-based exclusive co-ordinates. + e.g. from SDK manual: + 1 2 1 1024 1 1 + 3 4 1 1024 1 1 + 5 6 1 1024 1 1 + 7 8 1 1024 1 1 + 9 10 1 1024 1 1 */ + TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; + TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. + TrackDefn[TrackNo * 6 + 2] = minX + 1; + TrackDefn[TrackNo * 6 + 3] = minX + sizeX; + TrackDefn[TrackNo * 6 + 4] = binX; + TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); } checkStatus(SetCustomTrackHBin(binX)); checkStatus(SetComplexImage(int(TrackDefn.size() / ValuesPerTrack), &TrackDefn[0])); @@ -1409,8 +1409,8 @@ asynStatus AndorCCD::setupAcquisition() driverName, functionName, verticalShiftPeriod); checkStatus(SetVSSpeed(verticalShiftPeriod)); - if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) - { + if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) + { asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, SetVSAmplitude(%d)\n", driverName, functionName, verticalShiftAmplitude); From dc6463c7e7f47d86c47b023f8c11165c0a70ee32 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 2 Mar 2023 16:31:07 +0000 Subject: [PATCH 6/7] changes required to wait before setting Busy --- andorApp/src/andorCCD.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 1015144a..2ec0a99f 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -1682,18 +1682,22 @@ void AndorCCD::dataTask(void) if (adShutterMode == ADShutterModeEPICS) { ADDriver::setShutter(ADShutterClosed); } - - // Now clear main thread flag - mAcquiringData = 0; - setIntegerParam(ADAcquire, 0); - // Wait for the status thread to set ADStatus to something other than ADStatusAcquire + + // Wait for the status thread to set ADStatus to something other than Acquiring while (1) { epicsInt32 acquireStatus; - getIntegerParam(ADStatus, &acquireStatus); - if (acquireStatus != ADStatusAcquire) break; + getIntegerParam(ADStatus,&acquireStatus); + if (acquireStatus!=ADStatusAcquire) break; + // Allow other threads to update ADStatusAcquire + this->unlock(); epicsThreadSleep(0.01); + this->lock(); } + // Now clear main thread flag + mAcquiringData = 0; + setIntegerParam(ADAcquire, 0); + /* Call the callbacks to update any changes */ callParamCallbacks(); } // End of loop From 558fcc0b892e073d446b2ccdb5fc5567fd7b4235 Mon Sep 17 00:00:00 2001 From: Will Smith Date: Thu, 2 Mar 2023 16:31:21 +0000 Subject: [PATCH 7/7] Revert "changed line endings" This reverts commit 7c55466343e97c5546775cb8d59e1cc105321fcc. --- andorApp/src/andorCCD.cpp | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 2ec0a99f..abecd288 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -901,25 +901,25 @@ void AndorCCD::setupTrackDefn(int minX, int sizeX, int binX) setIntegerParam(NDArraySizeY, mMultiTrack.DataHeight()); for (size_t TrackNo = 0; TrackNo < mMultiTrack.size(); TrackNo++) { - /* - Each track must be defined by a group of six integers. - - The top and bottom positions of the tracks. - - The left and right positions for the area of interest within each track - - The horizontal and vertical binning for each track. */ - /* - Andor use 1-based exclusive co-ordinates. - e.g. from SDK manual: - 1 2 1 1024 1 1 - 3 4 1 1024 1 1 - 5 6 1 1024 1 1 - 7 8 1 1024 1 1 - 9 10 1 1024 1 1 */ - TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; - TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. - TrackDefn[TrackNo * 6 + 2] = minX + 1; - TrackDefn[TrackNo * 6 + 3] = minX + sizeX; - TrackDefn[TrackNo * 6 + 4] = binX; - TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); + /* + Each track must be defined by a group of six integers. + - The top and bottom positions of the tracks. + - The left and right positions for the area of interest within each track + - The horizontal and vertical binning for each track. */ + /* + Andor use 1-based exclusive co-ordinates. + e.g. from SDK manual: + 1 2 1 1024 1 1 + 3 4 1 1024 1 1 + 5 6 1 1024 1 1 + 7 8 1 1024 1 1 + 9 10 1 1024 1 1 */ + TrackDefn[TrackNo * 6 + 0] = mMultiTrack.TrackStart(TrackNo) + 1; + TrackDefn[TrackNo * 6 + 1] = mMultiTrack.TrackEnd(TrackNo) + 2; // CCDMultiTrack uses 0-based inlcusive co-ordinates. + TrackDefn[TrackNo * 6 + 2] = minX + 1; + TrackDefn[TrackNo * 6 + 3] = minX + sizeX; + TrackDefn[TrackNo * 6 + 4] = binX; + TrackDefn[TrackNo * 6 + 5] = mMultiTrack.TrackBin(TrackNo); } checkStatus(SetCustomTrackHBin(binX)); checkStatus(SetComplexImage(int(TrackDefn.size() / ValuesPerTrack), &TrackDefn[0])); @@ -1409,8 +1409,8 @@ asynStatus AndorCCD::setupAcquisition() driverName, functionName, verticalShiftPeriod); checkStatus(SetVSSpeed(verticalShiftPeriod)); - if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) - { + if ((mCapabilities.ulSetFunctions & AC_SETFUNCTION_VSAMPLITUDE) != 0) + { asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, SetVSAmplitude(%d)\n", driverName, functionName, verticalShiftAmplitude);