# /home/beams/USAXS/spec/macros/local/usaxs_tuning.mac
def preUSAXStune '
DCMfeedbackON
closeCCDshutter # close CCD shutter in case we are in Radiography mode
IfRequestedStopBeforeNextScan # stop if user chose to do so.
useModeUSAXS # should be done only in USAXS mode.
moveDetector DIODE_DX DIODE_DY # if user was in Radiography mode, move diode in place
global useSBUSAXS
global useMSstage
epics_put ("9idcLAX:USAXS:timeStamp", date())
epics_put ("9idcLAX:USAXS:state", "pre-USAXS optics tune")
openMonoShutter
usaxs_CheckBeamStandard
chk_beam_on
set_USAXS_Slits # make sure USAXS slits are set correctly...
autorange_I0I00amps # set correctly the gains for I0 and I00
tune_mr; # tune M stage to monochromator
tune_m2rp; # tune M stage paralelity
#tune_m2rp_fbe; # tune M stage paralelity using feedback
if(useSBUSAXS==1||useMSstage==1){tune_msrp} # tune msrp stage
if(useSBUSAXS==1){tune_asrp} # tune asrp stage and set ASRP0 value
autorange_UPDI0I00 # set correctly the ranges for all amplifiers
tune_ar ; # tune up the analyzer crystal pair
autorange_UPDI0I00 # set correctly the ranges for all amplifiers
tune_a2rp ; # tune up the analyzer crystal pair
#tune_a2rp_fbe # using the feedback
printf ("USAXS count time is %g second(s)\n", USAXS_TIME)
ct USAXS_TIME
epics_put ("9idcLAX:USAXS:timeStamp", date())
epics_put ("9idcLAX:USAXS:state", "pre-USAXS optics tuning done")
set_NumScansFromLastTune 0
set_RunPreUSAXStuneNext 0
set_EPOCHTimeOfLastTune time()
'
SPEC code: