#%TITLE% cls.mac
#%NAME%
# CLS
#%CATEGORY%
#%DESCRIPTION%
# Cold Light Source controller. This macro set allows to control CLS
# device trough the CLS PyTango device server.
# You need a recent Spec version allowing *tango_io* functions.
#%EXAMPLE%
#%DL%
#%DT%XXXsetup%DD%
#%SETUP%
# cls_setup id22/cls/1
#%UL%
#%LI%
#%XUL%
#
# $Log: cls.mac,v $
# Revision 1.6 2011/11/21 12:50:07 guilloud
# *fixed bug "d"
# *fixed bug : "()" for user stub
#
# Revision 1.4 2011/11/08 09:51:33 guilloud
# *use spec_utils
# *tub to hook user macros in cls_on : cls_on_user
# *_cls_state()
#
# Revision 1.3 2009/05/20 13:30:48 guilloud
# quote in cls_print...
#
# Revision 1.2 2009/04/15 08:53:01 guilloud
# *debug mode
# *debug message print function
#
#
# $Revision: 1.6 $
#
# $Date: 2011/11/21 12:50:07 $
#
# $Source: /segfs/bliss/source/spec/macros/RCS/cls.mac,v $
#
need spec_utils
# maybe CLS_PAR["sleep"] can be reduced ???
#%UU% <device_name>
#%MDESC%
#
def cls_setup '{
global CLS_PAR
# CLS_PAR["on"]
# CLS_PAR["device"]
# CLS_PAR["brightness"]
# CLS_PAR["sleep"]
# CLS_PAR["debug"]
if ($# < 1){
cprint("CLS--error--cls_setup : no device name provided.", 1)
}
else{
CLS_PAR["device"] = "$1"
printf("CLS - configuring Cold Light Source - device server = %s\n", CLS_PAR["device"])
CLS_PAR["brightness"] = 0
CLS_PAR["sleep"] = 0.2
}
}'
#%UU%
#%MDESC%
# Switches the debug mode on/off.
def cls_debug '{
CLS_PAR["debug"] = CLS_PAR["debug"] ? 0 : 1
printf("CLS debug mode is now ")
cprint_on_off(CLS_PAR["debug"])
}'
#%UU%
#%MDESC%
# Debug print.
def cls_print '{
if (CLS_PAR["debug"]) {
print "$*"
}
}'
#%UU%
#%MDESC%
#
def cls_unsetup '{
unglobal CLS_PAR
}'
# Stub to hook user macros in cls_on.
cdef ("cls_on_user", "", "_cls_")
#%UU%
#%MDESC%
#
def cls_on '{
cls_on_user
CLS_PAR["on"] = 1
tango_io(CLS_PAR["device"], "On")
cls_print "CLS Brightness ON"
}'
#%UU%
#%MDESC%
#
def cls_off '{
CLS_PAR["on"] = 0
tango_io(CLS_PAR["device"], "Off")
cls_print "CLS Brightness OFF"
}'
#%UU%
#%MDESC%
#
def cls_state '{
print "CLS State =", tango_io(CLS_PAR["device"], "State")
print "CLS Status =", tango_io(CLS_PAR["device"], "Status")
print "CLS Brightness (last read) =", CLS_PAR["brightness"]
}'
#%IU% ()
#%MDESC%
# returns "ON" / "OFF"
def _cls_state()'{
return tango_io(CLS_PAR["device"], "State")
}'
#%UU% [parma]
#%MDESC%
#
def cls_inc '{
cls_on
cls_print "CLS Brightness +"
sleep(CLS_PAR["sleep"])
CLS_PAR["brightness"] = tango_io(CLS_PAR["device"], "Increase_brightness")
if (CLS_PAR["brightness"] > 63){
CLS_PAR["brightness"] = 63
}
}'
#%UU% [parma]
#%MDESC%
#
def cls_dec '{
cls_on
cls_print "CLS Brightness -"
sleep(CLS_PAR["sleep"])
CLS_PAR["brightness"] = tango_io(CLS_PAR["device"], "Decrease_brightness")
if (CLS_PAR["brightness"] > 63){
CLS_PAR["brightness"] = 0
}
}'
#%UU% [parma]
#%MDESC%
#
def cls_set '{
local _new_val
if ($# < 1){
print "$0 usage : cls_set value ( value in 0..63)"
exit
}
if (("$1" > -1) && ("$1" < 64) ){
_new_val = $1
}
else {
print "$0 usage : cls_set value ( value in 0..63)"
exit
}
cls_print "CLS - Set - " "$1"
tango_put(CLS_PAR["device"], "Brightness", _new_val)
CLS_PAR["brightness"] = _new_val
}'
#%MACROS%
#%IMACROS%
#%TOC%
#%DEPENDENCIES%
#%AUTHOR%
# Cyril Guilloud fev.2009
#%END%
|