source: specdomain/trunk/src/specdomain/doc/ex_markup/hkl_ioc.mac @ 1022

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

work-in-progress

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