コード例 #1
0
def test_empty_fill():
    """
    Test that the empty fill provides empty frames
    """
    processed_frames = []

    class MyCamera(Simulator.Camera):
        def fillData(self, data):
            nonlocal processed_frames
            s = numpy.sum(data.buffer)
            processed_frames.append(s)

    cam = MyCamera()
    cam.getFrameGetter().setFillType(Simulator.FrameBuilder.Empty)
    hw = Simulator.Interface(cam)
    ct = Core.CtControl(hw)

    acq = ct.acquisition()
    acq.setTriggerMode(Core.IntTrig)
    acq.setAcqNbFrames(3)
    acq.setAcqExpoTime(0.01)

    ct.prepareAcq()
    ct.startAcq()

    for _ in range(30):
        if ct.getStatus().AcquisitionStatus != Core.AcqRunning:
            break
        time.sleep(0.1)
    else:
        assert False, "Simulator is still running"

    assert processed_frames == [0, 0, 0]
コード例 #2
0
def test_custom_frame():

    process_count = 0

    class MyCamera(Simulator.Camera):
        def fillData(self, data):
            nonlocal process_count
            assert data.frameNumber == 0
            assert data.buffer.shape == (1024, 1024)
            assert data.buffer.dtype == numpy.uint32
            # The buffer is writable
            data.buffer[0, 0] = 1
            data.buffer[-1, -1] = 1
            process_count += 1

    cam = MyCamera()
    hw = Simulator.Interface(cam)
    ct = Core.CtControl(hw)

    ct.prepareAcq()
    ct.startAcq()

    for _ in range(20):
        if ct.getStatus().AcquisitionStatus != Core.AcqRunning:
            break
        time.sleep(0.1)
    else:
        assert False, "Simulator is still running"

    assert process_count == 1
コード例 #3
0
def test_gauss_fill():
    """
    Test that the gauss fill increase frame after frame
    """
    processed_frames = []

    class MyCamera(Simulator.Camera):
        def fillData(self, data):
            nonlocal processed_frames
            s = numpy.sum(data.buffer)
            processed_frames.append(s)

    cam = MyCamera()
    hw = Simulator.Interface(cam)
    ct = Core.CtControl(hw)

    acq = ct.acquisition()
    acq.setTriggerMode(Core.IntTrig)
    acq.setAcqNbFrames(3)
    acq.setAcqExpoTime(0.01)

    ct.prepareAcq()
    ct.startAcq()

    for _ in range(30):
        if ct.getStatus().AcquisitionStatus != Core.AcqRunning:
            break
        time.sleep(0.1)
    else:
        assert False, "Simulator is still running"

    assert processed_frames == [1096524, 2225892, 3356544]
コード例 #4
0
def get_control(detector_ip_address = "0",**keys) :
    global _EigerIterface
    global _EigerCamera
    if _EigerIterface is None:
        _EigerCamera = EigerAcq.Camera(detector_ip_address)
        _EigerIterface = EigerAcq.Interface(_EigerCamera)
    return Core.CtControl(_EigerIterface)
コード例 #5
0
    def _init(self):
        self.scalingType = None
        self.forceUpdate = False
        self.camMirror = None

        self.__brightnessExists = False
        self.__contrastExists = False
        self.__gainExists = False
        self.__gammaExists = False

        self.camType = self.getProperty("type").lower()
        self.camAddress = self.getProperty("address")
        #self.camMirror = eval(self.getProperty("mirror_hor_ver"))

        if self.camType == 'prosilica':
            from Lima import Prosilica
            self.camera = Prosilica.Camera(self.camAddress)
            self.interface = Prosilica.Interface(self.camera)
        if self.camType == 'simulation':
            from Lima import Simulator
            self.camera = Simulator.Camera()
            self.interface = Simulator.Interface(self.camera)
        try:
            self.control = Core.CtControl(self.interface)
            self.video = self.control.video()
            self.video.setExposure(self.getProperty("interval") / 1000.0)
            self.__imageDimensions = self.camera.getMaxWidthHeight()
        except KeyError:
            logging.getLogger().warning(
                '%s: not initialized. Check camera settings', self.name())

        self.setImageTypeFromXml('imagetype')
        self.setIsReady(True)
コード例 #6
0
def get_control(frame_transmission_delay=0,
                inter_packet_delay=0,
                packet_size=8000,
                **keys):
    global _BaslerCam
    global _BaslerInterface

    if 'camera_id' in keys:
        camera_id = keys['camera_id']
    elif 'serial_number' in keys:
        camera_id = 'sn://' + keys['serial_number']
    elif 'cam_ip_address' in keys:
        camera_id = 'ip://' + keys['cam_ip_address']
    elif 'user_name' in keys:
        camera_id = 'uname://' + keys['user_name']
    else:
        # if no property is present it uses the server personal name
        # as Basler user name to identify the camera
        util = PyTango.Util.instance()
        camera_id = 'uname://' + util.get_ds_inst_name()

    print "basler camera_id:", camera_id

    if _BaslerCam is None:
        _BaslerCam = BaslerAcq.Camera(camera_id, int(packet_size))
        _BaslerCam.setInterPacketDelay(int(inter_packet_delay))
        _BaslerCam.setFrameTransmissionDelay(int(frame_transmission_delay))
        _BaslerInterface = BaslerAcq.Interface(_BaslerCam)
    return Core.CtControl(_BaslerInterface)
コード例 #7
0
def get_control(nbCards=1,
                maxFrames=1,
                baseIPaddress="",
                basePort=0,
                baseMACaddress="",
                nbChans=1,
                createScopeModule=0,
                scopeModName="",
                debug=1,
                cardIndex=0,
                noUDP=0,
                directoryName="",
                **keys):
    global _Xspress3Camera
    global _Xspress3Interface
    if _Xspress3Interface is None:
        _Xspress3Camera = Xspress3Acq.Camera(int(nbCards),
                                             int(maxFrames), baseIPaddress,
                                             int(basePort), baseMACaddress,
                                             int(nbChans),
                                             bool(int(createScopeModule)),
                                             scopeModName, int(debug),
                                             int(cardIndex), bool(int(noUDP)),
                                             directoryName)
        _Xspress3Interface = Xspress3Acq.Interface(_Xspress3Camera)
    return Core.CtControl(_Xspress3Interface)
コード例 #8
0
ファイル: Simulator.py プロジェクト: gjover/Lima_subtree
def get_control(**keys):
    global _SimuInterface
    if _SimuInterface is None:
        simu = Simulator.Camera()
        _SimuInterface = Simulator.Interface(simu)
        _SimuInterface._ref_interface = simu
    return Core.CtControl(_SimuInterface)
コード例 #9
0
    def __init__(self, camera='simulator'):
        if camera == 'maxipix':
            try:
                from Lima import Maxipix
            except ImportError:
                print(
                    "Cannot use the Maxipix camera plugin, Maxipix python module is not installed"
                )
                sys.exit()
            self.cam = Maxipix.Camera(
                1, '/users/blissadm/local/maxipix/tpxatl25', 'tpxatl25', True)
            self.cam_hw = Maxipix.Interface(self.cam)
        else:
            self.cam = Simulator.Camera()
            self.cam_hw = Simulator.Interface(self.cam)

        self.ct_control = Core.CtControl(self.cam_hw)
        self.ct_saving = self.ct_control.saving()
        self.ct_acq = self.ct_control.acquisition()

        self.format_list = [
            fmt.lower() for fmt in self.ct_saving.getFormatListAsString()
        ]

        self.overwrite2limaoverwrite = {
            'abort': self.ct_saving.Abort,
            'append': self.ct_saving.Append,
            'multiset': self.ct_saving.MultiSet,
            'overwrite': self.ct_saving.Overwrite
        }
コード例 #10
0
def get_control(**keys) :
    global _PilatusIterface
    if _PilatusIterface is None:
        _PilatusIterface = Interface.Interface()
    ct = Core.CtControl(_PilatusIterface)
    _PilatusIterface.setCtSavingLink(ct.saving())
    return ct
コード例 #11
0
def get_control(config_path="", **keys):
    global _LambdaCam
    global _LambdaInterface
    if _LambdaCam is None:
        _LambdaCam = LambdaAcq.Camera(config_path)
        _LambdaInterface = LambdaAcq.Interface(_LambdaCam)
    return Core.CtControl(_LambdaInterface)
コード例 #12
0
    def __init__(self):

        self.cam = Simulator.Camera()
        self.cam_hw = Simulator.Interface(self.cam)

        self.ct_control = Core.CtControl(self.cam_hw)
        self.ct_saving = self.ct_control.saving()
        self.ct_image = self.ct_control.image()
        self.ct_acq = self.ct_control.acquisition()
        self.ct_config = self.ct_control.config()
        self.conf_dict = {
            'conf1': {
                'exptime': 0.1,
                'nbframes': 3,
                'bin': Core.Bin(2, 2),
                'rot': Core.Rotation_180,
                'prefix': 'conf1_',
                'opolicy': Core.CtSaving.Overwrite
            },
            'conf2': {
                'exptime': 0.8,
                'nbframes': 2,
                'bin': Core.Bin(4, 4),
                'rot': Core.Rotation_90,
                'prefix': 'conf1_',
                'opolicy': Core.CtSaving.Abort
            }
        }
コード例 #13
0
def get_control(debug_control = "0", debug_module = "0", debug_type="0",
                debug_format = "0", **keys) :
    global _PcoCam
    global _PcoInterface


    debControl = int(debug_control,0)
    debModule = int(debug_module,0)
    debType = int(debug_type,0)
    debFormat = int(debug_format,0)

    


    if debControl:
        Core.DebParams.setModuleFlags(debModule)
        Core.DebParams.setTypeFlags(debType)
    else:
        Core.DebParams.setTypeFlags(0)
        Core.DebParams.setModuleFlags(0)

    #Core.DebParams.setFormatFlags(0x31)
    Core.DebParams.setFormatFlags(debFormat)

    if _PcoCam is None:
        _PcoCam = PcoAcq.Camera("")
        _PcoInterface = PcoAcq.Interface(_PcoCam)
    return Core.CtControl(_PcoInterface)
コード例 #14
0
def get_control(frame_transmission_delay = 0, inter_packet_delay = 0,
                packet_size = 8000,force_video_mode= 'false', **keys) :
    global _BaslerCam
    global _BaslerInterface

    if 'camera_id' in keys:
        camera_id = keys['camera_id']
    elif 'serial_number' in keys:
        camera_id = 'sn://' + keys['serial_number']
    elif 'cam_ip_address' in keys:
        camera_id = 'ip://' + keys['cam_ip_address']
    elif 'user_name' in keys:
        camera_id = 'uname://' + keys['user_name']
    else:
        # if no property is present it uses the server personal name
        # as Basler user name to identify the camera
        util = PyTango.Util.instance()
        camera_id = 'uname://' + util.get_ds_inst_name()

    print ("basler camera_id:", camera_id)
    
    # all properties are passed as string from LimaCCDs device get_control helper
    # so need to be converted to correct type
    if force_video_mode == 'true':
        force = True
    else: force = False

    if _BaslerCam is None:
        _BaslerCam = BaslerAcq.Camera(camera_id, int(packet_size))
        _BaslerCam.setInterPacketDelay(int(inter_packet_delay))
        _BaslerCam.setFrameTransmissionDelay(int(frame_transmission_delay))
        _BaslerInterface = BaslerAcq.Interface(_BaslerCam, force)
    return Core.CtControl(_BaslerInterface)
コード例 #15
0
	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)
コード例 #16
0
ファイル: Qt4_LimaVideo.py プロジェクト: folf/mxcube
    def init(self):
        """
        Descript. : 
        """
        self.force_update = False
        self.cam_type = self.getProperty("type").lower()
        self.cam_address = self.getProperty("address")

        try:       
            self.cam_mirror = eval(self.getProperty("mirror"))
        except:
            pass        

        if self.cam_type == 'prosilica':
            from Lima import Prosilica
            self.camera = Prosilica.Camera(self.cam_address)
            self.interface = Prosilica.Interface(self.camera)	

        self.control = Core.CtControl(self.interface)
        self.video = self.control.video()
        self.image_dimensions = list(self.camera.getMaxWidthHeight())
      
        self.setIsReady(True)

        if self.image_polling is None:
            self.video.startLive()
            self.change_owner()

            self.image_polling = gevent.spawn(self.do_image_polling,
                 self.getProperty("interval")/1000.0)

        print 111
        print self.getProperty("interval")
コード例 #17
0
def get_control(camera_library_path = "",**keys) :
    global _PhotonicScienceCam
    global _PhotonicScienceInterface
    if _PhotonicScienceCam is None:
	_PhotonicScienceCam = PhotonicScienceAcq.Camera(camera_library_path)
	_PhotonicScienceInterface = PhotonicScienceAcq.Interface(_PhotonicScienceCam)
    return Core.CtControl(_PhotonicScienceInterface)
コード例 #18
0
def get_control(address="0", **keys) :
    global _UeyeInterface
    if _UeyeInterface is None:
	ueye = UeyeModule.Camera(int(address))
        _UeyeInterface = UeyeModule.Interface(ueye)
	_UeyeInterface._ref_interface = ueye
    return Core.CtControl(_UeyeInterface)
コード例 #19
0
ファイル: Xpad.py プロジェクト: esrf-bliss/Lima-camera-xpad
def get_control(**keys):
    global _XpadCam
    global _XpadInterface
    if _XpadCam is None:
        _XpadCam = XpadAcq.Camera()
        _XpadInterface = XpadAcq.Interface(_XpadCam)
    return Core.CtControl(_XpadInterface)
コード例 #20
0
    def init(self):
        """
        Descript. : 
        """
        self.force_update = False
        self.scaling = pixmaptools.LUT.Scaling()
        self.cam_type = self.getProperty("type").lower()
        self.cam_address = self.getProperty("address")
        self.cam_mirror = eval(self.getProperty("mirror"))

        if self.cam_type == 'prosilica':
            from Lima import Prosilica
            self.camera = Prosilica.Camera(self.cam_address)
            self.interface = Prosilica.Interface(self.camera)
        if self.cam_type == 'ueye':
            from Lima import Ueye
            self.camera = Ueye.Camera(self.cam_address)
            self.interface = Ueye.Interface(self.camera)
        try:
            self.control = Core.CtControl(self.interface)
            self.video = self.control.video()
            self.image_dimensions = list(self.camera.getMaxWidthHeight())
        except KeyError:
            logging.getLogger().warning("Lima video not initialized.")

        self.setImageTypeFromXml('imageType')
        self.setIsReady(True)

        if self.image_polling is None:
            self.video.startLive()
            self.change_owner()

            self.image_polling = gevent.spawn(
                self.do_image_polling,
                self.getProperty("interval") / 1000.0)
コード例 #21
0
ファイル: Adsc.py プロジェクト: laurent-claustre/Lima-tango
def get_control(**keys) :
    global _AdscInterface
    if _AdscInterface is None:
        _AdscInterface = Interface()
    ct = Core.CtControl(_AdscInterface)
    _AdscInterface.setCtSavingLink(ct.saving())
    return ct
コード例 #22
0
    def __init__(self, espia_dev_nb, use_events=False, print_time=1,
                 sleep_time=0, all_frames=False):
        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)
        self.m_eserline      = Espia.SerialLine(self.m_edev)
        self.m_cam           = Frelon.Camera(self.m_eserline)
        self.m_buffer_mgr    = Core.BufferCtrlMgr(self.m_buffer_cb_mgr)
        self.m_hw_inter      = Frelon.Interface(self.m_acq,
                                                     self.m_buffer_mgr,
                                                     self.m_cam)
        self.m_acq_state     = Core.AcqState()
        self.m_ct            = Core.CtControl(self.m_hw_inter)
        self.m_ct_acq        = self.m_ct.acquisition()
        self.m_ct_saving     = self.m_ct.saving()
        self.m_ct_image      = self.m_ct.image()
        self.m_ct_buffer     = self.m_ct.buffer()
        self.m_ct_display    = self.m_ct.display()

        self.m_use_events    = use_events
        self.m_print_time    = print_time
        self.m_sleep_time    = sleep_time
        
        if self.m_use_events:
            cb = ImageStatusCallback(self.m_ct, self.m_acq_state, print_time,
                                     sleep_time, all_frames)
            self.m_img_status_cb = cb
            self.m_ct.registerImageStatusCallback(self.m_img_status_cb)

        self.m_ct_display.setNames('_ccd_ds_', 'frelon_live')
        self.m_ct_display.setActive(True)
コード例 #23
0
def get_control(camera_ip='marccd1', port_number=2222, image_path='/buffer/rayonix', **keys) :
    global _MarccdInterface
    if _MarccdInterface is None:
        marccd = Marccd.Camera(camera_ip, port_number, image_path)
        _MarccdInterface = Marccd.Interface(marccd)
    _MarccdInterface._ref_interface = marccd
    return Core.CtControl(_MarccdInterface)
コード例 #24
0
ファイル: Pilatus.py プロジェクト: soleil-ica/Lima-tango
def get_control(**keys):
    global _PilatusIterface
    global _PilatusCamera
    if _PilatusIterface is None:
        _PilatusCamera = PilatusAcq.Camera()
        _PilatusIterface = PilatusAcq.Interface(_PilatusCamera)
    return Core.CtControl(_PilatusIterface)
コード例 #25
0
    def __init__(self,
                 config_fname,
                 use_events=False,
                 print_time=1,
                 sleep_time=0,
                 all_frames=False):
        self.m_cam = SlsDetector.Camera(config_fname)
        self.m_hw_inter = SlsDetector.Interface(self.m_cam)
        self.m_acq_state = Core.AcqState()

        self.m_corr = None
        if self.m_cam.getType() == SlsDetector.EigerDet:
            self.m_eiger = SlsDetector.Eiger(self.m_cam)
            self.m_corr = self.m_eiger.createCorrectionTask()
        else:
            deb.Warning("Non-supported type: %s" % self.m_cam.getType())

        self.m_ct = Core.CtControl(self.m_hw_inter)
        self.m_ct_acq = self.m_ct.acquisition()
        self.m_ct_saving = self.m_ct.saving()
        self.m_ct_image = self.m_ct.image()
        self.m_ct_buffer = self.m_ct.buffer()

        self.m_use_events = use_events
        self.m_print_time = print_time
        self.m_sleep_time = sleep_time

        if self.m_corr:
            self.m_ct.setReconstructionTask(self.m_corr)

        if self.m_use_events:
            cb = ImageStatusCallback(self.m_ct, self.m_acq_state, print_time,
                                     sleep_time, all_frames)
            self.m_img_status_cb = cb
            self.m_ct.registerImageStatusCallback(self.m_img_status_cb)
コード例 #26
0
ファイル: Ueye.py プロジェクト: serge-cohen/Lima-tango
def get_control(**keys) :
    global _UeyeInterface
    if _UeyeInterface is None:
	ueye = Ueye.Camera()
        _UeyeInterface = Ueye.Interface(ueye)
	_UeyeInterface._ref_interface = ueye
    return Core.CtControl(_UeyeInterface)
コード例 #27
0
def get_control(peaks=[],
                peak_angles=[],
                mode=None,
                _Simulator=Simulator,
                _Camera=SimuMod.Camera,
                _Interface=SimuMod.Interface,
                **kwargs):
    """
    Called by LimaCCDs module to create Lima control object.

    In the simulator scope, it also create the Lima camera, Lima interface
    and register them into the Tango simulator class.

    Arguments:
        _Simulator: Tango class used to register Lima references
        _Camera: Lima class to create the camera instance
        _Interface: Lima class to create the interface instance
    """
    interface = _Simulator._SimuInterface
    camera = _Simulator._SimuCamera
    if interface is None:
        camera = _Camera()
        interface = _Interface(camera)
    control = Core.CtControl(interface)
    _Simulator._SimuCamera = camera
    _Simulator._SimuInterface = interface
    return control
コード例 #28
0
ファイル: Pco.py プロジェクト: teresanunez/Lima-tango-python
def get_control(debug_control="0",
                debug_module="0",
                debug_type="0",
                mem_factor="0",
                debug_format="0x31",
                params=[],
                **keys):

    global _PcoCam
    global _PcoInterface
    global _PcoControl

    debControl = int(debug_control, 0)
    debModule = int(debug_module, 0)
    debType = int(debug_type, 0)
    debFormat = int(debug_format, 0)
    memFactor = int(mem_factor, 0)

    if (type(params) == str):
        # <type 'str'>
        paramsIn = params
    else:
        # <class 'PyTango._PyTango.StdStringVector'>
        paramsIn = "".join("%s;" % (x, ) for x in params)

    print "============= Properties ============="
    print "         keys:", keys
    print "       params:", params
    print "     paramsIn:", paramsIn
    print "%s [%s] [0x%x]" % ("debug_control:", debug_control, debControl)
    print "%s [%s] [0x%x]" % (" debug_module:", debug_module, debModule)
    print "%s [%s] [0x%x]" % (" debug_format:", debug_format, debFormat)
    print "%s [%s] [0x%x]" % ("   debug_type:", debug_type, debType)
    print "%s [%s] [0x%x]" % ("   mem_factor:", mem_factor, memFactor)
    print "======================================"

    if debControl:
        Core.DebParams.setModuleFlags(debModule)
        Core.DebParams.setTypeFlags(debType)
    else:
        Core.DebParams.setTypeFlags(0)
        Core.DebParams.setModuleFlags(0)

    Core.DebParams.setFormatFlags(debFormat)

    if _PcoCam is None:
        _PcoCam = PcoAcq.Camera(paramsIn)
        _PcoInterface = PcoAcq.Interface(_PcoCam)
        _PcoControl = Core.CtControl(_PcoInterface)
        memFactor0 = _PcoControl.buffer().getMaxMemory()
        #_PcoControl.buffer().setMaxMemory(memFactor)
        #memFactor1 = _PcoControl.buffer().getMaxMemory()

    print "================================================="
    #print "%s org[%d] req[%d] now[%d]" % ("   mem_factor:", memFactor0, memFactor, memFactor1)
    print "%s org[%d]" % ("   mem_factor:", memFactor0)
    print "================================================="

    return _PcoControl
コード例 #29
0
def get_control(cam_num = "0",**keys) :
    global _RoperScientificCam
    global _RoperScientificInterface
    my_cam_num = int(cam_num)
    if _RoperScientificCam is None:
	_RoperScientificCam = RoperScientificAcq.Camera(my_cam_num)
	_RoperScientificInterface = RoperScientificAcq.Interface(_RoperScientificCam)
    return Core.CtControl(_RoperScientificInterface)
コード例 #30
0
def get_control(cam_ip_address = "0",**keys) :
    print ("cam_ip_address",cam_ip_address)
    global _ProsilicaCam
    global _ProsilicaInterface
    if _ProsilicaCam is None:
        _ProsilicaCam = ProsilicaAcq.Camera(cam_ip_address)
        _ProsilicaInterface = ProsilicaAcq.Interface(_ProsilicaCam)
    return Core.CtControl(_ProsilicaInterface)