DECLARE SUB vaximagramp (imag!) DECLARE SUB chkbact (imag!) DECLARE SUB getbact (bact!) DECLARE SUB abort () DECLARE SUB calibrate () DECLARE SUB filesearch () DECLARE SUB startup () DECLARE SUB statout () DECLARE SUB vaximagmeas (imag!) 'SCPPC.BAS This program is used to ramp the power supply for tests ' and measurements on the injector line quadrupoles located ' in building 26, heavy assembly building. ' 'Phil Radusewicz 9/29/94 SUB abort PRINT PRINT "Aborting the SCPPC.TPU macro." PRINT "IMAG: Power Supply Control routine complete." 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "procedure nextact" PRINT #fileout%, "abort_macro('User exit')" PRINT #fileout%, "endprocedure" CLOSE fileout% 'Let SCP know that the NEXT ACTION TPU macro is ready for execution: SHELL "del BACT.OUT" END SUB SUB calibrate 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "procedure nextact" PRINT #fileout%, "enterdata ('yes') ;" PRINT #fileout%, "pushbutton('CALB ') ;" PRINT #fileout%, "wait(60) ;" PRINT #fileout%, "pushbutton('MAGDALL ') ;" PRINT #fileout%, "pushbutton('TRIM ') ;" PRINT #fileout%, "endprocedure" CLOSE fileout% 'Let SCP know that the NEXT ACTION TPU macro is ready for execution SHELL "del BACT.OUT" 'Wait for SCP to finish executing the NEXT ACTION TPU macro CALL filesearch END SUB SUB chkbact (imag!) 'Count the number of trims.... ntrim% = 0 'Get the current value of BACT .... CALL getbact(bact!) 'Trim the supply if new imag value has not changed.... WHILE ((ABS(bact! - imag!) > .5) AND (ntrim% < 10)) 'If not successful after 5 trims inform the user... IF ntrim% > 5 THEN PRINT PRINT "********************************************************************" PRINT "*** The SCP was unsuccessful in trimming to the desired current. ***" PRINT "*** Inform the appropriate personnel to look into this further. ***" PRINT "********************************************************************" WHILE (username$ <> "MAGMEAS") PRINT : PRINT "Enter user group name to continue (MM): "; INPUT username$ username$ = UCASE$(username$) WEND END IF 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "procedure nextact" PRINT #fileout%, "pushbutton( 'TRIM ' ) ;" PRINT #fileout%, "endprocedure" CLOSE fileout% ntrim% = ntrim% + 1 'Let SCP know that the NEXT ACTION TPU macro is ready for execution.... SHELL "del BACT.OUT" 'Wait for SCP to finish executing the NEXT ACTION TPU macro.... CALL filesearch 'Get the current value of BACT.... CALL getbact(bact!) WEND END SUB SUB filesearch 'Waiting for SCP dbdump file BACT.OUT:" WHILE DIR$("BACT.OUT") <> "BACT.OUT" WEND END SUB SUB getbact (bact!) 'Read the current value of BACT.OUT filein% = FREEFILE OPEN "BACT.OUT" FOR INPUT ACCESS READ AS filein% FOR i = 1 TO 3 LINE INPUT #filein%, temp$ NEXT bact! = VAL(MID$(temp$, 12, 13)) CLOSE filein% END SUB SUB lgpsoff 'Move to the E: drive on the PC. ( E: => SLC_DATA:[MAGMEAS] ) SHELL "e:" 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT PRINT "The magnet current will now be ramped to 0.0 amps" PRINT "and the power supply shutoff....." PRINT #fileout%, "procedure nextact" PRINT #fileout%, "enterdata ('0.0') ;" PRINT #fileout%, "pushbutton( 'ENTRBDES' ) ;" PRINT #fileout%, "enterdata ( 'YES' ) ;" PRINT #fileout%, "pushbutton( 'LGOF ' ) ;" PRINT #fileout%, "endprocedure" CLOSE fileout% 'Let SCP know that the NEXT ACTION TPU macro is ready for execution: SHELL "del BACT.OUT" 'Wait for SCP to finish executing the NEXT ACTION TPU macro: CALL filesearch 'Abort the SCPPC.TPU macro 'CALL abort 'Return to original working directory SHELL "c:" END SUB SUB lgpson CALL startup 'Move to the E: drive on the PC. ( E: => SLC_DATA:[MAGMEAS] ) SHELL "e:" 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT PRINT "Turning on LGPS 1, this should take a few minutes..." PRINT #fileout%, "procedure nextact" PRINT #fileout%, "enterdata ( 'YES' ) ;" PRINT #fileout%, "pushbutton ( 'LGON ' ) ;" PRINT #fileout%, "endprocedure" CLOSE fileout% 'Let SCP know that the NEXT ACTION TPU macro is ready for execution SHELL "del BACT.OUT" 'Wait for SCP to finish executing the NEXT ACTION TPU macro CALL filesearch 'Parse the dbdump file STAT.OUT CALL statout 'Return to original working directory SHELL "c:" CLS END SUB SUB startup CLS PRINT PRINT "IMAG Program used to control the power supply during magnetic" PRINT " measurements of the injector line magnets." PRINT PRINT "Before continuing be sure that the SCPPC.TPU macro is executed." PRINT PRINT " 1) Logon to SLC. ($ SET HOST SLC)" PRINT " 2) Start the SLC control Program SCP. ($ SCPDIS)" PRINT " 3) Select the User Development Panel." PRINT " 4) Select the LI32 Magnet Panel." PRINT " 5) Execute the SCPPC macro." PRINT 'Move to the E: drive on the PC. ( E: => SLC_DATA:[MAGMEAS] ) SHELL "e:" PRINT "Waiting for the execution of the SCPPC macro....." 'Wait for SCP to finish executing the NEXT ACTION TPU macro CALL filesearch PRINT "The SCPPC macro is excuting." 'Return to original working directory SHELL "c:" END SUB SUB statout 'Parse the dbdump file STAT.OUT filein% = FREEFILE infile$ = "STAT.OUT" OPEN infile$ FOR INPUT ACCESS READ AS filein% FOR i = 1 TO 3 LINE INPUT #filein%, temp$ NEXT CLOSE filein% 'Checking calibration status... PRINT PRINT "Checking calibration status:" stat% = VAL("&h" + MID$(temp$, 11, 4)) PRINT temp$, stat% IF stat% AND &H40 THEN PRINT "Calibration okay..." 'ELSE ' PRINT "Calibrating...." ' CALL calibrate END IF END SUB SUB vaximagmeas (imag!) 'Move to the E: drive on the PC. ( E: => SLC_DATA:[MAGMEAS] ) SHELL "e:" ' Section used to have the SCP dump the file bact.out ' 'Write the NEXT ACTION TPU macro file: ' fileout% = FREEFILE ' outfile$ = "NEXTACT.TPU" ' OPEN outfile$ FOR OUTPUT AS fileout% ' ' PRINT #fileout%, "procedure nextact" ' PRINT #fileout%, "endprocedure" ' ' CLOSE fileout% ' ' 'Let SCP know that the NEXT ACTION TPU macro is ready for execution: ' SHELL "del BACT.OUT" ' ' 'Wait for SCP to finish executing the NEXT ACTION TPU macro: ' CALL filesearch 'Parse the dbdump file BACT.OUT filein% = FREEFILE infile$ = "BACT.OUT" OPEN infile$ FOR INPUT ACCESS READ AS filein% FOR i = 1 TO 3 LINE INPUT #filein%, temp$ NEXT imag! = VAL(MID$(temp$, 12, 13)) CLOSE filein% 'Return to original working directory SHELL "c:" END SUB SUB vaximagramp (imag!) 'Move to the E: drive on the PC. ( E: => SLC_DATA:[MAGMEAS] ) SHELL "e:" 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "procedure nextact" PRINT #fileout%, USING "enterdata ('###.##') ;"; imag! PRINT #fileout%, "pushbutton( 'ENTRBDES' ) ;" PRINT #fileout%, "pushbutton( 'TRIM ' ) ;" PRINT #fileout%, "endprocedure" CLOSE fileout% 'Let SCP know that the NEXT ACTION TPU macro is ready for execution: SHELL "del BACT.OUT" 'Wait for SCP to finish executing the NEXT ACTION TPU macro: CALL filesearch 'Check that current did ramp to new value: CALL chkbact(imag!) 'Return to original working directory SHELL "c:" END SUB SUB vaxstandardize PRINT PRINT "Standardizing the magnet..." 'Once the supply is on 1st ramp to a stable current... CALL vaximagramp(5!) 'Move to the E: drive on the PC. ( E: => SLC_DATA:[MAGMEAS] ) SHELL "e:" 'Write the NEXT ACTION TPU macro file: fileout% = FREEFILE outfile$ = "NEXTACT.TPU" OPEN outfile$ FOR OUTPUT AS fileout% PRINT #fileout%, "procedure nextact" PRINT #fileout%, "enterdata ( '2.0' ) ;" PRINT #fileout%, "pushbutton( 'ENTRBDES' ) ;" PRINT #fileout%, "pushbutton( 'TRIM ' ) ;" PRINT #fileout%, "enterdata ( 'YES' ) ;" PRINT #fileout%, "pushbutton( 'STDZ ' ) ;" PRINT #fileout%, "wait(90) ;" PRINT #fileout%, "pushbutton('MAGDALL ') ;" PRINT #fileout%, "pushbutton( 'TRIM ' ) ;" PRINT #fileout%, "enterdata ( 'YES' ) ;" PRINT #fileout%, "pushbutton( 'STDZ ' ) ;" PRINT #fileout%, "wait(90) ;" PRINT #fileout%, "pushbutton('MAGDALL ') ;" PRINT #fileout%, "pushbutton( 'TRIM ' ) ;" PRINT #fileout%, "endprocedure" CLOSE fileout% 'Let SCP know that the NEXT ACTION TPU macro is ready for execution: SHELL "del BACT.OUT" 'Wait for SCP to finish executing the NEXT ACTION TPU macro: CALL filesearch 'Extract the actual value the supply is set to: CALL vaximagmeas(imag!) 'Return to original working directory SHELL "c:" END SUB