def DevCcdSetRoI(self, argin): roi = Core.Roi(Core.Point(argin[0], argin[1]), Core.Point(argin[2], argin[3])) control = _control_ref() image = control.image() if roi == self.getMaxRoi() : roi = Core.Roi() image.setRoi(roi)
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)
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)
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 } }
def getMaxRoi(self): control = _control_ref() ct_image = control.image() max_roi_size = ct_image.getMaxImageSize() max_roi_size /= Core.Point(ct_image.getBin()) max_roi = Core.Roi(Core.Point(0, 0), max_roi_size) return max_roi
def __init__(self, cl, name): PyTango.Device_4Impl.__init__(self, cl, name) self.init_device() self.__FillMode = {'ON': True, 'OFF': False} self.__ThresholdGain = { 'DEFAULT': 0, 'LOW': 1, 'MID': 2, 'HIGH': 3, 'ULTRA HIGH': 4 } self.__CamStatus = { 'ERROR': 0, 'DISCONNECTED': 1, 'STANDBY': 2, 'SETTING_ENERGY': 3, 'SETTING_THRESHOLD': 4, 'SETTING_EXPOSURE': 5, 'SETTING_NB_IMAGE_IN_SEQUENCE': 6, 'SETTING_EXPOSURE_PERIOD': 7, 'SETTING_HARDWARE_TRIGGER_DELAY': 8, 'SETTING_EXPOSURE_PER_FRAME': 9, 'SETTING_ROI': 10, 'KILL_ACQUISITION': 11, 'RUNNING': 12, 'ANYCMD': 13 } self.__ReadoutRoi = { 'C60': Core.Roi(0, 0, 0, 0), #Full frame for 6M (0,0,2463,2527) 'C2': Core.Roi(988, 1060, 487, 407), #C2 for 6M 'C18': Core.Roi(494, 636, 1475, 1255) #C18 for 6M }
def getFrameInfo(self, acq_frame_nb): arr = self.__comm().getBuffer(acq_frame_nb) arr.resize(240, 566) data = arr[:, 5:565] FrameInfo = Core.HwFrameInfoType(acq_frame_nb,\ data,Core.Timestamp(),0,\ Core.HwFrameInfoType.Transfer) return FrameInfo
def __init__(self, edev_nr=0): self.edev = Espia.Dev(edev_nr) self.eser_line = Espia.SerialLine(self.edev) self.frelon = Frelon.Camera(self.eser_line) self.fser_line = self.frelon.getSerialLine() self.finish_cond = Core.Cond() self.finish_req = False self.log_cond = Core.Cond()
def write_Roi(self, attr): data = attr.get_write_value() state = self.dev_state() self.Stop() roi = Core.Roi() roi.setTopLeft(Core.Point(data[0], data[1])) roi.setSize(Core.Size(data[2], data[3])) self.image.setRoi(roi) if state == PyTango.DevState.ON: self.Start()
def apply_config(self, c): try: active = c.get("active", False) self.Stop() if active: self._runLevel = c.get("runLevel", 0) self.Start() namedRois = [] names = [] for name, d in c.iteritems(): try: if isinstance(d, dict): rType = d.get("type", None) if rType == RoiCounterTask.SQUARE: x = d["x"] y = d["y"] width = d["width"] height = d["height"] namedRois.append( (name, Core.Roi(x, y, width, height))) elif rType == RoiCounterTask.ARC: x = d["x"] y = d["y"] r1 = d["r1"] r2 = d["r2"] a1 = d["a1"] a2 = d["a2"] namedRois.append( (name, Core.ArcRoi(x, y, r1, r2, a1, a2))) elif rType == RoiCounterTask.MASK: x = d["x"] y = d["y"] data = d["data"] self.__roiCounterMgr.setLutMask( name, Core.Point(x, y), data) elif rType == RoiCounterTask.LUT: x = d["x"] y = d["y"] data = d["data"] self.__roiCounterMgr.setLut( name, Core.Point(x, y), data) names.append(name) except KeyError as err: PyTango.Except.throw_exception( 'Config error', 'Missing key %s in roi named %s' % (err, name), 'RoiCounterDeviceServer Class') self.__roiCounterMgr.updateRois(namedRois) self.add(names) except: import traceback traceback.print_exc()
def test_slsdetector_control(config_fname, enable_debug, use_events, print_time, sleep_time, all_frames): if enable_debug: Core.DebParams.enableModuleFlags(Core.DebParams.AllFlags) Core.DebParams.enableTypeFlags(Core.DebParams.AllFlags) else: Core.DebParams.disableModuleFlags(Core.DebParams.AllFlags) deb.Always("Creating SlsDetectorAcq") acq = SlsDetectorAcq(config_fname, use_events, print_time, sleep_time, all_frames) deb.Always("Done!") acq.initSaving("data", "img", ".edf", 0, Core.CtSaving.EDF, Core.CtSaving.AutoFrame, 1) deb.Always("First run with default pars") acq.run() deb.Always("Done!") exp_time = 100e-3 acq.setExpTime(exp_time) nb_acq_frames = 50 acq.setNbAcqFrames(nb_acq_frames) deb.Always("Run exp_time=%s, nb_acq_frames=%s" % (exp_time, nb_acq_frames)) acq.run() deb.Always("Done!") bin = Core.Bin(2, 2) acq.setBin(bin) nb_acq_frames = 5 acq.setNbAcqFrames(nb_acq_frames) deb.Always("Run bin=<%sx%s>, nb_acq_frames=%s" % (bin.getX(), bin.getY(), nb_acq_frames)) acq.run() deb.Always("Done!") roi = Core.Roi(Core.Point(256, 512), Core.Size(256, 512)) if acq.checkValidRoi(roi): acq.setRoi(roi) roi_tl, roi_size = roi.getTopLeft(), roi.getSize() deb.Always( "Run roi=<%s,%s>-<%sx%s>" % (roi_tl.x, roi_tl.y, roi_size.getWidth(), roi_size.getHeight())) acq.run() deb.Always("Done!")
def test_big_detector_size(): """Change the size of the simulator Make sure the hardware detector size matches the request """ cam = Simulator.Camera() hw = Simulator.Interface(cam) ct = Core.CtControl(hw) cam.setFrameDim(Core.FrameDim(2048, 2000, Core.Bpp32)) dim = ct.image().getImageDim() assert dim.getSize() == Core.Size(2048, 2000) detinfo = hw.getHwCtrlObj(Core.HwCap.DetInfo) assert detinfo.getMaxImageSize() == Core.Size(2048, 2000)
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)
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): """ 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)
def DevReadValues(self): control = _control_ref() img_data = control.ReadImage(-1) self.__bpm_task.process(img_data) release = getattr(img_data, 'releaseBuffer', None) if release: release() bpm_pars = self.__bpm_mgr.getResult(1) if bpm_pars.errorCode != self.__bpm_mgr.OK: raise Core.Exception('Error calculating beam params: %d' % bpm_pars.errorCode) nr_spots = 1 auto_cal = -1 exp_time = self.DevCcdGetExposure() if exp_time > 0: norm_intensity = bpm_pars.beam_intensity / exp_time else: norm_intensity = 0 return [ nr_spots, bpm_pars.beam_intensity, bpm_pars.beam_center_x, bpm_pars.beam_center_y, bpm_pars.beam_fwhm_x, bpm_pars.beam_fwhm_y, bpm_pars.AOI_max_x - bpm_pars.AOI_min_x, bpm_pars.AOI_max_y - bpm_pars.AOI_min_y, bpm_pars.max_pixel_value, bpm_pars.max_pixel_x, bpm_pars.max_pixel_y, bpm_pars.AOI_min_x, bpm_pars.AOI_min_y, bpm_pars.AOI_max_x, bpm_pars.AOI_max_y, bpm_pars.beam_center_x - bpm_pars.beam_fwhm_x / 2, bpm_pars.beam_center_y - bpm_pars.beam_fwhm_y / 2, bpm_pars.beam_center_x + bpm_pars.beam_fwhm_x / 2, bpm_pars.beam_center_y + bpm_pars.beam_fwhm_y / 2, norm_intensity, auto_cal ]
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)
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)
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")
def setTrigMode(self,trig_mode): com = self.__comm() if com.TRG_DICT.has_key(trig_mode): self.__trigMode = trig_mode com.setTrigMode(com.TRG_DICT[self.__trigMode]) else: raise Core.Exceptions(Core.Hardware,Core.NotSupported)
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)
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)
def get_control(**keys): global _PilatusIterface global _PilatusCamera if _PilatusIterface is None: _PilatusCamera = PilatusAcq.Camera() _PilatusIterface = PilatusAcq.Interface(_PilatusCamera) return Core.CtControl(_PilatusIterface)
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
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)
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)
def get_control(**keys) : global _AdscInterface if _AdscInterface is None: _AdscInterface = Interface() ct = Core.CtControl(_AdscInterface) _AdscInterface.setCtSavingLink(ct.saving()) return ct
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)
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)
def get_control(**keys): global _XpadCam global _XpadInterface if _XpadCam is None: _XpadCam = XpadAcq.Camera() _XpadInterface = XpadAcq.Interface(_XpadCam) return Core.CtControl(_XpadInterface)