source: specdomain/trunk/src/specdomain/markup_example/hkl_ioc.mac @ 1025

Last change on this file since 1025 was 1025, checked in by jemian, 11 years ago

should not nest one Sphinx project inside another

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
43#: preload check/setting here
44cdef("user_save_HKL","","ioc_HKL")
45cdef("calcHKL","calc(2); user_save_HKL;","ioc_HKL")
46
47#===============================================================================
48# global variables defined here
49#===============================================================================
50if( unset("SIOC_PV") ) {
51#: soft IOC PV prefix
52global SIOC_PV
53local foo tmp[]
54SIOC_PREFIX="4id"
55unix("hostname | cut -f1 -d.",foo)
56split(foo,tmp,"\n")
57foo=tmp[0]
58SIOC_PV = sprintf("%s:%s:spec",SIOC_PREFIX,foo)
59printf("Spec soft IOC PV(SIOC_PV): %s",SIOC_PV)
60}
61
62#===============================================================================
63# user macros defined here
64#===============================================================================
65def 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#===============================================================================
88def 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 
Note: See TracBrowser for help on using the repository browser.