예제 #1
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
            }
        }
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_frelon_acc(enable_debug, espia_dev_nb, vert_bin, exp_time,
                    acc_max_exp_time, nb_frames, acc_time_mode):

    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 FrelonAcq")
    acq = Frelon.FrelonAcq(espia_dev_nb)
    deb.Trace("Done!")

    cam = acq.getFrelonCamera()

    ct = acq.getGlobalControl()
    ct_image = ct.image()
    ct_acq = ct.acquisition()

    acq_state = Core.AcqState()
    status_cb = ImageStatusCallback(ct, acq_state)
    ct.registerImageStatusCallback(status_cb)

    deb.Always("Setting Full Frame Mode - Speed - Chan 3&4")
    cam.setSPB2Config(Frelon.SPB2Speed)
    cam.setFrameTransferMode(Frelon.FFM)
    cam.setInputChan(Frelon.Chan34)
    deb.Trace("Done!")

    frame_dim = acq.getFrameDim(max_dim=True)
    bin = Core.Bin(1, vert_bin)
    deb.Always("Setting binning %s" % bin)
    ct_image.setBin(bin)
    deb.Trace("Done!")

    image_size = frame_dim.getSize()
    nb_cols = image_size.getWidth()
    nb_lines = image_size.getHeight() / vert_bin
    roi = Core.Roi(Core.Point(0, nb_lines - 2), Core.Size(nb_cols, 1))
    deb.Always("Setting RoI %s" % roi)
    ct_image.setRoi(roi)
    deb.Trace("Done!")

    deb.Always("Setting Kinetic RoI mode")
    cam.setRoiMode(Frelon.Kinetic)
    deb.Trace("Done!")

    deb.Always("Setting Acc. mode")
    ct_acq.setAcqMode(Core.Accumulation)
    deb.Trace("Done!")

    deb.Always("Setting %s Acc. Time mode" % acc_time_mode)
    acc_mode = Core.CtAcquisition.Live \
               if acc_time_mode == 'Live' \
               else Core.CtAcquisition.Real
    ct_acq.setAccTimeMode(acc_mode)
    deb.Trace("Done!")

    deb.Always("Setting Acc. max. exp. time %s" % acc_max_exp_time)
    ct_acq.setAccMaxExpoTime(acc_max_exp_time)
    deb.Trace("Done!")

    deb.Always("Setting exp. time %s" % exp_time)
    ct_acq.setAcqExpoTime(exp_time)
    deb.Trace("Done!")

    deb.Always("Setting nb. frames %s" % nb_frames)
    ct_acq.setAcqNbFrames(nb_frames)
    deb.Trace("Done!")

    acc_nb_frames = ct_acq.getAccNbFrames()
    acc_dead_time = ct_acq.getAccDeadTime()
    acc_live_time = ct_acq.getAccLiveTime()
    deb.Always("AccNbFrames: %d, AccDeadTime: %.6f, AccLiveTime: %.6f" %
               (acc_nb_frames, acc_dead_time, acc_live_time))

    deb.Always("Preparing acq.")
    ct.prepareAcq()
    deb.Trace("Done!")

    deb.Always("Starting acq.")
    status_cb.start()
    ct.startAcq()
    deb.Trace("Done!")

    state_mask = Core.AcqState.Acquiring
    acq_state.waitNot(state_mask)
    deb.Always("Finished!")

    dead_time = cam.getDeadTime()
    read_time = cam.getReadoutTime()
    xfer_time = cam.getTransferTime()
    deb.Always("Dead Time: %.6f, Readout Time: %.6f, Transfer Time: %.6f" %
               (dead_time, read_time, xfer_time))
예제 #4
0
 def DevCcdSetBin(self, argin):
     bin = Core.Bin(argin[1], argin[0])
     control = _control_ref()
     image = control.image()
     image.setBin(bin)
def main(argv):

    deb.Always("Creating Espia.Dev")
    edev = Espia.Dev(0)

    deb.Always("Creating Espia.Acq")
    acq = Espia.Acq(edev)

    acqstat = acq.getStatus()
    deb.Always("Whether the Acquisition is running : %s" % acqstat.running)

    deb.Always("Creating Espia.BufferMgr")
    buffer_cb_mgr = Espia.BufferMgr(acq)

    deb.Always("Creating BufferCtrlMgr")
    buffer_mgr = Core.BufferCtrlMgr(buffer_cb_mgr)

    deb.Always("Creating Espia.SerialLine")
    eser_line = Espia.SerialLine(edev)

    deb.Always("Creating Frelon.Camera")
    cam = Frelon.Camera(eser_line)

    deb.Always("Creating the Hw Interface ... ")
    hw_inter = Frelon.Interface(acq, buffer_mgr, cam)

    deb.Always("Creating HW BufferSave")
    buffer_save = Core.HwBufferSave(Core.HwBufferSave.EDF, "img", 0, ".edf",
                                    True, 1)

    deb.Always("Getting HW detector info")
    hw_det_info = hw_inter.getHwCtrlObj(Core.HwCap.DetInfo)

    deb.Always("Getting HW buffer")
    hw_buffer = hw_inter.getHwCtrlObj(Core.HwCap.Buffer)

    deb.Always("Getting HW Sync")
    hw_sync = hw_inter.getHwCtrlObj(Core.HwCap.Sync)

    deb.Always("Getting HW Bin")
    hw_bin = hw_inter.getHwCtrlObj(Core.HwCap.Bin)

    deb.Always("Getting HW RoI")
    hw_roi = hw_inter.getHwCtrlObj(Core.HwCap.Roi)

    mis_cb = MaxImageSizeCallback()
    hw_det_info.registerMaxImageSizeCallback(mis_cb)

    deb.Always("Setting FTM")
    cam.setFrameTransferMode(Frelon.FTM)
    deb.Always("Setting FFM")
    cam.setFrameTransferMode(Frelon.FFM)

    soft_roi = Core.Roi()
    acq_state = Core.AcqState()
    deb.Always("Creating a TestFrameCallback")
    cb = TestFrameCallback(hw_inter, soft_roi, buffer_save, acq_state)

    do_reset = False
    if do_reset:
        deb.Always("Reseting hardware ...")
        hw_inter.reset(HwInterface.HardReset)
        deb.Always("  Done!")

    size = hw_det_info.getMaxImageSize()
    image_type = hw_det_info.getCurrImageType()
    frame_dim = Core.FrameDim(size, image_type)

    bin = Core.Bin(Core.Point(1))
    hw_bin.setBin(bin)

    #Roi set_roi, real_roi;
    #set_hw_roi(hw_roi, set_roi, real_roi, soft_roi);

    effect_frame_dim = Core.FrameDim(frame_dim)  # was (frame_dim / bin)
    hw_buffer.setFrameDim(effect_frame_dim)
    hw_buffer.setNbBuffers(10)
    hw_buffer.registerFrameCallback(cb)

    hw_sync.setExpTime(2)
    hw_sync.setNbFrames(3)

    deb.Always("Starting Acquisition")
    acq_state.set(Core.AcqState.Acquiring)
    hw_inter.startAcq()

    deb.Always("Waiting acq finished...")
    acq_state.waitNot(Core.AcqState.Acquiring)
    deb.Always("Acq finished!!")

    deb.Always("Stopping Acquisition")
    hw_inter.stopAcq()

    deb.Always("This is the End...")
def test_frelon_control(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 FrelonAcq")
    espia_dev_nb = 0
    acq = FrelonAcq(espia_dev_nb, 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 = 1e-6
    acq.setExpTime(exp_time)

    nb_acq_frames = 500
    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, 256), Core.Size(512, 512));
    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!")
    
    roi = Core.Roi(Core.Point(267, 267), Core.Size(501, 501));
    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!")
예제 #7
0
acq.setAcqNbFrames(1)
acq.setAcqExpoTime(0.001)

img = control.image()

print("Attach debugger now")
input()

roi = Core.Roi(1, 1, 598, 298)  # Almost full frame
#roi = Core.Roi(0, 0, 600, 300) # Full frame
img.setRoi(roi)

rots = [
    Core.Rotation_0, Core.Rotation_90, Core.Rotation_180, Core.Rotation_270
]
binnings = [Core.Bin(1, 1), Core.Bin(1, 2), Core.Bin(2, 1), Core.Bin(2, 2)]
flips = [
    Core.Flip(False, False),
    Core.Flip(False, True),
    Core.Flip(True, False),
    Core.Flip(True, True)
]


# Python function to print permutations of a given list (from SO)
def permutation(lst):
    if len(lst) == 0:
        return []

    if len(lst) == 1:
        return [lst]
예제 #8
0
###
img.reset()

# Rotate first, define ROI, unrotate
img.setRotation(Core.Rotation_90)
assert img.getMaxImageSize() == Core.Size(600, 800)

roi = Core.Roi(250, 300, 300, 450)
img.setRoi(roi)
img.setRotation(Core.Rotation_0)  # InvalidValue: Invalid corner coords

###
img.reset()

# Define ROI first, rotate
roi = Core.Roi(300, 50, 450, 300)
img.setRoi(roi)
img.setRotation(
    Core.Rotation_90
)  # InvalidValue: Roi out of limits m_max_roi=<0,0>-<800x600>, roi=<250,300>-<300x450>

###
img.reset()

# Define ROI first, bin
roi = Core.Roi(300, 50, 450, 300)
img.setRoi(roi)
img.setBin(Core.Bin(2, 2))
assert img.getMaxImageSize() == Core.Size(400, 300)  # Fail