Skip to content

genie_python Commands

JamesKingWork edited this page Jan 6, 2020 · 14 revisions

Scripting > genie_python Commands

Running genie_python commands

When running genie_python from an interactive console such as from the GUI or after running C:\Instrument\Apps\Python\genie_python.bat, the genie module will be aliased to g. Genie commands can then be accessed by using the prefix g.[COMMAND_NAME]. For example:

g.start()
g.cset("BLOCK_1",1)
g.abort()

This is particularly useful from the GUI which will auto-complete commands and provide tool tips describing each function and its arguments.

Note that in many cases, arguments will be optional. For instance, begin can be used as g.begin() despite supporting all of the arguments period, meas_id, meas_type, meas_subid, sample_id, delayed, quiet, paused, and verbose.

Running in simulation mode

Genie_python can be used in simulation mode. Simulation mode will allow you to run scripts but without changing items on your instrument. It does this by putting dummy commands in for some genie command, it also creates dummy blocks on the fly so that block values can be read and written to. N.B. This means that simulation can not be this will not validate your block names within the script. To run in simulation mode use the genie_python_simulate.bat found in C:\Instrument\Apps\Python.

Common genie_python commands

Many genie_python commands share the same name with their Open GENIE equivalent so it will often be very straightforward to find the function you're looking for. Still, here is a list of the most commonly used genie_python commands. This is not a complete list. For full information, consult the genie_python reference manual.

Starting and stopping a run

Command Description Example
begin Starts a new run g.begin()
end Ends the current run g.end()
abort Aborts the current run g.abort()
pause Pauses the current run g.pause()
resume Resumes the current run after it has been paused g.resume()

Pre and post command hooks

It is possible to hook in functions that run pre and post the execution of the starting and stopping run commands above (begin, end, abort, pause, resume). This is done passing functions to genie python setter commands. For each of the start and stop run commands there are two setters of the form set_<command>_precmd(func) and set_<command>_postcmd(func). For example set_begin_precmd(func) and set_begin_postcmd(func). Where func is a predefined and loaded function.

Updating blocks and PVs

Command Description Example
cget Gets the useful values associated with a block g.cget("NEW_BLOCK")
cset Sets the setpoint and runcontrol settings for blocks g.cset("NEW_BLOCK",1)
get_pv Gets the value for the specified PV g.get_pv("IN:INSTNAME:IOC_01:STAT")
set_pv Sets the value for the specified PV g.set_pv("IN:INSTNAME:IOC_01:STAT",1)

Run control

Clone this wiki locally