Commit 0c87a9af authored by ahoms's avatar ahoms
Browse files

* first implementation of CtControl::reset

* added common/python/Debug.py with debug helpers and decorators,
  include module as namespace and file name and line number
* updated debug testfreloninterface/control.py and [Frelon]TacoCcd.py



git-svn-id: https://scm.blissgarden.org/svn/lima/trunk@204 45c4679d-1946-429d-baad-37912b19538b
parent bef51120
......@@ -2,6 +2,7 @@ import os, sys, string, time, re
import numpy as N
from TacoServer import *
from lima import *
from Debug import *
DevCcdBase = 0xc180000
......@@ -188,11 +189,10 @@ class TacoCcdAcq(TacoServer):
AutoSave = 8
deb_params = DebParams(DebModApplication, "TacoCcdAcq")
DEB_CLASS(DebModApplication, 'TacoCcdAcq')
@DEB_MEMBER_FUNCT
def __init__(self, dev_name, dev_class=None, cmd_list=None):
deb_obj = DebObj(TacoCcdAcq.deb_params, "__init__")
if dev_class is None:
dev_class = 'TacoCcdDevClass'
if cmd_list is None:
......@@ -200,169 +200,197 @@ class TacoCcdAcq(TacoServer):
TacoServer.__init__(self, dev_name, dev_class, cmd_list)
self.dev_name = dev_name
@DEB_MEMBER_FUNCT
def reset(self):
#self.debugReset('Reseting the device!')
pass
deb.Trace('Reseting the device!')
@DEB_MEMBER_FUNCT
def getResources(self, default_resources):
#self.debugTrace('Getting device resources ...')
deb.Param('default_resources=%s' % default_resources)
pars = {}
for res_name, def_val in default_resources.items():
val = esrf_getresource(self.dev_name, res_name)
if not val:
val = def_val
pars[res_name] = val
deb.Return('pars=%s' % pars)
return pars
@DEB_MEMBER_FUNCT
def getState(self):
#self.debugState('Query device state ...')
self.state = DevCcdReady
#self.debugState('Device state: 0x%08x (%d)' % (state, state))
deb.Return('Device state: 0x%08x (%d)' % (state, state))
return self.state
@DEB_MEMBER_FUNCT
def getStatus(self):
state_desc = { DevCcdReady: 'CCD is Ready',
DevCcdAcquiring: 'CCD is Acquiring' }
state = self.getState()
status = state_desc[state]
#self.debugState('Device status: %s (0x%08x)' % (status, state))
deb.Return('Device status: %s (0x%08x)' % (status, state))
return status
@DEB_MEMBER_FUNCT
def getFrameDim(self, max_dim=False):
fdim = FrameDim(Size(1024, 1024), Bpp16)
#self.debugCmd('Frame dim: %s' % fdim)
deb.Return('Frame dim: %s' % fdim)
return fdim
@DEB_MEMBER_FUNCT
def getXSize(self):
deb_obj = DebObj(TacoCcdAcq.deb_params, "getXSize")
frame_dim = self.getFrameDim(max_dim=True)
width = frame_dim.getSize().getWidth()
deb_obj.Return("width=%s" % width)
deb.Return('width=%s' % width)
return width
@DEB_MEMBER_FUNCT
def getYSize(self):
frame_dim = self.getFrameDim(max_dim=True)
return frame_dim.getSize().getHeight()
height = frame_dim.getSize().getHeight()
deb.Return('height=%s' % height)
return height
@DEB_MEMBER_FUNCT
def getDepth(self):
frame_dim = self.getFrameDim(max_dim=True)
return frame_dim.getDepth()
depth = frame_dim.getDepth()
deb.Return('depth=%s' % depth)
return depth
@DEB_MEMBER_FUNCT
def getType(self):
type_nb = 0
#self.debugCmd('Getting type: %s (#%s)' % (ccd_type, type_nb))
deb.Return('Getting type: %s (#%s)' % (ccd_type, type_nb))
return type_nb
@DEB_MEMBER_FUNCT
def getLstErrMsg(self):
err_msg = ''
#self.debugCmd('Getting last err. msg: %s' % err_msg)
deb.Return('Getting last err. msg: %s' % err_msg)
return err_msg
@DEB_MEMBER_FUNCT
def setTrigger(self, ext_trig):
#self.debugCmd('Setting trigger: %s' % ext_trig)
pass
deb.Param('Setting trigger: %s' % ext_trig)
@DEB_MEMBER_FUNCT
def getTrigger(self):
ext_trig = 0
#self.debugCmd('Getting trigger: %s' % ext_trig)
deb.Return('Getting trigger: %s' % ext_trig)
return ext_trig
@DEB_MEMBER_FUNCT
def setNbFrames(self, nb_frames):
#self.debugCmd('Setting nb. frames: %s' % nb_frames)
pass
deb.Param('Setting nb. frames: %s' % nb_frames)
@DEB_MEMBER_FUNCT
def getNbFrames(self):
nb_frames = 1
#self.debugCmd('Getting nb. frames: %s' % nb_frames)
deb.Return('Getting nb. frames: %s' % nb_frames)
return nb_frames
@DEB_MEMBER_FUNCT
def setExpTime(self, exp_time):
#self.debugCmd('Setting exp. time: %s' % exp_time)
pass
deb.Param('Setting exp. time: %s' % exp_time)
@DEB_MEMBER_FUNCT
def getExpTime(self):
exp_time = 1
#self.debugCmd('Getting exp. time: %s' % exp_time)
deb.Return('Getting exp. time: %s' % exp_time)
return exp_time
@DEB_MEMBER_FUNCT
def setBin(self, bin):
# SPEC format Y,X -> incompat. with getBin ...
bin = Bin(bin[1], bin[0])
#self.debugCmd('Setting binning: %s' % bin)
deb.Param('Setting binning: %s' % bin)
@DEB_MEMBER_FUNCT
def getBin(self):
bin = Bin(1, 1)
#self.debugCmd('Getting binning: %s' % bin)
deb.Return('Getting binning: %s' % bin)
return [bin.getX(), bin.getY()]
@DEB_MEMBER_FUNCT
def setRoi(self, roi):
roi = Roi(Point(roi[0], roi[1]), Point(roi[2], roi[3]))
#self.debugCmd('Setting roi: %s' % roi)
deb.Param('Setting roi: %s' % roi)
@DEB_MEMBER_FUNCT
def getRoi(self):
roi = Roi()
#self.debugCmd('Getting roi: %s' % roi)
deb.Return('Getting roi: %s' % roi)
tl = roi.getTopLeft()
br = roi.getBottomRight()
return [tl.getX(), tl.getY(), br.getX(), br.getY()]
@DEB_MEMBER_FUNCT
def setFilePar(self, file_par_arr):
file_par = CcdFilePar(from_arr=file_par_arr)
config = self.getConfig()
config.setParam('FilePar', file_par)
config.apply()
@DEB_MEMBER_FUNCT
def getFilePar(self):
config = self.getConfig()
file_par = config.getParam('FilePar')
return file_par.strArray()
@DEB_MEMBER_FUNCT
def setChannel(self, input_chan):
#self.debugCmd('Setting input channel: %s' % input_chan)
pass
deb.Param('Setting input channel: %s' % input_chan)
@DEB_MEMBER_FUNCT
def getChannel(self):
input_chan = 0
#self.debugCmd('Getting input channel: %s' % input_chan)
deb.Return('Getting input channel: %s' % input_chan)
return input_chan
@DEB_MEMBER_FUNCT
def setMode(self, mode):
#self.debugCmd('Setting mode: %s (0x%x)' % (mode, mode))
deb.Param('Setting mode: %s (0x%x)' % (mode, mode))
auto_save = (mode & self.AutoSave) != 0
@DEB_MEMBER_FUNCT
def getMode(self):
auto_save = False
mode = (auto_save and self.AutoSave) or 0
#self.debugCmd('Getting mode: %s (0x%x)' % (mode, mode))
deb.Return('Getting mode: %s (0x%x)' % (mode, mode))
return mode
@DEB_MEMBER_FUNCT
def setHwPar(self, hw_par_str):
hw_par = map(int, string.split(hw_par_str))
#self.debugCmd('Setting hw par: %s' % hw_par)
deb.Param('Setting hw par: %s' % hw_par)
@DEB_MEMBER_FUNCT
def getHwPar(self):
hw_par = []
#self.debugCmd('Getting hw par: %s' % hw_par)
deb.Return('Getting hw par: %s' % hw_par)
hw_par_str = string.join(map(str, hw_par))
return hw_par_str
@DEB_MEMBER_FUNCT
def setKinetics(self, kinetics):
#self.debugCmd('Setting the profile: %s' % kinetics)
pass
deb.Param('Setting the profile: %s' % kinetics)
@DEB_MEMBER_FUNCT
def getKinetics(self):
kinetics = 0
#self.debugCmd('Getting the profile: %s' % kinetics)
deb.Return('Getting the profile: %s' % kinetics)
return kinetics
@DEB_MEMBER_FUNCT
def startAcq(self):
#self.debugCmd('Starting the device')
pass
deb.Trace('Starting the device')
@DEB_MEMBER_FUNCT
def stopAcq(self):
#self.debugCmd('Stopping the device')
pass
deb.Trace('Stopping the device')
@DEB_MEMBER_FUNCT
def readFrame(self, frame_data):
frame_nb, frame_size = frame_data
frame_dim = self.getFrameDim()
......@@ -377,36 +405,42 @@ class TacoCcdAcq(TacoServer):
(frame_size, len(s)))
return s
@DEB_MEMBER_FUNCT
def startLive(self):
pass
deb.Trace('Starting live mode')
@DEB_MEMBER_FUNCT
def getCurrent(self):
last_frame_nb = 0
return last_frame_nb
@DEB_MEMBER_FUNCT
def execCommand(self, cmd):
#self.debugCmd('Sending cmd: %s' % cmd)
deb.Param('Sending cmd: %s' % cmd)
resp = ''
#self.debugCmd('Received response:')
#for line in resp.split('\r\n'):
#self.debugCmd(line)
deb.Return('Received response: %s' % resp)
return resp
@DEB_MEMBER_FUNCT
def getChanges(self):
changes = 0
#self.debugCmd('Getting changes: %s' % changes)
deb.Return('Getting changes: %s' % changes)
return changes
class CcdServer:
DEB_CLASS(DebModApplication, 'CcdServer')
@DEB_MEMBER_FUNCT
def __init__(self, bin_name, pers_name):
self.bin_name = bin_name
self.pers_name = pers_name
self.server_name = '%s/%s' % (bin_name, pers_name)
#self.debugAlways('Getting devices for %s' % server_name)
deb.Always('Getting devices for %s' % self.server_name)
self.devices = []
@DEB_MEMBER_FUNCT
def getDevNameList(self, server_name=None):
if server_name is None:
server_name = self.server_name
......@@ -416,20 +450,23 @@ class CcdServer:
except:
sys.exit(1)
#self.debugAlways('Devices found in database for %s' % server_name)
#for dev_name in dev_name_list:
#self.debugAlways(' ' + dev_name)
deb.Always('Devices found in database for %s' % server_name)
for dev_name in dev_name_list:
deb.Always(' ' + dev_name)
return dev_name_list
@DEB_MEMBER_FUNCT
def addDev(self, dev):
deb.Param('Adding device %s' % dev.dev_name)
self.devices.append(dev)
@DEB_MEMBER_FUNCT
def startup(self, sleep_forever=1):
server_startup(self.devices, self.pers_name, self.bin_name)
if sleep_forever:
#self.debugAlways('That\'s all! Going to sleep ...')
deb.Always('That\'s all! Going to sleep ...')
while 1:
time.sleep(.01)
......
from TacoCcd import *
import gc
class FrelonAcq:
deb_params = DebParams(DebModApplication, "FrelonAcq")
DEB_CLASS(DebModApplication, "FrelonAcq")
@DEB_MEMBER_FUNCT
def __init__(self, espia_dev_nb):
deb_obj = DebObj(FrelonAcq.deb_params, "__init__")
self.m_edev = Espia.Dev(espia_dev_nb)
self.m_acq = Espia.Acq(self.m_edev)
self.m_buffer_cb_mgr = Espia.BufferMgr(self.m_acq)
......@@ -23,9 +23,8 @@ class FrelonAcq:
self.m_ct_buffer = self.m_ct.buffer()
@DEB_MEMBER_FUNCT
def __del__(self):
deb_obj = DebObj(FrelonAcq.deb_params, "__del__")
del self.m_ct_buffer, self.m_ct_image, self.m_ct_saving, self.m_ct_acq
del self.m_ct; gc.collect()
......@@ -76,163 +75,190 @@ class FrelonAcq:
class FrelonTacoAcq(TacoCcdAcq):
deb_params = DebParams(DebModApplication, "FrelonTacoAcq")
DEB_CLASS(DebModApplication, "FrelonTacoAcq")
@DEB_MEMBER_FUNCT
def __init__(self, dev_name, dev_class=None, cmd_list=None):
deb_obj = DebObj(FrelonTacoAcq.deb_params, "__init__")
TacoCcdAcq.__init__(self, dev_name, dev_class, cmd_list)
espia_dev_nb = 0
self.m_acq = FrelonAcq(espia_dev_nb)
@DEB_MEMBER_FUNCT
def __del__(self):
deb_obj = DebObj(FrelonTacoAcq.deb_params, "__del__")
pass
@DEB_MEMBER_FUNCT
def reset(self):
#self.debugReset('Reseting the device!')
pass
deb.Trace("Reseting the device!")
ct = self.m_acq.getGlobalControl()
ct.reset()
@DEB_MEMBER_FUNCT
def getState(self):
#self.debugState('Query device state ...')
deb.Trace('Query device state ...')
self.state = DevCcdReady
#self.debugState('Device state: 0x%08x (%d)' % (state, state))
deb.Return('Device state: 0x%08x (%d)' % (state, state))
return self.state
@DEB_MEMBER_FUNCT
def getStatus(self):
state_desc = { DevCcdReady: 'CCD is Ready',
DevCcdAcquiring: 'CCD is Acquiring' }
state = self.getState()
status = state_desc[state]
#self.debugState('Device status: %s (0x%08x)' % (status, state))
deb.Return('Device status: %s (0x%08x)' % (status, state))
return status
@DEB_MEMBER_FUNCT
def getFrameDim(self, max_dim=False):
deb_obj = DebObj(FrelonTacoAcq.deb_params, "getFrameDim")
ct_image = self.m_acq.getImageControl()
if max_dim:
max_size = ct_image.getMaxImageSize()
fdim = FrameDim(max_size, ct_image.getImageType())
else:
fdim = ct_image.getImageDim()
deb_obj.Trace()#self.debugCmd('Frame dim: %s' % fdim)
deb.Return('Frame dim: %s' % fdim)
return fdim
@DEB_MEMBER_FUNCT
def getType(self):
type_nb = 0
#self.debugCmd('Getting type: %s (#%s)' % (ccd_type, type_nb))
deb.Return('Getting type: %s (#%s)' % (ccd_type, type_nb))
return type_nb
@DEB_MEMBER_FUNCT
def getLstErrMsg(self):
err_msg = ''
#self.debugCmd('Getting last err. msg: %s' % err_msg)
deb.Return('Getting last err. msg: %s' % err_msg)
return err_msg
@DEB_MEMBER_FUNCT
def setTrigger(self, ext_trig):
#self.debugCmd('Setting trigger: %s' % ext_trig)
pass
deb.Param('Setting trigger: %s' % ext_trig)
@DEB_MEMBER_FUNCT
def getTrigger(self):
ext_trig = 0
#self.debugCmd('Getting trigger: %s' % ext_trig)
deb.Return('Getting trigger: %s' % ext_trig)
return ext_trig
@DEB_MEMBER_FUNCT
def setNbFrames(self, nb_frames):
#self.debugCmd('Setting nb. frames: %s' % nb_frames)
pass
deb.Param('Setting nb. frames: %s' % nb_frames)
@DEB_MEMBER_FUNCT
def getNbFrames(self):
nb_frames = 1
#self.debugCmd('Getting nb. frames: %s' % nb_frames)
deb.Return('Getting nb. frames: %s' % nb_frames)
return nb_frames
@DEB_MEMBER_FUNCT
def setExpTime(self, exp_time):
#self.debugCmd('Setting exp. time: %s' % exp_time)
deb.Param('Setting exp. time: %s' % exp_time)
pass
@DEB_MEMBER_FUNCT
def getExpTime(self):
exp_time = 1
#self.debugCmd('Getting exp. time: %s' % exp_time)
deb.Return('Getting exp. time: %s' % exp_time)
return exp_time
@DEB_MEMBER_FUNCT
def setBin(self, bin):
# SPEC format Y,X -> incompat. with getBin ...
bin = Bin(bin[1], bin[0])
#self.debugCmd('Setting binning: %s' % bin)
deb.Param('Setting binning: %s' % bin)
@DEB_MEMBER_FUNCT
def getBin(self):
bin = Bin(1, 1)
#self.debugCmd('Getting binning: %s' % bin)
deb.Return('Getting binning: %s' % bin)
return [bin.getX(), bin.getY()]
@DEB_MEMBER_FUNCT
def setRoi(self, roi):
roi = Roi(Point(roi[0], roi[1]), Point(roi[2], roi[3]))
#self.debugCmd('Setting roi: %s' % roi)
deb.Param('Setting roi: %s' % roi)
@DEB_MEMBER_FUNCT
def getRoi(self):
roi = Roi()
#self.debugCmd('Getting roi: %s' % roi)
deb.Return('Getting roi: %s' % roi)
tl = roi.getTopLeft()
br = roi.getBottomRight()
return [tl.getX(), tl.getY(), br.getX(), br.getY()]
@DEB_MEMBER_FUNCT
def setFilePar(self, file_par_arr):
file_par = CcdFilePar(from_arr=file_par_arr)
config = self.getConfig()
config.setParam('FilePar', file_par)
config.apply()
@DEB_MEMBER_FUNCT
def getFilePar(self):
config = self.getConfig()
file_par = config.getParam('FilePar')
return file_par.strArray()
@DEB_MEMBER_FUNCT
def setChannel(self, input_chan):
#self.debugCmd('Setting input channel: %s' % input_chan)
deb.Param('Setting input channel: %s' % input_chan)
pass
@DEB_MEMBER_FUNCT
def getChannel(self):
input_chan = 0
#self.debugCmd('Getting input channel: %s' % input_chan)
deb.Return('Getting input channel: %s' % input_chan)
return input_chan
@DEB_MEMBER_FUNCT
def setMode(self, mode):
#self.debugCmd('Setting mode: %s (0x%x)' % (mode, mode))
deb.Param('Setting mode: %s (0x%x)' % (mode, mode))
auto_save = (mode & self.AutoSave) != 0
@DEB_MEMBER_FUNCT
def getMode(self):
auto_save = False
mode = (auto_save and self.AutoSave) or 0
#self.debugCmd('Getting mode: %s (0x%x)' % (mode, mode))
deb.Return('Getting mode: %s (0x%x)' % (mode, mode))
return mode
@DEB_MEMBER_FUNCT
def setHwPar(self, hw_par_str):
hw_par = map(int, string.split(hw_par_str))
#self.debugCmd('Setting hw par: %s' % hw_par)
deb.Param('Setting hw par: %s' % hw_par)
@DEB_MEMBER_FUNCT
def getHwPar(self):
hw_par = []
#self.debugCmd('Getting hw par: %s' % hw_par)
deb.Return('Getting hw par: %s' % hw_par)
hw_par_str = string.join(map(str, hw_par))
return hw_par_str
@DEB_MEMBER_FUNCT
def setKinetics(self, kinetics):
#self.debugCmd('Setting the profile: %s' % kinetics)
deb.Param('Setting the profile: %s' % kinetics)
pass
@DEB_MEMBER_FUNCT
def getKinetics(self):
kinetics = 0
#self.debugCmd('Getting the profile: %s' % kinetics)
deb.Return('Getting the profile: %s' % kinetics)
return kinetics
@DEB_MEMBER_FUNCT
def startAcq(self):
#self.debugCmd('Starting the device')
deb.Trace('Starting the device')
pass
@DEB_MEMBER_FUNCT
def stopAcq(self):
#self.debugCmd('Stopping the device')
deb.Trace('Stopping the device')
pass
@DEB_MEMBER_FUNCT
def readFrame(self, frame_data):
frame_nb, frame_size = frame_data
frame_dim = self.getFrameDim()
......@@ -246,34 +272,40 @@ class FrelonTacoAcq(TacoCcdAcq):
(frame_size, len(s)))
return s
@DEB_MEMBER_FUNCT
def startLive(self):
pass