The scripting engine of the GDA is an extended version of Jython (Python implemented in Java). It is now common across all current beamlines at Diamond. It is used extensively on measurement beamlines such as I02-I04 and I22 to provide the underlying command infrastructure to support the Graphics User Interfaces (GUIs). It has proven very popular particularly on the experimental beamlines such as I06, I15, I16 and I18 where it provides command-line control of experiments to perform scans, creates bespoke objects to operate within those scans and enables general automation of experimental procedures.
The great advantage of Jython is that its syntax and functionality very closely resembles that of the widely used and popular Python language with the additional advantage that most Java libraries are automatically available. The language and concepts have proven easy to learn by non-specialised programmers and there has been a very significant uptake from Diamond beamline staff to do customisation of beamline operations.
The scripting language in the GDA is Jython, which is Python implemented in Java. Python was developed to have a simple and quick to learn syntax while still remaining a fully-featured programming language. Some basic concepts used in the GDA Jython environment which are listed in more detail in the later sections of this guide:
In the GDA Client, Jython commands may be typed in the JythonTerminal panel which provides a terminal-like prompt, or scripts (macros) may be typed in, saved and run from the JythonEditor panel. It is useful to note that the same commands can be used in both panels, and that they both use the same namespace in Jython i.e. a variable defined in the Jython command-line will be accessible from within scripts and vice-versa. User scripts must be stored in /dls/iXX/scripts (where XX is the beamline number).
There is a core set of commands for operating the beamlines. These are known as the GDA ‘extended syntax’ as to use these commands you do not have to use ‘proper’ Jython syntax. To save typing when using these commands you may omit brackets and commas. For example, instead of typing:
you only have to type:
>>> pos myMotor 10
(Although the first version is still a valid command to type). This is convenient for the most common commands. It is possible to dynamically extend the syntax in this way with your own commands using the ‘alias’ command.
Data is normally collected in beamlines using scans. Most scans are stepped scans i.e. move motors, collect data from detectors. move motors, collect data from detectors...etc. So to do this, scans contain two types of objects: detectors and ‘Scannables’. Scannable objects conceptually act like motors in the sense that they have a position and you can move them, but they can represent anything from low-level hardware to a complex calculation. Scans may be nested with no limit to the number of dimensions.
The data collected by scans is plotted live to the GDA Client. Scan data (from old data files as well) is held inside data objects which can be plotted or be used in mathematical operations.