esrf

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

#%TITLE% Skeleton_mh.mac
#$Revision: $
#%NAME% Macros for a the use of the Skeleton device as a macro motor.
#%DESCRIPTION%
# The macros provide users with an interface between SPEC and the Skeleton device.
#%INTERNALS%
# You may declare a motor and a counter, even for the same
# device! The macro motor/counter macros can handle that.
#%BR% %BR%Now declare a %B%motor\0controller%B%:
#%BR% %BR%
#%PRE%
#MOTORS\0\0\0\0DEVICE\0\0\0\0\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<>TYPE%BR%
#\0\0\0YES\0\0\0\0\0SKELETON\0idxx/skeleton/0_0\0\0\0\0\0\0\0\0\0\01\0\0\0\0\0\0\0Macro Motors
#%PRE%

# %BR%
#Then create the macro motor:
#%BR% %BR%Unit is always 0 !
#%PRE%
#Number:\0<>Controller\0\0\0\0\0\0\0\0\0\0\00:\0MAC_MOT
#%BR%
#Unit/[Module/]Channel\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00/0
#%BR%
#Name\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0Skeleton
#%BR%
#Mnemonic\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0skeleton
#%BR%
#Steps per degree/mm\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01
#%BR%
#Sign of user * dial\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01
#%BR%
#Backlash [steps]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00
#%BR%
#Steady-state rate [Hz]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01
#%BR%
#Base rate [Hz]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01
#%BR%
#Acceleration time [msec]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01
#%BR%
#Motor accumulator\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00
#%BR%
#Restrictions <>\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0NONE
#%BR%
#
#%BR%
#Dial = accumulator / steps
#%BR%
#\0\0High limit\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01000.0000
#%BR%
#\0\0Current\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00.0000
#%BR%
#\0\0Low limit\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00.0000
#%BR%
#User = sign * dial + offset
#%BR%
#\0\0Offset\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00.0000
#%BR%
#\0\0`High' limit\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\01000.0000
#%BR%
#\0\0Current\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00.0000
#%BR%
#\0\0`Low' limit\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\00.0000
#%PRE%
#%BR%
# (Skeleton: possibly necessary ?)Then hit 'm' twice. Set the following for your motor:
#%PRE%
#Hardware\0read\0mode\0<>\0\0\0\0\0\0\0\0PR\0+\0AL\0+\0NQ
#%PRE%
#%BR% %BR%Now declare a %B%scaler\0controller%B%:
#%PRE%
#SCALERS\0\0\0\0\0\0\0\0\0DEVICE\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<>TYPE%BR%
#\0\0\0YES\0\0\0\0\0\0\0\0\0\0\0SKELETON\0sr/comploop/id18_0\01\0\0\0\0\0\0\0\0\0\01\0\0\0\0\0\0Macro Counter
#%PRE%%BR%
#%BR% %BR%
# The %B%counter%B% is then configured as :
#%PRE%
#Number\0\0\0\0\0\0\0\0Name\0\0Mnemonic\0\0<>Device\0\0Unit\0\0Chan\0\0\0<>Use\0As\0\0Scale\0Factor
#\0\0\0\0\03\0\0\0\0\0\0Skel\0\0\0\0Skel\0\0\0MAC_CNT\0\0\0\0\00\0\0\0\0\01\0\0\0\0counter\0\0\0\0\0\0\0\0\0\0\0\0\01
#%PRE%%BR%
#%BR% %BR%
#%END%
#%HISTORY%
#$Log:  $


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


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

def __Skeleton_tango_catch_error '{
    if (TANGO_ERR != "0") {
        tty_cntl("md")
        __errstr = macfname " - " func "- ERROR: " what "(" addr ", " attr ")"
        __skeleton_error(__errstr)
        __skeletondebug  TANGO_ERR
        tty_cntl("me")
    }
}
'

#%IU%(mesg)
#%MDESC% Attempts to write indentical error message only once in a while
def __skeleton_error(errstr) '{
    global __SkeletonERR[]
    local expiry, now, str
    str = "Skeleton: " errstr
    expiry  =   5   # seconds before message is redisplayed
    now     = time()
    if (errstr in __SkeletonERR[]) {
        if ((time() - __SkeletonERR[][errstr]) > expiry) {
            __SkeletonERR[][errstr] = now
            cprint(str, 0, 7)
        }
    } else {
        __SkeletonERR[][errstr] = now
        cprint(str, 0, 7)
    }
    local x
    for (x in __SkeletonERR[]) {
        if ((time() - __SkeletonERR[][x]) > 20) {
            delete __SkeletonERR[][x]
        }
    }
}
'



#%IU%(mne, type, unit, mod, chan)
#%MDESC%
# Called by spec
def SKELETON_config(mne, type, unit, mod, chan) '{
    __skeletondebug "Configuring Skeleton", mne, type, unit, mod, chan

    if (mne == "..") {
        return
    }
    else if (type == "mot") {
        return 
    }
}
'

#%IU%
#%MDESC%
# Called by spec
def SKELETON_cmd(mne, cmd, p1, p2, p3) '{
  local unit, module, channel
  __skeletondebug "Command Skeleton", mne, cmd, p1, p2, p3
  if (mne != "..") {
    if (cmd == "start_one") {
      # start counter, when it is one
      if (p2 == 0) {
        return
      }
    }
    else if (cmd == "position") {
      # return position
      return(retval)
    }
    else if (cmd == "get_status") {
      return(0)
    }
    else if (cmd == "counts") { # this is for the counter
      return(retval)
    }
    else if (cmd == "abort_one") {
      return(0)
    }
  }
}
'



#%MACROS%
#%IMACROS%
#%INTERNALS%
#%AUTHOR% Yourself, BLISS - ESRF, 
#$Revision: $, $Date:  $
#%TOC%