Package: lima-toolbox
Lima tool boxA set of command line tools which hopefully ease the configuration and
development ofLimacameras.InstallationTL;DRFrom within your favorite python environment, type:pip install lima-toolbox[all]The toolbox is composed of a core library and plug-ins for diverse set of
cameras.The core can be installed with:pip install lima-toolboxTo install support for specific camera(s) use (example):pip install lima-toolbox[basler,eiger]At the end you can find a mini-catalog of the available cameras.PRs which implement new cameras (or improve, or fix existing ones) are most
welcome.CLIProbably the most useful tool is the CLI. You can use it to discover cameras
on the network, display information about a specfic camera and even perform
acquisitions.The lima CLI provides global commands likescanwhich are not camera specific.
In addtition, each camera provides its own set of sub-commands. They are accessible
by typinglima <camera> <sub-command>(ex:lima eiger --host=bl99eiger info).Typinglima --helpwill display help. Help is context sensitive, so
typinglima basler --helpwill display help for the basler subset of
commands.camera discoverycamera toolbox plug-ins which providescancapability allow you to
discover them by using thescancommand:$limascan--table-style=box_roundedBasler:╭──────────────┬──────────────────────────────┬───────────────────────┬───────────┬────────────┬───────────┬────────╮│    Class     │        Friendly name         │       Full name       │   Name    │ Serial Nb. │ User name │ Vendor │├──────────────┼──────────────────────────────┼───────────────────────┼───────────┼────────────┼───────────┼────────┤│ BaslerCamEmu │ Basler Emulation (0815-0000) │ Emulation (0815-0000) │ Emulation │ 0815-0000  │           │ Basler │├──────────────┼──────────────────────────────┼───────────────────────┼───────────┼────────────┼───────────┼────────┤│ BaslerCamEmu │ Basler Emulation (0815-0001) │ Emulation (0815-0001) │ Emulation │ 0815-0001  │           │ Basler │├──────────────┼──────────────────────────────┼───────────────────────┼───────────┼────────────┼───────────┼────────┤│ BaslerCamEmu │ Basler Emulation (0815-0002) │ Emulation (0815-0002) │ Emulation │ 0815-0002  │           │ Basler │╰──────────────┴──────────────────────────────┴───────────────────────┴───────────┴────────────┴───────────┴────────╯Eiger:╭───────────┬───────────┬─────────────┬──────┬───────╮│   Host    │ Alias(es) │ Address(es) │ Port │  API  │├───────────┼───────────┼─────────────┼──────┼───────┤│ bl04eiger │           │ 172.95.4.11 │ 8000 │ 1.6.0 │╰───────────┴───────────┴─────────────┴──────┴───────╯MythenSLS:╭────────────┬─────────────┬──────┬────────┬──────────┬──────────┬───────────┬────────────╮│    Host    │     IP      │ Port │  Type  │ #Modules │ Settings │ Threshold │ Dyn. Range │├────────────┼─────────────┼──────┼────────┼──────────┼──────────┼───────────┼────────────┤│ bl04mythen │ 172.95.4.10 │ 1952 │ MYTHEN │    6     │ STANDARD │   9071    │     32     │╰────────────┴─────────────┴──────┴────────┴──────────┴──────────┴───────────┴────────────╯Here you can see 3 simulatedBaslercameras, anEigercamera and aMythen SLScamera are available.Common camera commandsAs mentioned above, each camera provides its own set of specific sub-commands.
The sub-commandsinfoandacquireare common to all cameras (altough the specific
sub-command options could vary).The set of options which identify a camera are specific to each camera. For example,
to identify an eiger you must provide the--url=<hostname>option.Note that there is nothing enforcing a specific camera to implement any of the
common sub-commands. But it is considered good taste if a plugin does it (for the sake
of coherency).A camera plugin may optionally implement thescancommand. It should provide the same
result as the global scan with results restricted to the camera type.Camera informationBasic information about a camera can be retrieved with theinfosub-command.Examples:$limaeiger--url=bl04eigerinfoCurrImageType: 10DefImageType: 10DetectorImageSize: <3110x3269>DetectorModel: Dectris Eiger 9MDetectorType: E-18-0102InstrumentName: instrumentMaxImageSize: <3110x3269>PixelSize: (7.5e-05, 7.5e-05)UserDetectorName: E-18-0102$limamythensls--urlbl04mytheninfoCurrImageType   10DefImageType   10DetectorImageSize   <7680x1>DetectorModel   Mythen-IIDetectorType   MythenSLSInstrumentName   instrumentMaxImageSize   <7680x1>PixelSize   (1.0, 1.0)UserDetectorName   MythenSLSDetector type   MYTHENSerial number   1719109785Software version   1867412Status   IDLEDynamic range   32Energy threshold   9071Exposure time   1.0Number of frames   0Number of cycles   0Number of gates   0Master   NO_MASTERSynchronization   NONETiming   AUTO_TIMINGDelay after triger   0.0Readout   NORMAL_READOUTSettings   STANDARDExternal signals   ['GATE_OUT_ACTIVE_HIGH', 'TRIGGER_IN_RISING_EDGE', 'OFF','OFF']Camera acquisitionAquisitions can be made with theacquiresub-command.The common options include-nb-frames,--exposure-time,--latency-time. You
can see the complete list of options withlima <camera> acquire --help.Here is an example performing an acquisition on an eiger camera:How to write a plug-in for your cameraYou have two options:1. Add a plug-in extension to Lima-toolboxWrite a PR to this repo with the camera you intend to add. This should always be
possible independently of the type of camera you are writing the plug-in for.Let's say you want to create a plugin for theSimulatorcamera.First,create a new file insrc/limatb/cameracalledsimulator.py.
The lima toolbox CLI uses theclicklibrary
to help create a powerful command line interface.To create asimulatorsub-command you can simply use the lima toolboxcameradecorator (aclick.grouphelper) and write a function which should return aLima.Interfaceobject:# src/limatb/camera/simulator.pyfromlimatb.cliimportcamerafromLima.SimulatorimportCamera,Interface@camera(name='simulator')defsimulator():camera=Simulator.Camera()interface=Interface(camera)returninterfaceThe second and last thing to do is to register the new command in the lima
toolbox setup.py like this:extras_require={"simulator":[]#  add any extra python dependencies if necessary}setup(...,entry_points={"lima.cli.camera":[..."Simulator = limatb.camera.simulator:simulator [simulator]"]})That's it. Next time you install lima-toolbox there should be asimulatorcamera available with the defaultinfoandacquiresub-commands availableout of the box.Congratulations! You are now ready to make a PR to this repo with your new camera.Read further to find how to implement camera options, details about the camera
decorator and how to implement your own camera specific sub-commands.Examples of existing cameras can be found in thesrc/limatb/cameradirectory.Custom optionsIf you need to add any option to the command line to identify or configure your
camera you can do it usingclick.option. Here is an example extending the
previous one:importclick@camera(name='simulator')@click.option('--fill-type',click.Choice(['gauss','diffraction'],case_sensitive=False),default='gauss')defsimulator(fill_type):camera=Simulator.Camera()interface=Interface(camera)fill_type=getattr(Lima.Simulator.FrameBuilder,fill_type.capitalize())frame_getter=camera.getFrameGetter()frame_getter.setFillType(fill_type)returninterfaceThecameradecoratorThe@cameradecorator helper provides aclick.groupdecorator enhanced with
theinfoandacquiresub-commands by default and the facility that the
returned interface gets inserted into the click context objectctx.obj['interface']which can be accessed by any camera sub-commands you
decide to implement.Here is an example on how to implement a specific sub-command:@simulator.command("initialize")definitialize(self):# Initialization code here...scan commandThe lima toolbox CLI implements globalscancommand which has the purpose
of discovering all the cameras in the system.To make the specificscancommand of your system visible to the global scan
command you need to register a scan function with the signature:[async]defscan(timeout:float=None)->beautifultable.BeautifulTableand register the entry point in setup.py with:setup(...,entry_points={"lima.cli.camera.scan":[..."Simulator = limatb.camera.simulator:scan [simulator]"]})The scan function can have any name you which. If you provide a coroutine
(withasynckeyword) the lima tIf now you typelima scanon the command line, the cameras2. Write a Lima-toolbox entry point in an external projectAnother option, if your camera plugin is installable via asetup.py, is to apply the
same recipes above, where the only difference resides in implementing the code in your
own python detector package and modifying your setup.py instead.An example of a project which following this phylosophy is theSLS Mythen.Supported camerasProvided inside lima toolboxBaslerEigerKnown third party camerasSLS MythenFeel free to make a PR adding your own camera to this list. They are most welcome!