DECLARE SUB imagstandardize () DECLARE SUB initfile (ok$) DECLARE SUB gpibinit () DECLARE SUB hp3457init () DECLARE SUB dac488hrinit () DECLARE SUB dac488hrsetupv () DECLARE SUB k7011init () DECLARE SUB rtmain () DECLARE SUB imagramp (inom!) DECLARE SUB spolmain () DECLARE SUB fileheader (logfile$) DECLARE SUB fileihead (logfile$, iname$, n%, imag!()) DECLARE SUB filemkdir (destdir$) DECLARE SUB fileopenout (destdir$, basename$, ext$, filename$, ok$) DECLARE SUB fileplot (file$, epfile$) DECLARE SUB fileprnt (file$) DECLARE SUB fileprot (file$) DECLARE SUB gettestparam () '**************************************************************************** 'Program HERSEX 'This program is used to make the rotating coil measurements of the 'B-Factory HER sextupoles. It samples the voltage from the rotating 'coil and Fourier analyzes the samples to get the strengths of 'each component of the field. ' 'Zachary Wolf '3/2/95, 5/8/95 '**************************************************************************** 'Open the parameter file 'This is required to fill the current arrays 'Such statements can only be executed in the main module REM $INCLUDE: 'param.inc' 'The parameters required for this module are contained in 'GETPARAM 'FILE 'IMAG ' 'The required parameters are 'nimagstandP% 'imagstandP!() 'nimagtestP% 'imagtestP!() 'magnameP$ 'barcodeP$ 'runP$ 'rtdatP$ 'sldatP$ 'slpltP$ 'hardatP$ 'harpltP$ 'logfileP$ 'rawfileP$ 'Prepare the screen CLS 'Initialize the GPIB CALL gpibinit 'Initialize the HP3457 CALL hp3457init 'Initialize the DAC CALL dac488hrinit CALL dac488hrsetupv 'Initialize the multiplexer CALL k7011init 'Print a message about the program PRINT PRINT "Program HERSEX" PRINT "This program performs the rotating coil measurements on the" PRINT "B-Factory HER sextupoles." 'Get test parameters from the operator testparam: CALL gettestparam 'Initialize the files for this run CALL initfile(ok$) IF ok$ <> "y" THEN PRINT PRINT "Problem initializing the data files." PRINT "Make sure you are using a new run number." GOTO testparam: END IF 'Perform the RT measurements CALL rtmain 'Standardize the magnet CALL imagstandardize 'Measure the sextupole field and harmonics CALL spolmain 'Ramp to 0 amps CALL imagramp(0!) 'Message PRINT "The test is complete." END SUB initfile (ok$) '**************************************************************************** 'This subroutine does all the file initialization for the HER sextupole 'measurements. ' 'Output: ' ok$, ="y" if the file handling went ok, "n" otherwise ' 'Zachary Wolf '11/15/94 '**************************************************************************** 'Initialize ok$ = "n" 'Create the \magdata subdirectory to store the files subdir$ = "c:\magdata\" + LEFT$("s" + magnameP$ + "b" + barcodeP$, 8) CALL filemkdir(subdir$) 'Form the extension for all the files r% = VAL(runP$) IF r% < 10 THEN ext$ = "ru" + runP$ IF r% >= 10 THEN ext$ = "r" + runP$ 'RT 'Initialize the dat file for the rt measurements 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "rtdat", ext$, rtdatP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit 'Write headers to the dat file CALL fileheader(rtdatP$) 'Make a .bat file to write protect the data CALL fileprot(rtdatP$) 'Make a .bat file to print the dat file CALL fileprnt(rtdatP$) 'SL 'Initialize the data, and plot files for the SL vs I measurements 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "sldat", ext$, sldatP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit CALL fileopenout(subdir$, "slplt", ext$, slpltP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit 'Write a header to the dat file CALL fileheader(sldatP$) CALL fileihead(sldatP$, "Standardization Currents (A):", nimagstandP%, imagstandP!()) CALL fileihead(sldatP$, "Test Currents (A):", nimagtestP%, imagtestP!()) 'Make a .bat file to write protect the data CALL fileprot(sldatP$) CALL fileprot(slpltP$) 'Make a .bat file to print the dat file CALL fileprnt(sldatP$) 'Make a .bat file to plot the plt file CALL fileplot(slpltP$, "epsl.dat") 'HAR 'Initialize the data, and plot files for the harmonics measurements CALL fileopenout(subdir$, "hardat", ext$, hardatP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit CALL fileopenout(subdir$, "harplt", ext$, harpltP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit 'Write headers to the data file CALL fileheader(hardatP$) CALL fileihead(hardatP$, "Standardization Currents (A):", nimagstandP%, imagstandP!()) CALL fileihead(hardatP$, "Test Currents (A):", nimagtestP%, imagtestP!()) 'Make a .bat file to write protect the data CALL fileprot(hardatP$) CALL fileprot(harpltP$) 'Make a .bat file to print the dat file CALL fileprnt(hardatP$) 'Make a .bat file to plot the plt file CALL fileplot(harpltP$, "ephar.dat") 'LOGFILE 'Initialize the log file for the run 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "logfile", ext$, logfileP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit 'Write headers to the log file CALL fileheader(logfileP$) CALL fileihead(logfileP$, "Standardization Currents (A):", nimagstandP%, imagstandP!()) CALL fileihead(logfileP$, "Test Currents (A):", nimagtestP%, imagtestP!()) 'Make a .bat file to write protect the data CALL fileprot(logfileP$) 'Make a .bat file to print the log file 'CALL fileprnt(logfileP$) 'RAW DATA FILE 'Initialize the raw data file for the run 'Exit with ok$="n" if there is a problem CALL fileopenout(subdir$, "rawfile", ext$, rawfileP$, okopen$) IF okopen$ <> "y" THEN GOTO pblmexit 'If we made it this far, things are ok ok$ = "y" pblmexit: END SUB