MyCamera

../../../_images/my-camera.jpg

Introduction

This is the official Lima camera template. It has been made to help you getting started with Lima and to test/play Lima without any hardware.

Prerequisite

There is no special prerequisite, the template can be compiled and tested on both Linux and Windows platforms.

Installation & Module configuration

Follow the generic instructions in Build and Install. If using CMake directly, add the following flag:

-DLIMACAMERA_SIMULATOR=true

For the Tango server installation, refers to PyTango Device Server.

Initialisation and Capabilities

Implementing a new plugin for new detector is driven by the LIMA framework but the developer has some freedoms to choose which standard and specific features will be made available. This section is supposed to give you the correct information regarding how the camera is exported within the LIMA framework.

Camera initialisation

The camera will be initialized within the Camera object. The Camera() constructor takes an optional mode parameter.

The class Camera can be parametrized with:

  • setFrameDim(): set a new frame dimension (max. is 1024x1024)

  • setPeaks(): set a list of GaussPeak positions (GaussPeak struct -> x, y, fwhm, max)

  • setPeakAngles(): set a list of GaussPeak angles

  • setFillType(): set the image fill type Gauss or Diffraction (default is Gauss)

  • setRotationAxis(): set the rotation axis policy Static, RotationX or RotationY (default is RotationY)

  • setRotationAngle(): set a peak rotation angle in deg (default is 0)

  • setRotationSpeed(): set a peak rotation speed ixin deg/frame (default is 0)

  • setGrowFactor(): set a growing factor (default is 1.0)

  • setDiffractionPos(): set the source diplacement position x and y (default is center)

  • setDiffractionSpeed(): set the source diplacement speed sx and sy (default is 0,0)

Standard capabilities

Described the standard capabilites offered by the camera.

Optional capabilities

Described the optional capabilites offered by the camera.

Configuration

Described the eventual configuration steps.

Getting started

For a quick test one can use the python binding, here is a short code example:

from Lima import Simulator
from lima import Core
import time

def test_mode_generator(cam, nb_frames_prefetched = 0):
    if nb_frames_prefetched:
        cam.setMode(Simulator.Camera.MODE_GENERATOR_PREFETCH)
        fb = cam.getFrameGetter()
        fb.setNbPrefetchedFrames(nb_frames_prefetched);
    else:
        cam.setMode(Simulator.Camera.MODE_GENERATOR)
        fb = cam.getFrameGetter()

    # Add a peak
    p1 = Simulator.GaussPeak(10, 10, 23, 1000) # peak at 10,10 fwhm=23 and max=1000
    fb.setPeaks([p1])


def test_mode_loader(cam, nb_frames_prefetched = 0):
    if nb_frames_prefetched:
        cam.setMode(Simulator.Camera.MODE_LOADER_PREFETCH)
        fb = cam.getFrameGetter()
        test = fb.getNbPrefetchedFrames();
    else:
        cam.setMode(Simulator.Camera.MODE_LOADER)
        fb = cam.getFrameGetter()

    # Set file pattern
    fb.setFilePattern(b'input\\test_*.edf')

cam = Simulator.Camera()

# Select one of the mode to test
#test_mode_generator(cam)
#test_mode_generator(cam, 10)
#test_mode_loader(cam)
test_mode_loader(cam, 100)

# Get the hardware interface
hwint = Simulator.Interface(cam)

# Get the control interface
control = Core.CtControl(hwint)

# Get the acquisition control
acq = control.acquisition()

# Set new file parameters and autosaving mode
saving=control.saving()

pars=saving.getParameters()
pars.directory='/tmp/'
pars.prefix='testsimul_'
pars.suffix='.edf'
pars.fileFormat=Core.CtSaving.EDF
pars.savingMode=Core.CtSaving.AutoFrame
saving.setParameters(pars)

# Now ask for 2 sec. exposure and 10 frames
acq.setAcqExpoTime(2)
acq.setAcqNbFrames(10)

control.prepareAcq()
control.startAcq()

# Wait for last image (#9) ready
lastimg = control.getStatus().ImageCounters.LastImageReady
while lastimg !=9:
  time.sleep(0.1)
  lastimg = control.getStatus().ImageCounters.LastImageReady

# read the first image
im0 = control.ReadImage(0)