Commit 4afd607b authored by seb's avatar seb
Browse files

Wednesday checkin (Pilatus)...


git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@221 45c4679d-1946-429d-baad-37912b19538b
parent 307068e9
import weakref
import lima
class BufferCtrlObj(lima.HwBufferCtrlObj):
DEB_CLASS(DebModCamera,"BufferCtrlObj","Pilatus")
@DEB_MEMBER_FUNCT
def __init__(self,comm_object,det_info) :
lima.HwBufferCtrlObj.__init__(self)
self.__com = weakref.ref(comm_object)
self.__det_info = weakref.ref(det_info)
self.__cbk = None
@DEB_MEMBER_FUNCT
def setFrameDim(self,frame_dim) :
pass
@DEB_MEMBER_FUNCT
def getFrameDim(self) :
det_info = self.__det_info()
return lima.FrameDim(det_info.getDetectorImageSize(),
det_info.getDefImageType())
@DEB_MEMBER_FUNCT
def setNbBuffers(self,nb_buffers) :
if nb_buffers != 1:
raise lima.Exceptions(lima.Hardware,lima.NotSupported)
@DEB_MEMBER_FUNCT
def getNbBuffers(self) :
return 1
@DEB_MEMBER_FUNCT
def setNbConcatFrames(self,nb_concat_frames) :
if nb_concat_frames != 1:
raise lima.Exceptions(lima.Hardware,lima.NotSupported)
@DEB_MEMBER_FUNCT
def getNbConcatFrames(self) :
return 1
@DEB_MEMBER_FUNCT
def setNbAccFrames(self,nb_acc_frames) :
com = self.__com()
com.set_nb_exposure_per_frame(nb_acc_frames)
@DEB_MEMBER_FUNCT
def getNbAccFrames(self) :
com = self.__com()
return com.nb_exposure_per_frame()
@DEB_MEMBER_FUNCT
def getMaxNbBuffers(self) :
return 1
@DEB_MEMBER_FUNCT
def getBufferPtr(self,buffer_nb,concat_frame_nb = 0) :
pass
@DEB_MEMBER_FUNCT
def getFramePtr(self,acq_frame_nb) :
pass
@DEB_MEMBER_FUNCT
def getStartTimestamp(self,start_ts) :
pass
@DEB_MEMBER_FUNCT
def getFrameInfo(self,acq_frame_nb) :
pass
@DEB_MEMBER_FUNCT
def registerFrameCallback(self,frame_cb) :
self.__cbk = frame_cb
@DEB_MEMBER_FUNCT
def unregisterFrameCallback(self,frame_cb) :
self.__cbk = None
@DEB_MEMBER_FUNCT
def getLastAcquiredFrame(self) :
pass
......@@ -188,7 +188,10 @@ class Communication:
with self.__cond:
self._error_message = None
self._state = self.OK
def hard_reset(self) :
with self.__cond:
self.__asynSock.send('resetcam')
def connect(self,host,port) :
self._init_variable()
......
import weakref
import os
from lima import HwDetInfoCtrlObj
from lima import Debug
CAMERA_NAME_TOKEN = 'camera_name'
CAMERA_WIDE_TOKEN = 'camera_wide'
CAMERA_HIGH_TOKEN = 'camera_high'
CAMERA_BPP_TOKEN = 'camera_bpp'
CAMERA_INFO_FILE = os.path.expanduser(os.path.join('~det','p2_det/config/cam_data/camera.def')
##@brief to find information for the detector, we looking for
#file named CAMERA_INFO_FILE in HOME directory of the users
#@todo check if we can do best
class DetInfoCtrlObj(HwDetInfoCtrlObj) :
DEB_CLASS(DebModCamera, "DetInfoCtrlObj","Pilatus")
def __init__(self,interface) :
self.__cnt = weakref.ref(interface)
self.__readConfig()
#Variables
self.__name = None
self.__width = None
self.__height = None
self.__bpp = None
@DEB_MEMBER_FUNCT
def getMaxImageSize(self) :
return lima.Size(self.__width,self.__height)
@DEB_MEMBER_FUNCT
def getDetectorImageSize(self) :
return self.getMaxImageSize()
@DEB_MEMBER_FUNCT
def getDefImageType(self) :
if self.__bpp == 32:
return lima.Bpp32
else: # TODO
raise lima.Exceptions(lima.Hardware,lima.NotSupported)
@DEB_MEMBER_FUNCT
def getCurrImageType(self) :
return self.getDefImageType()
@DEB_MEMBER_FUNCT
def setCurrImageType(self) :
raise lima.Exceptions(lima.Hardware,lima.NotSupported)
@DEB_MEMBER_FUNCT
def getPixelSize(self) :
return 172e-6
@DEB_MEMBER_FUNCT
def getDetectorType(self) :
return 'Pilatus'
@DEB_MEMBER_FUNCT
def getDetectorModel(self):
return self.__name.split(',')[0].split()[-1]
##@brief image size won't change so no callback
@DEB_MEMBER_FUNCT
def registerMaxImageSizeCallback(cb) :
pass
##@brief image size won't change so no callback
@DEB_MEMBER_FUNCT
def unregisterMaxImageSizeCallback(cb) :
pass
@DEB_MEMBER_FUNCT
def get_min_exposition_time(self):
return 1e-6
##@todo don't know realy what is the maximum exposure time
#for now set to a high value 1 hour
@DEB_MEMBER_FUNCT
def get_max_exposition_time(self) :
return 3600
@DEB_MEMBER_FUNCT
def get_min_latency(self) :
period = None
model = self.getDetectorModel()
if model == '300K' or model == '300KWF' :
period = 1/200. # 200Hz
else: # PILATUS UNKNOWN
period = 1/12. # frequence of the Pilatus 6M (slowest)
latency = period - self.get_min_exposition_time()
return latency
##@todo don't know
#@see get_max_exposition_time
@DEB_MEMBER_FUNCT
def get_max_latency(self):
return self.get_min_latency()
@DEB_MEMBER_FUNCT
def __readConfig(self) :
f = file(CAMERA_INFO_FILE)
for line in f:
if line.startswith(CAMERA_NAME_TOKEN) :
self.__name = line.split('=').stip(' \t\"')
elif line.startswith(CAMERA_WIDE_TOKEN) :
self.__width = int(line.split('=').stip(' \t'))
elif line.startswith(CAMERA_HIGH_TOKEN) :
self.__height = int(line.split('=').stip(' \t'))
elif line.startswith(CAMERA_NAME_TOKEN) :
self.__bpp = int(line.split('=').stip(' \t'))
f.close()
import lima
from DetInfoCtrlObj import DetInfoCtrlObj
from SyncCtrlObj import SyncCtrlObj
from BufferCtrlObj import BufferCtrlObj
DEFAULT_SERVER_PORT = 41234
class Interface(lima.HwInterface) :
DEB_CLASS(DebModCamera, "Interface","Pilatus")
def __init__(self,port = DEFAULT_SERVER_PORT) :
lima.HwInterface.__init__(self)
self.__port = port
self.__comm = Communication('localhost',self.__port)
self.__detInfo = DetInfoCtrlObj(self)
self.__syncObj = SyncCtrlObj(self.__comm,self.__detInfo)
self.__buffer = BufferCtrlObj(self.__comm,self.__detInfo)
@DEB_MEMBER_FUNCT
def getCapList(self) :
return [self.__detInfo,self.__syncObj,self.__buffer]
@DEB_MEMBER_FUNCT
def getHwCtrlObj(cap_type) :
if cap_type == lima.HwCap.DetInfo:
return self.__detInfo
elif cap_type == lima.HwCap.Sync:
return self.__syncObj
elif cap_type == lima.HwCap.Buffer:
return self.__buffer
@DEB_MEMBER_FUNCT
def reset(self,reset_level):
if reset_level == self.HardReset:
self.__comm.hard_reset()
self.__comm.soft_reset()
@DEB_MEMBER_FUNCT
def prepareAcq(self):
camserverStatus = self.__comm.status()
if camserverStatus == self.__comm.DISCONNECTED:
self.__comm.connect('localhost',self.__port)
@DEB_MEMBER_FUNCT
def startAcq(self) :
self.__comm.start_acquisition()
@DEB_MEMBER_FUNCT
def stopAcq(self) :
self.__comm.stop_acquisition()
@DEB_MEMBER_FUNCT
def getStatus(self) :
camserverStatus = self.__comm.status()
lima.AcqReady, lima.AcqRunning, lima.AcqFault
status = lima.HwInterface.Status()
if camserverStatus == self.__comm.ERROR:
status.det = lima.DetFault
status.acq = lima.AcqFault
else:
if camserverStatus == self.__comm.RUNNING:
status.det = lima.DetExposure
status.acq = lima.AcqRunning
else:
status.det = lima.DetIdle
status.acq = lima.AcqReady # TODO test if the file save is finnished
status.det_mask = (lima.DetExposure|lima.DetFault)
return status
@DEB_MEMBER_FUNCT
def getNbAcquiredFrames(self) :
return self.__buffer.getLastAcquiredFrame()
@DEB_MEMBER_FUNCT
def getNbHwAcquiredFrames(self):
pass
import weakref
import lima
class SyncCtrlObj(lima.HwSyncCtrlObj) :
DEB_CLASS(DebModCamera, "SyncCtrlObj","Pilatus")
def __init__(self,comm_object,det_info) :
lima.HwSyncCtrlObj.__init__(self)
self.__comm = weakref.ref(comm_object)
self.__det_info = weakref.ref(det_info)
#Variables
self.__exposure = self.__comm.exposure()
self.__latency = self.__comm.exposure_period() - self.__comm.exposure()
@DEB_MEMBER_FUNCT
def setTrigMode(self,trig_mode):
com = self.__comm()
cvt_trigger_mode = None
if trig_mode == lima.IntTrig:
com.set_trigger_mode(com.INTERNAL)
elif trig_mode == lima.ExtTrigSingle:
com.set_trigger_mode(com.EXTERNAL_START)
elif trig_mode == lima.ExtTrigMult:
com.set_trigger_mode(com.EXTERNAL_MULTI_START)
elif trig_mode == lima.ExtGate :
com.set_trigger_mode(com.EXTERNAL_GATE)
else:
raise lima.Exceptions(lima.Hardware,lima.NotSupported)
@DEB_MEMBER_FUNCT
def getTrigMode(self) :
cvt_trigger_mode = None
com = self.__comm()
trig_mode = com.trig_mode()
if trig_mode == com.INTERNAL :
cvt_trigger_mode = lima.IntTrig
elif trig_mode == com.EXTERNAL_START:
cvt_trigger_mode = lima.ExtTrigSingle
elif trig_mode == com.EXTERNAL_MULTI_START:
cvt_trigger_mode = lima.ExtTrigMult
elif trig_mode == com.EXTERNAL_GATE:
cvt_trigger_mode = lima.ExtGate
return cvt_trigger_mode
@DEB_MEMBER_FUNCT
def setExpTime(self,exp_time):
self.__exposure = exp_time
@DEB_MEMBER_FUNCT
def getExpTime(self) :
return self.__exposure
@DEB_MEMBER_FUNCT
def setLatTime(self,lat_time):
self.__latency = lat_time
@DEB_MEMBER_FUNCT
def getLatTime(self) :
return self.__latency
@DEB_MEMBER_FUNCT
def setNbFrames(self,nb_frames) :
self.__nb_frames = nb_frames
@DEB_MEMBER_FUNCT
def getNbFrames(self) :
return self.__nb_frames
@DEB_MEMBER_FUNCT
def setNbHwFrames(self,nb_frames) :
self.setNbFrames(nb_frames)
@DEB_MEMBER_FUNCT
def getNbHwFrames(self) :
return self.getNbHwFrames()
@DEB_MEMBER_FUNCT
def getValidRanges(self) :
det_info = self.__det_info()
valid_ranges = self.ValidRangesType()
valid_ranges.min_exp_time = det_info.get_min_exposition_time()
valid_ranges.max_exp_time = det_info.get_max_exposition_time()
valid_ranges.min_lat_time = det_info.get_min_latency()
valid_ranges.max_lat_time = det_info.get_max_latency()
return valid_ranges
......@@ -433,12 +433,17 @@ void CtControl::newBaseImageReady(Data &aData)
{
aLock.unlock();
newFrameToSave(aData);
aLock.lock();
}
if(m_display_active_flag)
m_ct_sps_image->frameReady(aData);
aLock.unlock();
{
aLock.unlock();
m_ct_sps_image->frameReady(aData);
}
else
aLock.unlock();
if (img_status_changed && m_img_status_cb)
m_img_status_cb->imageStatusChanged(m_status.ImageCounters);
......@@ -478,8 +483,9 @@ void CtControl::newImageReady(Data &aData)
aLock.unlock();
newFrameToSave(aData);
}
else
aLock.unlock();
aLock.unlock();
if (m_img_status_cb && img_status_changed)
m_img_status_cb->imageStatusChanged(m_status.ImageCounters);
......
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