1 | """ |
---|
2 | SPEC macros for the Advanced Photon Source |
---|
3 | |
---|
4 | Beamline/Sector |
---|
5 | 4ID |
---|
6 | |
---|
7 | Macro Package |
---|
8 | hkl_ioc.mac |
---|
9 | |
---|
10 | Version |
---|
11 | 1.0 (August,2005) |
---|
12 | |
---|
13 | Description |
---|
14 | A user defined calcHKL to write the current HKL postion to a |
---|
15 | soft IOC. It requires spec softioc running. |
---|
16 | |
---|
17 | Written by |
---|
18 | X. Jiao 08/08/2005 |
---|
19 | |
---|
20 | Modified by: |
---|
21 | |
---|
22 | User macros |
---|
23 | ioc_HKL -> to turn on/off the feature of putting HKL to shared |
---|
24 | memory. |
---|
25 | |
---|
26 | Internal macros |
---|
27 | ioc_put_HKL -> write HKL to the soft IOC |
---|
28 | |
---|
29 | Modification history: |
---|
30 | |
---|
31 | ======== =================== ======= ===================================== |
---|
32 | Revision date/time author remarks |
---|
33 | ======== =================== ======= ===================================== |
---|
34 | 1.3 2006/05/22 20:34:35 jiaox removed unsed lines in ioc_HKL. |
---|
35 | 1.2 2006/05/11 17:46:31 jiaox Added CVS Log entry. |
---|
36 | ======== =================== ======= ===================================== |
---|
37 | """ |
---|
38 | |
---|
39 | #=============================================================================== |
---|
40 | # preload check/setting here |
---|
41 | #=============================================================================== |
---|
42 | |
---|
43 | #: preload check/setting here |
---|
44 | cdef("user_save_HKL","","ioc_HKL") |
---|
45 | cdef("calcHKL","calc(2); user_save_HKL;","ioc_HKL") |
---|
46 | |
---|
47 | #=============================================================================== |
---|
48 | # global variables defined here |
---|
49 | #=============================================================================== |
---|
50 | if( unset("SIOC_PV") ) { |
---|
51 | #: soft IOC PV prefix |
---|
52 | global SIOC_PV |
---|
53 | local foo tmp[] |
---|
54 | SIOC_PREFIX="4id" |
---|
55 | unix("hostname | cut -f1 -d.",foo) |
---|
56 | split(foo,tmp,"\n") |
---|
57 | foo=tmp[0] |
---|
58 | SIOC_PV = sprintf("%s:%s:spec",SIOC_PREFIX,foo) |
---|
59 | printf("Spec soft IOC PV(SIOC_PV): %s",SIOC_PV) |
---|
60 | } |
---|
61 | |
---|
62 | #=============================================================================== |
---|
63 | # user macros defined here |
---|
64 | #=============================================================================== |
---|
65 | def ioc_HKL '{ |
---|
66 | """to turn on/off the feature of putting HKL to shared memory.""" |
---|
67 | |
---|
68 | if($# != 1) { eprint "Usage: ioc_HKL on/off ";exit} |
---|
69 | |
---|
70 | |
---|
71 | if(("$1" == "on")) { |
---|
72 | cdef("user_save_HKL","ioc_put_HKL","ioc_HKL","0x20") |
---|
73 | print "Now put HKL to softioc." |
---|
74 | exit |
---|
75 | } |
---|
76 | if(("$1" == "off")) { |
---|
77 | cdef("user_save_HKL","","ioc_HKL","delete") |
---|
78 | print "Stop put HKL to softioc." |
---|
79 | exit |
---|
80 | } |
---|
81 | eprint "Usage: ioc_HKL on/off " |
---|
82 | }' |
---|
83 | |
---|
84 | |
---|
85 | #=============================================================================== |
---|
86 | # internal macros defined here |
---|
87 | #=============================================================================== |
---|
88 | def ioc_put_HKL ' |
---|
89 | """write HKL to the soft IOC""" |
---|
90 | |
---|
91 | epics_put(sprintf("%s:H",SIOC_PV),H) |
---|
92 | epics_put(sprintf("%s:K",SIOC_PV),K) |
---|
93 | epics_put(sprintf("%s:L",SIOC_PV),L) |
---|
94 | epics_put(sprintf("%s:NPTS",SIOC_PV),NPTS) |
---|
95 | ' |
---|
96 | |
---|
97 | |
---|