esrf

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

#%TITLE% TW.MAC
#%NAME%
#  Macros to combine different motors and counting in a twit
#%DESCRIPTION%
#  The following macros are available
#%UL%
#%LI% tw1
#%LI% twct
#%LI% tw2
#%LI% tw2ct
#%LI% tw3
#%LI% tw3ct
#%XUL%
#%END%


#%UU%
#%MDESC%
# twit one motor
def tw1 '
	if ($# != 2) {
		print "Usage:  tw motor step_size"
		exit
	}
	_check0 "$1"

        _twnm = 1
        _twct=0   
        _twm[0] = $1
        _tws[0] = $2

        _tw
'

#%UU%
#%MDESC%
# twit one motor and count after each step
def twct '
	if ($# < 2) {
		print "Usage:  twct motor step_size [count-time]"
		exit
	}
	_check0 "$1"

        _twnm = 1
        _twct = 1;_twtime=($#==3)?($3):COUNT
        _twm[0] = $1
        _tws[0] = $2

        _tw
'

#%UU%
#%MDESC%
# twit two motors
def tw2 '
	if ($# != 4) {
		print "Usage:  tw2 motor1 motor2 step1 step2 "
		exit
	}
	_check0 "$1"
	_check0 "$2"

        _twnm = 2
        _twct = 0
        _twm[0] = $1;_twm[1] = $2
        _tws[0] = $3;_tws[1] = $4

        _tw 
'

#%UU%
#%MDESC%
# twit two motors and count after each step
def tw2ct '
	if ($# < 4) {
		print "Usage:  tw2ct motor1 motor2 step1 step2 [count-time]"
		exit
	}
	_check0 "$1"
	_check0 "$2"

        _twnm = 2
        _twct = 1;_twtime=($#==5)?($5):COUNT
        _twm[0] = $1;_twm[1] = $2
        _tws[0] = $3;_tws[1] = $4

        _tw 
'

#%UU%
#%MDESC%
# twit three motors 
def tw3 '
	if ($# != 6) {
		print "Usage:  tw3 motor1 motor2 motor3 step1 step2 step3"
		exit
	}
	_check0 "$1"
	_check0 "$2"
	_check0 "$3"

        _twnm = 3
        _twct = 0
        _twm[0] = $1;_twm[1] = $2;_twm[2] = $3
        _tws[0] = $4;_tws[1] = $5;_tws[2] = $6

        _tw
'

#%UU%
#%MDESC%
# twit three motors and count after each step
def tw3ct '
	if ($# < 6) {
		print "Usage:  tw3ct motor1 motor2 motor3 step1 step2 step3 [count-time]"
		exit
	}
	_check0 "$1"
	_check0 "$2"
	_check0 "$3"

        _twnm = 3
        _twct = 1;_twtime=($#==7)?($7):COUNT
        _twm[0] = $1;_twm[1] = $2;_twm[2] = $3
        _tws[0] = $4;_tws[1] = $5;_tws[2] = $6

        _tw
'
#%IU%
# 
def _tw '
{
        local i

	def cleanup \'
		undef cleanup
		get_angles
		#
	\'
	get_angles
	print "Indicate direction with + (or p) or - (or n)."
	print "Type something else (or ^C) to quit.\n"
	{
	    local s t str
	    for (s="+";;) {
		waitmove; get_angles
                str=""
                for (i=0;i<_twnm;i++) 
                   str = sprintf("%s%s = %g, ",str,motor_name(_twm[i]),A[_twm[i]])
		t = input(sprintf("%swhich way (%s)? ",str,s))
		if (t == "")
			t = s
		if (!index("+-pn", t))
			break
		s = t
		if (s == "+" || s == "p")
                       for (i=0;i<_twnm;i++) 
			  A[_twm[i]] += _tws[i]
		else if (s == "-" || s == "n")
                       for (i=0;i<_twnm;i++) 
			  A[_twm[i]] -= _tws[i]
		else
			break
		move_em
                if (_twct) {
                   waitmove; get_angles
                   count_em _twtime
                   waitcount
                   onp; twshow_cnts; offp
                }
	    }
	}
	cleanup
}
'

#%IU%
#
def twshow_cnts '
{
       local i
       get_counts
       for (i=0;i<COUNTERS;i++)
            if (cnt_name(i) != "unused")
                printf("%12s = %g%s\n", cnt_name(i), S[i], \
                    i != sec && S[sec]? sprintf(" (%g/s)", S[i] / S[sec]):"")
}
'
#%MACROS%
#%IMACROS%
#%AUTHOR%
#  TW.MAC Vicente Rey - 28 Feb. 1996
# taken out all fprintf(PRINTER , Holger, 9.12.2004
#%TOC%