program "%Z% MODULE: %M% RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/sim/src/take_pic.src"
descr "take_pic - takes verification images (in VC2)"
# program take_pic.src, created 95.12.14 Igor Zayer 
#	20.12.95  (IZ) modified to have exposure time hardcoded at 600 ticks
#		      and don't bother with asking for IDL procedure...
#
# Part of alignment procedure: takes verification images;
# usually called by 'alignit.src'
#
# Variable usage:
#----------------
# !GI0: exposure time (ticks)
# !GI9: wait time (seconds)
# !GS7: 'enable calling the leg routine' string (is set once picture is taken)
# !GS8: name of 160k file
# !GS9: name of user logfile
#
# !LI0: loop count variable
# !LI1: loop count variable
# !LI3: status of HR telemetry (= 2 for VC2)
# !LI5: temporarily stores !GI0
# !LS0: answer string
#----------------

display "Executing procedure take_pic"
write  !GS9 "Executing procedure take_pic :"
write  !GS9 " %s" !DATE
writen !GS9 " %s" !TIME

##SET HEADER TO INVOKE 4X4 IP SUMMING (table index 30)
tcblock mbcmhdr1 0x4040 0x4040 0 1 30
writen !GS9 " using index 30 = QPROG_TAP_CONT_4X4BIN"

## SET EXPOSURE TIME TO 600 TICKS
set !GI0 = 600
set !GI9 = 7

for !LI0 = 0 to 32000
  ##TAKE PICTURE IF STILL IN VC2
  set !LI3 = getint(mksqrg3)
  if !LI3 = 2 then
    tcblock mbcmtp1 0 0 !GI0
    ###sync hk###
    write !GS9 " taking exposure with %d" !GI0
    writen !GS9 " ticks"
    setstr !GS7 = "enable legs"
    wait time !GI9
  else
    beep
    beep
    display "Not in VC2 - sorry!!"
    writen !GS9 "Not in VC2 - quitting!!"
    goto done
  end if
  menu !LS0 "TAKE ANOTHER PICTURE?" "YES, another one..." "NO, enough!"
  exit if !LS0 = "NO, enough!"
end for

done:
writen !GS9 "Finished procedure take_pic : %s" !TIME
writen !GS9 " "
display "Finished Procedure take_pic                                    "
return
