Back: 9.1 An enhanced cw-EPR experiment Forward: 9.3 cw-EPR monitor script   FastBack: 9. Example EDL Scripts Up: 9. Example EDL Scripts FastForward: 10. Command Line Options         Top: fsc2 Contents: Table of Contents Index: Index About: About This Document

9.2 GUI-fying the script

Looking again at the above script one may recognize that there are only a few variables that always need to be edited when doing a new experiment. These are the start and end field, the field step size and the number of runs. Having to edit the script all of the time can become rather tedious. But there's a simple method to add a graphical user interface to the program that lets one set these parameters and does not require to load the script into an editor, change it and then load the script into fsc2.

All what's needed is to add and change a few lines.:

 
 1 === START_FIELD float [ 1460 : 19900 ] [ 3360 ] "Start field:" "G"
 2 === END_FIELD float [ 1460 : 19900 ] [ 3450 ] "End field:" "G"
 3 === FIELD_STEP float [ 1.1e-3 : ] [ 0.5 ] "Field step:" "G"
 4 === NUMBER_OF_RUNS int [ 1 : ] [ 10 ] "Number of runs:"
 5 DEVICES:
 6   er035m_s;              // gaussmeter module
 7   aeg_x_band;            // magnet module
 8   sr530;                 // lock-in amplifier module
 9 
10 VARIABLES:
11 === if START_FIELD < END_FIELD
12   start_field    = START_FIELD G;
13   end_field      = END_FIELD G;
14 === else
15   start_field    = END_FIELD G;
16   end_field      = START_FIELD G;
17 === endif
19   field_step     = FIELD_STEP G;
20   Number_of_runs = NUMBER_OF_RUNS;
21 
22   field = start_field;
23   Number_of_points = 1 + int( ( start_field - end_field ) 
24                               / field_step );
25   data;
26   mean_data[ Number_of_points ];
27   I, J;
38   File_1, File_2;
39   tc;
30 
31 PREPARATIONS:
32   magnet_setup( start_field, field_step );
33   init_1d( 2, Number_of_points, start_field, field_step,
34            "Magnetic field [G]", "Signal strength [uV]"  );
35 
36 EXPERIMENT:
37 
38   File_1 = get_file( "File for storing all runs:" );
39   File_2 = get_file( "File for storing end results:" );
40 
41   tc = lockin_time_constant( );
42 
43   FOR I = 1 : Number_of_runs
44   {
45     FOR J = 1 : Number_of_points
46     {
47       wait( tc );
48       data = lockin_get_data( );
49       mean_data[ J ] += data;
50       display_1d( J, data / 1 uV, 1,
51                   J, mean_data[ J ] / ( I * 1 uV ), 2 );
52       fsave( File_1, "# #\n", field, data );
53       field = magnet_sweep_up( );
54     }
55 
56     fsave( File_1, "\n" );
57     field = magnet_reset_field( );
58     clear_curve( 1 );
59   }
60 
61   fsave( File_2, "% Start field     = # G\n", start_field );
62   fsave( File_2, "% End field       = # G\n", end_field );
63   fsave( File_2, "% Field step      = # G\n", field_step );
64   fsave( File_2, "% Number of runs  = #\n", Number_of_runs );
65   fsave( File_2, "% Time constant   = # ms\n", tc / 1 ms );
66   save( File_2, mean / Number_of_runs );

The new first four lines are for defining some special variables that will be used by the program for the graphical user interface. Each of the lines starts with three equal-signs in a row, followed by the variable name. This variable name must be different from all names already used in the EDL script and also may not be EDL keywords. Directly after the name follows the type of the variable, here we only use floating point and integer variables. The type is followed by the allowed range of the variable, enclosed in square braces and with the upper and lower limit separated by a colon, ":". As you can see, you may leave out one (or even both) limits. Here we use the field range that can be measured with the gaussmeter as the limits for the start and end field . For the field step variable there's only a lower limit, the smallest step size possible with the magnet power supply. Also for the number of runs only a lower limit is given, which is 1 for obvious reasons.

Following the ranges a default value may be given, also enclosed in square braces, we use here the values we previously had hard-coded into the script. Finally, two strings can be given to be shown on the left and right side of the entry field in the graphical user interface.

With these declarations a program for the graphical user interface can be created automatically which will show four entry fields for filling in the parameters using the fsc2_guify tool. There will also be another button that allows to create the above script with the user supplied parameters filled in an to directly send it to fsc2 for execution.

Of course, for this tool to be able to fill in the user supplied parameters into the right positions we also must change a few lines. E.g. in the place where previously the start field was hard-coded into the script we now have to fill in the variable for the start field, START_FIELD, and the same hold for the end field, the field step size and the number of runs.

There is already some security mechanism to keep the user from entering bogus parameters, the possibility to restrict the values of the variables to a certain range. This will keep the user from entering e.g. too small a field step size (or even a negative one) or less than one number of runs. But, unfortunately, it's still possible to enter an end field that is lower than the start field. To catch this kind of mistake, in the script above at line 11 it is checked that the value for the start field is lower than the end field before assigning START_FIELD and END_FIELD to the corresponding EDL variables. But if START_FIELD is higher than END_FIELD in line 14 ff. the assignment is reversed, so that the EDL variable start_field is guaranteed to be lower than end_field even when the user made a mistake while filling in the form.

To finally create the program with the graphical user interface all we now to do is save the above script, e.g. with the file name `cw_epr.EDL' and, on the command line, apply the fsc2_guify tool to get an immediately executable program called cw_epr:

 
fsc2_guify cw_epr.EDL cw_epr

From now on all an user has to do to start a cw-EPR experiment is to execute the cw_epr program, enter the parameters and push the button for starting the experiment.


Back: 9.1 An enhanced cw-EPR experiment Forward: 9.3 cw-EPR monitor script   FastBack: 9. Example EDL Scripts Up: 9. Example EDL Scripts FastForward: 10. Command Line Options

This document was generated by Jens Thoms Toerring on September 6, 2017 using texi2html 1.82.