Posted to tcl by auriocus at Mon Jun 20 22:40:45 GMT 2016view pretty

# instantiate motors
motor Sample-X Sample-X
motor Sample-Y Sample-Y
motor Sample-Z Sample-Z
# instantiate detector channels
channel Diode K1norm
channel Monitor Ring_1

Sample-X goto 3.0 
# tell the motor to run
Sample-X wait 
# wait for this motor to arrive
Sample-Y goto 2
Sample-Z goto 7.5
motor waitforall
# wait until all known motors are in position

# now run a scan
for {set x 3} {$x<=5} {set x [expr {$x+0.1}]} {
	Sample-Y goto $x
	Sample-X wait 
	lassign [channel readall Diode Monitor -timeout 2000] d m
	# trigger both detectors to read a value
	# return a list if both have finished reading
	# or NaN if the timeout fires first
	puts [expr {$d/$m}]
}