DECLARE SUB GetTime (plottime$) DECLARE SUB GetDate (plotdate$) DECLARE SUB GetMagnetRun (mag$(), runnumber$) DECLARE SUB DisplayFileInfo (mag$(), runnumber$, magday$(), magtime$(), include$(), gout$(), gin$(), gmid$(), grad$(), hout$(), hin$(), roll$()) DECLARE SUB OutputData (mag$(), runnumber$, magday$(), magtime$(), include$(), gout$(), gin$(), gmid$(), grad$(), hout$(), hin$(), roll$()) DECLARE SUB PlotData (mag$()) 'BLSUM: This program summarizes the measurements made during ' a Hysteresis run. It extracts the measurement made at 650A ' and appends it to the summary file BLSUM.DAT. ' 'Phil Radusewicz 8/18/94 DIM mag$(1 TO 2) CALL GetMagnetRun(mag$(), runnumber$) CALL PlotData(mag$()) SUB DisplayFileInfo (mag$(), runnumber$, magday$(), magtime$(), include$(), gout$(), gin$(), gmid$(), grad$(), hout$(), hin$(), roll$()) nmags% = 1 'Display the magnet file information for magnet under test: FOR m = 1 TO nmags% CLS filein% = FREEFILE filein2% = FREEFILE IF VAL(runnumber$) < 10 THEN infile$ = "\philr\bfact\data\gapdat.ru" + runnumber$ IF VAL(runnumber$) > 10 THEN infile$ = "\philr\bfact\data\gapdat.r" + runnumber$ 'IF VAL(runnumber$) < 10 THEN infile$ = "\magdata\" + mag$(m) + "\gapdat.ru" + runnumber$ 'IF VAL(runnumber$) > 10 THEN infile$ = "\magdata\" + mag$(m) + "\gapdat.r" + runnumber$ 'Read file gapdat.ru# to extract 650A test data OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 24 LINE INPUT #filein%, include$(m) IF i >= 1 AND i <= 9 THEN PRINT include$(m) IF i >= 11 AND i <= 19 THEN PRINT include$(m) IF i >= 20 AND i <= 24 THEN PRINT include$(m) IF i = 2 THEN magday$(m) = include$(m) IF i = 3 THEN magtime$(m) = include$(m) IF i = 13 THEN gout$(m) = include$(m) IF i = 14 THEN gin$(m) = include$(m) IF i = 15 THEN gmid$(m) = include$(m) IF i = 16 THEN grad$(m) = include$(m) IF i = 20 THEN hout$(m) = include$(m) IF i = 21 THEN hin$(m) = include$(m) IF i = 24 THEN roll$(m) = include$(m) NEXT CLOSE filein% IF m = 1 THEN PRINT PRINT "Press any key to continue: "; INPUT temp$ END IF NEXT END SUB SUB GetDate (plotdate$) plotdate$ = DATE$ 'Reformat the file date: day$ = MID$(plotdate$, 1, 2) mon$ = MID$(plotdate$, 4, 2) year$ = MID$(plotdate$, 9, 2) plotdate$ = day$ + "/" + mon$ + "/" + year$ END SUB SUB GetMagnetRun (mag$(), runnumber$) DIM magday$(2), magtime$(2), include$(2), include2$(2) DIM gout$(2), gin$(2), gmid$(2), grad$(2), hout$(2), hin$(2), roll$(2) CLS PRINT PRINT PRINT "GAPSUM: Program summary of GAP Measurements made on" PRINT " the B-Factory dipoles during production testing." PRINT PRINT "Would you like to include a new set of magnets in the summary [N]: "; INPUT response$ response$ = UCASE$(response$) IF response$ = "Y" THEN PRINT PRINT "Input magnet name: "; INPUT mag$(1) PRINT "Input run number: "; INPUT runnumber$ CALL DisplayFileInfo(mag$(), runnumber$, magday$(), magtime$(), include$(), gout$(), gin$(), gmid$(), grad$(), hout$(), hin$(), roll$()) CALL OutputData(mag$(), runnumber$, magday$(), magtime$(), include$(), gout$(), gin$(), gmid$(), grad$(), hout$(), hin$(), roll$()) END IF END SUB SUB GetTime (plottime$) T$ = TIME$ hr = VAL(T$) IF hr < 12 THEN ampm$ = " AM" ELSE ampm$ = " PM" IF hr > 12 THEN hr = hr - 12 plottime$ = STR$(hr) + RIGHT$(T$, 6) + ampm$ END SUB SUB OutputData (mag$(), runnumber$, magday$(), magtime$(), include$(), gout$(), gin$(), gmid$(), grad$(), hout$(), hin$(), roll$()) DIM gout!(2), gin!(2), gmid!(2), grad!(2), hout!(2), hin!(2), roll!(2) DIM goute!(2), gine!(2), gmide!(2), grade!(2), houte!(2), hine!(2), rolle!(2) CLS PRINT PRINT PRINT "GAPSUM: Program summary of GAP Measurements made on" PRINT " the B-Factory dipoles during production testing." PRINT PRINT "The following magnet information has been entered:" PRINT PRINT USING "Magnet number: &"; mag$(1) PRINT USING "Magnet run number: &"; runnumber$ PRINT PRINT "Would you like to include this run in the summary [Y]: "; INPUT response$ response$ = UCASE$(response$) IF response$ <> "N" THEN nmags% = 1 PRINT FOR m = 1 TO nmags% 'Reformat the file date: day$ = MID$(magday$(m), 7, 2) mon$ = MID$(magday$(m), 10, 2) year$ = MID$(magday$(m), 15, 2) magday$(m) = day$ + "/" + mon$ + "/" + year$ 'Reformat the file time: magtime$(m) = MID$(magtime$(m), 7, 5) 'Covert strings to numeric values inorder to reformat output: gout!(m) = VAL(MID$(gout$(m), 33, 9)) goute!(m) = VAL(MID$(gout$(m), 46, 9)) gin!(m) = VAL(MID$(gin$(m), 32, 9)) gine!(m) = VAL(MID$(gin$(m), 46, 9)) gmid!(m) = VAL(MID$(gmid$(m), 32, 9)) gmide!(m) = VAL(MID$(gmid$(m), 46, 9)) dec1% = INSTR(grad$(m), ".") dec2% = INSTR(MID$(grad$(m), dec1% + 2, 30), ".") + dec1% + 2 grad!(m) = 1000 * VAL(MID$(grad$(m), dec1% - 2, 13)) grade!(m) = 1000 * VAL(MID$(grad$(m), dec2% - 2, 13)) hout!(m) = VAL(MID$(hout$(m), 39, 9)) houte!(m) = VAL(MID$(hout$(m), 53, 9)) IF INSTR(hout$(m), "E-0") > 30 THEN dec1% = INSTR(hout$(m), ".") dec2% = INSTR(MID$(hout$(m), dec1% + 2, 30), ".") + dec1% + 2 hout!(m) = VAL(MID$(hout$(m), dec1% - 2, 13)) houte!(m) = VAL(MID$(hout$(m), dec2% - 2, 9)) END IF hin!(m) = VAL(MID$(hin$(m), 38, 9)) hine!(m) = VAL(MID$(hin$(m), 52, 9)) IF INSTR(hout$(m), "E-0") > 30 THEN dec1% = INSTR(hin$(m), ".") dec2% = INSTR(MID$(hin$(m), dec1% + 2, 30), ".") + dec1% + 2 hin!(m) = VAL(MID$(hin$(m), dec1% - 2, 13)) hine!(m) = VAL(MID$(hin$(m), dec2% - 2, 9)) END IF dec1% = INSTR(roll$(m), ".") dec2% = INSTR(MID$(roll$(m), dec1% + 2, 30), ".") + dec1% + 2 roll!(m) = VAL(MID$(roll$(m), dec1% - 2, 13)) rolle!(m) = VAL(MID$(roll$(m), dec2% - 2, 9)) NEXT FOR m = 1 TO nmags% 'Output the GAP data for the magnets under test to GAPSUM.DAT PRINT USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT USING "####.## ##.#### "; gout!(m); goute!(m); PRINT USING "####.## ##.#### "; gin!(m); gine!(m); PRINT USING "####.## ##.####"; gmid!(m); gmide!(m) fileout% = FREEFILE outfile$ = "\philr\bfact\summary\gapsum.dat" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT #fileout%, USING "####.## ##.#### "; gout!(m); goute!(m); PRINT #fileout%, USING "####.## ##.#### "; gin!(m); gine!(m); PRINT #fileout%, USING "####.## ##.####"; gmid!(m); gmide!(m) CLOSE fileout% NEXT PRINT "Added to file GAPSUM.DAT" FOR m = 1 TO nmags% 'Output the GAP data for the magnets under test to HGHSUM.DAT PRINT USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT USING "##.#### ##.#### "; hout!(m); houte!(m); PRINT USING "##.#### ##.####"; hin!(m); hine!(m) fileout% = FREEFILE outfile$ = "\philr\bfact\summary\hghsum.dat" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT #fileout%, USING "##.#### ##.#### "; hout!(m); houte!(m); PRINT #fileout%, USING "##.#### ##.####"; hin!(m); hine!(m) CLOSE fileout% NEXT PRINT "Added to file HGHSUM.DAT" FOR m = 1 TO nmags% 'Output the GAP data for the magnets under test to ROLLSUM.DAT PRINT USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT USING "##.###### ##.###### "; roll!(m); rolle!(m) fileout% = FREEFILE outfile$ = "\philr\bfact\summary\rollsum.dat" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT #fileout%, USING "##.###### ##.###### "; roll!(m); rolle!(m) CLOSE fileout% NEXT PRINT "Added to file ROLLSUM.DAT" FOR m = 1 TO nmags% 'Output the GAP data for the magnets under test to GRADSUM.DAT PRINT USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT USING "##.###### ##.###### "; grad!(m); grade!(m) fileout% = FREEFILE outfile$ = "\philr\bfact\summary\gradsum.dat" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & "; mag$(m); runnumber$; magday$(m); magtime$(m); PRINT #fileout%, USING "##.###### ##.###### "; grad!(m); grade!(m) CLOSE fileout% NEXT PRINT "Added to file GRADSUM.DAT" END IF END SUB SUB PlotData (mag$()) DIM yname$(8) yname$(1) = "Outer Gap Width (mils)" yname$(2) = "Inner Gap Width (mils)" yname$(3) = "Middle Gap Width (mils)" yname$(4) = "Outer Midplane Height (mils)" yname$(5) = "Inner Midplane Height (mils)" yname$(6) = "Gradient (E-03/m)" yname$(7) = "Roll Angle (mrads)" sigma$ = "Standard Deviation " mils$ = "(mils)" mrads$ = "(mrads)" em$ = "(E-03/m)" group$ = "Summary File: " PRINT PRINT "Would you like to plot any data [Y]: "; INPUT response$ response$ = UCASE$(response$) WHILE response$ <> "N" SHELL "cls" PRINT PRINT "GAPSUM: Plot summary of GAP measurements made at on" PRINT " the B-Factory dipoles during production testing." PRINT PRINT "Select from the following:" PRINT PRINT " 1) Outer Gap Width" PRINT " 2) Inner Gap Width" PRINT " 3) Middle Gap Width" PRINT " 4) Outer Midplane Height" PRINT " 5) Inner Midplane Height" PRINT " 6) Gradient" PRINT " 7) Roll Angle" PRINT " 8) STANDARD DEVIATIONS" PRINT " 9) OUTPUT TO PRINTER" PRINT " 10) EXIT" PRINT PRINT "Input Selection: "; INPUT selection% IF selection% = 10 THEN EXIT SUB CALL GetTime(plottime$) CALL GetDate(plotdate$) plot% = 0 IF selection% = 9 THEN plot% = 1 PRINT "Input plot to print: "; INPUT selection% END IF std% = 0 IF selection% = 8 THEN std% = 1 PRINT "Input Standard Deviation selection : "; INPUT selection% IF selection% >= 1 AND selection% <= 5 THEN stitle$ = sigma$ + mils$ IF selection% = 6 THEN stitle$ = sigma$ + em$ IF selection% = 7 THEN stitle$ = sigma$ + mrads$ END IF IF selection% >= 1 AND selection% <= 3 THEN sumfile$ = "GAPSUM.DAT" IF selection% >= 4 AND selection% <= 5 THEN sumfile$ = "HGHSUM.DAT" IF selection% = 6 THEN sumfile$ = "GRADSUM.DAT" IF selection% = 7 THEN sumfile$ = "ROLLSUM.DAT" title$ = yname$(selection%) IF selection% = 4 THEN selection% = 1 IF selection% = 5 THEN selection% = 2 IF selection% = 6 THEN selection% = 1 IF selection% = 7 THEN selection% = 1 td$ = "xiiiiiiiiii" IF std% = 0 THEN MID$(td$, 4 + 2 * selection% - 1) = "y" IF std% = 1 THEN MID$(td$, 4 + 2 * selection%) = "y" fileout% = FREEFILE outfile$ = "\philr\bfact\summary\epgap.dat" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "/fpo bg" PRINT #fileout%, "//rem_tmps" PRINT #fileout%, "//abs_err" PRINT #fileout%, " " IF plot% = 1 THEN PRINT #fileout%, "/fpp ps" PRINT #fileout%, "/ag" PRINT #fileout%, "/se y on" PRINT #fileout%, "/td ", td$ PRINT #fileout%, "/sc off" PRINT #fileout%, USING "/ac \philr\bfact\summary\&"; sumfile$ PRINT #fileout%, "/et g 'B-Factory Dipole Measurements: "; PRINT #fileout%, title$; "'" PRINT #fileout%, "/et x 'Magnet Number'" IF std% = 0 THEN PRINT #fileout%, "/et y "; "'"; title$; "'" IF std% = 1 THEN PRINT #fileout%, "/et y "; "'"; stitle$; "'" PRINT #fileout%, USING "/aa 0.02 0.02 'Date/Time: & &"; plotdate$; plottime$; PRINT #fileout%, "' A" PRINT #fileout%, USING "/aa 0.675 0.02 '&"; group$; PRINT #fileout%, USING "&"; sumfile$; "' A" PRINT #fileout%, "//wait" IF plot% = 1 THEN PRINT #fileout%, "/fp p" PRINT #fileout%, "/ed g" PRINT #fileout%, "/fq y" CLOSE fileout% SHELL "\easyplot\ep \philr\bfact\summary\epgap.dat" WEND END SUB