#%TITLE% e725.MAC
#%NAME% 2725.MAC - Macros to access the e725 encoder
#
#%AUTHOR% BLISS - Cyril Guilloud - guilloud@esrf.fr
#%DATE% January 2006
#%DESCRIPTION%
# This macro set allows you to:
# - read the e725 encoder
# - define a pseudo counter in spec
#%EXAMPLE%
#%DL%
#%DT% e725setup ztable 1 %DD%
# The E725 encoder will be associated with counter ztable
# and counting will be done as soon as it is defined in config.
#
#%DT% e725off %DD%
# Access to e725 will be temporarily forbiden.
# Reset this feature with balzeron
#%DT% e725show %DD%
# Will show current configuration
#%XDL%
# UPDATES:
# by: date: desc:
#
# TODO :
# - multi controller version ?
# - reset ?
# - set the tare level ?
# - average read ?
#%UU% <counter mne> <serial tango device>
#%MDESC%
# This macro takes two parameters : the counter mnemonic to use and the
# device server name.
# exemple : e725_setup ztable "id22/e725/ztable"
def e725_setup '{
global E725_PAR[]
# E725_PAR["device"]
# E725_PAR["counter_mne"]
# E725_PAR["dbg"]
# E725_PAR["on"]
# E725_PAR["sleep"]
local _nbparam
_nbparam = $#
# if (_nbparam != 2) {
# print "E725 setup usage : e725_setup <counter_mnemonique> " \
# "<Serial_line_number>"
# print " ---> exit"
# exit
# }
if (_nbparam != 2) {
print "E725 setup usage : e725_setup <counter_mnemonique> " \
"<Serial line DS name>"
print " ---> exit"
exit
}
E725_PAR["counter_mne"] = "$1"
# E725_PAR["serial_device"] = "$2"
E725_PAR["device"] = "$2"
E725_PAR["sleep"] = 0.05
if (E725_PAR["dbg"]) {
#printf ( "%s is a E725 counter read from serial line %s", \
# E725_PAR["counter_mne"], E725_PAR["serial_device"] )
printf ( "%s is a E725 counter read from device %s", \
E725_PAR["counter_mne"], E725_PAR["device"] )
}
# 0x02 : only include if key is a counter mnemonic and the counter is not disabled.
cdef("user_getcounts", "\n e725_getcounts \n", E725_PAR["counter_mne"], 0x02 )
}'
#%UU%
#%MDSEC%
def e725_unsetup '{
e725_off
# Removing the call in user_getcounts.
cdef("user_getcounts", "", E725_PAR["counter_mne"], "delete")
}'
#%UU%
#%MDSEC%
def e725_on '{
global E725_PAR
if (E725_PAR["dbg"]) {
print "e725 is now on"
}
E725_PAR["on"] = 1
}'
#%UU%
#%MDSEC%
def e725_off '{
global E725_PAR
if (E725_PAR["dbg"]) {
print "e725 is now off"
}
# Cleanning S array.
S[cnt_num(E725_PAR["counter_mne"])] = 0
E725_PAR["on"] = 0
}'
#%IU%
#%MDESC%
def e725_getcounts '{
global E725_PAR
local ctnum
ctnum = cnt_num(E725_PAR["counter_mne"])
if (E725_PAR["dbg"]) {
print "e725 ctnum = ", ctnum
}
if (E725_PAR["on"]){
S[ctnum] = e725_read_value()
}
}'
#%UU%
#%MDSEC%
def e725_read_value() '{
global E725_PAR
local _ans
local _result
# # Ask the value to the e725 controler.
# _ans = tango_io(E725_PAR["serial_device"], "DevSerWriteString", "#00 SCAN\r\n")
#
# # _ans = ser_put( E725_PAR["serial_nb"], "#00 SCAN\r\n")
#
# if (_ans == -1){
# printf ("ERROR, check that Serial device \"%s\" is well configured", \
# E725_PAR["serial_device"])
# print " ---> exit"
# exit
# }
#
# sleep(E725_PAR["sleep"])
#
# # Reads the value from the serial line.
# # retval = ser_get( E725_PAR["serial_nb"], "\r\n")
# _ans = tango_io(E725_PAR["serial_device"], "DevSerReadLine")
#
# if (E725_PAR["dbg"]) {
# print "e725 read value is", _ans
# }
#
# # This is to have a number.
# _result = _ans + 0.0
_result = tango_get(E725_PAR["device"], "Position")
return( _result )
}'
#%UU%
#%MDSEC%
def e725_read_version() '{
global E725_PAR
local _ans
# local retval
#
# # ask for the version number of the controler
# # _ans = ser_put( E725_PAR["serial_nb"], "#00 SYS\r\n")
#
# tango_io(E725_PAR["serial_device"], "DevSerWriteString", "#00 SYS\r\n")
#
# if (_ans == -1){
# printf ("ERROR, check that Serial device %s is well configured", E725_PAR["serial_device"])
# print " ---> exit"
# exit
# }
#
# # Reads the value from the serial line.
# sleep(E725_PAR["sleep"])
# _ans = tango_io(E725_PAR["serial_device"], "DevSerReadLine")
_ans = tango_get(E725_PAR["device"], "Version")
return( _ans )
}'
# (Dis)able debug prints.
def e725_dbg '{
global E725_PAR
if($# == 1){
if ("$1" == "on" || "$1" == 1) {
E725_PAR["dbg"] = 1
print "e725 debug activated"
}
else{
E725_PAR["dbg"] = 0
print "e725 debug disabled"
}
}
else{
if(E725_PAR["dbg"]) {
E725_PAR["dbg"] = 0
print "e725 debug disabled"
}
else {
E725_PAR["dbg"] = 1
print "e725 debug activated"
}
}
}'
#%MACROS%
#%IMACROS%
#%AUTHOR% C.Guilloud
#%TOC%
|