Esempio n. 1
0
class Adsc(PyTango.Device_4Impl):
    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self,cl, name):
        PyTango.Device_4Impl.__init__(self,cl,name)
        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#------------------------------------------------------------------
#    LoadConfiguration command
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def takeDarks(self,Texp):
         _AdscInterface.takeDarks(Texp)
class Prosilica(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')


#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self,*args) :
        PyTango.Device_4Impl.__init__(self,*args)

        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return AttrHelper.get_attr_string_value_list(self, attr_name)

    def __getattr__(self,name) :
        return AttrHelper.get_attr_4u(self, name, ProsilicaAcq)
Esempio n. 3
0
class Xpad(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)

        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        valueList = []
        dict_name = '_' + self.__class__.__name__ + '__' + ''.join(
            [x.title() for x in attr_name.split('_')])
        d = getattr(self, dict_name, None)
        if d:
            valueList = d.keys()

        return valueList

    def __getattr__(self, name):
        if name.startswith('read_') or name.startswith('write_'):
            split_name = name.split('_')[1:]
            attr_name = ''.join([x.title() for x in split_name])
            dict_name = '_' + self.__class__.__name__ + '__' + attr_name
            d = getattr(self, dict_name, None)
            attr_name = self.__Attribute2FunctionBase.get(
                '_'.join(split_name), attr_name)
            if d:
                if name.startswith('read_'):
                    functionName = 'get' + attr_name
                    function2Call = getattr(_XpadAcq, functionName)
                    callable_obj = CallableReadEnum(d, function2Call)
                else:
                    functionName = 'set' + attr_name
                    function2Call = getattr(_XpadAcq, function2Call)
                    callable_obj = CallableWriteEnum(d, function2Call)
                self.__dict__[name] = callable_obj
                return callable_obj
        raise AttributeError('Xpad has no attribute %s' % name)
Esempio n. 4
0
    class _PushingThread(threading.Thread):
        Core.DEB_CLASS(Core.DebModApplication, "_PushingThread")

        def __init__(self, task):
            threading.Thread.__init__(self)
            self._task = task
            self.timestamp = time.time()

        def run(self):
            task = self._task
            while task._stop is False:

                with task._lock:
                    while (task._new_frame_ready is False
                           and task._stop is False):
                        task._lock.wait()
                    if task._stop:
                        break
                    task._new_frame_ready = False

                dt = time.time() - self.timestamp
                if dt > 0.04:
                    bvdata, bvdata_format = construct_bvdata(
                        self._task._bpm_device)
                    self._task._bpm_device.push_change_event(
                        "bvdata", bvdata_format, bvdata)
                    self.timestamp = time.time()
Esempio n. 5
0
class Eiger(PyTango.Device_4Impl):

    #--------- Add you global variables here --------------------------
    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, cl, name):
        PyTango.Device_4Impl.__init__(self, cl, name)
        self.init_device()

        self.__CountrateCorrection = {'ON': True, 'OFF': False}
        self.__FlatfieldCorrection = {'ON': True, 'OFF': False}
        self.__AutoSummation = {'ON': True, 'OFF': False}
        self.__EfficiencyCorrection = {'ON': True, 'OFF': False}
        self.__VirtualPixelCorrection = {'ON': True, 'OFF': False}
        self.__PixelMask = {'ON': True, 'OFF': False}

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#------------------------------------------------------------------
#    getAttrStringValueList command:
#
#    Description: return a list of authorized values if any
#    argout: DevVarStringArray
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return AttrHelper.get_attr_string_value_list(self, attr_name)
#----------------------------------------------------------------------------
#                      delete all memory files
#----------------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def deleteMemoryFiles(self):
        _EigerCamera.deleteMemoryFiles()

#==================================================================
#
#    Eiger read/write attribute methods
#
#==================================================================

    def __getattr__(self, name):
        return AttrHelper.get_attr_4u(self, name, _EigerCamera)
Esempio n. 6
0
class HDF5SavingDeviceServer(BasePostProcess):
    HDF5_TASK_NAME = 'HDF5SavingTask'
    Core.DEB_CLASS(Core.DebModApplication, 'HDF5Saving')

    def __init__(self, cl, name):
        self.__HDF5SavingTask = None
        self.__HDF5Sink = None
        self.__HDF5Writer = None
        self.get_device_properties(self.get_device_class())
        self.__extension = ""
        self.__subdir = None
        BasePostProcess.__init__(self, cl, name)
        HDF5SavingDeviceServer.init_device(self)

    def set_state(self, state):
        if (state == PyTango.DevState.OFF):
            if (self.__HDF5SavingTask):
                self.__HDF5Writer.close()
                self.__callback = None
                self.__HDF5Writer = None
                self.__HDF5SavingTask = None
                ctControl = _control_ref()
                extOpt = ctControl.externalOperation()
                extOpt.delOp(self.HDF5_TASK_NAME)
        elif (state == PyTango.DevState.ON):
            if not self.__HDF5SavingTask:
                try:
                    ctControl = _control_ref()
                    extOpt = ctControl.externalOperation()
                    self.__HDF5SavingTask = extOpt.addOp(
                        Core.USER_SINK_TASK, self.HDF5_TASK_NAME,
                        self._runLevel)
                    if not self.__HDF5Sink:
                        self.__HDF5Writer = HDF5Writer()
                        self.__HDF5Sink = HDF5Sink(self.__HDF5Writer)
                    self.__HDF5SavingTask.setSinkTask(self.__HDF5Sink)
                    self.__callback = PrepareAcqCallback(
                        ctControl, self.__HDF5Sink)
                    self.__HDF5SavingTask.registerCallback(self.__callback)

                except:
                    import traceback
                    traceback.print_exc()
                    return
        PyTango.Device_4Impl.set_state(self, state)

    def Reset(self):
        if (self.__HDF5Sink):
            self.__HDF5Sink.reset()

    def read_Parameters(self, the_att):
        """
        Called  when reading the "Parameters" attribute
        """
        if self.__HDF5Sink:
            the_att.set_value(self.__HDF5Sink.__repr__())
        else:
            the_att.set_value("No HDF5 Sink processlib active for the moment")
Esempio n. 7
0
class Basler(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')


#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self,*args) :
        PyTango.Device_4Impl.__init__(self,*args)

        self.__TestImageSelector = {'TESTIMAGE_OFF': BaslerAcq.Camera.TestImage_Off,
                                    'TESTIMAGE_1': BaslerAcq.Camera.TestImage_1,
                                    'TESTIMAGE_2': BaslerAcq.Camera.TestImage_2,
                                    'TESTIMAGE_3': BaslerAcq.Camera.TestImage_3,
                                    'TESTIMAGE_4': BaslerAcq.Camera.TestImage_4,
                                    'TESTIMAGE_5': BaslerAcq.Camera.TestImage_5,
                                    'TESTIMAGE_6': BaslerAcq.Camera.TestImage_6,
                                    'TESTIMAGE_7': BaslerAcq.Camera.TestImage_7,
        }
        
        self.__Attribute2FunctionBase = {
        }
        
        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#------------------------------------------------------------------
#    getAttrStringValueList command:
#
#    Description: return a list of authorized values if any
#    argout: DevVarStringArray
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        #use AttrHelper
        return AttrHelper.get_attr_string_value_list(self, attr_name)
#==================================================================
#
#    Basler read/write attribute methods
#
#==================================================================
    def __getattr__(self,name) :
        #use AttrHelper
        return AttrHelper.get_attr_4u(self,name,_BaslerCam)
Esempio n. 8
0
class Dexela(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)

        self.init_device()

        self.__Attribute2FunctionBase = {}

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

        #Full well mode
        self.__FullWellMode = {
            'HIGH': _DexelaInterface.High,
            'LOW': _DexelaInterface.Low
        }
        self.__SkipFirstFrame = {'YES': True, 'NO': False}
#------------------------------------------------------------------
#    getAttrStringValueList command:
#
#    Description: return a list of authorized values if any
#    argout: DevVarStringArray
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        #use AttrHelper
        return get_attr_string_value_list(self, attr_name)
#==================================================================
#
#    Dexela read/write attribute methods
#
#==================================================================

    def __getattr__(self, name):
        #use AttrHelper
        return get_attr_4u(self, name, _DexelaInterface)
Esempio n. 9
0
class XPad(PyTango.Device_4Impl):
    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self,cl, name):
        PyTango.Device_4Impl.__init__(self,cl,name)
        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#------------------------------------------------------------------
#    LoadConfiguration command
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def loadConfiguration(self,filearr):
         _XPadInterface.loadConfig(filearr[0],filearr[1])

#------------------------------------------------------------------
#    Attrubute read/write methods
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def read_config_id(self, attr):
        Id = _XPadInterface.getConfigId()
        attr.set_value(Id)
    
    @Core.DEB_MEMBER_FUNCT
    def write_config_id(self, attr):
        data = []
        attr.get_write_value(data)
        Id = data[0]
        _XPadInterface.setConfigId(Id)
    
    @Core.DEB_MEMBER_FUNCT
    def read_ITHLoffset(self, attr):
        th = _XPadInterface.getITHLoffset()
        attr.set_value(th)
    
    @Core.DEB_MEMBER_FUNCT
    def write_ITHLoffset(self, attr):
        data = []
        attr.get_write_value(data)
        th = data[0]
        _XPadInterface.getITHLoffset(th)
Esempio n. 10
0
class _ExampleThreshold(Core.CtAccumulation.ThresholdCallback):
    Core.DEB_CLASS(Core.DebModApplication, '_ExampleThreshold')

    def __init__(self):
        Core.CtAccumulation.ThresholdCallback.__init__(self)

    ##@brief the effective callback methode
    @Core.DEB_MEMBER_FUNCT
    def aboveMax(self, data, value):
        deb.Trace('aboveMax: data=%s, value=%s' % (data, value))
class MaxImageSizeCallback(Core.HwMaxImageSizeCallback):

    Core.DEB_CLASS(Core.DebModTest, "MaxImageSizeCallback")

    @Core.DEB_MEMBER_FUNCT
    def maxImageSizeChanged(self, size, image_type):
        fdim = Core.FrameDim(size, image_type)
        msg = "size=%sx%s, image_type=%s, depth=%d" % \
              (size.getWidth(), size.getHeight(), image_type, \
               fdim.getDepth())
        deb.Always("MaxImageSizeChanged: %s" % msg)
class ImageStatusCallback(Core.CtControl.ImageStatusCallback):

    Core.DEB_CLASS(Core.DebModTest, "ImageStatusCallback")

    @Core.DEB_MEMBER_FUNCT
    def __init__(self, ct, acq_state):
        Core.CtControl.ImageStatusCallback.__init__(self)

        self.m_ct = ct
        self.m_acq_state = acq_state
        self.m_nb_frames = 0

    @Core.DEB_MEMBER_FUNCT
    def start(self):
        self.m_acq_state.set(Core.AcqState.Acquiring)
        self.m_start_time = time.time()
        self.m_stat_acc = [0.0] * 4
        ct_acq = self.m_ct.acquisition()
        self.m_nb_frames = ct_acq.getAcqNbFrames()

    @Core.DEB_MEMBER_FUNCT
    def imageStatusChanged(self, cb_img_status):
        t = time.time()
        global_status = self.m_ct.getStatus()
        acq_status = global_status.AcquisitionStatus
        img_status = global_status.ImageCounters

        last_acq_frame_nb = img_status.LastImageAcquired
        last_base_frame_nb = img_status.LastBaseImageReady
        last_ready_frame_nb = img_status.LastImageReady

        dt = t - self.m_start_time
        n = last_acq_frame_nb + 1
        acc = self.m_stat_acc
        acc[0] += n
        acc[1] += n**2
        acc[2] += dt
        acc[3] += n * dt

        acq_state_changed = False
        if last_ready_frame_nb == self.m_nb_frames - 1:
            self.m_acq_state.set(Core.AcqState.Finished)
            acq_state_changed = True

        pt = t0 = 0
        if n > 1:
            pt = (acc[0] * acc[2] - n * acc[3]) / (acc[0]**2 - n * acc[1])
            t0 = (acc[2] - pt * acc[0]) / n
        if True:
            deb.Always("Last Acquired: %8d, Last Base: %8d, " \
                       "Last Ready: %8d, Status: %s, PT: %.6f, T0: %.6f" %
                       (last_acq_frame_nb, last_base_frame_nb,
                        last_ready_frame_nb, acq_status, pt, t0))
Esempio n. 13
0
class BackgroundSubstractionDeviceServer(BasePostProcess):
    BACKGROUND_TASK_NAME = 'BackGroundTask'
    Core.DEB_CLASS(Core.DebModApplication, 'BackgroundSubstraction')

    def __init__(self, cl, name):
        self.__backGroundTask = None
        self.__backGroundImage = Core.Processlib.Data()
        self.get_device_properties(self.get_device_class())
        self.__deleteDarkAfterRead = False

        BasePostProcess.__init__(self, cl, name)
        BackgroundSubstractionDeviceServer.init_device(self)

    def set_state(self, state):
        if (state == PyTango.DevState.OFF):
            if (self.__backGroundTask):
                self.__backGroundTask = None
                ctControl = _control_ref()
                extOpt = ctControl.externalOperation()
                extOpt.delOp(self.BACKGROUND_TASK_NAME)
        elif (state == PyTango.DevState.ON):
            if not self.__backGroundTask:
                try:
                    ctControl = _control_ref()
                    extOpt = ctControl.externalOperation()
                    self.__backGroundTask = extOpt.addOp(
                        Core.BACKGROUNDSUBSTRACTION, self.BACKGROUND_TASK_NAME,
                        self._runLevel)
                    self.__backGroundTask.setBackgroundImage(
                        self.__backGroundImage)
                except:
                    import traceback
                    traceback.print_exc()
                    return
        PyTango.Device_4Impl.set_state(self, state)

    def read_delete_dark_after_read(self, attr):
        attr.set_value(self.__deleteDarkAfterRead)

    def write_delete_dark_after_read(self, attr):
        data = []
        attr.get_write_value(data)
        self.__deleteDarkAfterRead = data[0]

    @Core.DEB_MEMBER_FUNCT
    def setBackgroundImage(self, filepath):
        deb.Param('filepath=%s' % filepath)
        self.__backGroundImage = getDataFromFile(filepath)
        if self.__deleteDarkAfterRead:
            os.unlink(filepath)
        if (self.__backGroundTask):
            self.__backGroundTask.setBackgroundImage(self.__backGroundImage)
Esempio n. 14
0
class BVDataTask(Core.Processlib.SinkTaskBase):
    Core.DEB_CLASS(Core.DebModApplication, "BVDataTask")

    class _PushingThread(threading.Thread):
        Core.DEB_CLASS(Core.DebModApplication, "_PushingThread")

        def __init__(self, task):
            threading.Thread.__init__(self)
            self._task = task
            self.timestamp = time.time()

        def run(self):
            task = self._task
            while task._stop is False:

                with task._lock:
                    while (task._new_frame_ready is False
                           and task._stop is False):
                        task._lock.wait()
                    if task._stop:
                        break
                    task._new_frame_ready = False

                dt = time.time() - self.timestamp
                if dt > 0.04:
                    bvdata, bvdata_format = construct_bvdata(
                        self._task._bpm_device)
                    self._task._bpm_device.push_change_event(
                        "bvdata", bvdata_format, bvdata)
                    self.timestamp = time.time()

    def __init__(self, bpm_manager, bpm_device):
        Core.Processlib.SinkTaskBase.__init__(self)
        self._bpm_device = bpm_device
        self._bpm_manager = bpm_manager
        self._lock = threading.Condition()
        self._new_frame_ready = False
        self._stop = False
        self._pushing_event_thread = self._PushingThread(self)
        self._pushing_event_thread.start()

    def __del__(self):
        self._stop = True
        self._pushing_event_thread.join()

    def process(self, data):
        with self._lock:
            # just inform pushing_thread of a new image
            self._new_frame_ready = True
            self._lock.notify()
Esempio n. 15
0
class DeadTimeChangedCallback(Frelon.Camera.DeadTimeChangedCallback):

    Core.DEB_CLASS(Core.DebModTest, "DeadTimeChangedCallback")

    @Core.DEB_MEMBER_FUNCT
    def __init__(self, cam):
        Frelon.Camera.DeadTimeChangedCallback.__init__(self)
        self.m_cam = cam

    @Core.DEB_MEMBER_FUNCT
    def deadTimeChanged(self, dead_time):
        cam = self.m_cam
        deb.Always("dead_time=%.6f, readout_time=%.6f, xfer_time=%.6f" %
                   (dead_time, cam.getReadoutTime(), cam.getTransferTime()))
Esempio n. 16
0
class Ueye(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)

        self.init_device()

        self.__Attribute2FunctionBase = {}

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#------------------------------------------------------------------
#    getAttrStringValueList command:
#
#    Description: return a list of authorized values if any
#    argout: DevVarStringArray
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        #use AttrHelper
        return AttrHelper.get_attr_string_value_list(self, attr_name)
#==================================================================
#
#    Ueye read/write attribute methods
#
#==================================================================

    def __getattr__(self, name):
        #use AttrHelper
        return AttrHelper.get_attr_4u(self, name, _UeyeInterface)
Esempio n. 17
0
class RoperScientific(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)

        self.__AdcRate = {
            'MHZ1': 0,
            'KHZ100': 1,
        }
        self.__InternalAcqMode = {
            'FOCUS': 'FOCUS',
            'STANDARD': 'STANDARD',
        }
        self.__Attribute2FunctionBase = {
            'adc_rate': 'SpeedTableIndex',
        }
        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return get_attr_string_value_list(self, attr_name)

    def __getattr__(self, name):
        return get_attr_4u(self, name, _RoperScientificCam)

    def read_InternalAcqMode(self, attr):
        int_acq_mode = _RoperScientificCam.getInternalAcqMode()
        attr.set_value(int_acq_mode)
class SoftRoiCallback(Core.Processlib.TaskEventCallback):

    Core.DEB_CLASS(Core.DebModTest, "SoftRoiCallback")

    DataType2ImageType = {
        N.int8: Core.Bpp8,
        N.uint8: Core.Bpp8,
        N.int16: Core.Bpp16,
        N.uint16: Core.Bpp16,
        N.int32: Core.Bpp32,
        N.uint32: Core.Bpp32
    }

    @Core.DEB_MEMBER_FUNCT
    def __init__(self, hw_inter, buffer_save, acq_state):
        Core.Processlib.TaskEventCallback.__init__(self)
        self.m_hw_inter = hw_inter
        self.m_buffer_save = buffer_save
        self.m_acq_state = acq_state

    @Core.DEB_MEMBER_FUNCT
    def finished(self, data):
        finfo, fdim = self.data2FrameInfo(data)
        self.m_buffer_save.writeFrame(finfo)

        hw_sync = self.m_hw_inter.getHwCtrlObj(Core.HwCap.Sync)
        nb_frames = hw_sync.getNbFrames()
        if finfo.acq_frame_nb == nb_frames - 1:
            self.m_acq_state.set(Core.AcqState.Finished)

    @Core.DEB_MEMBER_FUNCT
    def data2FrameInfo(self, data):
        arr = data.buffer
        arr_type = arr.dtype.type
        arr_height, arr_width = arr.shape

        image_type = self.DataType2ImageType[arr_type]

        buffer_ctrl = self.m_hw_inter.getHwCtrlObj(Core.HwCap.Buffer)
        start_ts = buffer_ctrl.getStartTimestamp()

        fdim = Core.FrameDim(arr_width, arr_height, image_type)
        timestamp = Core.Timestamp(data.timestamp)
        valid_pixels = Core.Point(fdim.getSize()).getArea()

        ownership = Core.HwFrameInfoType.Managed
        finfo = Core.HwFrameInfoType(data.frameNumber, arr, timestamp,
                                     valid_pixels, ownership)
        return finfo, fdim
class TestFrameCallback(Core.HwFrameCallback):

    Core.DEB_CLASS(Core.DebModTest, "TestFrameCallback")

    ImageType2DataType = {
        Core.Bpp8: Data_UINT8,
        Core.Bpp16: Data_UINT16,
        Core.Bpp32: Data_UINT32
    }

    @Core.DEB_MEMBER_FUNCT
    def __init__(self, hw_inter, soft_roi, buffer_save, acq_state):
        Core.HwFrameCallback.__init__(self)
        self.m_hw_inter = hw_inter
        self.m_soft_roi = soft_roi
        self.m_acq_state = acq_state
        self.m_roi_task = Core.Processlib.Tasks.SoftRoi()
        self.m_roi_cb = SoftRoiCallback(hw_inter, buffer_save, acq_state)

    @Core.DEB_MEMBER_FUNCT
    def newFrameReady(self, frame_info):
        msg = 'acq_frame_nb=%d, ' % frame_info.acq_frame_nb
        data = self.frameInfo2Data(frame_info)
        buffer = data.buffer
        msg += 'frame_dim=%dx%dx%d, ' % \
               (buffer.shape[1], buffer.shape[0], buffer.dtype.itemsize)
        msg += 'frame_timestamp=%.6f, ' % frame_info.frame_timestamp
        msg += 'valid_pixels=%d' % frame_info.valid_pixels
        deb.Always("newFrameReady: %s" % msg)

        if self.m_soft_roi.isActive():
            pass
        else:
            self.m_roi_cb.finished(data)

        return True

    @Core.DEB_MEMBER_FUNCT
    def frameInfo2Data(self, frame_info):
        data = Core.Processlib.Data()
        data.buffer = frame_info.frame_data
        data.frameNumber = frame_info.acq_frame_nb
        data.timestamp = frame_info.frame_timestamp

        return data
Esempio n. 20
0
class TestControlAutoSync:
	Core.DEB_CLASS(Core.DebModTest, 'TestControlAutoSync')

	def __init__(self):
		self.test_control = TestControl()
		self.traceRefCount(1)

	def __del__(self):
		self.traceRefCount(2)
		self.test_control.sync()
		self.traceRefCount(3)

	@Core.DEB_MEMBER_FUNCT
	def traceRefCount(self, point):
		deb.Trace("%s* refcount(test_control): %s" %
			  (point, sys.getrefcount(self.test_control)))

	def __getattr__(self, name):
		return getattr(self.test_control, name)
Esempio n. 21
0
class imXPAD(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')


#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    def __init__(self,*args) :
        PyTango.Device_4Impl.__init__(self,*args)

        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())


    @Core.DEB_MEMBER_FUNCT
    def loadConfig(self,config_prefix) :
        config_path = self.config_path
        _imXPADCam.loadConfigGFromFile(os.path.join(config_path,'%s.cfg' % config_prefix))
        _imXPADCam.loadConfigLFromFileToSRAM(os.path.join(config_path,'%s.cfl' % config_prefix))
        _imXPADCam.loadConfigLSRAMToDetector()
        
    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return get_attr_string_value_list(self, attr_name)

    def __getattr__(self,name) :
        return get_attr_4u(self, name, XpadAcq)
Esempio n. 22
0
class Lambda(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)
        #self.__Attribute2FunctionBase = {'distortion_correction': 'DistortionCorrection',
        #                                 }

        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return get_attr_string_value_list(self, attr_name)

    def __getattr__(self, name):
        return get_attr_4u(self, name, _LambdaCam)
Esempio n. 23
0
class AzimuthalIntegrationDeviceServer(BasePostProcess):
    AZIMUTHAL_TASK_NAME = 'AzimuthalIntegrationTask'
    Core.DEB_CLASS(Core.DebModApplication, 'AzimuthalIntegration')

    def __init__(self, cl, name):
        self.__azimuthalIntegratorTask = None
        self.__jsonConfig = None
        self.__pyFAISink = None
        self.get_device_properties(self.get_device_class())
        self.__extension = ""
        self.__subdir = None
        BasePostProcess.__init__(self, cl, name)
        AzimuthalIntegrationDeviceServer.init_device(self)

    def set_state(self, state):
        if (state == PyTango.DevState.OFF):
            if (self.__azimuthalIntegratorTask):
                self.__azimuthalIntegratorTask = None
                ctControl = _control_ref()
                extOpt = ctControl.externalOperation()
                extOpt.delOp(self.AZIMUTHAL_TASK_NAME)
        elif (state == PyTango.DevState.ON):
            if not self.__azimuthalIntegratorTask:
                try:
                    ctControl = _control_ref()
                    extOpt = ctControl.externalOperation()
                    self.__azimuthalIntegratorTask = extOpt.addOp(
                        Core.USER_SINK_TASK, self.AZIMUTHAL_TASK_NAME,
                        self._runLevel)
                    if not self.__pyFAISink:
                        self.__pyFAISink = SinkPyFAI()
                    if self.__jsonConfig:
                        self.__pyFAISink.setJsonConfig(self.__jsonConfig)
                    if self.__extension:
                        self.__pyFAISink.setExtension(self.__extension)
                    if self.__subdir:
                        self.__pyFAISink.setSubdir(self.__subdir)
                    self.__azimuthalIntegratorTask.setSinkTask(
                        self.__pyFAISink)
                except:
                    import traceback
                    traceback.print_exc()
                    return
        PyTango.Device_4Impl.set_state(self, state)

    def setBackgroundImage(self, filepath):
        if (self.__pyFAISink):
            self.__pyFAISink.setBackgroundFile(filepath)

    def setFlatfieldImage(self, filepath):
        if (self.__pyFAISink):
            self.__pyFAISink.setFlatfieldFile(filepath)

    def setJsonConfig(self, filepath):
        self.__jsonConfig = filepath
        if (self.__pyFAISink):
            self.__pyFAISink.setJsonConfig(filepath)

    def setProcessedSubdir(self, filepath):
        """
        Directory  (relative or absolute) for processed data
        """
        self.__subdir = filepath
        if self.__pyFAISink:
            self.__pyFAISink.setSubdir(self.__subdir)

    def setProcessedExt(self, ext):
        """
        Extension for prcessed data files
        """
        self.__extension = ext
        if self.__pyFAISink:
            self.__pyFAISink.setExtension(self.__extension)

    def Reset(self):
        if (self.__pyFAISink):
            self.__pyFAISink.reset()

    def Reconfig(self, shape):
        if (self.__pyFAISink):
            self.__pyFAISink.reconfig(shape)

    def read_Parameters(self, the_att):
        """
        Called  when reading the "Parameters" attribute
        """
        if self.__pyFAISink:
            the_att.set_value(self.__pyFAISink.__repr__())
        else:
            the_att.set_value("No pyFAI Sink processlib active for the moment")
Esempio n. 24
0
class Interface(Core.HwInterface) :
    Core.DEB_CLASS(Core.DebModCamera, "Interface")

    def __init__(self) :
	Core.HwInterface.__init__(self)

        self.__comm = Communication()
        self.__comm.start()
        self.__detInfo = DetInfoCtrlObj()
        self.__detInfo.init()
        self.__buffer = BufferCtrlObj(self.__comm,self.__detInfo)
        self.__syncObj = SyncCtrlObj(self.__comm,self.__detInfo)

    def __del__(self) :
        self.__comm.quit()

    def quit(self) :
        self.__comm.quit()
        
    @Core.DEB_MEMBER_FUNCT
    def getCapList(self) :
        return [Core.HwCap(x) for x in [self.__detInfo,self.__syncObj,self.__buffer]]

    @Core.DEB_MEMBER_FUNCT
    def reset(self,reset_level):
        pass
        
    @Core.DEB_MEMBER_FUNCT
    def prepareAcq(self):
        self.__syncObj.prepareAcq()
#        while self.__comm.getCurrentCommand() != Communication.COM_NONE:
#            time.sleep(0.1)

    @Core.DEB_MEMBER_FUNCT
    def loadConfig(self,file1,file2):
        self.__comm.setCalFiles(file1,file2)
        self.__comm.Configure()            

    @Core.DEB_MEMBER_FUNCT
    def setITHLoffset(self,th) :
         self.__comm.setITHLoffset(th)

    @Core.DEB_MEMBER_FUNCT
    def getITHLoffset(self) :
        return self.__comm.getITHLoffset()

    @Core.DEB_MEMBER_FUNCT
    def setConfigId(self,Id):
        self.__comm.setConfigId(Id)

    @Core.DEB_MEMBER_FUNCT
    def getConfigId(self):
        return self.__comm.getConfigId()

    @Core.DEB_MEMBER_FUNCT
    def startAcq(self) :
        self.__comm.startAcquisition()

    @Core.DEB_MEMBER_FUNCT
    def stopAcq(self) :
        pass
        
    @Core.DEB_MEMBER_FUNCT
    def getStatus(self) :
        CommOk = self.__comm.isAlive() and self.__comm.isRunning()
        CommState = self.__comm.getCurrentCommand()
        status = Core.HwInterface.StatusType()

        if not CommOk:
            status.det = Core.DetFault
            status.acq = Core.AcqFault
            deb.Error("Detector communication is not running")
        elif CommState == Communication.COM_NONE:
            status.det = Core.DetIdle
            status.acq = Core.AcqReady
        elif not self.__comm.isConfigured() :
            status.det = Core.DetFault
            status.acq = Core.AcqConfig
        else:
            if CommState == Communication.COM_START or \
                   CommState == Communication.COM_TEST:
                status.det = Core.DetExposure
            else:
                status.det = Core.DetFault
            if self.__syncObj.getNbFrames() == self.__comm.getNbFramesReady():
                status.acq = Core.AcqReady
            else:
                status.acq = Core.AcqRunning

        status.det_mask = (Core.DetExposure|Core.DetFault)
        return status
    
    @Core.DEB_MEMBER_FUNCT
    def getNbAcquiredFrames(self) :
        return self.__comm.getNbFramesReady()
    
    @Core.DEB_MEMBER_FUNCT
    def getNbHwAcquiredFrames(self):
        return self.getNbAcquiredFrames()
Esempio n. 25
0
class Pco(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)

        #self._Pco__Rollingshutter = { "only for EDGE": "-1", "GLOBAL": "0", "ROLLING":"1" }

        self.__Attribute2FunctionBase = {
            'acqTimeoutRetry': 'AcqTimeoutRetry',
            'adc': 'Adc',
            'adcMax': 'AdcMax',
            'binInfo': 'BinningInfo',
            'bitAlignment': 'BitAlignment',
            'bytesPerPixel': 'BytesPerPixel',
            'camInfo': 'CamInfo',
            'camName': 'CameraName',
            'camNameBase': 'CameraNameBase',
            'camNameEx': 'CameraNameEx',
            'camType': 'CamType',
            'cdiMode': 'CDIMode',
            'clXferPar': 'ClTransferParam',
            'cocRunTime': 'CocRunTime',
            'coolingTemperature': 'CoolingTemperature',
            'doubleImageMode': 'DoubleImageMode',
            'firmwareInfo': 'FirmwareInfo',
            'frameRate': 'FrameRate',
            'info': 'CamInfo',
            'lastError': 'LastError',
            'lastImgAcquired': 'LastImgAcquired',
            'lastImgRecorded': 'LastImgRecorded',
            'logMsg': 'MsgLog',
            'logPcoEnabled': 'PcoLogsEnabled',
            'maxNbImages': 'MaxNbImages',
            'pixelRate': 'PixelRate',
            'pixelRateInfo': 'PixelRateInfo',
            'pixelRateValidValues': 'PixelRateValidValues',
            'roiInfo': 'RoiInfo',
            'roiLastFixed': 'LastFixedRoi',
            'rollingShutter': 'RollingShutter',
            'rollingShutterInfo': 'RollingShutterInfo',
            'temperatureInfo': 'TemperatureInfo',
            'traceAcq': 'TraceAcq',
            'version': 'Version',
            'versionSdk': 'SdkRelease',
            'camerasFound': 'CamerasFound',
            'debugInt': 'DebugInt',
            'debugIntTypes': 'DebugIntTypes',
            'test': 'Test',
            'timestampMode': 'TimestampMode',
        }

        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass

#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())

#==================================================================
#
#    Pco read/write attribute methods
#
#==================================================================

    def __getattr__(self, name):
        return get_attr_4u(self, name, _PcoCam)

    def read_versionAtt(self, attr):
        attr.set_value(VERSION_ATT)

#==================================================================
#
#    Pco command methods
#
#==================================================================

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return get_attr_string_value_list(self, attr_name)

    @Core.DEB_MEMBER_FUNCT
    def talk(self, argin):
        val = _PcoCam.talk(argin)
        return val
Esempio n. 26
0
class Frelon(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaFrelon')

    #------------------------------------------------------------------
    #    Device constructor
    #------------------------------------------------------------------
    def __init__(self, *args):
        PyTango.Device_4Impl.__init__(self, *args)

        self.__ImageMode = {
            'FRAME TRANSFER': FrelonAcq.FTM,
            'FULL FRAME': FrelonAcq.FFM
        }

        self.__RoiMode = {
            'NONE': FrelonAcq.None,
            'SLOW': FrelonAcq.Slow,
            'FAST': FrelonAcq.Fast,
            'KINETIC': FrelonAcq.Kinetic
        }

        self.__InputChannel = {
            '1': 0x1,
            '2': 0x2,
            '3': 0x4,
            '4': 0x8,
            '1-2': 0x3,
            '3-4': 0xc,
            '1-3': 0x5,
            '2-4': 0xA,
            '1-2-3-4': 0xf
        }

        self.__E2VCorrection = {'ON': True, 'OFF': False}

        self.__Spb2Config = {'PRECISION': 0, 'SPEED': 1}

        self.__Attribute2FunctionBase = {
            'image_mode': 'FrameTransferMode',
            'input_channel': 'InputChan',
            'e2v_correction': 'E2VCorrectionActive',
            'spb2_config': 'SPB2Config'
        }

        self.init_device()

#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------

    def delete_device(self):
        pass


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------

    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)
        self.get_device_properties(self.get_device_class())
        self.ResetLinkWaitTime = 5

    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return get_attr_string_value_list(self, attr_name)

    def __getattr__(self, name):
        return get_attr_4u(self, name, _FrelonAcq)

    @Core.DEB_MEMBER_FUNCT
    def execSerialCommand(self, command_string):
        return _FrelonAcq.execFrelonSerialCmd(command_string)

    @Core.DEB_MEMBER_FUNCT
    def resetLink(self):
        _FrelonAcq.getEspiaDev().resetLink()
        time.sleep(self.ResetLinkWaitTime)

    ## @brief read the espia board id
    #
    def read_espia_dev_nb(self, attr):
        espia_dev_nb = 0
        if self.espia_dev_nb:
            espia_dev_nb = self.espia_dev_nb
        attr.set_value(espia_dev_nb)

    def read_roi_bin_offset(self, attr):
        roi_bin_offset = _FrelonAcq.getRoiBinOffset()
        attr.set_value(roi_bin_offset.y)

    def write_roi_bin_offset(self, attr):
        roi_bin_offset = Core.Point(0, attr.get_write_value())
        _FrelonAcq.setRoiBinOffset(roi_bin_offset)
Esempio n. 27
0
class FrelonTacoProxy:

    Core.DEB_CLASS(Core.DebModApplication, 'FrelonTacoProxy')

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetType(self):
        model = _FrelonAcq.getCameraModel()
        type_nb = ((model.getAdcBits() == 16) and 2016) or 2014
        deb.Return('Getting type: %s' % type_nb)
        return type_nb

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetLstErrMsg(self):
        err_msg = ''
        deb.Return('Getting last err. msg: %s' % err_msg)
        return err_msg

    @Core.DEB_MEMBER_FUNCT
    def DevCcdSetChannel(self, input_chan):
        _FrelonAcq.setInputChan(input_chan)

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetChannel(self):
        return _FrelonAcq.getInputChan()

    @Core.DEB_MEMBER_FUNCT
    def DevCcdSetHwPar(self, hw_par_str):
        hw_par = map(int, string.split(hw_par_str))
        deb.Param('Setting hw par: %s' % hw_par)
        kin_win_size, kin_line_beg, kin_stripes = self.getKinPars()
        flip_mode, kin_line_beg, kin_stripes, d0, roi_mode_int = hw_par
        flip = Core.Flip(flip_mode >> 1, flip_mode & 1)
        _FrelonAcq.setFlip(flip)
        roi_mode = FrelonAcq.RoiMode(roi_mode_int)
        _FrelonAcq.setRoiMode(roi_mode)
        if roi_mode == FrelonAcq.Kinetic:
            max_frame_dim = _FrelonAcq.getFrameDim(max_dim=True)
            frame_height = max_frame_dim.getSize().getHeight()
            if kin_line_beg + kin_win_size > frame_height:
                kin_win_size = frame_height - kin_line_beg
                bin_y = _FrelonAcq.getBin().getY()
                kin_win_size = (kin_win_size / bin_y) * bin_y
                deb.Trace('Re-adjusting kin_win_size to %d to fit chip' %
                          kin_win_size)
            self.setKinPars(kin_win_size, kin_line_beg, kin_stripes)
        else:
            deb.Warning('Ingoring Kinetic parameters')

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetHwPar(self):
        flip = _FrelonAcq.getFlip()
        flip_mode = flip.x << 1 | flip.y
        roi_mode = _FrelonAcq.getRoiMode()
        kin_win_size, kin_line_beg, kin_stripes = self.getKinPars()
        hw_par = [flip_mode, kin_line_beg, kin_stripes, 0, roi_mode]
        deb.Return('Getting hw par: %s' % hw_par)
        hw_par_str = string.join(map(str, hw_par))
        return hw_par_str

    @Core.DEB_MEMBER_FUNCT
    def DevCcdSetKinetics(self, kinetics):
        deb.Param('Setting the profile: %s' % kinetics)
        if kinetics == 0:
            ftm = FrelonAcq.FFM
        elif kinetics == 3:
            ftm = FrelonAcq.FTM
        else:
            raise Core.Exception, 'Invalid profile value: %s' % kinetics
        _FrelonAcq.setFrameTransferMode(ftm)

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetKinetics(self):
        ftm = _FrelonAcq.getFrameTransferMode()
        if ftm == FrelonAcq.FTM:
            kinetics = 3
        else:
            kinetics = 0
        deb.Return('Getting the profile: %s' % kinetics)
        return kinetics

    @Core.DEB_MEMBER_FUNCT
    def DevCcdSetKinWinSize(self, kin_win_size):
        deb.Param('Setting the kinetics window size: %s' % kin_win_size)
        prev_win_size, kin_line_beg, kin_stripes = self.getKinPars()
        self.setKinPars(kin_win_size, kin_line_beg, kin_stripes)

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetKinWinSize(self):
        kin_win_size, kin_line_beg, kin_stripes = self.getKinPars()
        deb.Return('Getting the kinetics window size: %s' % kin_win_size)
        return kin_win_size

    @Core.DEB_MEMBER_FUNCT
    def setKinPars(self, kin_win_size, kin_line_beg, kin_stripes):
        deb.Param('Setting kin pars: ' +
                  'kin_win_size=%s, kin_line_beg=%s, kin_stripes=%s' % \
                  (kin_win_size, kin_line_beg, kin_stripes))
        if kin_stripes > 1:
            deb.Warning('Ignoring kin_stripes=%d' % kin_stripes)

        bin = _FrelonAcq.getBin()
        if kin_win_size % bin.getY() != 0:
            msg = 'Invalid kinetics window size (%d): ' % kin_win_size + \
                  'must be multiple of vert. bin (%d)' % bin.getY()
            raise Core.Exception, msg

        roi = _FrelonAcq.getRoi()
        roi = roi.getUnbinned(bin)
        tl = Core.Point(roi.getTopLeft().x, kin_line_beg)
        size = Core.Size(roi.getSize().getWidth(), kin_win_size)
        roi = Core.Roi(tl, size)
        roi = roi.getBinned(bin)
        _FrelonAcq.setRoi(roi)

        _FrelonAcq.setRoiLineBegin(kin_line_beg)

    @Core.DEB_MEMBER_FUNCT
    def getKinPars(self):
        bin = _FrelonAcq.getBin()
        roi = _FrelonAcq.getRoi()
        roi = roi.getUnbinned(bin)
        kin_win_size = roi.getSize().getHeight()
        kin_line_beg = _FrelonAcq.getRoiLineBegin()
        kin_stripes = 1
        deb.Return('Getting kin pars: ' +
                   'kin_win_size=%s, kin_line_beg=%s, kin_stripes=%s' % \
                   (kin_win_size, kin_line_beg, kin_stripes))
        return kin_win_size, kin_line_beg, kin_stripes

    @Core.DEB_MEMBER_FUNCT
    def DevCcdCommand(self, cmd):
        return _FrelonAcq.execFrelonSerialCmd(cmd)

    @Core.DEB_MEMBER_FUNCT
    def DevCcdGetChanges(self):
        changes = 0
        deb.Trace('Getting changes: %s' % changes)
        return changes

    @Core.DEB_MEMBER_FUNCT
    def getAutoResetCtStatus(self):
        return True
Esempio n. 28
0
class TestControl:
	Core.DEB_CLASS(Core.DebModTest, 'TestControl')

	class ImageStatusCallback(Core.CtControl.ImageStatusCallback):
		def __init__(self, test_control, cb_end):
			Core.CtControl.ImageStatusCallback.__init__(self)
			self.test_control = weakref.ref(test_control)
			self.cb_end = cb_end

		def imageStatusChanged(self, image_status):
			test_control = self.test_control()
			if not test_control:
				return
			self.cb_end.clear()
			test_control.imageStatusChanged(image_status)
			del test_control
			self.cb_end.set()

	@Core.DEB_MEMBER_FUNCT
	def __init__(self):
		self.simu = Simulator.Camera()
		self.simu_hw = Simulator.Interface(self.simu)
		self.ct_control = Core.CtControl(self.simu_hw)
		self.cb_end = threading.Event()
		self.cb = self.ImageStatusCallback(self, self.cb_end)
		self.ct_control.registerImageStatusCallback(self.cb)

	@Core.DEB_MEMBER_FUNCT
	def __del__(self):
		del self.ct_control
		del self.simu_hw

	@Core.DEB_MEMBER_FUNCT
	def start(self, exp_time, nb_frames, prepare_timeout, sleep_time):
		ct_acq = self.ct_control.acquisition()
		ct_acq.setAcqExpoTime(exp_time)
		ct_acq.setAcqNbFrames(nb_frames)
		self.sleep_time = sleep_time
		if hasattr(self.ct_control, 'setPrepareTimeout'):
			self.ct_control.setPrepareTimeout(prepare_timeout)
		self.ct_control.prepareAcq()
		deb.Always('prepareAcq finished')
		self.ct_control.startAcq()

	@Core.DEB_MEMBER_FUNCT
	def waitAcq(self):
		def acq_status():
			return self.ct_control.getStatus().AcquisitionStatus
		while acq_status() == Core.AcqRunning:
			time.sleep(10e-3)
		deb.Always('Acq. is ready')

	@Core.DEB_MEMBER_FUNCT
	def sync(self):
		self.waitAcq()
		self.cb_end.wait()

	@Core.DEB_MEMBER_FUNCT
	def imageStatusChanged(self, img_status):
		last_img_ready = img_status.LastImageReady
		if last_img_ready < 0:
			return

		image = self.ct_control.ReadImage(last_img_ready)
		time.sleep(self.sleep_time)
		deb.Always('Forcing read frame %d memory' % last_img_ready)
		data = b' ' + image.buffer.tostring()
Esempio n. 29
0
class Andor3(PyTango.Device_4Impl):

#--------- Add you global variables here --------------------------
    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')

#------------------------------------------------------------------
#    Device constructor
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def __init__(self,cl, name):
        PyTango.Device_4Impl.__init__(self,cl,name)
        # dictionnaries to be used with AttrHelper.get_attr_4u
        self.__AdcGain = {'b11_hi_gain':  _Andor3Camera.b11_hi_gain,
                             'b11_low_gain': _Andor3Camera.b11_low_gain,
                             'b16_lh_gain':  _Andor3Camera.b16_lh_gain,
                          }
        self.__AdcRate = {'MHZ10':  _Andor3Camera.MHz10,
                          'MHZ100': _Andor3Camera.MHz100,
                          'MHZ200': _Andor3Camera.MHz200,
                          'MHZ280': _Andor3Camera.MHz280,
                          }
        self.__Cooler = {'ON':  True,
                         'OFF': False}
        self.__FanSpeed = {'OFF':  _Andor3Camera.Off,
                           'LOW':  _Andor3Camera.Low,
                           'HIGH': _Andor3Camera.On,
                           }
        self.__ElectronicShutterMode = {'ROLLING': _Andor3Camera.Rolling,
                                        'GLOBAL': _Andor3Camera.Global,
                                        }
        self.__DestrideActive = {'YES': True,
                                 'NO':  False}
        self.__Attribute2FunctionBase = {'adc_gain': 'SimpleGain',
                                         'adc_rate': 'AdcRate',
                                         'temperature': 'Temperature',
                                         'temperature_sp': 'TemperatureSP',
                                         'cooler': 'Cooler',
                                         'cooling_status': 'CoolingStatus',
                                         'fan_speed': 'FanSpeed',
                                         'electronic_shutter_mode': 'ElectronicShutterMode',
                                         'destride_active': 'DestrideActive',
                                         'frame_rate': 'FrameRate',
                                         'max_frame_rate_transfer': 'MaxFrameRateTransfer',
                                         'readout_time': 'ReadoutTime',
                                         }
        self.init_device()
                                               
#------------------------------------------------------------------
#    Device destructor
#------------------------------------------------------------------
    def delete_device(self):
        pass


#------------------------------------------------------------------
#    Device initialization
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def init_device(self):
        self.set_state(PyTango.DevState.ON)

        # Load the properties
        self.get_device_properties(self.get_device_class())

        # Apply properties if any
        if self.adc_gain:
            _Andor3Interface.setAdcGain(self.__AdcGain[self.adc_gain])
            
        if self.adc_rate:
            _Andor3Interface.setAdcRate(self.__AdcRate[self.adc_rate])
            
        if self.temperature_sp:            
            _Andor3Camera.setTemperatureSP(self.temperature_sp)
            
        if self.cooler:
            _Andor3Camera.setCooler(self.__Cooler[self.cooler])
            

#==================================================================
#
#    Andor3 read/write attribute methods
#
#==================================================================


    def __getattr__(self,name) :
        try:
            return get_attr_4u(self, name, _Andor3Interface)
        except:
            return get_attr_4u(self, name, _Andor3Camera)


#==================================================================
#
#    Andor3 command methods
#
#==================================================================

#------------------------------------------------------------------
#    getAttrStringValueList command:
#
#    Description: return a list of authorized values if any
#    argout: DevVarStringArray   
#------------------------------------------------------------------
    @Core.DEB_MEMBER_FUNCT
    def getAttrStringValueList(self, attr_name):
        return get_attr_string_value_list(self, attr_name)
Esempio n. 30
0
class Andor3(PyTango.Device_4Impl):

    Core.DEB_CLASS(Core.DebModApplication, 'LimaCCDs')