#%TITLE% gauge.mac
#%CATEGORY% vacuum
#%NAME%
# Macros to get a penning reading as counter in spec.
#%DESCRIPTION%
# Very simple macro set to get the reading of a penning gauge
# as a counter in spec
#%BR%%BR%
# This macro set oversedes the macro set balzer.mac
#%BR%%BR%
# Two options to configure them:%BR%
# 1/ as macro counter%BR%
# * create a macro counter controller.%BR%
# * set the number of channels to what you need%BR%
# * set the prefix as "gauge"%BR%
# * add counters in the scaler window with controller MAC_CNT%BR%
# * set unit as appropiate%BR%
# * in the additional parameter window (type "p" when %BR%
# you are over the counter line) add a parameter%BR%
# called device with the right value%BR%
# %BR%
# 2/ as old style pseudo counter%BR%
# * define counters in the scaler window with controller%BR%
# as NONE%BR%
# * add lines like "gaugeadd mne devname" in setup%BR%
#
#%END%
global GAUGE_DEV
#%UU% ctmne devname
#%MDESC%
# Setup counter ctmne to accept pressure reading from device devname
# The counter needs to be defined in config
#
# If the line is configure in setup file, just taking the line away
# or commenting it out will deactivate the counter
def gaugeadd '{
if ($# != 2) {
print "Usage: gaugeadd ctmne devname"
exit
}
GAUGE_DEV["$1"] = "$2"
cdef("user_getcounts",sprintf("gauge_getcounts %s\n", "$1"),"$1",0x2)
setup_tail("gauge_","$1")
}'
#%UU%
#%MDESC%
# Activates reading on all gauges defined in setup with gaugeadd
def gaugeon '{
for (ky in GAUGE_DEV) {
cdef("user_getcounts",sprintf("gauge_getcounts %s\n", ky),ky,0x2)
}
}'
#%UU%
#%MDESC%
# Deactivates reading on all gauges defined in setup with gaugeadd
def gaugeoff '{
for (ky in GAUGE_DEV) {
S[cnt_num(ky)] = 0
cdef("","",ky,"delete")
}
}'
#%IU%
#%MDESC%
def gauge_getcounts '{
local ctmne devname ctnum
local argout
local _is_tango _pressure _pressure_attr
ctmne = "$1"
ctnum = cnt_num(ctmne)
devname = GAUGE_DEV["$1"]
_is_tango = ( index(devname, "tango") == 1)
if (_is_tango){
_pressure_attr = sprintf("%s/pressure", devname)
_pressure = esrf_io(_pressure_attr, "DevRead")
}
else{
esrf_io(devname, "DevReadSigValues", argout)
_pressure = argout[0]
}
S[ctnum] = _pressure
}'
#%IU%
#%MDESC%
def gauge_unsetup '{
local mne
mne = "$1"
S[cnt_num(mne)] = 0
delete GAUGE_DEV[ mne ]
cdef("","", mne ,"delete")
}'
#
# CODE FOR MACRO COUNTERS
#
#%IU%
#%MDESC%
# Checks that a device name has been set for each counter after reconfig
# Otherwise sets the counter as unusable
def gauge_config( mne, type, unit, mod, chan) '{
if ( type == "cnt") {
devname = counter_par(mne, "device")
if (devname == 0 || devname == "") {
printf("Device name for gauge counter \"%s\" not defined.\n", cnt_mne(mne))
printf(" Please:\n")
printf(" - go to the scaler screen in config\n")
printf(" - use \"p\" to access the aditional parameter screen\n")
printf(" - then use \"i\" to enter a new parameter\n")
printf(" - call the new parameter \"device\" and enter a value for it\n")
return ".error."
}
}
}'
#%IU%
#%MDESC%
# Read pressure value
def gauge_cmd( mne, key, p1, p2, unit ) '{
local argout
local _is_tango _pressure_attr _pressure
if ( key == "counts") {
devname = counter_par( mne, "device")
_is_tango = ( index(devname, "tango") == 1)
if (_is_tango){
_pressure_attr = sprintf("%s/pressure", devname)
_pressure = esrf_io(_pressure_attr, "DevRead")
}
else{
esrf_io(devname, "DevReadSigValues", argout)
_pressure = argout[0]
}
return _pressure
}
}'
#%MACROS%
#%IMACROS%
#%TOC%
#%AUTHOR% V.Rey / BLISS / ESRF - Feb 2008 %BR%
# C.Guilloud / BLISS / ESRF - Feb 2012 for tango version
|