Commit fde340a6 authored by Laurent Claustre's avatar Laurent Claustre

* Check now if images are missing when acquiring multi-frames

 * Added an extra delay when acquiring with external trigger, this
   is for IKon model only today, no way to test with other models.
parent bdea8434
......@@ -28,6 +28,37 @@
#endif
#include <atmcdLXd.h>
#ifndef DRV_P11INVALID
#define DRV_P11INVALID 20087
#define DRV_GATESTEPERROR 20092
#define DRV_INVALID_COUNTCONVERT_MODE 20101
#define DRV_OA_NULL_ERROR 20173
#define DRV_OA_PARSE_DTD_ERROR 20174
#define DRV_OA_DTD_VALIDATE_ERROR 20175
#define DRV_OA_FILE_ACCESS_ERROR 20176
#define DRV_OA_FILE_DOES_NOT_EXIST 20177
#define DRV_OA_XML_INVALID_OR_NOT_FOUND_ERROR 20178
#define DRV_OA_PRESET_FILE_NOT_LOADED 20179
#define DRV_OA_USER_FILE_NOT_LOADED 20180
#define DRV_OA_PRESET_AND_USER_FILE_NOT_LOADED 20181
#define DRV_OA_INVALID_FILE 20182
#define DRV_OA_FILE_HAS_BEEN_MODIFIED 20183
#define DRV_OA_BUFFER_FULL 20184
#define DRV_OA_INVALID_STRING_LENGTH 20185
#define DRV_OA_INVALID_CHARS_IN_NAME 20186
#define DRV_OA_INVALID_NAMING 20187
#define DRV_OA_GET_CAMERA_ERROR 20188
#define DRV_OA_MODE_ALREADY_EXISTS 20189
#define DRV_OA_STRINGS_NOT_EQUAL 20190
#define DRV_OA_NO_USER_DATA 20191
#define DRV_OA_VALUE_NOT_SUPPORTED 20192
#define DRV_OA_MODE_DOES_NOT_EXIST 20193
#define DRV_OA_CAMERA_NOT_SUPPORTED 20194
#define DRV_OA_FAILED_TO_GET_MODE 20195
#endif
#include <stdlib.h>
#include <limits>
......
......@@ -316,6 +316,24 @@ void Camera::startAcq()
DEB_ERROR() << "Cannot start acquisition" << " : error code = " << m_camera_error_str;
THROW_HW_ERROR(Error) << "Cannot start acquisition";
}
// in external mode even with FastExtTrigger enabled the camera can not grab the trigger
// within a too short delay, 100ms is the minimum required, very slow camera !!!
// and unfortunately the status is not reflecting this lack of synchro.
//while(1)
//{
// if (andorError(GetStatus(&status)))
// {
// DEB_ERROR() << "Cannot get status" << " : error code = " << m_camera_error_str;
// THROW_HW_ERROR(Error) << "Cannot get status";
// }
// if (status== DRV_ACQUIRING) break;
// usleep(1e3);
//}
if (m_trig_mode != IntTrig && m_trig_mode != IntTrigMult)
{
usleep(1e5);
}
}
//---------------------------
......@@ -340,6 +358,13 @@ void Camera::_stopAcq(bool internalFlag)
{
// signal the acq. thread to stop acquiring and to return the wait state
m_wait_flag = true;
// Thread is maybe waiting for the Andor acq. event
if (andorError(CancelWait()))
{
DEB_ERROR() << "CancelWait() failed" << " : error code = " << m_camera_error_str;
THROW_HW_ERROR(Error) << "CancelWait() failed";
}
m_cond.wait();
}
aLock.unlock();
......@@ -353,7 +378,7 @@ void Camera::_stopAcq(bool internalFlag)
{
DEB_ERROR() << "Cannot abort acquisition" << " : error code = " << m_camera_error_str;
THROW_HW_ERROR(Error) << "Cannot abort acquisition";
}
}
_setStatus(Camera::Ready,false);
}
}
......@@ -384,6 +409,13 @@ void Camera::_AcqThread::threadFunction()
aLock.unlock();
bool continueAcq = true;
int first = 0, last = 0, prev_last = 0;
FrameDim frame_dim = buffer_mgr.getFrameDim();
Size frame_size = frame_dim.getSize();
int size = frame_size.getWidth() * frame_size.getHeight();
int validfirst, validlast;
while(continueAcq && (!m_cam.m_nb_frames || m_cam.m_image_number < m_cam.m_nb_frames))
{
// Check first if acq. has been stopped
......@@ -392,8 +424,21 @@ void Camera::_AcqThread::threadFunction()
continueAcq = false;
continue;
}
// Wait for an "acquisition" event, and use less cpu resources, in kinetic mode (multiframe)
// an event is generated for each new image
if(m_cam.andorError(WaitForAcquisition()))
{
// If CancelWait() or acq. not started yet
if(m_cam.m_camera_error == DRV_NO_NEW_DATA) continue;
else
{
DEB_ERROR() << "WaitForAcquisition() failed" << " : error code = " << m_cam.m_camera_error_str;
THROW_HW_ERROR(Error) << "WaitForAcquisition() failed";
}
}
// --- Get the available images in cicular buffer
int first, last;
prev_last = last;
if (m_cam.andorError(GetNumberNewImages(&first, &last)))
{
if (m_cam.m_camera_error == DRV_NO_NEW_DATA) continue;
......@@ -404,15 +449,17 @@ void Camera::_AcqThread::threadFunction()
}
}
DEB_TRACE() << "Available images: first = " << first << " last = " << last;
// Check if we lose an image
if(first != prev_last +1 )
{
m_cam._setStatus(Camera::Fault,false);
continueAcq = false;
DEB_ERROR() << "Lost image(s) from " << prev_last << "to "<< first-1;
THROW_HW_ERROR(Error) << "Lost image(s) from " << prev_last << "to "<< first-1;
}
// --- Images are available, process images
m_cam._setStatus(Camera::Readout,false);
FrameDim frame_dim = buffer_mgr.getFrameDim();
Size frame_size = frame_dim.getSize();
int size = frame_size.getWidth() * frame_size.getHeight();
int validfirst, validlast;
for (long im=first; im <= last; im++)
{
DEB_TRACE() << "image #" << m_cam.m_image_number <<" acquired !";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment