How to call methods from the worker in a runmanager labscript file

67 views
Skip to first unread message

GABRIEL CHATELAIN

unread,
Mar 27, 2023, 4:43:40 PM3/27/23
to the labscript suite
Hi everyone, new labscript user here,

I need to create a new device class from scratch to control a laser through serial command, and so far I'm able to manually interact with it from BLACS: I wrote the worker's code and I'm sending commands to the laser via the "program_manual" method when a GUI value is changed.

My question is, how should I call methods from the worker in a labscript file that gets loaded in RUNMANAGER? Or, in other terms, what should I do in order to send instructions to my device not manually but in an experimental sequence?

Sorry if this question was already asked. If you can redirect me to some resources, I would appreciate.

Many thanks for your help,

Best,

Gabriel

dihm....@gmail.com

unread,
Apr 13, 2023, 10:53:21 AM4/13/23
to the labscript suite
Gabriel,

Welcome to the labscript community! Hopefully you haven't gotten too stuck on this. Unfortunately, writing custom device drivers that don't share significant functionality with something that already exists can be tricky, but it is certainly possible. The basic overview of the process is here.

Given that you already have a BLACS tab and worker functioning, then next step to is to define the labscript-device code. What you generally will need to do is subclass `Device` or `IntermediateDevice`, implement some methods that mirror what you want to do (ie turn_laser_on()). You will then need to overload the `generate_code` method to take information from the function calls you have written and puts it into hardware instructions that can be passed off to the worker for programming.

If you provide a little more detail about what functionality you are going for (most importantly, is it hardware timed [ie you connect to the pseudoclock] or just static) I can try to point you to a similar device that may provide some further inspiration.

-David

GABRIEL CHATELAIN

unread,
Apr 19, 2023, 7:33:21 PM4/19/23
to the labscript suite
Hi David,

Thank you very much for your reply.

After posting my question, I browsed this Google group and found a discussion that helped me. I managed to find a way to do what I wanted based on the Arduino code that was shared in this thread.

Based on the code posted there, I did exactly what you recommended (i.e. define the labscript-device code and overload the `generate_code` method).

I attached the code for my device if you'd like to have a look.

I also wondered if you could provide me with a clarification: such a device can't be called during a shot but only at the beginning or at the end of it, correct?

Many thanks again for your help.

Best,

Gabriel
IBeamSmart.zip
Reply all
Reply to author
Forward
0 new messages