DECLARE SUB GetTime (plottime$) DECLARE SUB GetDate (plotdate$) DECLARE SUB GetMagnetRun (mag$(), runnumber$) DECLARE SUB DisplayFileInfo (mag$(), runnumber$, magday$(), magtime$(), include$(), include2$(), ref$) DECLARE SUB OutputData (mag$(), runnumber$, magday$(), magtime$(), include$(), include2$(), ref$) DECLARE SUB PlotData (mag$()) 'HARSUM: This program summarizes the measurements made during a ' Field Uniformity run. It extracts the measurement made at 650A ' and appends it to the summary file HARSUM.DAT. ' 'Phil Radusewicz 8/16/94 DIM mag$(1 TO 2) CALL GetMagnetRun(mag$(), runnumber$) CALL PlotData(mag$()) SUB DisplayFileInfo (mag$(), runnumber$, magday$(), magtime$(), include$(), include2$(), ref$) 'Display the magnet file information for magnet under test: FOR m = 1 TO 2 CLS filein% = FREEFILE filein2% = FREEFILE IF VAL(runnumber$) < 10 THEN infile$ = "\magdata\" + mag$(m) + "\hardat.ru" + runnumber$ IF VAL(runnumber$) > 10 THEN infile$ = "\magdata\" + mag$(m) + "\hardat.r" + runnumber$ IF VAL(runnumber$) < 10 THEN infile2$ = "\magdata\" + mag$(m) + "\harlog.ru" + runnumber$ IF VAL(runnumber$) > 10 THEN infile2$ = "\magdata\" + mag$(m) + "\harlog.r" + runnumber$ 'Read file hardat.ru# to extract 650A test data OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 34 LINE INPUT #filein%, include$(m) IF i = 2 THEN magday$(m) = include$(m) IF i = 3 THEN magtime$(m) = include$(m) IF i >= 1 AND i <= 18 THEN PRINT include$(m) IF i = 25 THEN ref$ = include$(m) IF i >= 30 AND i <= 32 THEN PRINT include$(m) IF i = 34 THEN PRINT include$(m) NEXT CLOSE filein% 'Read file harlog.ru# to extract integrated voltage OPEN infile2$ FOR INPUT AS filein2% FOR i = 1 TO 36 LINE INPUT #filein2%, include2$(m) NEXT CLOSE filein2% IF m = 1 THEN PRINT PRINT "Press any key to see information on the next magnet: "; INPUT temp$ END IF IF m = 2 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) CLS PRINT PRINT PRINT "HARSUM: Program summary of Field Uniformity Measurements made" PRINT " on 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 on test stand D1: "; INPUT mag$(1) PRINT "Input magnet name on test stand D2: "; INPUT mag$(2) PRINT "Input run number: "; INPUT runnumber$ CALL DisplayFileInfo(mag$(), runnumber$, magday$(), magtime$(), include$(), include2$(), ref$) CALL OutputData(mag$(), runnumber$, magday$(), magtime$(), include$(), include2$(), ref$) 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$(), include2$(), ref$) DIM d$(2) d$(1) = "1" d$(2) = "2" CLS PRINT PRINT PRINT "HARSUM: Program summary of Field Uniformity Measurements made" PRINT " on the B-Factory dipoles during production testing." PRINT PRINT "The following magnet information has been entered:" PRINT PRINT USING "Magnet on test stand D1: &"; mag$(1) PRINT USING "Magnet on test stand D2: &"; mag$(2) 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 PRINT FOR m = 1 TO 2 '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) 'Reformat the output for the magnet under test: cur$ = MID$(include$(m), 1, 7) vt$ = MID$(include2$(m), 16, 9) vtxc$ = MID$(include$(m), 14, 7) ratio$ = MID$(include$(m), 50, 7) bl$ = MID$(include$(m), 32, 7) tf! = 1000! * VAL(bl$) / VAL(cur$) 'Output the data for the magnets under test to HARSUM.TXT PRINT USING "\ \ \\ & & & &"; mag$(m); runnumber$; d$(m); magday$(m); magtime$(m); PRINT USING "& & & & & #.#####"; cur$; vt$; vtxc$; ratio$; bl$; tf! fileout% = FREEFILE outfile$ = "\philr\bfact\summary\harsum.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & & &"; mag$(m); runnumber$; d$(m); magday$(m); magtime$(m); PRINT #fileout%, USING "& & & & & #.#####"; cur$; vt$; vtxc$; ratio$; bl$; tf! CLOSE fileout% NEXT PRINT PRINT "Added to file HARSUM.TXT" 'Reformat the output for the reference magnet: cur$ = MID$(ref$, 2, 6) vt$ = MID$(ref$, 14, 7) vte$ = MID$(ref$, 23, 7) bl$ = MID$(ref$, 32, 7) tf! = 1000! * VAL(bl$) / VAL(cur$) 'Output the data for the reference magnet to HARREF.TXT PRINT PRINT PRINT USING "000 & & "; magday$(1); magtime$(1); PRINT USING "& & & & #.#####"; cur$; vt$; vte$; bl$; tf! fileout% = FREEFILE outfile$ = "\philr\bfact\summary\harref.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "000 & & "; magday$(1); magtime$(1); PRINT #fileout%, USING "& & & & #.#####"; cur$; vt$; vte$; bl$; tf! CLOSE fileout% PRINT PRINT "Added to file HARREF.TXT" PRINT END IF END SUB SUB PlotData (mag$()) DIM yname$(8) yname$(1) = "Current (A)" yname$(2) = "Integrated Voltage (Vs)" yname$(3) = "X-Cal Integrated Voltage (Vs)" yname$(4) = "Ratio to Reference" yname$(5) = "Integral Bdl (Tm)" yname$(6) = "Transfer Function (Tm/kA)" group$ = "Summary File: HARSUM.TXT" PRINT PRINT "Would you like to plot any data [Y]: "; INPUT response$ response$ = UCASE$(response$) WHILE response$ <> "N" SHELL "cls" PRINT PRINT "HARSUM: Plot summary of Field Uniformity measurements made at 650A" PRINT " on the B-Factory dipoles during production testing." PRINT PRINT "Select from the following:" PRINT PRINT " 1) Magnet Current" PRINT " 2) Integrated Voltage" PRINT " 3) X-Cal Integrated Voltage" PRINT " 4) Ratio to Reference" PRINT " 5) Integral Bdl" PRINT " 6) Transfer Function" PRINT " 7) OUTPUT TO PRINTER" PRINT " 8) EXIT" PRINT PRINT "Input Selection: "; INPUT selection% IF selection% = 8 THEN EXIT SUB CALL GetTime(plottime$) CALL GetDate(plotdate$) plot% = 0 IF selection% = 7 THEN plot% = 1 PRINT "Input plot to print: "; INPUT selection% END IF td$ = "xiiiiiiiiii" MID$(td$, 5 + selection%) = "y" fileout% = FREEFILE outfile$ = "\philr\bfact\batch\epbatch.txt" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "/fpo bg" PRINT #fileout%, "//np_legend_box" PRINT #fileout%, "//nosv" PRINT #fileout%, "//def_leg_pos 0.16 0.875" PRINT #fileout%, "//rem_tmps" PRINT #fileout%, "//rev_curves" 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%, "/ac \philr\bfact\summary\harsum.txt" PRINT #fileout%, "/et g 'B-Factory Dipole Measurements @ 650A: "; PRINT #fileout%, yname$(selection%); "'" PRINT #fileout%, "/et x 'Magnet Number'" PRINT #fileout%, "/et y "; "'"; yname$(selection%); "'" PRINT #fileout%, USING "/aa 0.02 0.02 'Date/Time: & &"; plotdate$; plottime$; PRINT #fileout%, "' A" PRINT #fileout%, "/aa 0.675 0.02 '"; group$; "' 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\batch\epbatch.txt" WEND END SUB