source: specdomain/src/specdomain/test/test-battery.mac @ 956

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

refs #8, basics of the parser are established

  • 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 956 2012-06-21 03:57:40Z 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   - user_precount
77   - user_getcounts
78   - cleanup_always
79 
80HISTORY
81   2004/11/06 (CS):
82   
83           - modified the first original version to comply with naming and format
84             conventions
85           - implemented help-file support and wrote help texts.
86             2010/03/30 (CS):
87           - added the following global variables to make macro more easily portable::
88         
89                    SHUTTER_CONTROL_PV      # EPICS PV name for the shutter control (bo)
90                    SHUTTER_CONTROL_OPEN    # EPICS control value for open shutter
91                    SHUTTER_CONTROL_CLOSED  # EPICS control value for closed shutter
92                    SHUTTER_STATUS_PV       # EPICE PV name for the shutter status (bi)
93                    SHUTTER_STATUS_OPEN     # EPICS status value for open shutter
94                    SHUTTER_STATUS_CLOSED   # EPICS status value for closed shutter
95                    SHUTTER_IS_ON           # flag for automatic shutter control
96                    SHUTTER_SLEEP_TIME      # SPEC sleep time after opening shutter
97 
98   2010/07/23 (CS):
99           - added SVN keywords (replacing CVS keywords)
100 
101   2011/12/19 (CS):
102           - reformatted code documentation to work with ROBODoc
103           - added shutter_setup with following internal macros:
104         
105             * _shutter_print_setup
106             * _shutter_set_option
107             * _clear_screen
108         
109           - replaced SHUTTER_STATUS* with SHUTTER_MONITOR*
110           - replaced global variables _OPEN with _OPEN_VAL and
111             _CLOSED with _CLOSED_VAL
112"""
113#==============================================================================
114
115#==============================================================================
116# Define some global variables
117# ----------------------------
118
119    global SHUTTER_MAC
120           SHUTTER_MAC = DOFILE
121
122    # EPICS PV of the binary output which controls the shutter
123    #
124    global SHUTTER_CONTROL_PV
125           SHUTTER_CONTROL_PV = "X04SA-ES3-SC:FPS"
126
127    global SHUTTER_CONTROL_OPEN_VAL
128           SHUTTER_CONTROL_OPEN_VAL = "On"
129
130    global SHUTTER_CONTROL_CLOSED_VAL
131           SHUTTER_CONTROL_CLOSED_VAL = "Off"
132
133    # EPICS PV of the binary input which monitors the state of the shutter
134    # if SHUTTER_MONITOR_PV = "", no monitoring is performed
135    #
136    global SHUTTER_MONITOR_PV
137           SHUTTER_MONITOR_PV = ""
138
139    global SHUTTER_MONITOR_OPEN_VAL
140           SHUTTER_MONITOR_OPEN_VAL = "open"
141
142    global SHUTTER_MONITOR_CLOSED_VAL
143           SHUTTER_MONITOR_CLOSED_VAL = "closed"
144
145    global SHUTTER_IS_ON
146           SHUTTER_IS_ON = 0
147
148    global SHUTTER_SLEEP_TIME
149           SHUTTER_SLEEP_TIME = 0.1
150
151
152#==============================================================================
153# This macro file contains the following commands:
154#==============================================================================
155
156#------------------------------------------------------------------------------
157
158def shutter_help 'sh_help'
159
160def sh_help '{
161        """
162        .. spec:def:: sh_help, shutter_help
163       
164        sh_help, shutter_help
165        =============================
166       
167        Displays the shutter help text.
168       
169        usage::
170       
171           > sh_help
172       
173        .. note::
174           The help text is generated by simply displaying the text file
175           ``shutter_mac.txt``, which should reside in the same directory as ``shutter.mac``.
176           If the file does not exist, a generic help text is shown.
177        """
178
179  unix (sprintf ("dirname %s", SHUTTER_MAC), _1)
180  ll = length (_1)
181  if (substr (_1, ll, 1) == "\n") _1 = substr (_1, 1, (ll - 1))
182  file = sprintf ("%s/shutter_mac.txt", _1)
183  if (file_info (file, "-e")) {
184    unix (sprintf ("cat %s", file))
185  } else {
186    printf("\n  Macros available in file shutter.mac:\n")
187    printf(  "                           ===========\n")
188    printf("\n")
189    printf("  sh_help      - creates this help text\n")
190    printf("  shop         - opens the fast shutter\n")
191    printf("\n")
192  }
193}'
194
195"""there is more in shutter.mac"""
196
197#==============================================================================
198
199def _ascan ''
200
201kohzuMove_PV = "32ida:KohzuPutBO"
202Und_Delay = 0.1
203
204def kohzuE_cmd(mne,key,p1) '{
205     if (key == "set_position") {
206      return
207     }
208}'
209
210def show_und'
211   printf("\n%40.40s","Current Undulator Status")
212'
213
214  # cleanup macro for ^C usage
215  rdef _cleanup3 \'resetUSAXS\'
216  rdef _cleanup3 \'\'
217     cdef("Fheader", fheader,  "UCOL", 0x20)
218     rdef Flabel \'""\'
219
220#==============================================================================
221
222global kohzu_PV kohzuMV_PV UND_PV Und_Off UNDE_TRACK_ON
223global       kohzuStop_PV kohzuMode_PV      kohzuMove_PV
224global CCD_PREFIX            # EPICS PV for CCD server
225global CCD_OVERHEAD_SECS        # readout time
226global CCD_OVERHEAD_SECS_MEASURED   # measured readout time
227
228    global @A_name[] @B_name[]
229       unglobal @A_name
230       unglobal @B_name
231global CCD_DARK_NUM CCDDARK CCD_THROW
232global MULTI_IMGS # useful 8-ID's imm fileformat; currently not used
233
234constant TWO_PI 6.283
235local _newspaper
236
237#==============================================================================
238
239"""
240TODO: need some good test cases for arrays.
241But this is not the highest priority.
242
243[[extern] shared] [type] array var[cols]
244    Declares a one-dimensional data array.
245
246[[extern] shared] [type] array var[rows][cols]
247    Declares a two-dimensional data array.
248"""
249
250#==============================================================================
251
252"""    # This is the start of an extended comment
253
254this is located within an extended comment
255
256"""    # this is a normal comment after the extended comment
257
258
259a = 42.0    #  """ this is not an extended comment"""
260#==============================================================================
261
262
263"""End of $Id: test-battery.mac 956 2012-06-21 03:57:40Z jemian $"""
Note: See TracBrowser for help on using the repository browser.