esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

"""
#%TITLE% Can556_mm.MAC
#%NAME%
#  Macros to control a Canberra AIM 556 via a macro MCA
#
#%CATEGORY% MCA - 1d
#%INTERNALS%
#%SETUP%
#
#Now declare a %B%MCA\0controller%B% (type the lettre  A):
#
#%PRE%
#MCA\0\0\0\0\0\0\0\0\0\0DEVICE\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0ADDR\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0<>TYPE
#\04\0\0\0\0\0YES\0\0\0Can556\0\0\0\0\0\0id14/can556/729\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0Macro MCA
#%PRE%
#%END%

# First attempt (30/11/2022) HW
#
"""


#%IU%(mcanum, type, par1, par2)
#%MDESC%
#
def Can556_config(mcanum, type, par1, par2) '{
    global ___Can556
    __Can556_debug ">>> Can556_config: ",mcanum, type, par1, par2, Can445_ADDR
    # they have 8k channels
    ___Can556["max_channels"] = 8192 # tango_get(Can556_ADDR, "channels")
    unglobal ___Can556data
    global ulong array ___Can556data[___Can556["max_channels"]]
    return sprintf("%s %s", ___Can556["max_channels"], " ulong")
}'



#%IU%(mcanum, type, par1, par2)
#%MDESC%
#
def Can556_par(mcanum, type, par1, par2) '{
    __Can556_debug "--->Can556_par: ",mcanum, type, par1, par2, "ADDR", Can556_ADDR
    if (type == "max_channels") {
        return ___Can556["max_channels"]
    } else
    if (type == "group_size") {
        return ___Can556["max_channels"]
    } else
    if (type == "select_group") {
        return ___Can556["max_channels"]
    } else
    if ((type == "elapsed_live") || (type == "LiveTime")) {
        return tango_get(Can556_ADDR , "LiveTime")
    } else
    if ((type == "elapsed_real") || (type == "RealTime")) {
        return tango_get(Can556_ADDR , "RealTime")
    }
}'



#%IU%(mcanum, type, par1, par2)
#%MDESC%
#
def Can556_cmd(mcanum, type, par1, par2) '{
    __Can556_debug "Can556_cmd: ",mcanum, type, par1, par2
    local addr; addr = Can556_ADDR
    if (type == "clear") {
        return tango_io(Can556_ADDR , "ClearMemory")
    } else
    if (type == "run") {
        tango_put(Can556_ADDR , "PresetLiveTime", par1)
        return tango_io(Can556_ADDR , "On")
    } else
    if (type == "halt") {
        return tango_io(Can556_ADDR , "Off")
    } else
    if (type == "get_status") {
        return ! tango_io(Can556_ADDR , "State") # server give opposite value to spec`s needs
    } else
    if (type == "read") {
        ___Can556data = tango_get(Can556_ADDR , "Data", @par2)
        return par2
    }
}'




#%UU%
#%MDESC%
#    Toggles the debug mode.
if (!(whatis("__Can556_debug")  & 2)) rdef __Can556_debug \'#$*\'

def Can556_debug '{
  if ((whatis("__Can556_debug")>>16) <= 3) { # macro length is 3 bytes: comment
     rdef __Can556_debug "eprint \"Can556 \""
     print "Can556 macro debug mode is ON"
  }
  else {
     rdef __Can556_debug \'#\$*\'
     print "Can556 macro debug mode is OFF"
  }
}'


#%MACROS%
#%IMACROS%
#%DEPENDENCIES% A macro file multimca.mac newer than 1.43.
#%AUTHOR% Holger - Nov/Dec 2022
#$Revision: 1.1 $, $Date: 2022/12/05 16:04:35 $
#%TOC%