Genie Python Commands
Running genie_python commands
When running python from an interactive console such as from
the GUI, or after running C:\Instrument\Apps\Python3\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.begin()
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.
For user or instrument scripts, the standard way of importing genie_python is:
from genie_python import genie as g
Note that in many cases, arguments will be optional. For instance,
g.begin can be used as g.begin(), despite additionally supporting optional
arguments including period, meas_id, meas_type, meas_subid,
sample_id, delayed, quiet, paused, and verbose.
Common genie_python commands
Some commonly used genie_python commands are listed below.
This is not a complete list; For full information, consult the genie_python reference manual. Click on a command name below to view the detailed documentation for that command in the reference manual.
Starting and stopping a run
Command |
Description |
Example |
|---|---|---|
Starts a new run |
|
|
Ends the current run (saving data) |
|
|
Aborts the current run (discarding data) |
|
|
Pauses the current run |
|
|
Resumes the current run after it has been paused |
|
Updating blocks and PVs
Command |
Description |
Example |
|---|---|---|
Gets the useful values associated with a block |
|
|
Sets the setpoint, and optionally runcontrol settings, for a block |
|
|
Gets the value of the specified PV |
|
|
Sets the value of the specified PV |
|
Run control
Command |
Description |
Example |
|---|---|---|
Gets the number of micro-amp hours of beam collected in the current run |
|
|
Gets the number of good frames of beam collected in the current run |
|
|
Gets the total counts for all the detectors, in millions of events. |
|
|
Gets the total counts for all the detectors. |
|
|
Waits until certain conditions are met. |
|
|
Waits until block reaches specific value. |
|
|
Waits for a specified amount of time. |
|
|
Waits for the number of total good frames collected in the current run to reach the specified total value. |
|
|
Waits for the number of total micro-amp hours collected in the current run to reach the specified total value. |
|
|
Waits for a particular instrument run state. |
|
|
Waits for all motion, or specified motion axes, to complete. |
|
Toggling options
Various options can be toggled using the genie_toggle_settings module.
For example, toggling the verbosity of all calls to a command using toggle.cset_verbose(True). This can be convenient, as there will be no need to explicitly set verbose=True for each cset call.
There are also advanced options such as toggle.exceptions_raised(True), which will allow exceptions to propagate instead of genie handling them, in case you want to handle exceptions yourself.
Warning
If you have exceptions_raised toggled to True and there is an exception within genie_python, it will stop your script from running unless you catch the exception yourself.
Running in simulation mode
Genie_python supports a basic simulation mode; see Simulating Scripts for how to use this.