esrf

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

#%TITLE% lakeshore_gaussmeter455_mc.mac
#$Revision: 1.1 $
#%NAME% Macros for a the use of a Lakeshore Gaussmeter Type 455
#%DESCRIPTION%
# IDN is : LSCI,MODEL455,4550252,06062006
#%BR%
#%BR% %BR%
# In the config editor in the "Motor and Counter Device Configuration" page (hit
# "D") create a counter controller like follows:
# %BR%
#SCALERS\0\0\0\0\0\0DEVICE\0\0\0\0\0\0\0\0\0\0\0\0ADDR\0\0<>MODE\0\0NUM\0\0\0\0\0\0\0\0\0\0\0\0\0\0<>TYPE%BR%
#\0\0\0YES\0\0\0\0\0\0\0LSGM455\0\0\0\0\0\0\0\0\0\0\00:12\0\0\0\0\0\0\0\0\0\0\0\01\0\0\0\0\0\0\0Macro Counter
# %BR%
#Then type "S" to go to the Scaler configuration screen to create the counters.
# Change the number of counters at the bottom of the screen to 20.
#Scaler\0(Counter)\0Configuration
#
#Number\0\0\0\0\0\0\0\0Name\0\0Mnemonic\0\0<>Device\0\0Unit\0\0Chan\0\0<>Use\0As\0\0\0Factor
#\0\0\0\0\03\0\0\0\0\0\0\0\0lsgm\0\0\0\0\0\0lsgm\0\0\0MAC_CNT\0\0\0\0\00\0\0\0\0\00\0\0\0counter\0\0\0\0\0\0\0\01
#%ATTENTION%
# After a fresh start the macros needed for the macro counters are most
# likely not available, which necessitates a reconfig first thing.
#%END%

if (!(whatis("__lsgm_debug")  & 2)) rdef __lsgm_debug \'#$*\'
  

#%UU%
#%MDESC% toggle debug mode for the present macros.
def lsgm_debug '{
  if ((whatis("__lsgm_debug")>>16) <= 2) { # just a # sign -> off
    rdef __lsgm_debug "eprint"
    print "lsgm debug is ON"
  } else {
    rdef __lsgm_debug \'#$*\'
    print "lsgm debug is OFF"
  }
}
'

#%IU%(mne, type, unit, mod, chan)
#%MDESC%
# Called by spec
def LSGM_config(mne, type, unit, mod, chan) '{
  __lsgm_debug "LSGM config", mne, type, unit, mod, chan
  local  answer, ident
  if (mne == "..") {
    if ((answer = __lsgm_io(LSGM_ADDR, "*IDN?")) == "") {
      eprint "No connection with the Kepco power supply!"
      return(".error.")
    }
    ident  = "LSCI,MODEL455,"
    if (substr(ident, answer) != ident) {
      print "The interface does not answer the correct identification string!"
      print "Are the interface informations correct?"
      return(".error.")
    }
  }
}
'


#%IU%(mne, key, p1, p2, p3)
#%MDESC%
# Called by spec
def LSGM_cmd(mne, key, p1, p2, p3) '{
  __lsgm_debug "LSGM command", mne, key, p1, p2, p3
  if (key == "counts") {
    return(__lsgm_io(LSGM_ADDR, "RDGFIELD?"))
  }
}
'



#%IU%(addr, cmd)
#%MDESC% Called by spec, write command to controller and read answer.
def __lsgm_io(addr, cmd) '{
  __lsgm_debug "__lsgm_io(\"" addr "\", \"" cmd "\")"
  if (__lsgm_put(addr, cmd) == ".error.") {
    return(".error.")
  } 
  local i, x, str, answer, error, aux[]
  i = 100
  while ((!gpib_poll(addr)) && i--)  {
    sleep(.01)
  }
  if (!i) eprint "took a long time to read lsgm!"
  answer = gpib_get(addr, "\n")
  return(answer)
}
'


#%IU%(addr, cmd)
#%MDESC% Called by spec, write command to controller, no answer expected.
def __lsgm_put(addr, cmd) '{
  local str
  str = cmd "\n"
  __lsgm_debug "__lsgm_put(\"" addr "\", \"" cmd "\")"
  if ((answ = gpib_put(addr, str)) == -1) {
    return(".error.")
  }
  return 0
}
'



#%MACROS%
#%IMACROS%
#%END%
#%BUGS% Bugs ? What bugs ??
#%AUTHOR%
#Holger (BLISS) for ID18.
#%TOC%