DECLARE SUB rtsum (mag$(), rt$) DECLARE SUB blsum (mag$(), bl$) DECLARE SUB harsum (mag$(), har$) DECLARE SUB FileCheck (mag$(), rt$, bl$, har$, ok$) DECLARE SUB Backup (mag$()) DECLARE SUB makedir (m%, mag$()) DECLARE SUB backcoil (m%, mag$()) DECLARE SUB RTGetMagnetInfo (mag$(), rt$, rtday$, rttime$, rtdata$(), rtref$) DECLARE SUB RTOutputSummary (mag$(), rt$, rtday$, rttime$, rtdata$(), rtref$) DECLARE SUB BLGetMagnetInfo (mag$(), bl$, blday$, bltime$, bldata$(), bldata2$(), blref$) DECLARE SUB BLOutputSummary (mag$(), bl$, blday$, bltime$, bldata$(), bldata2$(), blref$) DECLARE SUB HARGetMagnetInfo (mag$(), har$, harday$, hartime$, hardata$(), hardata2$(), harref$) DECLARE SUB HAROutputSummary (mag$(), har$, harday$, hartime$, hardata$(), hardata2$(), harref$) 'SUMMARY: Program which checks and summaries the data taken during ' Magnetic Measurements on the B-Factory Dipoles ' '8/31/94 Phil Radusewicz DIM mag$(1 TO 2) CLS PRINT PRINT "MAGDONE: Program which checks and summaries the data taken during" PRINT " Magnetic Measurements on the B-Factory Dipoles" PRINT PRINT "1) Magnet Identification:" PRINT " Test Stand D1 Magnet: "; INPUT mag$(1) PRINT " Test Stand D2 Magnet: "; INPUT mag$(2) PRINT PRINT PRINT "Input the last run number for each of the following:" PRINT PRINT "2) RT Resistance and Temperature Run: "; INPUT rt$ PRINT "3) BL Hysteresis Measurement Run: "; INPUT bl$ PRINT "4) HAR Field Uniformity Measurement Run: "; INPUT har$ meas% = 1 WHILE meas% = 1 OR meas% = 2 OR meas% = 3 OR meas% = 4 meas% = 0 CLS PRINT PRINT "MAGDONE: Program which checks and summaries the data taken during" PRINT " Magnetic Measurements on the B-Factory Dipoles" PRINT PRINT "The following information has been entered:" PRINT PRINT "1) Magnet Identification:" PRINT USING " Test Stand D1 Magnet: &"; mag$(1) PRINT USING " Test Stand D2 Magnet: &"; mag$(2) PRINT PRINT USING "2) RT Resistance and Temperature Run: &"; rt$ PRINT USING "3) BL Hysteresis Measurement Run: &"; bl$ PRINT USING "4) HAR Field Uniformity Measurement Run: &"; har$ PRINT PRINT "Enter number to change else to continue: "; INPUT meas% IF meas% = 1 OR meas% = 2 OR meas% = 3 OR meas% = 4 THEN IF meas% = 1 THEN PRINT "1) Magnet Identification:" PRINT USING " Test Stand D1 Magnet [&]: "; mag$(1); INPUT tmp$ IF tmp$ <> "" THEN mag$(1) = tmp$ PRINT USING " Test Stand D2 Magnet [&]: "; mag$(2); INPUT tmp$ IF tmp$ <> "" THEN mag$(2) = tmp$ END IF IF meas% = 2 THEN PRINT USING "2) RT Resistance and Temperature Run:[&] "; rt$; INPUT tmp$ IF tmp$ <> "" THEN rt$ = tmp$ END IF IF meas% = 3 THEN PRINT USING "3) BL Hysteresis Measurement Run:[&] "; bl$; INPUT tmp$ IF tmp$ <> "" THEN bl$ = tmp$ END IF IF meas% = 4 THEN PRINT USING "4) HAR Field Uniformity Measurement Run:[&] "; har$; INPUT tmp$ IF tmp$ <> "" THEN har$ = tmp$ END IF END IF WEND 'Check to see if the files exist. If not exist program. CALL FileCheck(mag$(), rt$, bl$, har$, ok$) IF ok$ = "n" THEN END 'Call the routines which reads the data and summarizes the results: CALL rtsum(mag$(), rt$) CALL blsum(mag$(), bl$) CALL harsum(mag$(), har$) 'Call the routine which will backup the data to a floppy in drive b: CALL Backup(mag$()) END SUB backcoil (m%, mag$()) fileout% = FREEFILE outfile$ = "\philr\bfact\progs\backcoil.bat" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "copy c:\magdata\" + mag$(m%) + "\bl*.* b:\" + mag$(m%) + "\bl" PRINT #fileout%, "copy c:\magdata\" + mag$(m%) + "\har*.* b:\" + mag$(m%) + "\har" PRINT #fileout%, "copy c:\magdata\" + mag$(m%) + "\rt*.* b:\" + mag$(m%) + "\rt" PRINT #fileout%, "copy c:\magdata\" + mag$(m%) + "\nmrh*.* b:\" + mag$(m%) + "\nmrh" CLOSE fileout% SHELL outfile$ END SUB SUB Backup (mag$()) PRINT PRINT PRINT "Next, backup the Magnetic Measurement Data to Floppy " SHELL "pause" FOR m% = 1 TO 2 SHELL "cls" PRINT " " PRINT "BACKUP: This program creates a directory structure for " PRINT USING " magnet & on a floppy in drive b: and then does a"; mag$(m%) PRINT " backup of all files created during magnetic measurements." PRINT 'Call routine which will create directory structure on floppy in drive b: CALL makedir(m%, mag$()) 'Call routine which will backup the data to the disk CALL backcoil(m%, mag$()) CLS PRINT PRINT USING "BACKUP: The backup of magnet & is complete."; mag$(m%) PRINT PRINT "Remove the floppy and label it as follows:" PRINT PRINT USING " Magnet & &"; mag$(m%); DATE$ PRINT " B-Factory Dipole" PRINT " RT, BL, HAR" PRINT IF m% = 1 THEN SHELL "pause" NEXT PRINT PRINT "The summary and backup routine MAGDONE is complete." PRINT PRINT "Now, take both floppies to the Gap Measurements station and" PRINT USING "backup the gap measurement data for magnets & and &."; mag$(1); mag$(2) END SUB SUB BLGetMagnetInfo (mag$(), bl$, blday$, bltime$, bldata$(), bldata2$(), blref$) 'Display the magnet file information for magnet under test: FOR m = 1 TO 2 filein% = FREEFILE 'IF VAL(bl$) < 10 THEN infile$ = "\philr\bfact\data\bldat.ru" + bl$ 'IF VAL(bl$) > 10 THEN infile$ = "\philr\bfact\data\bldat.r" + bl$ 'IF VAL(bl$) < 10 THEN infile2$ = "\philr\bfact\data\bllog.ru" + bl$ 'IF VAL(bl$) > 10 THEN infile2$ = "\philr\bfact\data\bllog.r" + bl$ IF VAL(bl$) < 10 THEN infile$ = "\magdata\" + mag$(m) + "\bldat.ru" + bl$ IF VAL(bl$) > 10 THEN infile$ = "\magdata\" + mag$(m) + "\bldat.r" + bl$ IF VAL(bl$) < 10 THEN infile2$ = "\magdata\" + mag$(m) + "\bllog.ru" + bl$ IF VAL(bl$) > 10 THEN infile2$ = "\magdata\" + mag$(m) + "\bllog.r" + bl$ 'Read file bldat.ru# to extract 650A test data OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 48 LINE INPUT #filein%, bldata$(m) IF i = 2 THEN blday$ = bldata$(m) IF i = 3 THEN bltime$ = bldata$(m) IF i = 28 THEN blref$ = bldata$(m) NEXT CLOSE filein% 'Read file bllog.ru# to extract integrated voltage filein2% = FREEFILE OPEN infile2$ FOR INPUT AS filein2% FOR i = 1 TO 57 LINE INPUT #filein2%, bldata2$(m) NEXT CLOSE filein2% NEXT END SUB SUB BLOutputSummary (mag$(), bl$, blday$, bltime$, bldata$(), bldata2$(), blref$) DIM d$(1 TO 2) d$(1) = "1" d$(2) = "2" 'Reformat the file date: day$ = MID$(blday$, 7, 2) mon$ = MID$(blday$, 10, 2) year$ = MID$(blday$, 15, 2) blday$ = day$ + "/" + mon$ + "/" + year$ 'Reformat the file time: bltime$ = MID$(bltime$, 7, 5) IF response$ <> "N" THEN ' PRINT PRINT "2) Hysteresis Measurement Summary BLSUM.TXT and BLREF.TXT" FOR m = 1 TO 2 'Reformat the output for the magnet under test: cur$ = MID$(bldata$(m), 1, 7) vt$ = MID$(bldata2$(m), 16, 9) vtxc$ = MID$(bldata$(m), 10, 7) ratio$ = MID$(bldata$(m), 28, 7) bdl$ = MID$(bldata$(m), 46, 7) tf$ = MID$(bldata$(m), 64, 7) 'Output the data for the magnets under test to BLSUM.TXT ' PRINT USING "\ \ \\ & & & &"; mag$(m); bl$; d$(m); blday$; bltime$; ' PRINT USING "& & & & & &"; cur$; vt$; vtxc$; ratio$; bdl$; tf$ fileout% = FREEFILE outfile$ = "\philr\bfact\summary\blsum.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & & &"; mag$(m); bl$; d$(m); blday$; bltime$; PRINT #fileout%, USING "& & & & & &"; cur$; vt$; vtxc$; ratio$; bdl$; tf$ CLOSE fileout% NEXT 'Reformat the output for the reference magnet: cur$ = MID$(blref$, 2, 6) vt$ = MID$(blref$, 10, 7) vte$ = MID$(blref$, 19, 7) bdl$ = MID$(blref$, 28, 7) tf$ = MID$(blref$, 46, 7) 'Output the data for the reference magnet to BLREF.TXT ' PRINT ' PRINT USING "000 & & "; blday$; bltime$; ' PRINT USING "& & & & &"; cur$; vt$; vte$; bdl$; tf$ fileout% = FREEFILE outfile$ = "\philr\bfact\summary\blref.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "000 & & "; blday$; bltime$; PRINT #fileout%, USING "& & & & &"; cur$; vt$; vte$; bdl$; tf$ CLOSE fileout% END IF END SUB SUB blsum (mag$(), bl$) DIM bldata$(1 TO 2), bldata2$(1 TO 2) PRINT CALL BLGetMagnetInfo(mag$(), bl$, blday$, bltime$, bldata$(), bldata2$(), blref$) CALL BLOutputSummary(mag$(), bl$, blday$, bltime$, bldata$(), bldata2$(), blref$) END SUB SUB FileCheck (mag$(), rt$, bl$, har$, ok$) 'Check to see if data files exist, if not then exit to check IF VAL(rt$) < 10 THEN rtrun$ = ".ru" + rt$ IF VAL(rt$) > 10 THEN rtrun$ = ".r" + rt$ IF VAL(bl$) < 10 THEN blrun$ = ".ru" + bl$ IF VAL(bl$) > 10 THEN blrun$ = ".r" + bl$ IF VAL(har$) < 10 THEN harrun$ = ".ru" + har$ IF VAL(har$) > 10 THEN harrun$ = ".r" + har$ magpath$ = "c:\magdata\" + mag$(1) + "\" 'magpath$ = "c:\philr\bfact\data\" rtcheck$ = DIR$(magpath$ + "rtlog" + rtrun$) blcheck$ = DIR$(magpath$ + "bllog" + blrun$) harcheck$ = DIR$(magpath$ + "harlog" + harrun$) IF rtcheck$ = "" OR blcheck$ = "" OR harcheck$ = "" THEN PRINT PRINT PRINT "The following runs do not exist:" IF rtcheck$ = "" THEN PRINT USING "2) RT Resistance and Temperature measurement Run: &"; rt$ IF blcheck$ = "" THEN PRINT USING "3) BL Hysteresis measurement Run: &"; bl$ IF harcheck$ = "" THEN PRINT USING "4) HAR Field Uniformity measurement Run: &"; har$ PRINT PRINT USING "Check the directories \magdata\& and \magdata\& "; mag$(1); mag$(2) PRINT "to see if the corresponding files with these run numbers actually exist." ok$ = "n" END IF END SUB SUB HARGetMagnetInfo (mag$(), har$, harday$, hartime$, hardata$(), hardata2$(), harref$) 'Display the magnet file information for magnet under test: FOR m = 1 TO 2 filein% = FREEFILE filein2% = FREEFILE 'IF VAL(har$) < 10 THEN infile$ = "\philr\bfact\data\hardat.ru" + har$ 'IF VAL(har$) > 10 THEN infile$ = "\philr\bfact\data\hardat.r" + har$ 'IF VAL(har$) < 10 THEN infile2$ = "\philr\bfact\data\harlog.ru" + har$ 'IF VAL(har$) > 10 THEN infile2$ = "\philr\bfact\data\harlog.r" + har$ IF VAL(har$) < 10 THEN infile$ = "\magdata\" + mag$(m) + "\hardat.ru" + har$ IF VAL(har$) > 10 THEN infile$ = "\magdata\" + mag$(m) + "\hardat.r" + har$ IF VAL(har$) < 10 THEN infile2$ = "\magdata\" + mag$(m) + "\harlog.ru" + har$ IF VAL(har$) > 10 THEN infile2$ = "\magdata\" + mag$(m) + "\harlog.r" + har$ 'Read file hardat.ru# to extract 650A test data OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 34 LINE INPUT #filein%, hardata$(m) IF i = 2 THEN harday$ = hardata$(m) IF i = 3 THEN hartime$ = hardata$(m) IF i = 25 THEN harref$ = hardata$(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%, hardata2$(m) NEXT CLOSE filein2% NEXT END SUB SUB HAROutputSummary (mag$(), har$, harday$, hartime$, hardata$(), hardata2$(), harref$) DIM d$(2) d$(1) = "1" d$(2) = "2" 'Reformat the file date: day$ = MID$(harday$, 7, 2) mon$ = MID$(harday$, 10, 2) year$ = MID$(harday$, 15, 2) harday$ = day$ + "/" + mon$ + "/" + year$ 'Reformat the file time: hartime$ = MID$(hartime$, 7, 5) IF response$ <> "N" THEN ' PRINT PRINT "3) Field Uniformity Measurement Summary HARSUM.TXT and HARREF.TXT" FOR m = 1 TO 2 'Reformat the output for the magnet under test: cur$ = MID$(hardata$(m), 1, 7) vt$ = MID$(hardata2$(m), 16, 9) vtxc$ = MID$(hardata$(m), 14, 7) ratio$ = MID$(hardata$(m), 50, 7) bdl$ = MID$(hardata$(m), 32, 7) tf! = 1000! * VAL(bdl$) / VAL(cur$) 'Output the data for the magnets under test to HARSUM.TXT ' PRINT USING "\ \ \\ & & & &"; mag$(m); har$; d$(m); harday$; hartime$; ' PRINT USING "& & & & & #.#####"; cur$; vt$; vtxc$; ratio$; bdl$; tf! fileout% = FREEFILE outfile$ = "\philr\bfact\summary\harsum.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & & &"; mag$(m); har$; d$(m); harday$; hartime$; PRINT #fileout%, USING "& & & & & #.#####"; cur$; vt$; vtxc$; ratio$; bdl$; tf! CLOSE fileout% NEXT 'Reformat the output for the reference magnet: cur$ = MID$(harref$, 2, 6) vt$ = MID$(harref$, 14, 7) vte$ = MID$(harref$, 23, 7) bdl$ = MID$(harref$, 32, 7) tf! = 1000! * VAL(bdl$) / VAL(cur$) 'Output the data for the reference magnet to HARREF.TXT ' PRINT ' PRINT USING "000 & & "; harday$; hartime$; ' PRINT USING "& & & & #.#####"; cur$; vt$; vte$; bdl$; tf! fileout% = FREEFILE outfile$ = "\philr\bfact\summary\harref.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "000 & & "; harday$; hartime$; PRINT #fileout%, USING "& & & & #.#####"; cur$; vt$; vte$; bdl$; tf! CLOSE fileout% END IF END SUB SUB harsum (mag$(), har$) DIM hardata$(1 TO 2), hardata2$(1 TO 2) PRINT CALL HARGetMagnetInfo(mag$(), har$, harday$, hartime$, hardata$(), hardata2$(), harref$) CALL HAROutputSummary(mag$(), har$, harday$, hartime$, hardata$(), hardata2$(), harref$) END SUB SUB makedir (m%, mag$()) IF m% = 1 THEN PRINT PRINT USING "Magnet & Data backup routine"; mag$(m%) PRINT PRINT "Insert the 1st Floppy into drive b: " END IF IF m% = 2 THEN PRINT PRINT USING "Magnet & Data backup routine"; mag$(m%) PRINT PRINT "Insert the 2nd Floppy into drive b: " END IF SHELL "pause" fileout% = FREEFILE outfile$ = "\philr\bfact\progs\makedir.bat" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "echo off" PRINT #fileout%, "label b:mag" + mag$(m%) PRINT #fileout%, "b:" PRINT #fileout%, "mkdir " + mag$(m%) PRINT #fileout%, "cd " + mag$(m%) PRINT #fileout%, "mkdir gap" PRINT #fileout%, "mkdir rt" PRINT #fileout%, "mkdir bl" PRINT #fileout%, "mkdir har" PRINT #fileout%, "mkdir nmrh" PRINT #fileout%, "dir" PRINT #fileout%, "cd .." PRINT #fileout%, "c:" CLOSE fileout% SHELL outfile$ END SUB SUB RTGetMagnetInfo (mag$(), rt$, rtday$, rttime$, rtdata$(), rtref$) 'Get the magnet file information: FOR m = 1 TO 2 filein% = FREEFILE IF VAL(rt$) < 10 THEN infile$ = "\magdata\" + mag$(m) + "\rtlog.ru" + rt$ IF VAL(rt$) > 10 THEN infile$ = "\magdata\" + mag$(m) + "\rtlog.r" + rt$ 'IF VAL(rt$) < 10 THEN infile$ = "\philr\bfact\data\rtlog.ru" + rt$ 'IF VAL(rt$) > 10 THEN infile$ = "\philr\bfact\data\rtlog.r" + rt$ OPEN infile$ FOR INPUT AS filein% FOR i = 1 TO 18 LINE INPUT #filein%, rtdata$(m) IF i = 2 THEN rtday$ = rtdata$(m) IF i = 3 THEN rttime$ = rtdata$(m) NEXT ' Get information for the reference magnet FOR i = 19 TO 38 LINE INPUT #filein%, rtref$ NEXT CLOSE filein% NEXT END SUB SUB RTOutputSummary (mag$(), rt$, rtday$, rttime$, rtdata$(), rtref$) DIM d$(1 TO 2) d$(1) = "1" d$(2) = "2" 'Reformat the file date: day$ = MID$(rtday$, 7, 2) mon$ = MID$(rtday$, 10, 2) year$ = MID$(rtday$, 15, 2) rtday$ = day$ + "/" + mon$ + "/" + year$ 'Reformat the file time: rttime$ = MID$(rttime$, 7, 5) IF response$ <> "N" THEN PRINT PRINT "1) Resistance and Temperature Summary RTSUM.TXT and RTREF.TXT:" FOR m = 1 TO 2 'Reformat the output for the magnets under test: magtime$ = MID$(rtdata$(m), 1, 5) cur$ = MID$(rtdata$(m), 11, 6) vol$ = MID$(rtdata$(m), 19, 6) res$ = MID$(rtdata$(m), 28, 5) in$ = MID$(rtdata$(m), 36, 5) out$ = MID$(rtdata$(m), 44, 5) iron$ = MID$(rtdata$(m), 52, 5) coil$ = MID$(rtdata$(m), 60, 5) room$ = MID$(rtdata$(m), 68, 5) ' PRINT USING "\ \ \\ & & & &"; mag$(m); rt$; d$(m); rtday$; rttime$; ' PRINT USING "& & & & & & & &"; cur$; vol$; res$; in$; out$; iron$; coil$; room$ fileout% = FREEFILE outfile$ = "\philr\bfact\summary\rtsum.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "\ \ \\ & & & &"; mag$(m); rt$; d$(m); rtday$; rttime$; PRINT #fileout%, USING "& & & & & & & &"; cur$; vol$; res$; in$; out$; iron$; coil$; room$ CLOSE fileout% NEXT 'Reformat the output for the reference magnet: magtime$ = MID$(rtref$, 1, 5) cur$ = MID$(rtref$, 11, 6) vol$ = MID$(rtref$, 19, 6) res$ = MID$(rtref$, 28, 5) in$ = MID$(rtref$, 36, 5) out$ = MID$(rtref$, 44, 5) iron$ = MID$(rtref$, 52, 5) coil$ = MID$(rtref$, 60, 5) room$ = MID$(rtref$, 68, 5) ' PRINT ' PRINT USING "000 & & "; rtday$; rttime$; ' PRINT USING "& & & & & & & &"; cur$; vol$; res$; in$; out$; iron$; coil$; room$ fileout% = FREEFILE outfile$ = "\philr\bfact\summary\rtref.txt" OPEN outfile$ FOR APPEND AS fileout% PRINT #fileout%, USING "000 & & "; rtday$; rttime$; PRINT #fileout%, USING "& & & & & & & &"; cur$; vol$; res$; in$; out$; iron$; coil$; room$ CLOSE fileout% END IF END SUB SUB rtsum (mag$(), rt$) DIM rtdata$(1 TO 2) CLS PRINT PRINT "SUMMARY: Program which checks and summaries the data taken during" PRINT " Magnetic Measurements on the B-Factory Dipoles" PRINT " The following will be added to the summary files." PRINT PRINT PRINT " The following summary files will be updated:" CALL RTGetMagnetInfo(mag$(), rt$, rtday$, rttime$, rtdata$(), rtref$) CALL RTOutputSummary(mag$(), rt$, rtday$, rttime$, rtdata$(), rtref$) END SUB