esrf

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

def resolution_config(mne, type, p1, p2) '{
  if (mne != "..") { 
    if (motor_num("res") == -1) {
      printf("Error: Resolution: resolution motor does not exist in Spec config. !\n")
      return ".error."
    }

    if (motor_num(motor_par(res, "misc_par_1")) == -1) {
      printf("Error: Resolution: detector distance motor is not specified, or does not exist !\n")
      return ".error." 
    }

    return motor_par(res, "misc_par_1")
  }
}'


def resolution_calc(motornum, mode) '{
  local detdistmot

  if (motornum == "..") {
    return
  }

  detdistmot = motor_num(motor_par(res, "misc_par_1"))

  #print "detdistmot " detdistmot " " motornum " " mode
 
  if ( mode == 0 ) {
    # spec wants the resolution
    A[res] = CalculateResolutionFromDistance() 
  } else {
    # spec needs to move the real motor
    A[detdistmot] = CalculateDistanceFromResolution(A[res])
  }  
}'


def _setreslimits ''
def _setreslimits2 '{
  local lowlim hilim detdistmot

  chg_dial(res, CalculateResolutionFromDistance())
  detdistmot = motor_num(motor_par(res, "misc_par_1"))
  lowlim = get_lim(detdistmot, -1)
  hilim = get_lim(detdistmot, 1)
  set_lim(res, CalculateResolutionFromDistance(lowlim), CalculateResolutionFromDistance(hilim))
}'


def res_mv '{
  local detdistmot

  detdistmot = motor_num(motor_par(res, "misc_par_1"))

  if (fabs(A[res] - CalculateResolutionFromDistance(A[detm])) > 0.001) { 
    #printf("%g %g %d\n", A[res], A[detm], int(CalculateDistanceFromResolution()))

    A[detdistmot]=int(CalculateDistanceFromResolution())
  }
}' 


def resmoton '{
    if (motor_num("res") == -1) {
      printf("Error: Resolution: resolution motor does not exist in Spec config. !\n")
      exit
    }

    if (motor_num(motor_par(res, "misc_par_1")) == -1) {
      printf("Error: Resolution: detector distance motor is not specified, or does not exist !\n")
      exit
    }

    getangles
    _setreslimits

    cdef("user_getpangles","A[res]=CalculateResolutionFromDistance()\n", "res", 0x10)
    cdef("user_checkall", "res_mv\n", "res", 0x10|0x01)
    cdef("user_premove", "_setreslimits;", "res", 0x01)
}'


def resmotoff '{
    cdef ("","","res","delete")
}'