1 | |
---|
2 | ########### SVN repository information ################### |
---|
3 | # $ Date: 2011-09-16 13:04:57 -0500 (Fri, 16 Sep 2011) $ |
---|
4 | # $ Author: jemian $ |
---|
5 | # $ Revision: 463 $ |
---|
6 | # $ HeadURL: https://subversion.xor.aps.anl.gov/spec/beamline_config/trunk/usaxs/usaxs/usaxs_load.mac $ |
---|
7 | # $ Id: usaxs_load.mac 463 2011-09-16 18:04:57Z jemian $ |
---|
8 | ########### SVN repository information ################### |
---|
9 | |
---|
10 | """ |
---|
11 | Example SPEC Macro Source code file for demonstration purposes only. |
---|
12 | |
---|
13 | :: |
---|
14 | |
---|
15 | $Id: example.mac 1007 2012-07-12 22:56:32Z jemian $ |
---|
16 | |
---|
17 | This file is used to demonstrate how to document SPEC [#]_ macro files |
---|
18 | using Sphinx [#]_ and restructured text (reST) [#]_ markup. |
---|
19 | |
---|
20 | Provides: |
---|
21 | |
---|
22 | * :spec:def:`inc1scan` |
---|
23 | * :spec:def:`CheckSaveToFile` |
---|
24 | |
---|
25 | .. rubric:: Footnote |
---|
26 | .. [#] SPEC: http://www.certif.com |
---|
27 | .. [#] Sphinx: http://sphinx.pocoo.org/ |
---|
28 | .. [#] reST: http://docutils.sf.net/rst.html |
---|
29 | |
---|
30 | ------------- |
---|
31 | """ |
---|
32 | |
---|
33 | global example_global #: this is an example of a global variable |
---|
34 | local example_local #: a local variable is unusual at the global level |
---|
35 | |
---|
36 | #: Conversion constant between wavelength (A) and photon energy (keV) |
---|
37 | constant A_keV 12.3984 |
---|
38 | |
---|
39 | def inc1scan '{ |
---|
40 | """specify a single motor scan with interval rather than # of intervals""" |
---|
41 | if ($# != 5) { |
---|
42 | print "Usage: inc1scan motor start finish increment time" |
---|
43 | exit |
---|
44 | } |
---|
45 | ascan $1 $2 $3 fabs(($3-$2)/$4)+0.5 $5 |
---|
46 | }' |
---|
47 | |
---|
48 | def CheckSaveToFile '{ |
---|
49 | """ |
---|
50 | This macro will run when SPEC starts and checks |
---|
51 | if the output is directed into a file or might be ignored. |
---|
52 | It runs :spec:def:`newsample` if the output might be ignored. |
---|
53 | """ |
---|
54 | if (unset("DATAFILE") || (DATAFILE == "/dev/null") || (DATAFILE == "null")) { |
---|
55 | print "!!!You have not started to save your data to a file!!!" |
---|
56 | print "(newsample)" |
---|
57 | # prompt the user for a data file |
---|
58 | newsample |
---|
59 | } |
---|
60 | }' |
---|
61 | #: register CheckSaveToFile to run on startup |
---|
62 | cdef("begin_mac", "CheckSaveToFile\n", "CheckSaveToFile", 0x20) |
---|