2. The GDA Command line

2.1. Background

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.

2.2. Basic Concepts

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:

  1. 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).

  2. 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:

    >>> pos(myMotor,10)
    

    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.

  3. 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.

  4. 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.

2.3. Sources for help

  • Beamline manuals which list how to use the specific panels and Jython objects used on that beamline.
  • Useful Jython websites:
  • The help command in the GDA Jython interpreter.

Table Of Contents

Previous topic

1. Introduction to the GDA

Next topic

3. Extended Syntax Commands

This Page