Skip to content

Commit 8bd8b38

Browse files
authored
Merge pull request #23 from jwlodek/adjust-acquire-logic
Use value of ADAcquire parameter to determine whether or not to start…
2 parents 543bc3d + fcd885c commit 8bd8b38

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

kinetixApp/src/ADKinetix.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,11 @@ void ADKinetix::acquireStop() {
747747
if (this->acquisitionActive) {
748748
// Abort current acquisition
749749
pl_exp_abort(this->cameraContext->hcam, CCS_HALT);
750+
751+
// Mark acquisition as inactive
750752
this->acquisitionActive = false;
751753

752-
// Set acquire PV to 0, wait for acq thread to join
753-
setIntegerParam(ADAcquire, 0);
754+
// Wait for acquisition thread to join
754755
INFO("Waiting for acquisition thread to join...");
755756
epicsThreadMustJoin(this->acquisitionThreadId);
756757
INFO("Acquisition stopped.");
@@ -772,10 +773,10 @@ NDDataType_t ADKinetix::getCurrentNDBitDepth() {
772773
getIntegerParam(KTX_ReadoutPortIdx, &readoutPortIdx);
773774
getIntegerParam(KTX_SpeedIdx, &speedIdx);
774775
getIntegerParam(KTX_GainIdx, &gainIdx);
776+
SpdtabGain currentGainMode = this->cameraContext->speedTable[readoutPortIdx].speeds[speedIdx].gains[gainIdx];
775777

776778
NDDataType_t dataType = NDUInt8;
777-
if (this->cameraContext->speedTable[readoutPortIdx].speeds[speedIdx].gains[gainIdx].bitDepth !=
778-
8) {
779+
if (currentGainMode.bitDepth != 8) {
779780
dataType = NDUInt16;
780781
}
781782
return dataType;
@@ -1081,20 +1082,23 @@ asynStatus ADKinetix::setMinExpRes(KTX_MIN_EXP_RES currentExpRes, KTX_MIN_EXP_RE
10811082
asynStatus ADKinetix::writeInt32(asynUser *pasynUser, epicsInt32 value) {
10821083
const char *functionName = "writeInt32";
10831084
int function = pasynUser->reason;
1084-
int currentExpRes;
1085+
int currentExpRes, acquiring;
10851086
asynStatus status = asynSuccess;
10861087

10871088
// Need to know current exp res when switching in case we cannot update
10881089
getIntegerParam(KTX_MinExpRes, &currentExpRes);
10891090

1091+
// Certain actions depend on whether or not we are currently acquiring
1092+
getIntegerParam(ADAcquire, &acquiring);
1093+
10901094
/* Set the parameter and readback in the parameter library. This may be overwritten when we
10911095
* read back the status at the end, but that's OK */
10921096
status = setIntegerParam(function, value);
10931097

10941098
if (function == ADAcquire) {
1095-
if (this->acquisitionActive && value == 0) {
1099+
if (acquiring == 1 && value == 0) {
10961100
this->acquireStop();
1097-
} else if (!this->acquisitionActive && value == 1) {
1101+
} else if (acquiring == 0 && value == 1) {
10981102
this->acquireStart();
10991103
} else if (value == 0) {
11001104
ERR("Acquisition not active!");

0 commit comments

Comments
 (0)