# File newfocus.src	12 Sep 95	R. Bush
#
# Performs a 1x and 3x focus series at all 4 PAW positions 
#
#     !GI0 = exposure time in shutter ticks (0.25 msec/tick)
#     !GI7 = Sequence ID;  !GI7 = 0xc012
#     !GI9 = wait time after exposure command in seconds
#     !GS9 = log file name - set in openlog procedure
#

program "@(#) MODULE: newfocus.src RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/eof/src/newfocus.src"
descr "newfocus - Performs focus series at all 4 PAW positions"

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

queue on

tcblock mbcmsumm 1 1
tcblock mbcmaadc 3
#writen !GS9 "  CCD amplifier A, offset: 3"

tcblock mbiplbic 4 4
tcblock mbcmhdr1 0x4040 0x4040 0 1 0
#write !GS9 "  Taking central 256x256"
#writen !GS9 " in FD & HR OBS mode"

set !GI7 = 0xc012

set !GI0 = 16000
ask !RI "Enter exposure time ('0' for default of 16000 ticks)"
if !RI > 0 then
  set !GI0 = !RI
end if
set !GI9 = !GI0 / 4000.
#set !GI9 = !GI9 + 4 
#if !GI9 < 8 then
#  set !GI9 = 8
#end if
#write !GS9 "  Exposure time:"
#write !GS9 " %d" !GI0
#write !GS9 " ticks with %d" !GI9
#writen !GS9 " second waits"

open decom160 !LS1
#writen !GS9 "  160k data stored in: %s" !LS1

#
# This procedure takes a 1x focus series @ all PAW positions
#

#writen !GS9 "    Focus series in full disk mode;"
#writen !GS9 "    PAW positions 125, 90, 18, 54"

display "Full disk focus series in s-wave (PAW 125)"
tcblock mbdpconf 0xffff 0xffff 125
perform newfdfoc

display "Full disk focus series in p-wave (PAW 89)"
tcblock mbdpconf 0xffff 0xffff 89
perform newfdfoc

display "Full disk focus series in lcp (PAW 17)"
tcblock mbdpconf 0xffff 0xffff 17
perform newfdfoc

display "Full disk focus series in rcp (PAW 53)"
tcblock mbdpconf 0xffff 0xffff 53
perform newfdfoc

#
# This procedure takes a 3x focus series @ all PAW positions
#

#writen !GS9 "    Focus series in high resolution mode;"
#writen !GS9 "    PAW positions 125, 90, 18, 54"

display "High res focus series in s-wave (PAW 125)"
tcblock mbdpconf 0xffff 0xffff 125
perform newhrfoc

display "High res focus series in p-wave (PAW 89)"
tcblock mbdpconf 0xffff 0xffff 89
perform newhrfoc

display "High res focus series in lcp (PAW 17)"
tcblock mbdpconf 0xffff 0xffff 17
perform newhrfoc

display "High res focus series in rcp (PAW 53)"
tcblock mbdpconf 0xffff 0xffff 53
perform newhrfoc

queue off

display "Soft dark image"
tcblock mbcmdrkr !GI7 !GI0 !GI0
wait time !GI9
#writen !GS9 "    Soft DARK"

perform newobsmd

close decom160

#writen !GS9 "Finished procedure newfocus : %s" !TIME
#writen !GS9 "  "
display "End procedure newfocus"
