Commit e88cdcd5 authored by Laurent Claustre's avatar Laurent Claustre

Merge commit 'ef10c69f'

parents f06fb354 ef10c69f
......@@ -56,7 +56,131 @@ Installation
- And probably Tango server :ref:`tango_installation`
Initialisation and Capabilities
````````````````````````````````
In order to help people to understand how the camera plugin has been implemented in LImA this section
provide some important information about the developer's choices.
Camera initialisation
......................
The camera will be initialized within the AndorCamera object. The AndorCamera contructor
sets the camera with default parameters for Preampifier-Gain, VerticalShiftSpeed and the ADC/HorizontalSpeed.
These parameters are optimized for the faster mode, which means the maximum gain, the "fasten recommended" VSSpeed (i.e as returned
by GetFastestRecommendedVSSpeed() SDK function call) and the ADC with the faster Horizontal speed.
All the parameters can be set and get using the corresponding methods, the default values (max speeds and gain)
can be applied with -1 as passed value:
set/getPGain()
set/getVsSpeed()
set/getADCSpeed()
Std capabilites
................
This plugin has been implement in respect of the mandatory capabilites but with some limitations which
are due to the camera and SDK features. We only provide here extra information for a better understanding
of the capabilities for Andor cameras.
* HwDetInfo
getCurrImageType/getDefImageType(): the methods call the SDK GetBitDepth() function to resolve the image
data type. The bit-depth correspond to the AD channel dynamic range which depends on the selected ADC channel.
By experience and with IKon detectors we only have Bpp16 of dynamic range, but the methods can return Bpp8 and Bpp32
as well.
setCurrImageType(): this method do not change the image type which is fixed to 16bpp.
* HwSync
get/setTrigMode(): the only supported mode are IntTrig, ExtTrigSingle, ExtGate and IntTrigMult
Optional capabilites
........................
In addition to the standard capabilities, we make the choice to implement some optional capabilities which
are supported by the SDK and the I-Kon cameras. A Shutter control, a hardware ROI and a hardware Binning are available.
* HwShutter
setMode(): only ShutterAuto and ShutterManual modes are supported
* HwRoi
There is no restriction for the ROI setting
* HwBin
There is no restriction for the Binning but the maximum binning is given by the SDK function GetMaximumBinning() which depends
on the camera model
Configuration
`````````````
- Plug your USB camera on any USB port of the computer, that's all !!!
How to use
````````````
This is a python code example for a simple test:
.. code-block:: python
from Lima import Andor
from lima impor Core
cam = Andor.Camera("/usr/local/etc/andor", 0)
hwint = Andor.Interface(cam)
control = Core.control(hwint)
acq = control.acquisition()
# configure some hw parameters
hwint.setTemperatureSP(-30)
hwint.setCooler(True)
.... wait here for cooling
hwint.setPGain(2)
# setting new file parameters and autosaving mode
saving=c.saving()
pars=saving.getParameters()
pars.directory='/buffer/lcb18012/opisg/test_lima'
pars.prefix='test1_'
pars.suffix='.edf'
pars.fileFormat=Core.CtSaving.EDF
pars.savingMode=Core.CtSaving.AutoFrame
saving.setParameters(pars)
# set accumulation mode
acq_pars= acq.getPars()
#0-normal,1-concatenation,2-accumu
acq_pars.acqMode = 2
acq_pars.accMaxExpoTime = 0.05
acq_pars.acqExpoTime =1
acq_pars.acqNbFrames = 1
acq.setPars(acq_pars)
# here we should have 21 accumalated images per frame
print acq.getAccNbFrames()
# now ask for 2 sec. exposure and 10 frames
acq.setAcqExpoTime(2)
acq.setNbImages(10)
acq.prepareAcq()
acq.startAcq()
......@@ -74,25 +74,7 @@ namespace lima
{
namespace Andor
{
/*******************************************************************
* \class Camera
* \brief object controlling the andor camera via Pylon driver
*******************************************************************/
class Camera
{
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Andor");
friend class Interface;
public:
enum Status {
Ready, Exposure, Readout, Latency, Fault
};
enum ShutterMode {
FRAME,
MANUAL
};
enum SpoolingMethod
{
SM_SEQ_INT32 = 0,
......@@ -130,6 +112,26 @@ namespace lima
SINGLE_TRACK,
IMAGE
};
/*******************************************************************
* \class Camera
* \brief object controlling the andor camera via Pylon driver
*******************************************************************/
class Camera
{
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "Andor");
friend class Interface;
public:
enum Status {
Ready, Exposure, Readout, Latency, Fault
};
enum ShutterMode {
FRAME,
MANUAL
};
Camera(const std::string& config_path,int camera_number=0);
~Camera();
......@@ -191,16 +193,19 @@ namespace lima
void reset();
// -- andor specific, LIMA don't worry about it !
// -- andor specific
void _mapAndorError();
bool andorError(unsigned int code);
void initialiseController();
void initAdcSpeed();
void setAdcSpeed(int adc);
void initVSS();
void setVSS(int vss);
void getAdcSpeed(int& adc);
void initVsSpeed();
void setVsSpeed(int vss);
void getVsSpeed(int& vss);
void initPGain();
void setPGain(int gain);
void getPGain(int& gain);
void setFastExtTrigger(bool flag);
void getFastExtTrigger(bool& flag);
void setShutterLevel(int level);
......@@ -214,7 +219,7 @@ namespace lima
void setSpooling(bool flag, SpoolingMethod method, std::string path, int frameBufferSize);
void setHighCapacity(HighCapacityMode mode);
void setGateMode(GateMode mode);
void setReadMode(ReadMode mode);
//void setReadMode(ReadMode mode);
......
......@@ -30,13 +30,13 @@
#include "AndorBinCtrlObj.h"
#include "AndorRoiCtrlObj.h"
namespace lima
{
namespace Andor
{
class Interface;
/*******************************************************************
* \class Interface
* \brief Andor hardware interface
......@@ -59,6 +59,27 @@ namespace lima
virtual void getStatus(StatusType& status);
virtual int getNbHwAcquiredFrames();
// - From AndorCamera
void setAdcSpeed(int adc);
void getAdcSpeed(int& adc);
void setVsSpeed(int vss);
void getVsSpeed(int& vss);
void setPGain(int gain);
void getPGain(int& gain);
void setFastExtTrigger(bool flag);
void getFastExtTrigger(bool& flag);
void setShutterLevel(int level);
void getShutterLevel(int& level);
void setTemperatureSP(int temp);
void getTemperatureSP(int& temp);
void getTemperature(int& temp);
void setCooler(bool flag);
void getCooler(bool& flag);
void getCoolingStatus(std::string& status);
void setSpooling(bool flag, SpoolingMethod method, std::string path, int frameBufferSize);
void setHighCapacity(HighCapacityMode mode);
void setGateMode(GateMode mode);
private:
Camera& m_cam;
CapList m_cap_list;
......
namespace Andor
{
class Camera
{
%TypeHeaderCode
#include <AndorCamera.h>
%End
public:
enum Status {
Ready, Exposure, Readout, Latency, Fault
};
enum ShutterMode{
FRAME,
MANUAL
};
enum SpoolingMethod
{
SM_SEQ_INT32 = 0,
......@@ -56,6 +42,24 @@ namespace Andor
IMAGE
};
class Camera
{
%TypeHeaderCode
#include <AndorCamera.h>
%End
public:
enum Status {
Ready, Exposure, Readout, Latency, Fault
};
enum ShutterMode{
FRAME,
MANUAL
};
Camera(const std::string& config_path,int camera_number=0);
~Camera();
......@@ -109,10 +113,13 @@ namespace Andor
void initialiseController();
void initAdcSpeed();
void setAdcSpeed(int adc);
void initVSS();
void setVSS(int vss);
void getAdcSpeed(int& adc /Out/);
void initVsSpeed();
void setVsSpeed(int vss);
void getVsSpeed(int& vss /Out/);
void initPGain();
void setPGain(int gain);
void getPGain(int& gain /Out/);
void setFastExtTrigger(bool flag);
void getFastExtTrigger(bool& flag /Out/);
void setShutterLevel(int level);
......@@ -123,10 +130,10 @@ namespace Andor
void setCooler(bool flag);
void getCooler(bool& flag /Out/);
void getCoolingStatus(std::string& status /Out/);
void setSpooling(bool flag, SpoolingMethod method, std::string path, int frameBufferSize);
void setHighCapacity(HighCapacityMode mode);
void setGateMode(GateMode mode);
void setReadMode(ReadMode mode);
void setSpooling(bool flag, Andor::SpoolingMethod method, std::string path, int frameBufferSize);
void setHighCapacity(Andor::HighCapacityMode mode);
void setGateMode(Andor::GateMode mode);
//void setReadMode(Andor::ReadMode mode);
};
......
......@@ -6,6 +6,8 @@ namespace Andor
#include <AndorInterface.h>
%End
public:
Interface(Andor::Camera& cam);
virtual ~Interface();
......@@ -19,5 +21,24 @@ namespace Andor
virtual void getStatus(StatusType& status /Out/);
virtual int getNbHwAcquiredFrames();
void setAdcSpeed(int adc);
void getAdcSpeed(int& adc /Out/);
void setVsSpeed(int vss);
void getVsSpeed(int& vss /Out/);
void setPGain(int gain);
void getPGain(int& gain /Out/);
void setFastExtTrigger(bool flag);
void getFastExtTrigger(bool& flag /Out/);
void setShutterLevel(int level);
void getShutterLevel(int& level /Out/);
void setTemperatureSP(int temp);
void getTemperatureSP(int& temp);
void getTemperature(int& temp /Out/);
void setCooler(bool flag);
void getCooler(bool& flag /Out/);
void getCoolingStatus(std::string& status /Out/);
void setSpooling(bool flag, Andor::SpoolingMethod method, std::string path, int frameBufferSize);
void setHighCapacity(Andor::HighCapacityMode mode);
void setGateMode(Andor::GateMode mode);
};
};
//###########################################################################
///###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2012
......@@ -1079,13 +1079,13 @@ void Camera::initialiseController()
<< m_adc_speeds[is].speed << ((is == m_adc_speed_max)? " [max]": "");
}
// --- Set adc / speed
// --- Set adc / speed to max
setAdcSpeed(m_adc_speed_max);
DEB_TRACE() << " => Set to " << m_adc_speeds[m_adc_speed_max].speed << "MHz";
// --- Init VS Speeds
initVSS();
initVsSpeed();
DEB_TRACE() << "* Vertical Shift Speed:";
for (is=0; is<m_vss_number; is++)
......@@ -1094,12 +1094,12 @@ void Camera::initialiseController()
<< ((is == m_vss_best)? " [recommended]": "");
}
// --- Set VS Speed
setVSS(m_vss);
// --- Set VS Speed to fasten recommended
setVsSpeed(m_vss_best);
DEB_TRACE() << " => Set " << m_vsspeeds[m_vss] << "us";
// --- Init Preamp Gain
// --- Init Preamp Gain to max
initPGain();
DEB_TRACE() << "* Preamp Gain:";
......@@ -1111,7 +1111,7 @@ void Camera::initialiseController()
}
// --- Set Preamp Gain
setPGain(m_gain);
setPGain(m_gain_max);
DEB_TRACE() << " => Set to x" << m_preamp_gains[m_gain];
}
//-----------------------------------------------------
......@@ -1158,9 +1158,7 @@ void Camera::initAdcSpeed()
THROW_HW_ERROR(Error) << "Cannot get Horizontal Speed ";
}
m_adc_speeds[is].adc= ia;
m_adc_speeds[is].hss= ih;
// --- iKon/iXon= speed in MHz ; others in us/pixel shift --> convert in MHz
m_adc_speeds[is].hss= ih; // --- iKon/iXon= speed in MHz ; others in us/pixel shift --> convert in MHz
if ((m_camera_capabilities.ulCameraType!=1)&&(m_camera_capabilities.ulCameraType!=13))
m_adc_speeds[is].speed = (float)(1./ m_adc_speeds[is].speed);
......@@ -1173,9 +1171,9 @@ void Camera::initAdcSpeed()
}
}
//-----------------------------------------------------
// @brief get ADC/Speed settings
// @param adc pais adc/speed index (if =-1, set to max speed)
//-----------------------------------------------------
// @brief set ADC/Speed settings
// @param adc pair adc/speed index (if =-1, set to max speed)
//
//-----------------------------------------------------
void Camera::setAdcSpeed(int adc)
......@@ -1208,13 +1206,23 @@ void Camera::setAdcSpeed(int adc)
}
//-----------------------------------------------------
// @brief get ADC/Speed settings
// @param adc index
//
//-----------------------------------------------------
void Camera::getAdcSpeed(int& adc)
{
adc = m_adc;
}
//-----------------------------------------------------
// @brief get possible VSS (vertical shift speed) for controller
//
// Initialise the list of possible vss index and their value
// Get also the recommended VSS.
//-----------------------------------------------------
void Camera::initVSS()
void Camera::initVsSpeed()
{
DEB_MEMBER_FUNCT();
float speed;
......@@ -1251,11 +1259,11 @@ void Camera::initVSS()
//-----------------------------------------------------
// @brief get Vertical Shift Speed
// @brief set Vertical Shift Speed
// @param vss index (if =-1, set to recommended)
//
//-----------------------------------------------------
void Camera::setVSS(int vss)
void Camera::setVsSpeed(int vss)
{
DEB_MEMBER_FUNCT();
int is;
......@@ -1270,12 +1278,22 @@ void Camera::setVSS(int vss)
}
if (andorError(SetVSSpeed(is)))
{
DEB_ERROR() << "Failed to set VSS #" << is <<" : error code = " << m_camera_error_str;
THROW_HW_ERROR(Error) << "Failed to set VSS";
DEB_ERROR() << "Failed to set VS speed #" << is <<" : error code = " << m_camera_error_str;
THROW_HW_ERROR(Error) << "Failed to set VS speed";
}
m_vss = is;
DEB_TRACE() << "VSSpeed Set to " <<m_vsspeeds[is] << "us";
DEB_TRACE() << "VS speed Set to " <<m_vsspeeds[is] << "us";
}
//-----------------------------------------------------
// @brief get Vertical Shift Speed
// @param vss index
//
//-----------------------------------------------------
void Camera::getVsSpeed(int& vss)
{
vss = m_vss;
}
//-----------------------------------------------------
......@@ -1317,7 +1335,7 @@ void Camera::initPGain()
//-----------------------------------------------------
// @brief set Preamp Gain
// @param gain premap gain index
// @param gain preamp gain index
//
//-----------------------------------------------------
void Camera::setPGain(int gain)
......@@ -1331,6 +1349,11 @@ void Camera::setPGain(int gain)
}
else
{
if (gain<-1 || gain>=m_gain_number)
{
DEB_ERROR() << "Invalid gain index range is" << "[0," << m_gain_number-1 << "] or -1 for max gain";
THROW_HW_ERROR(Error) << "Invalid gain index range is" << "[0," << m_gain_number-1 << "] or -1 for max gain";
}
ig= gain;
}
......@@ -1344,6 +1367,16 @@ void Camera::setPGain(int gain)
DEB_TRACE() << "Preamp Gain set to x" << m_preamp_gains[ig];
}
//-----------------------------------------------------
// @brief get Preamp Gain
// @param gain preamp gain index
//
//-----------------------------------------------------
void Camera::getPGain(int& gain)
{
gain = m_gain;
}
//-----------------------------------------------------
// @brief set external trigger for fast mode
// @param flag fast or not (boolean)
......@@ -1708,16 +1741,18 @@ void Camera::setGateMode(GateMode mode)
// @param mode mode to set
//
//-----------------------------------------------------
void Camera::setReadMode(ReadMode mode)
{
DEB_MEMBER_FUNCT();
if(andorError(SetReadMode((int) mode)))
{
DEB_ERROR() << "Error while setting read mode" <<" : error code = " << m_camera_error_str;
THROW_HW_ERROR(Error) << "Failed to set read mode";
}
}
// CANNOT BE USED WITHOUT A MaxImageSizeCallback because the read-mode
// changes the image size.
//void Camera::setReadMode(ReadMode mode)
//{
// DEB_MEMBER_FUNCT();
// if(andorError(SetReadMode((int) mode)))
// {
// DEB_ERROR() << "Error while setting read mode" <<" : error code = " << m_camera_error_str;
// THROW_HW_ERROR(Error) << "Failed to set read mode";
// }
//}
//-----------------------------------------------------
// @brief handle the andor error codes
......
......@@ -149,6 +149,7 @@ void Interface::getStatus(StatusType& status)
DEB_RETURN() << DEB_VAR1(status);
}
//-----------------------------------------------------
// @brief return the hw number of acquired frames
//-----------------------------------------------------
......@@ -160,6 +161,206 @@ int Interface::getNbHwAcquiredFrames()
return acq_frames;
}
/////////////////////////////////////////////////////////////
// HERE we just map setter/getter methods of the AndorCamera
// class for a public access, stupid but useful !!
// one could merge AndorCamera and AndorInterface, ok next
// release.
/////////////////////////////////////////////////////////////
//-----------------------------------------------------
// @brief set ADC/Speed settings
// @param adc pais adc/speed index (if =-1, set to max speed)
//
//-----------------------------------------------------
void Interface::setAdcSpeed(int adc)
{
m_cam.setAdcSpeed(adc);
}
//-----------------------------------------------------
// @brief get ADC/Speed settings
// @param adc index
//
//-----------------------------------------------------
void Interface::getAdcSpeed(int& adc)
{
m_cam.getAdcSpeed(adc);
}
//-----------------------------------------------------
// @brief set Vertical Shift Speed
// @param vss index (if =-1, set to recommended)
//
//-----------------------------------------------------
void Interface::setVsSpeed(int vss)
{
m_cam.setVsSpeed(vss);
}
//-----------------------------------------------------
// @brief get Vertical Shift Speed
// @param vss index
//
//-----------------------------------------------------
void Interface::getVsSpeed(int& vss)
{
m_cam.getVsSpeed(vss);
}
//-----------------------------------------------------
// @brief set Preamp Gain
// @param gain premap gain index
//
//-----------------------------------------------------
void Interface::setPGain(int gain)
{
m_cam.setPGain(gain);
}
//-----------------------------------------------------
// @brief get Preamp Gain
// @param gain premap gain index
//
//-----------------------------------------------------
void Interface::getPGain(int& gain)
{
m_cam.getPGain(gain);
}
//-----------------------------------------------------
// @brief set external trigger for fast mode
// @param flag fast or not (boolean)
//
//-----------------------------------------------------
void Interface::setFastExtTrigger(bool flag)
{
m_cam.setFastExtTrigger(flag);
}
//-----------------------------------------------------
// @brief get external fast trigger mode
// @param flag fast or not (boolean)
//
//-----------------------------------------------------
void Interface::getFastExtTrigger(bool& flag)
{
m_cam.getFastExtTrigger(flag);
}
//-----------------------------------------------------
// @brief set the shutter output level
// @param level 0 or 1
//
//-----------------------------------------------------
void Interface::setShutterLevel(int level)
{
m_cam.setShutterLevel(level);
}
//-----------------------------------------------------
// @brief get the shutter output level
// @param level 0 or 1
//
//-----------------------------------------------------
void Interface::getShutterLevel(int& level)
{
m_cam.getShutterLevel(level);
}
//-----------------------------------------------------
// @brief set the temperature set-point
// @param temperature in centigrade
//
//-----------------------------------------------------
void Interface::setTemperatureSP(int temp)
{
m_cam.setTemperatureSP(temp);
}
//-----------------------------------------------------
// @brief return the temperature set-point
// @param temperature in centigrade
//
//-----------------------------------------------------
void Interface::getTemperatureSP(int& temp)
{
m_cam.getTemperatureSP(temp);
}
//-----------------------------------------------------
// @brief Gets the real temperature of the detector sensor
// @param temp temperature in centigrade
//
//-----------------------------------------------------
void Interface::getTemperature(int& temp)
{
m_cam.getTemperature(temp);
}
//-----------------------------------------------------
// @brief start or Stop the cooler
// @param flag true-on, false-off
//
//-----------------------------------------------------
void Interface::setCooler(bool flag)
{
m_cam.setCooler(flag);
}
//-----------------------------------------------------
// @brief Get the Cooler status
// @param flag true-on, false-off
//
//-----------------------------------------------------
void Interface::getCooler(bool& flag)
{
m_cam.getCooler(flag);
}
//-----------------------------------------------------
// @brief Gets cooling status
// @param status status as a string
//
//-----------------------------------------------------
void Interface::getCoolingStatus(std::string& status)
{
m_cam.getCoolingStatus(status);
}
//-----------------------------------------------------
// @brief Sets spooling specific parameters
// @param flag enable/disable spooling
// @param method used spooling method
// @param path spooling dir/file
// @param framBufferSize size of the internal circular buffer
//
//-----------------------------------------------------
void Interface::setSpooling(bool flag, SpoolingMethod method, string path, int frameBufferSize)
{
m_cam.setSpooling(flag, method, path, frameBufferSize);
}
//-----------------------------------------------------
// @brief Sets the High capacity mode
// @param mode mode to set
//
//-----------------------------------------------------
void Interface::setHighCapacity(HighCapacityMode mode)
{
m_cam.setHighCapacity(mode);
}