diff --git a/src/IrisCamera.cpp b/src/IrisCamera.cpp index 8bd27c21485b273fa9955974fbd253231f3f2ec3..aa1e37af7342ef1f528951ec8dbc72d18418872a 100644 --- a/src/IrisCamera.cpp +++ b/src/IrisCamera.cpp @@ -150,28 +150,17 @@ void Camera::_AcqThread::threadFunction() { bool continueAcq = true; const int16 bufferMode = CIRC_OVERWRITE; - if (!numberframes) { - if (PV_OK != pl_exp_setup_cont(ctx->hcam, 1, &ctx->region, trigMode, exposureTime, &exposureBytes, bufferMode)) { - CloseAllCamerasAndUninit(m_cam.contexts); - m_cam._setStatus(Camera::Fault, false); - THROW_HW_ERROR(Error) << (pl_error_code(), "pl_exp_setup_cont() error"); - } - } else { - if (PV_OK != pl_exp_setup_seq(ctx->hcam, 1, 1, &ctx->region, trigMode, exposureTime, &exposureBytes)) { - CloseAllCamerasAndUninit(m_cam.contexts); - m_cam._setStatus(Camera::Fault, false); - THROW_HW_ERROR(Error) << (pl_error_code(), "Error setting up sequential acq"); - } + if (PV_OK != pl_exp_setup_cont(ctx->hcam, 1, &ctx->region, trigMode, exposureTime, &exposureBytes, bufferMode)) { + CloseAllCamerasAndUninit(m_cam.contexts); + m_cam._setStatus(Camera::Fault, false); + THROW_HW_ERROR(Error) << (pl_error_code(), "pl_exp_setup_cont() error"); } DEB_TRACE() << "Acquisition setup successful"; UpdateCtxImageFormat(ctx); - uns32 circBufferBytes = exposureBytes; - if (!numberframes) - // TODO: check if +1 is still needed - uns32 circBufferBytes = (numberframes + 1) * exposureBytes; + uns32 circBufferBytes = (numberframes + 1) * exposureBytes; uns8* frame = new(std::nothrow) uns8[circBufferBytes]; @@ -180,36 +169,23 @@ void Camera::_AcqThread::threadFunction() { THROW_HW_ERROR(Error) << "Unable to allocate buffer"; } - if (!numberframes) { - if (PV_OK != pl_exp_start_cont(ctx->hcam, frame, circBufferBytes)) { - const int16 errorCode = pl_error_code(); - char errorMsg[ERROR_MSG_LEN]; - pl_error_message(errorCode, errorMsg); - isError = true; - m_cam._setStatus(Camera::Fault, false); - continueAcq = false; - CloseAllCamerasAndUninit(m_cam.contexts); - delete [] frame; - THROW_HW_ERROR(Error) << pl_error_code() << errorMsg; - } + if (PV_OK != pl_exp_start_cont(ctx->hcam, frame, circBufferBytes)) { + const int16 errorCode = pl_error_code(); + char errorMsg[ERROR_MSG_LEN]; + pl_error_message(errorCode, errorMsg); + isError = true; + m_cam._setStatus(Camera::Fault, false); + continueAcq = false; + CloseAllCamerasAndUninit(m_cam.contexts); + delete [] frame; + THROW_HW_ERROR(Error) << pl_error_code() << errorMsg; } m_cam._setStatus(Camera::Readout, false); while(continueAcq && (!numberframes || m_cam.m_image_number < numberframes)) { - if (numberframes) { - if (PV_OK != pl_exp_start_seq(ctx->hcam, frame)) { - isError = true; - m_cam._setStatus(Camera::Fault, false); - continueAcq = false; - CloseAllCamerasAndUninit(m_cam.contexts); - delete [] frame; - THROW_HW_ERROR(Error) << pl_error_code(); - break; - } - } if (!WaitForEofEvent(ctx, 5000, isError)) - break; + break; const uint8_t* pImageBuffer = (uint8_t*) ctx->eofFrame; @@ -275,8 +251,10 @@ void Camera::_getDetectorType() { void Camera::prepareAcq() { DEB_MEMBER_FUNCT(); + CameraContext* ctx = contexts[cSingleCamIndex]; m_image_number = 0; m_acq_started = false; + ctx->threadAbortFlag = false; } void Camera::_startAcq() { @@ -322,19 +300,15 @@ void Camera::_stopAcq(bool internalFlag) { if (m_status != Camera::Ready) { DEB_TRACE() << "Stop acq"; - // TODO: call only if frame number = 0? if (PV_OK != pl_exp_abort(ctx->hcam, CCS_HALT)) { THROW_HW_ERROR(Error) << pl_error_code(); } else { - while (!internalFlag && m_thread_running) { + ctx->threadAbortFlag = true; m_wait_flag = true; - m_cond.wait(); - } - - aLock.unlock(); - - _setStatus(Camera::Ready, false); + _setStatus(Camera::Ready, false); + m_cond.broadcast(); } + aLock.unlock(); } } catch(Exception e) {