source: specdomain/trunk/src/specdomain/macros/test-battery.mac @ 983

Last change on this file since 983 was 983, checked in by jemian, 10 years ago

refs #8, now parses most macro definitions (just the initial declaration, not the muiltiline content, for now)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision URL Header
File size: 7.7 KB
Line 
1"""
2###############################################################################
3       User macros to configure spec with the Image Server program
4###############################################################################
5
6* $Id: test-battery.mac 983 2012-06-28 21:34:54Z jemian $
7* sample file to test sphinx documentation of SPEC macro files
8
9This file contains SPEC macro fragments to test various
10parts of the SPHINX documentation builder.
11"""
12
13def ccdhelp '
14    printf("\nUser macros for the BCDA ccd package\n")
15    printf("\t%c%sccdsetup\n",27,"[1m")
16    # ...
17'
18
19local A2Rp0
20      A2Rp0 = 15.759                    ;#  A2Rp center
21
22
23#==============================================================================
24"""
25common/shutter
26==============
27 
28NAME
29   shutter.mac
30 
31SUMMARY
32   Commands to control a fast photon shutter.
33 
34DESCRIPTION
35   The macro causes the fast photon shutter to be opened immediately prior to
36   any count command, and closed again upon its completion. A configurable
37   delay time assures that the shutter is fully open before issuing the
38   count command.
39 
40   The photon shutter is controlled via an EPICS binary output channel, and
41   the shutter status is optionally monitored via a binary input channel (in
42   which case the delay time is not used, but the monitor signal is used to
43   check for completion of the opening process).
44 
45AUTHOR
46   Christian M. Schlepuetz (CS, cschlep)
47 
48CREATION DATE
49   2004/11/06
50 
51COPYRIGHT
52   Copyright 2006-2011 by the above authors (see AUTHOR/AUTHORS)
53 
54   This program is free software: you can redistribute it and/or modify
55   it under the terms of the GNU General Public License as published by
56   the Free Software Foundation, either version 3 of the License, or
57   (at your option) any later version.
58 
59   This program is distributed in the hope that it will be useful,
60   but WITHOUT ANY WARRANTY; without even the implied warranty of
61   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
62   GNU General Public License for more details.
63 
64   You should have received a copy of the GNU General Public License
65   along with this program.  If not, see http://www.gnu.org/licenses/.
66 
67VERSION::
68 
69   $. Date: 2010-11-04 19:06:06 -0400 (Thu, 04 Nov 2010) $
70   $. Author: cschlep $
71   $. URL: file:///data/svn/software/spec/trunk/common/shutter.mac $
72   $. Revision: 17 $
73 
74DEPENDENCIES
75   Chained macro definitions affected by this macro:
76   
77   - user_precount
78   - user_getcounts
79   - cleanup_always
80 
81HISTORY
82   2004/11/06 (CS):
83   
84           - modified the first original version to comply with naming and format
85             conventions
86           - implemented help-file support and wrote help texts.
87             2010/03/30 (CS):
88           - added the following global variables to make macro more easily portable::
89         
90                    SHUTTER_CONTROL_PV      # EPICS PV name for the shutter control (bo)
91                    SHUTTER_CONTROL_OPEN    # EPICS control value for open shutter
92                    SHUTTER_CONTROL_CLOSED  # EPICS control value for closed shutter
93                    SHUTTER_STATUS_PV       # EPICE PV name for the shutter status (bi)
94                    SHUTTER_STATUS_OPEN     # EPICS status value for open shutter
95                    SHUTTER_STATUS_CLOSED   # EPICS status value for closed shutter
96                    SHUTTER_IS_ON           # flag for automatic shutter control
97                    SHUTTER_SLEEP_TIME      # SPEC sleep time after opening shutter
98 
99   2010/07/23 (CS):
100           - added SVN keywords (replacing CVS keywords)
101 
102   2011/12/19 (CS):
103           - reformatted code documentation to work with ROBODoc
104           - added shutter_setup with following internal macros:
105         
106             * _shutter_print_setup
107             * _shutter_set_option
108             * _clear_screen
109         
110           - replaced SHUTTER_STATUS* with SHUTTER_MONITOR*
111           - replaced global variables _OPEN with _OPEN_VAL and
112             _CLOSED with _CLOSED_VAL
113"""
114#==============================================================================
115
116#==============================================================================
117# Define some global variables
118# ----------------------------
119
120    global SHUTTER_MAC
121           SHUTTER_MAC = DOFILE
122
123    # EPICS PV of the binary output which controls the shutter
124   
125    global SHUTTER_CONTROL_PV
126           SHUTTER_CONTROL_PV = "X04SA-ES3-SC:FPS"
127
128    global SHUTTER_CONTROL_OPEN_VAL
129           SHUTTER_CONTROL_OPEN_VAL = "On"
130
131    global SHUTTER_CONTROL_CLOSED_VAL
132           SHUTTER_CONTROL_CLOSED_VAL = "Off"
133
134    # EPICS PV of the binary input which monitors the state of the shutter
135    # if SHUTTER_MONITOR_PV = "", no monitoring is performed
136   
137    global SHUTTER_MONITOR_PV
138           SHUTTER_MONITOR_PV = ""
139
140    global SHUTTER_MONITOR_OPEN_VAL
141           SHUTTER_MONITOR_OPEN_VAL = "open"
142
143    global SHUTTER_MONITOR_CLOSED_VAL
144           SHUTTER_MONITOR_CLOSED_VAL = "closed"
145
146    global SHUTTER_IS_ON
147           SHUTTER_IS_ON = 0
148
149    global SHUTTER_SLEEP_TIME
150           SHUTTER_SLEEP_TIME = 0.1
151
152
153#==============================================================================
154# This macro file contains the following commands:
155#==============================================================================
156
157#------------------------------------------------------------------------------
158
159def shutter_help 'sh_help'
160
161def sh_help '{
162        """
163        .. spec:def:: sh_help, shutter_help
164       
165        sh_help, shutter_help
166        =============================
167       
168        Displays the shutter help text.
169       
170        usage::
171       
172           > sh_help
173       
174        .. note::
175           The help text is generated by simply displaying the text file
176           ``shutter_mac.txt``, which should reside in the same directory as ``shutter.mac``.
177           If the file does not exist, a generic help text is shown.
178        """
179
180  unix (sprintf ("dirname %s", SHUTTER_MAC), _1)
181  ll = length (_1)
182  if (substr (_1, ll, 1) == "\n") _1 = substr (_1, 1, (ll - 1))
183  file = sprintf ("%s/shutter_mac.txt", _1)
184  if (file_info (file, "-e")) {
185    unix (sprintf ("cat %s", file))
186  } else {
187    printf("\n  Macros available in file shutter.mac:\n")
188    printf(  "                           ===========\n")
189    printf("\n")
190    printf("  sh_help      - creates this help text\n")
191    printf("  shop         - opens the fast shutter\n")
192    printf("\n")
193  }
194}'
195
196""".. note:: there is much more content in ``shutter.mac``"""
197
198#==============================================================================
199
200def _ascan ''
201
202kohzuMove_PV = "32ida:KohzuPutBO"
203Und_Delay = 0.1
204
205def kohzuE_cmd(mne,key,p1) '{
206     if (key == "set_position") {
207      return
208     }
209}'
210
211def show_und'
212   printf("\n%40.40s","Current Undulator Status")
213'
214
215  # cleanup macro for ^C usage
216  rdef _cleanup3 \'resetUSAXS\'
217  rdef _cleanup3 \'\'
218     cdef("Fheader", fheader,  "UCOL", 0x20)
219     rdef Flabel \'""\'
220
221#==============================================================================
222
223global kohzu_PV kohzuMV_PV UND_PV Und_Off UNDE_TRACK_ON
224global       kohzuStop_PV kohzuMode_PV      kohzuMove_PV
225global CCD_PREFIX            # EPICS PV for CCD server
226global CCD_OVERHEAD_SECS        # readout time
227global CCD_OVERHEAD_SECS_MEASURED   # measured readout time
228
229    global @A_name[] @B_name[]
230       unglobal @A_name
231       unglobal @B_name
232global CCD_DARK_NUM CCDDARK CCD_THROW
233global MULTI_IMGS # useful 8-ID's imm fileformat; currently not used
234
235constant TWO_PI 6.283
236local _newspaper
237
238#==============================================================================
239
240"""
241TODO: need some good test cases for arrays.
242But this is not the highest priority.
243
244[[extern] shared] [type] array var[cols]
245    Declares a one-dimensional data array.
246
247[[extern] shared] [type] array var[rows][cols]
248    Declares a two-dimensional data array.
249"""
250
251#==============================================================================
252
253"""    # This is the start of an extended comment
254
255this is located within an extended comment
256
257"""    # this is a normal comment after the extended comment
258
259
260a = 42.0    #  """ this is not an extended comment"""
261#==============================================================================
262
263
264"""End of $Id: test-battery.mac 983 2012-06-28 21:34:54Z jemian $"""
Note: See TracBrowser for help on using the repository browser.