-- Last edited by Chi Yung, April 23, 1982 5:06 PM -- Last edited by Chi Yung, April 30, 1982 2:05 PM -- Last edited by Chi Yung, May 21, 1982 12:23 PM -- Last edited by Chi Yung, September 1, 1983 11:21 AM -- Last edited by JWhite, 7-May-85 9:05:37 DIRECTORY Ascii, BruceDefs, MachineParseDefs, String, Storage, InlineDefs, inD: FROM "interactordefs", exD: FROM "exceptiondefs", vmD: FROM "VirtualMgrDefs"; BruceCompiler: PROGRAM IMPORTS BruceDefs, MachineParseDefs, String, Storage, InlineDefs, exD, inD EXPORTS BruceDefs = BEGIN OPEN MachineParseDefs; DescribeTable: TYPE = DESCRIPTOR FOR ARRAY [1..20] OF CARDINAL; --The number of indexing elements (20 here) should be changed when there --are more than 20 calibration points for either the temperature correction --table or the boat speed conversion table or the flow rate coversion --table. Record: TYPE = RECORD[a,b: DescribeTable]; --DescribeTable and Record allow arrays of different sizes to use or call --the same procedures,such as the procedure known as Interpolation2 or --FillArray.It is an efficient and compact way to transmit informations, --such as the contents of a big array, into a procedure. -- The following 4 constants are compiled time constants. They can not be -- changed or updated by the constant file. If one or more of these -- constants has to be changed, one must compile the BruceCompiler program -- and then bind it by bind BruceTalk. NumberOfProfiledTemp: CARDINAL = 5; -- This number should be changed if you want to expand the correctable -- range of temperature or if you want to increase the accuracy of the -- interpolation. NumberOfGasType: CARDINAL = 12; -- This number should be changed if there are more than 12 types of gases. NumberOfCalibratedGasRate: CARDINAL = 11; -- This number should be changed if you want to increase the accuracy of -- the interpolation. NumberOfCalibratedboatRate: CARDINAL = 10; -- This number should be changed if you want to increase the accuracy of -- the interpolation. -- GasOneToGasTwoSafetyRatioHole:CARDINAL; GasOneToGasTwoSafetyRatio: CARDINAL = 250; -- The safety ratio of Hydrogen (Gas1) to Oxygen (Gas2) is set to be 2.5. -- If the ratio of H2 to O2 mixture in any of our steps is larger -- than this saftey ratio, the program will stop. The number, 2.5, is -- multiplied by a factor 100 to improve the accuracy of comparision. GasOne: STRING = "H2"; GasTwo: STRING = "O2"; tcaON: BOOLEAN _ FALSE; O2ON: BOOLEAN _ FALSE; POCl3ON: BOOLEAN _ FALSE; boatScaledFactor:CARDINAL _ 1; TempScaledFactor:CARDINAL _ 1; GasScaledFactor:CARDINAL _ 2; -- ScaledFactor is the number of digits allowed after the decimal. -- Temperatures are scaled by a factor of 10. -- Gas flow rates are scaled by a factor of 100. -- The reason for the factor of a 100 is because the parsing of the -- gas flow rate is done with a multiplication factor of a 100 so as -- to talk with the DDC microcontroller of the Bruce furnaces. For -- similar reason temperature has be scaled by a factor of 10 to -- talk with the DDC. boatSpeedInchUpperBound:CARDINAL _ 1000; --Max boat speed rate is 100 inches/min. Since the scale factor for boat --speed is 1 therefore 100 becomes 1000. boatSpeedPercentUpperBound:CARDINAL _ 990; --Max boat speed rate is 99%. Since the scale factor for boat speed is 1 --therefore 99% becomes 990. GasFlowLitreUpperBound: CARDINAL _ 2000; --Max gas flow rate is 20 l/m.Since the scale factor for gas flow is 2 --therefore 20 becomes 2000. GasFlowPercentUpperBound:CARDINAL _ 9999; --Max gas flow rate is 99.99%.Since the scale factor for gas flow is 2 --therefore 99.99% becomes 9999. NumberOfGasController: CARDINAL = 7; -- At present, each of the Bruce 8-stack furnace has a maximum capability -- of controlling 7 gas controllers. MinProfiledTemp: ARRAY BruceDefs.TubeNumber OF Index51; Index51: TYPE =ARRAY Reaction OF CARDINAL; MaxProfiledTemp: ARRAY BruceDefs.TubeNumber OF Index61; Index61: TYPE =ARRAY Reaction OF CARDINAL; maxRampRateUp:CARDINAL; maxRampRateDown:CARDINAL; MinGasFlowConversion: CARDINAL; MaxGasFlowConversion: CARDINAL; boatSpeedLoBound: CARDINAL; boatSpeedHiBound: CARDINAL; boatSpeedSafetyLimit: CARDINAL; ProfiledTemp: TYPE = CARDINAL; ProfiledTempIndex: TYPE = [1..NumberOfProfiledTemp]; ProfiledTempTable: TYPE = ARRAY BruceDefs.TubeNumber OF Index11; Index11: TYPE = ARRAY Reaction OF Index12; Index12: TYPE = ARRAY ProfiledTempIndex OF ProfiledTemp; ptt:ProfiledTempTable; -- The first and the last components of ptt[BruceDefs.TubeNumber][Reaction] -- are automtically the MinProfiledTemp[BruceDefs.TubeNumber][Reaction] and -- the MaxProfiledTemp[BruceDefs.TubeNumber][Reaction]. ProfiledTempCorrectionTable: TYPE = ARRAY BruceDefs.TubeNumber OF Index1; Index1: TYPE = ARRAY Reaction OF Index2; Index2: TYPE = ARRAY BruceDefs.ZoneIndex OF Index3; Index3: TYPE = ARRAY ProfiledTempIndex OF CARDINAL; ptct: ProfiledTempCorrectionTable; --tables for tube dependent coefficient informaltion FurnaceControlTable: TYPE = ARRAY BruceDefs.TubeNumber OF RECORD[ controlTable: BruceDefs.ControlTable, tempRangeTable: BruceDefs.TempRangeTable]; fct:FurnaceControlTable; CalibratedGasRate: TYPE = CARDINAL; --this rate is in litres per minute x 100 CalibratedGasRateIndex: TYPE = [1..NumberOfCalibratedGasRate]; CalibratedGasRateTable: TYPE = ARRAY CalibratedGasRateIndex OF CalibratedGasRate; cgrt: CalibratedGasRateTable; -- The first and the last components of cgrt are automatically the -- MinGasFlowConversion and the MaxGasFlowConversion. CailibratedGasRateConversionTable: TYPE = ARRAY GasTypeIndex OF Index31; Index31: TYPE = ARRAY CalibratedGasRateIndex OF CARDINAL; cgrct: CailibratedGasRateConversionTable; Gas: TYPE = STRING; GasControllerIndex: TYPE = [1..NumberOfGasController]; GasTypeIndex: TYPE = [1..NumberOfGasType]; GasPlumbingTable: TYPE = ARRAY BruceDefs.TubeNumber OF Index21; Index21: TYPE = ARRAY GasControllerIndex OF Gas; GasTypeTable: TYPE = ARRAY GasTypeIndex OF Gas; gpt: GasPlumbingTable; gtt: GasTypeTable; -- gtt is where you enter the names of the gases that you are going to use -- in all eight furnace tubes. CalibratedboatRate: TYPE = CARDINAL; --this rate is in inches per minute CalibratedboatRateIndex: TYPE = [1..NumberOfCalibratedboatRate]; CalibratedboatRateTable: TYPE = ARRAY CalibratedboatRateIndex OF CalibratedboatRate; cbrt: CalibratedboatRateTable; -- The first and the last components cbrt are automatically the -- boatSpeedLoBound and the boatSpeedHiBound. CalibratedboatRateConversionTable: TYPE = ARRAY CalibratedboatRateIndex OF CARDINAL; cbrct: CalibratedboatRateConversionTable; Reaction: TYPE ={Dry, Wet}; R: Reaction; s:STRING _ [10]; sDry:STRING = "dry"; sWet:STRING = "wet"; j: BruceDefs.GasColIndex; l: GasTypeIndex; WriteGasRow: BOOLEAN _ TRUE; WriteTempRow:BOOLEAN _ TRUE; GasOneFlow: CARDINAL _ 0;-- Gas1 now is H2. GasTwoFlow: CARDINAL _ 0;-- Gas2 now is O2. tNumberOfDigits, gNumberOfDigits, bNumberOfDigits: CARDINAL; -- tNumberOfFDigits is the number of digits plus decimal if applicable in -- the temperature parsing. ( eg. tNumberOfDigits for 899.9 is 5.) -- Similarly gNumberOfDigits and bNumberOfDigits are for gas and boat. InitTube: ARRAY BruceDefs.TubeNumber OF BOOLEAN; -- If the idle conitions for a tube (eg. tube 5 ) is specified in the idle -- condition table , then the corresponding entry in the InitTube array is -- set to be TRUE. This allows the checking of whether the idle conditions -- of the tube were set when we parse the tube number in the -- BruceRecipe.text. ( InitTube[5]_ TRUE ) CompileData: TYPE=RECORD[ brp:BruceDefs.RecipePtr, parsedTube:BOOLEAN, tube:BruceDefs.TubeNumber]; CompileHandle: TYPE=POINTER TO CompileData; IdleData: TYPE = RECORD[ IdleTube:BruceDefs.TubeNumber, IdleReaction: ARRAY BruceDefs.TubeNumber OF Reaction, IdleTempTable: ARRAY BruceDefs.TubeNumber OF BruceDefs.TempRow _ ALL[ALL[0]], IdleGasTable: ARRAY BruceDefs.TubeNumber OF BruceDefs.GasRow _ ALL[ALL[0]], IdleFunction1Table: ARRAY BruceDefs.TubeNumber OF BruceDefs.Function1Bits]; IdleHandle: TYPE = POINTER TO IdleData; id: IdleData; InitTables: PUBLIC PROCEDURE [constantsdata: vmD.VirtualMessagePtr] = -- This procedure calls on six other procedures to intake the informations -- from the BruceConstants.text file to initialize the furnaces tubes. BEGIN ph:ParseHandle _ @pd; pd:ParseData; fields: ARRAY [0 .. 7) OF FieldRec _ [["BoatRateCalibration"L, ParseBoatRateCalibration], ["Constants"L, ParseConstants], ["GasFlowCalibration"L, ParseGasFlowCalibration], ["GasPlumbing"L, ParseGasPlumbing], ["TemperatureCalibration"L, ParseTemperatureCalibration], ["IdleConditions"L, ParseIdleConditions], ["FurnaceControlCoefficients"L, ParseFurnaceCoefficients]]; pd.breakSet _ ":.@""+/"L; pd.blankSet _ " "L; ph.message _ constantsdata; pd.userData _ @id; FOR i: CARDINAL IN GasTypeIndex DO gtt[i] _ Storage.String[10]; ENDLOOP; -- This loop initializes gtt, the gas type table, so that each component -- ,which is the name of the name of a gas, is a string of at most ten -- characters. FOR i: CARDINAL IN GasTypeIndex DO String.AppendString[gtt[i], "GasName"]; ENDLOOP; -- This loop sets up the dummy names for the gas type table to be -- GasName. This implies that the real name of the gas cannot be GasName. FOR i: CARDINAL IN BruceDefs.TubeNumber DO FOR k: CARDINAL IN GasControllerIndex DO gpt[i][k] _ Storage.String[10]; ENDLOOP; ENDLOOP; -- This double loop initializes gpt, the gas plumbing table, so that each -- component , which is the name of a gas, is a string of at most ten -- characters. FOR i: CARDINAL IN BruceDefs.TubeNumber DO FOR k: CARDINAL IN GasControllerIndex DO String.AppendString[gpt[i][k], "*"]; ENDLOOP; ENDLOOP; -- This double loop sets up the gas plumbing table in such a way that if -- the gas controller of the furance tube is not plumbed then a * is -- assigned to the corresponding component. This implies that the -- real name of a gas cannot have the symbol *. ParseMessage[ph, DESCRIPTOR[fields]]; exD.DisplayBothExceptionLines ["Hi! I am ready. Get your favorite recipe and click the word compile inside", 0, "the lower menu. Let's start cooking! I am hungry! Aren't you?", 0, FALSE]; END; -- of InitTables ParseBoatRateCalibration: FieldParseProc= BEGIN ih:IdleHandle _ ph.userData; dtcbrt: DescribeTable _ DESCRIPTOR[cbrt]; -- This DesribeTable, dtcbrt, describes the CalibratedBoatRateTable. dtcbrct: DescribeTable _ DESCRIPTOR[cbrct]; cbrt _ALL[0]; -- All the entries for cbrt is initialized to be zero. cbrct _ ALL[0]; IF ParseToLeadingChar[ph] THEN BEGIN CheckWord[ph, "InchesPerMin"]; FillArray[ph, dtcbrt, boatScaledFactor, boatSpeedInchUpperBound]; CheckWord[ph, "Percentage"]; FillArray[ph, dtcbrct, boatScaledFactor, boatSpeedPercentUpperBound]; boatSpeedLoBound _ cbrt[1]; boatSpeedHiBound _ cbrt[LENGTH[cbrt]]; ParseToEndOfField[ph]; END ELSE ERROR ParseFault["BoatRateCalibration field is missing.", ph.currentChar-1, ph.currentChar-1]; END; -- of BoatRateCalibration ParseConstants: FieldParseProc= BEGIN SubFieldRecord: TYPE = RECORD [name: STRING, var: CARDINAL, ScaleFactor: CARDINAL, LowBound: CARDINAL, HiBound: CARDINAL, Unit: CHARACTER, found: BOOLEAN _ FALSE]; ih:IdleHandle _ ph.userData; curPosition, lastPosition: vmD.CharIndex; word: STRING _ [30]; SubFieldName: STRING _ [30]; ErrorMessage: STRING _ [100]; SubField: ARRAY [0..3) OF SubFieldRecord _ [["boatSpeedSafetyLimit"L , 0, boatScaledFactor, boatSpeedLoBound, boatSpeedHiBound, '"], ["maxRampRateUp"L, 0, TempScaledFactor, 0, 1000, Ascii.ControlD], ["maxRampRateDown"L, 0, TempScaledFactor, 0, 1000, Ascii.ControlD]]; --The following procedure is an internal procedure called within this --ParseConstants procedure. ReadConstantLine: PROCEDURE[ph: ParseHandle, ScaleFactor: CARDINAL, LowBound: CARDINAL, HiBound: CARDINAL, Unit: CHARACTER] RETURNS[Value: CARDINAL]= BEGIN ParseToNonWhite[ph]; CheckChar[ph, '_]; MissingValueCheck[ph]; Value _ ParseScaledNumber[ph, ScaleFactor, LowBound, HiBound].n; ParseToNonWhite[ph]; CheckChar[ph, Unit]; ParseToNonWhite[ph]; CheckChar[ph,'/]; CheckWord[ph,"min"]; ParseToEndOfLine[ph]; END;-- Of ReadConstantLine IF ParseToLeadingChar[ph] THEN BEGIN WHILE ParseToLeadingChar[ph] DO curPosition _ ph.currentChar; SubFieldName.length _ 0; DO ParseWord[ph,word]; IF word[0] ~IN ['a..'z] THEN BEGIN ph.currentChar _ ph.currentChar-word.length; EXIT; END; String.AppendString[SubFieldName, word]; ENDLOOP; lastPosition _ ph.currentChar; FOR i: CARDINAL IN [0..3) DO IF String.EquivalentString[SubFieldName,SubField[i].name] THEN BEGIN IF SubField[i].found = FALSE THEN BEGIN SubField[i].var _ReadConstantLine [ph,SubField[i].ScaleFactor,SubField[i].LowBound, SubField[i].HiBound, SubField[i].Unit].Value; SubField[i].found _ TRUE; EXIT; END ELSE ERROR ParseFault["Multiple defined subfield illegal", curPosition,lastPosition]; END REPEAT FINISHED => ParseFault["Unrecogonizable constant!",curPosition,lastPosition]; ENDLOOP; ENDLOOP; boatSpeedSafetyLimit _ SubField[0].var; maxRampRateUp _ SubField[1].var; maxRampRateDown _ SubField[2].var; FOR i: CARDINAL IN [0..3) DO IF SubField[i].found = FALSE THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, SubField[i].name]; String.AppendString[ErrorMessage," subfield is missing."]; ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; ENDLOOP; END ELSE ERROR ParseFault["Constants field is missing.", ph.currentChar-1, ph.currentChar-1]; END; -- of ParseConstants ParseGasFlowCalibration: FieldParseProc= BEGIN dtcgrct: DescribeTable; i: CARDINAL _ 0; ih:IdleHandle _ ph.userData; dtcgrt: DescribeTable _ DESCRIPTOR[cgrt]; -- This DesribeTable, dtcgrt, describes the CalibratedGasRateTable. GasTypeName: STRING _ [10]; ErrorMessage: STRING _ [100]; cgrt _ ALL [0]; cgrct _ ALL[ALL[0]]; -- ALL the components of the cgrt and cgrct are initialized to be zero. IF ParseToLeadingChar[ph] THEN BEGIN CheckWord[ph, "Gas"]; FillArray[ph, dtcgrt, GasScaledFactor, GasFlowLitreUpperBound]; MinGasFlowConversion _ cgrt[1]; MaxGasFlowConversion _ cgrt[LENGTH[cgrt]]; WHILE ParseToLeadingChar[ph] DO IF i >= NumberOfGasType THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "> "]; String.AppendNumber[ErrorMessage, NumberOfGasType, 10]; String.AppendString[ErrorMessage, " gas types. Change in the BruceCompiler.mesa is needed."]; ERROR ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; ParseWord[ph,GasTypeName]; FOR m: CARDINAL IN [1..i] DO IF String.EquivalentString[GasTypeName, gtt[m]] THEN ERROR ParseFault["This gas has already been calibrated.", ph.currentChar - GasTypeName.length, ph.currentChar]; ENDLOOP; i _ i +1; gtt[i].length _ 0; -- This reintializes the name of the gas to be nil so that we can -- use String.AppendString String.AppendString[gtt[i], GasTypeName]; dtcgrct _ DESCRIPTOR[cgrct[i]]; FillArray[ph, dtcgrct, GasScaledFactor,GasFlowPercentUpperBound]; ENDLOOP; -- End of the WHILE statement. END ELSE ParseFault["GasFlowCalibration field is missing.", ph.currentChar-1, ph.currentChar-1]; END; -- Of GasFlowCalibration ParseGasPlumbing: FieldParseProc= BEGIN i, m, n: CARDINAL; p: CARDINAL _ 0; GasPlumbingName: STRING _[10]; ErrorMessage: STRING _ [100]; ih:IdleHandle _ ph.userData; IF ParseToLeadingChar[ph] THEN BEGIN WHILE ParseToLeadingChar[ph] DO IF p>=8 THEN ERROR ParseFault["There are only 8 furnace tubes.",ph.currentChar, ph.currentChar + 1]; i _ ParseDecimal[ph,1,8]; p _ p +1; -- The following codes check whether the tube is plumbed or not. n _ 0; FOR q: [1..NumberOfGasController] IN [1..NumberOfGasController] DO IF String.EquivalentString[gpt[i][q], "*"] THEN n_n+1 ELSE EXIT; ENDLOOP; IF n # NumberOfGasController THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Tube number "]; String.AppendNumber[ErrorMessage, i, 10]; String.AppendString[ErrorMessage, " has already been plumbed."]; ERROR ParseFault[ErrorMessage, ph.currentChar -1, ph.currentChar]; END;-- of tube plumbing check. FOR k: [1..NumberOfGasController] IN [1..NumberOfGasController] DO ParseWord[ph, GasPlumbingName]; -- The following codes check the name of the gas with the names in -- the gas type table. IF ~String.EquivalentString[GasPlumbingName, "*"] THEN BEGIN m _ 0; FOR r: [1..LENGTH[gtt]] IN [1..LENGTH[gtt]] DO IF ~String.EquivalentString[GasPlumbingName, gtt[r]] THEN m_m+1 ELSE EXIT; ENDLOOP; IF m = LENGTH[gtt] THEN ERROR ParseFault["The gas you specified has not be calibrated at all.", ph.currentChar-GasPlumbingName.length, ph.currentChar]; END; -- of gas name check. gpt[i][k].length _0; -- this initializes the string to be nil so that we can use -- String.AppendString. String.AppendString[gpt[i][k], GasPlumbingName]; ENDLOOP; IF ParseToLeadingCharOnLine[ph] THEN BEGIN ParseWord[ph, GasPlumbingName]; ParseFault["You can't have more than 7 gases plumbed.", ph.currentChar-GasPlumbingName.length, ph.currentChar]; END; ENDLOOP; -- End of the WHILE statement. END ELSE ParseFault["GasPlumbing field is missing.", ph.currentChar-1, ph.currentChar-1]; END; --Of GasPlumbing ParseTemperatureCalibration: FieldParseProc= BEGIN ReactionIndex: TYPE = Reaction[Dry..Wet]; RecordTemp: TYPE = RECORD[a, b,c,d : CARDINAL]; c, i, m, e, w, NoOfDigits: CARDINAL; pArray: ARRAY [1.. NumberOfProfiledTemp] OF POINTER TO RecordTemp; pptt:ARRAY [1.. NumberOfProfiledTemp] OF POINTER TO RecordTemp; RecordArray: ARRAY [1.. NumberOfProfiledTemp] OF RecordTemp; TemStore: ARRAY [1.. NumberOfProfiledTemp] OF RecordTemp; curPosition: vmD.CharIndex; st: STRING _ [10]; ExtraNumber: STRING _ [10]; ErrorMessage: STRING _ [100]; ih:IdleHandle _ ph.userData; ptt _ ALL[ALL[ALL[0]]]; -- initialize ptt. ptct _ ALL[ALL[ALL[ALL[0]]]]; -- initialize ptct. MinProfiledTemp _ ALL[ALL[0]];-- initialize MinProfiledTemp MaxProfiledTemp _ ALL[ALL[0]];-- initialize MaxProfiledTemp IF ParseToLeadingChar[ph] THEN BEGIN WHILE ParseToLeadingChar[ph] DO curPosition _ ph.currentChar; -- This provides a "marker" for the error message. i _ ParseDecimal[ph,1,8]; ParseWord[ph, st];-- This provides the word in the error message below. ph.currentChar _ ph.currentChar - st.length; -- this allow the handle to go back in front of the word so that -- we can use the procedure GetReaction. R _ GetReaction[ph]; -- The following codes fill the ptt[i][R] and check for full ptt[i][R]. FOR m IN [1..NumberOfProfiledTemp] DO IF ptt[i][R][m] = 0 THEN BEGIN MissingValueCheck[ph]; [ptt[i][R][m], NoOfDigits] _ ParseScaledNumber[ph,TempScaledFactor,0,13000]; -- 1300 degree C is the absolute maximum temperature allowed. EXIT; END; REPEAT FINISHED => BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Entries for tube "]; String.AppendNumber[ErrorMessage, i, 10]; String.AppendString[ErrorMessage, ", "]; String.AppendString[ErrorMessage, st]; String.AppendString[ErrorMessage, " process profiled temp table is full."]; ERROR ParseFault[ErrorMessage, curPosition, curPosition]; END; ENDLOOP;-- End of fill ptt[i][R]. -- The following codes fill the ptct. FOR k: BruceDefs.ZoneIndex IN BruceDefs.ZoneIndex DO IF ~ParseToLeadingCharOnLine[ph] THEN BEGIN ErrorMessage.length _ 0; String.AppendNumber[ErrorMessage, 4-k , 10]; String.AppendString[ErrorMessage, " of the 3 entries for the 3 zones are missing."]; ERROR ParseFault[ErrorMessage, ph.currentChar , ph.currentChar]; END; [ptct[i][R][k][m], NoOfDigits] _ ParseScaledNumber[ph,TempScaledFactor,0,13000] ENDLOOP; -- End of fill ptct. -- The following codes take care of the extra number on the line. IF ParseToLeadingCharOnLine[ph] THEN BEGIN ParseWord[ph, ExtraNumber]; e _ ExtraNumber.length; IF ParseCharIfCharIs[ph, '.] THEN BEGIN ParseWord[ph, ExtraNumber]; e _ e +1 +ExtraNumber.length; END; ERROR ParseFault["There are only three zones in the furnace.", ph.currentChar-e, ph.currentChar]; END; -- of taking care of the extra number on the line. ENDLOOP; --End of the WHILE statement. -- The following codes check for partially filled table. FOR u : BruceDefs.TubeNumber IN BruceDefs.TubeNumber DO FOR v: ReactionIndex IN ReactionIndex DO IF ptt[u][v][1] # 0 AND ptt[u][v][NumberOfProfiledTemp] = 0 THEN BEGIN FOR w IN [2..NumberOfProfiledTemp] DO IF ptt[u][v][w] = 0 THEN EXIT; ENDLOOP; ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Profiled temp table needs "]; String.AppendNumber[ErrorMessage, NumberOfProfiledTemp - w +1, 10]; String.AppendString[ErrorMessage, " more rows for tube "]; String.AppendNumber[ErrorMessage, u, 10]; IF v = Dry THEN String.AppendString[ErrorMessage, " dry process."] ELSE String.AppendString[ErrorMessage, " wet process."]; ERROR ParseFault[ErrorMessage, ph.currentChar-1, ph.currentChar-1]; END; ENDLOOP; ENDLOOP; -- End of check for partially filled table. -- The following loops sort out the order of the profiled temperatures. -- This subroutine is NOT based on binary search. FOR u : BruceDefs.TubeNumber IN BruceDefs.TubeNumber DO FOR v: ReactionIndex IN ReactionIndex DO IF ptt[u][v][1] # 0 THEN BEGIN FOR g: CARDINAL IN [1..NumberOfProfiledTemp] DO RecordArray[g] _[ ptt[u][v][g] , ptct[u][v][1][g] , ptct[u][v][2][g], ptct[u][v][3][g]]; pptt[g] _ @RecordArray[g]; ENDLOOP; pArray _ pptt; FOR h: CARDINAL IN [2..NumberOfProfiledTemp] DO c _h; UNTIL c = 1 DO IF pptt[c]^.a < pptt[c-1]^.a THEN BEGIN pArray[c]_pptt[c-1]; pArray[c-1]_pptt[c]; c _ c-1; pptt _ pArray; END ELSE BEGIN c _ c-1; END; ENDLOOP; ENDLOOP; FOR f: CARDINAL IN [1..NumberOfProfiledTemp] DO TemStore[f] _ pArray[f]^; ENDLOOP; FOR f: CARDINAL IN [1..NumberOfProfiledTemp] DO ptt[u][v] [f]_ TemStore[f].a; ptct[u][v][1][f]_ TemStore[f].b; ptct[u][v][2][f]_ TemStore[f].c; ptct[u][v][3][f]_ TemStore[f].d; ENDLOOP; END; ENDLOOP; ENDLOOP; -- End of the sorting routine. FOR u : BruceDefs.TubeNumber IN BruceDefs.TubeNumber DO FOR v: ReactionIndex IN ReactionIndex DO FOR z: BruceDefs.ZoneIndex IN BruceDefs.ZoneIndex DO FOR f: CARDINAL IN [2..NumberOfProfiledTemp] DO IF ptct[u][v][z][f]< ptct[u][v][z][f-1] THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Profiled temp "]; AppendScaleNumber[ptt[u][v][f], TempScaledFactor,ErrorMessage]; String.AppendString[ErrorMessage, " for tube # "]; String.AppendNumber[ErrorMessage, u, 10]; IF v = Dry THEN String.AppendString[ErrorMessage, " dry process"] ELSE String.AppendString[ErrorMessage, " wet process"]; String.AppendString[ErrorMessage, " zone # "]; String.AppendNumber[ErrorMessage, z, 10]; String.AppendString[ErrorMessage, " is not in ascending order. "]; exD.DisplayBothExceptionLines[ ErrorMessage,0, "", 0, FALSE]; IF ~inD.Confirm[2] THEN ERROR ParseFault ["Change profiled temps and click InitTables in the lower menu.", ph.currentChar, ph.currentChar]; END; ENDLOOP; ENDLOOP; ENDLOOP; ENDLOOP; FOR u : BruceDefs.TubeNumber IN BruceDefs.TubeNumber DO FOR v: ReactionIndex IN ReactionIndex DO MinProfiledTemp[u][v] _ ptt[u][v][1]; MaxProfiledTemp[u][v] _ ptt[u][v][NumberOfProfiledTemp] ; ENDLOOP; ENDLOOP; END ELSE ParseFault["TemperatureCalibration field is missing.", ph.currentChar-1, ph.currentChar-1]; END; --Of TemperatureCalibration ParseIdleConditions: FieldParseProc= BEGIN k,m,n: CARDINAL; temp: CARDINAL; gas: CARDINAL; TempCorrectArray:ARRAY[1..3] OF CARDINAL; gasName: STRING _ [10]; ErrorMessage: STRING _ [100]; curPosition: vmD.CharIndex; ih: IdleHandle _ph.userData; id.IdleTempTable _ ALL[ALL[0]]; id.IdleGasTable_ ALL[ALL[0]]; id.IdleFunction1Table _ ALL[ALL[0]]; FOR q:CARDINAL IN BruceDefs.TubeNumber DO InitTube[q] _ FALSE; -- this loop initializes the InitTube. ENDLOOP; IF ParseToLeadingChar[ph] THEN BEGIN WHILE ParseToLeadingChar[ph] DO curPosition _ ph.currentChar; MissingValueCheck[ph]; id.IdleTube _ ParseDecimal[ph, 1, 8]; IF id.IdleTempTable[id.IdleTube][1] # 0 THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Idle conditions for tube no. "]; String.AppendNumber[ErrorMessage, id.IdleTube, 10]; String.AppendString[ErrorMessage, " have already been entered "]; ERROR ParseFault[ErrorMessage, curPosition, curPosition]; END; R _ GetReaction [ph]; id.IdleReaction[id.IdleTube] _ R; IF ptt[id.IdleTube][R][1] = 0 THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Temperatures for tube no. "]; String.AppendNumber[ErrorMessage, id.IdleTube, 10]; IF R = Dry THEN String.AppendString[ErrorMessage, " dry process"] ELSE String.AppendString[ErrorMessage, " wet process"]; String.AppendString[ErrorMessage, " have not been profiled."]; ERROR ParseFault[ErrorMessage, curPosition, curPosition]; END; -- Check for plumbing. n _ 0; FOR q: [1..NumberOfGasController] IN [1..NumberOfGasController] DO IF String.EquivalentString[gpt[id.IdleTube][q], "*"] THEN n_n+1 ELSE EXIT; ENDLOOP; IF n = NumberOfGasController THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Tube number "]; String.AppendNumber[ErrorMessage, id.IdleTube, 10]; String.AppendString[ErrorMessage, " has not been plumbed."]; ERROR ParseFault[ErrorMessage, curPosition, curPosition]; END; -- End of check for plumbing. InitTube[id.IdleTube] _ TRUE; MissingValueCheck[ph]; -- The following codes take care of the temperature. curPosition _ ph.currentChar; [temp,tNumberOfDigits] _BruceDefs.ParseTemp [ph,MinProfiledTemp[id.IdleTube][R],MaxProfiledTemp[id.IdleTube][R]]; FOR p:BruceDefs.TempColIndex IN BruceDefs.TempColIndex DO id.IdleTempTable[id.IdleTube][p] _ temp ENDLOOP; FOR u: ProfiledTempIndex IN ProfiledTempIndex DO IF temp # ptt[id.IdleTube][R][u] THEN m_u ELSE EXIT; ENDLOOP; IF m = NumberOfProfiledTemp THEN BEGIN exD.DisplayBothExceptionLines ["Temp not profiled. Program will proceed with temp obtained by interpolation.", 0, "", 0, FALSE]; -- There are only two lines in the bottom message window. BruceDefs.WarningCarat[curPosition, curPosition + tNumberOfDigits]; IF ~inD.Confirm[2] THEN ERROR ParseFault ["Change temperature value and compile again.", curPosition, curPosition + tNumberOfDigits]; END; FOR zo: BruceDefs.ZoneIndex IN BruceDefs.ZoneIndex DO table1: DescribeTable _ DESCRIPTOR[ptt[id.IdleTube][R]]; table2: DescribeTable _ DESCRIPTOR[ptct[id.IdleTube][R][zo]]; recordtable: Record _ [table1, table2]; TempCorrectArray[zo] _ Interpolation2 [temp, recordtable]; ENDLOOP; id.IdleTempTable[id.IdleTube][1] _ TempCorrectArray[1]; id.IdleTempTable[id.IdleTube][2] _ TempCorrectArray[2]; id.IdleTempTable[id.IdleTube][3] _ TempCorrectArray[3]; -- The following codes take care of the gas. IF id.IdleTube IN [1..4] THEN id.IdleFunction1Table[id.IdleTube][3]_1; --function switch # 6 will be 1 for interval 0 for tube 1 to 4. DO ParseWord[ph,gasName]; IF gasName[0] IN ['0..'9] OR gasName[0] ='. OR gasName[0] ='@ THEN ERROR ParseFault["Please specify the name of gas.", ph.currentChar-gasName.length -1, ph.currentChar-gasName.length -1]; FOR i:GasControllerIndex IN GasControllerIndex DO IF String.EquivalentString[gasName,gpt[id.IdleTube][i]] THEN BEGIN k _ i; EXIT; END; REPEAT FINISHED => ERROR ParseFault["The system was not hooked up with the type of gas you specified.", ph.currentChar-gasName.length, ph.currentChar]; ENDLOOP; ParseToNonWhite[ph]; CheckChar[ph,'@]; MissingValueCheck[ph]; [gas, gNumberOfDigits] _ BruceDefs.ParseGas[ph, MinGasFlowConversion,MaxGasFlowConversion]; IF String.EquivalentString[gasName,GasOne] THEN GasOneFlow _ gas; IF String.EquivalentString[gasName,GasTwo] THEN GasTwoFlow _ gas; IF String.EquivalentString[gasName,"tca"] THEN tcaON _ TRUE; IF String.EquivalentString[gasName,"O2"] THEN O2ON _ TRUE; IF String.EquivalentString[gasName,"POCl3"] THEN POCl3ON _ TRUE; IF String.EquivalentString[gasName,"N2"] AND id.IdleTube IN [1..4] THEN BEGIN id.IdleFunction1Table[id.IdleTube][4] _ 1; k _ 4; END; IF String.EquivalentString[gasName,"N2"] AND id.IdleTube IN [5..6] THEN BEGIN id.IdleFunction1Table[id.IdleTube][4] _ 1; k _ 3; END; id.IdleGasTable[id.IdleTube][k]_ GetGasFlow[ph, gasName, gas, gNumberOfDigits] ; id.IdleFunction1Table[id.IdleTube][9-k] _ 1; IF ~ParseToLeadingCharOnLine[ph] THEN EXIT; IF ~ParseCharIfCharIs[ph,'+] THEN EXIT; ENDLOOP; -- End of the gas DO loop. IF GasOneFlow # 0 AND GasTwoFlow # 0 THEN BEGIN IF (LONG[GasOneFlow] *LONG[100])/LONG[GasTwoFlow] >= LONG[GasOneToGasTwoSafetyRatio] THEN BEGIN GasOneFlow _ 0; GasTwoFlow _ 0; ErrorMessage.length _ 0; String.AppendString[ErrorMessage, " The ratio of "]; String.AppendString[ErrorMessage, GasOne]; String.AppendString[ErrorMessage, " to "]; String.AppendString[ErrorMessage, GasTwo]; String.AppendString[ErrorMessage, " >= "]; AppendScaleNumber[GasOneToGasTwoSafetyRatio, GasScaledFactor, ErrorMessage]; String.AppendString[ErrorMessage, ". Explosion may occur. Process rejected "]; ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; END; GasOneFlow _ 0; GasTwoFlow _ 0; IF tcaON = TRUE AND O2ON = FALSE THEN BEGIN tcaON _ FALSE; ParseFault ["You have your tca on without the O2. Please turn on the O2", ph.currentChar, ph.currentChar]; END; tcaON _ FALSE; O2ON _ FALSE; IF POCl3ON = TRUE AND O2ON = FALSE THEN BEGIN POCl3ON _ FALSE; ParseFault ["You have your POCl3 on without the O2. Please turn on the O2", ph.currentChar, ph.currentChar]; END; POCl3ON _ FALSE; O2ON _ FALSE; ENDLOOP; END ELSE ParseFault["IdleConditions field is missing.", ph.currentChar-1, ph.currentChar-1]; END; --Of IdleConditions ParseFurnaceCoefficients: FieldParseProc= BEGIN b,c,d:CHARACTER; tubeErrMsg: ARRAY[1..8] OF STRING _[ "Tube 1 Control Coefficients missing", "Tube 2 Control Coefficients missing", "Tube 3 Control Coefficients missing", "Tube 4 Control Coefficients missing", "Tube 5 Control Coefficients missing", "Tube 6 Control Coefficients missing", "Tube 7 Control Coefficients missing", "Tube 8 Control Coefficients missing"]; rp:BruceDefs.RecipePtr _ ph.userData; FOR k: BruceDefs.TubeNumber IN BruceDefs.TubeNumber DO IF ~ParseToLeadingChar[ph] THEN ERROR ParseFault["Data for Coefficient Missing", ph.currentChar-1, ph.currentChar]; d _ ParseChar[ph]; IF k # d - '0 THEN ERROR ParseFault[tubeErrMsg[k] ,ph.currentChar - 1, ph.currentChar]; FOR i:BruceDefs.FactorIndex IN BruceDefs.FactorIndex DO IF ~ParseToLeadingChar[ph] THEN ERROR ParseFault["Data for Coefficient Missing", ph.currentChar-1, ph.currentChar]; b _ ParseChar[ph]; IF i # b - '@ THEN SELECT i FROM = 1 => ERROR ParseFault["Row A of Coefficient Table is missing", ph.currentChar - 2, ph.currentChar]; = 2 => ERROR ParseFault["Row B of Coefficient Table is missing", ph.currentChar - 2, ph.currentChar]; = 3 => ERROR ParseFault["Row C of Coefficient Table is missing", ph.currentChar - 2, ph.currentChar]; = 4 => ERROR ParseFault["Row D of Coefficient Table is missing", ph.currentChar - 2, ph.currentChar]; ENDCASE; FOR j:BruceDefs.ZoneIndex IN BruceDefs.ZoneIndex DO IF ~ParseToLeadingChar[ph] THEN ERROR ParseFault ["Part of the Data for the Coefficient Table is missing", ph.currentChar-1, ph.currentChar]; c _ ParseChar[ph]; IF j # c - '0 THEN SELECT j FROM = 1 => ERROR ParseFault["Zone 1 of Coefficient Table is missing", ph.currentChar - 1, ph.currentChar]; = 2 => ERROR ParseFault["Zone 2 of Coefficient Table is missing", ph.currentChar - 1, ph.currentChar]; = 3 => ERROR ParseFault["Zone 3 of Coefficient Table is missing", ph.currentChar - 1, ph.currentChar]; ENDCASE; fct[k].controlTable.factorArray[i].calibration[j] _ ParseInteger[ph]; fct[k].controlTable.factorArray[i].latency[j] _ ParseDecimal[ph]; fct[k].controlTable.factorArray[i].outerLoopRate[j] _ ParseDecimal[ph]; fct[k].controlTable.factorArray[i].rate[j] _ ParseDecimal[ph]; fct[k].controlTable.factorArray[i].reset[j] _ ParseDecimal[ph]; fct[k].controlTable.factorArray[i].proportionalBand[j] _ ParseDecimal[ph]; IF j=FIRST[BruceDefs.ZoneIndex] THEN fct[k].tempRangeTable[i] _ ParseScaledNumber[ph, TempScaledFactor, 0, 15000].n; ENDLOOP; ENDLOOP; IF ~ParseToLeadingChar[ph] THEN ERROR ParseFault["WierdIndex is missing from the Coefficient Table", ph.currentChar-5, ph.currentChar]; FOR i:BruceDefs.WierdIndex IN BruceDefs.WierdIndex DO fct[k].controlTable.wierdStuff[i] _ ParseDecimal[ph]; ENDLOOP; ENDLOOP; ParseToEndOfField[ph]; END; --Of ParseFurnaceCoefficients SpecToBinary: PUBLIC PROCEDURE [data, spec: vmD.VirtualMessagePtr, brp:BruceDefs.RecipePtr] RETURNS[tube:BruceDefs.TubeNumber]= BEGIN cd:CompileData; ph:ParseHandle _ @pd; pd:ParseData; fields: ARRAY [0 .. 2) OF FieldRec _ [["Tube"L, ParseTube], ["Recipe"L, ParseRecipe]]; pd.breakSet _ ":.@""+/"L; pd.blankSet _ " "L; ph.message _ spec; pd.userData _ @cd; cd.brp _ brp; cd.parsedTube _ FALSE; ParseMessage[ph, DESCRIPTOR[fields]]; RETURN[cd.tube]; END; -- of SpecToBinary FillArray: PROCEDURE[ph:ParseHandle, dt:DescribeTable, ScaledFactor:CARDINAL, UpperBound:CARDINAL]= BEGIN i: CARDINAL; k: CARDINAL _ 0; ExtraNumber: STRING _ [10]; ErrorMessage: STRING _ [100]; FOR i IN [1..LENGTH[dt]] DO IF ~ParseToLeadingCharOnLine[ph] THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "There should be "]; String.AppendNumber[ErrorMessage, LENGTH[dt] - i +1, 10]; String.AppendString[ErrorMessage, " more entries on this line."]; ERROR ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; MissingValueCheck[ph]; dt[i] _ ParseScaledNumber[ph, ScaledFactor, 0, UpperBound].n; ENDLOOP; IF ParseToLeadingCharOnLine[ph] THEN BEGIN ParseWord[ph, ExtraNumber]; k _ ExtraNumber.length; IF ParseCharIfCharIs[ph, '.] THEN BEGIN ParseWord[ph, ExtraNumber]; k _ k +1 +ExtraNumber.length; END; ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "> "]; String.AppendNumber[ErrorMessage, LENGTH[dt], 10]; String.AppendString[ErrorMessage, " entries. Change in the BruceCompiler.mesa is needed."]; ERROR ParseFault[ErrorMessage, ph.currentChar-k, ph.currentChar]; END; END; -- of FillArray CheckWord: PROCEDURE[ph:ParseHandle, Word: STRING] = BEGIN st: STRING _ [40]; ErrorMessage: STRING _ [100]; IF ParseToLeadingChar[ph] THEN BEGIN ParseWord[ph,st]; IF ~String.EquivalentString[st, Word] THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "The word should be "]; String.AppendString[ErrorMessage, Word]; String.AppendString[ErrorMessage, ". No space in between."]; ERROR ParseFault[ErrorMessage, ph.currentChar- st.length , ph.currentChar]; END; END ELSE BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "The word, "]; String.AppendString[ErrorMessage, Word]; String.AppendString[ErrorMessage, ", and the corresponding entries are missing."]; ERROR ParseFault[ErrorMessage, ph.currentChar-1, ph.currentChar-1]; END; END; -- of CheckWord CheckAndInc: PROCEDURE[ph:ParseHandle, val:CARDINAL, max:CARDINAL] RETURNS[newval:CARDINAL]= BEGIN IF val=max THEN ERROR ParseFault["Table overflow", ph.currentChar, ph.currentChar]; newval _ val+1; END; -- of CheckAndInc Interpolation2: PROCEDURE[ value:CARDINAL, recordtable: Record] RETURNS[returnValue:CARDINAL] = BEGIN a, b, c, d, e: LONG CARDINAL; FOR i: CARDINAL IN [2..LENGTH[recordtable.a]] DO IF value <= recordtable.a[i] THEN BEGIN a _ recordtable.a[i - 1]; b _ recordtable.a[i]; c _ recordtable.b[i - 1]; d _ recordtable.b[i]; IF d >= c THEN e _( ( d - c ) * ( value - a ) * 10 / ( b - a ) + 5 ) / 10 + c ELSE e _ c -( ( c - d ) * ( value - a ) * 10 / ( b - a ) + 5 ) / 10 ; returnValue _ InlineDefs.LowHalf [e]; EXIT; END; ENDLOOP; END; GetReaction: PROCEDURE[ph: ParseHandle] RETURNS[R: Reaction] = BEGIN ParseToNonWhite[ph]; ParseWord[ph, s]; DO IF s[s.length-1] IN ['0..'9] THEN BEGIN s.length _ s.length -1; ph.currentChar _ ph.currentChar - 1; END ELSE EXIT; ENDLOOP; IF String.EquivalentString[s,sDry] OR String.EquivalentString[s,"d"] THEN R _Dry ELSE IF String.EquivalentString[s,sWet] OR String.EquivalentString[s,"w"] THEN R _Wet ELSE IF s[0] IN ['0..'9] THEN ERROR ParseFault ["Specify your process by typing in the word Dry(orD) or Wet(orW) at the blinking carat", ph.currentChar - s.length -1 , ph.currentChar - s.length -1] ELSE ERROR ParseFault ["Unknown word. Type in the word Dry(orD) or Wet(orW) at the blinking carat", ph.currentChar - s.length , ph.currentChar]; END; -- GetReaction TempCorrection: PROCEDURE [ph:ParseHandle, rp: BruceDefs.RecipePtr, t:CARDINAL, tn:BruceDefs.TubeNumber, R:Reaction, temp:CARDINAL, tNumberOfDigits:CARDINAL] RETURNS[a, b, c: CARDINAL] = -- This procedure corrects the temperatures to be used in columns 1, 2 and -- 3 of the temperature setpoint tables due to the different thermal -- behavior of the different tubes,the different zones within each tube , -- the different temperatures and the different reactions (exothermic or -- endothermic-) used when one is using the normal control mode.Note that -- all the temperatures are multiplied by a factor of 10 in order to -- communicate with the DDC microcontroller of the Bruce furnaces. BEGIN m: CARDINAL; k: CARDINAL _0; TempCorrectArray:ARRAY[1..3] OF CARDINAL; FOR i: ProfiledTempIndex IN ProfiledTempIndex DO IF temp # ptt[tn][R][i] THEN m_i ELSE EXIT; ENDLOOP; FOR i: CARDINAL IN [1..t-1] DO IF temp = rp.temp[i][6] THEN BEGIN k_i; EXIT; END; ENDLOOP; IF k = 0 AND m = NumberOfProfiledTemp THEN BEGIN exD.DisplayBothExceptionLines["Temp not profiled. Program will proceed with temp obtained by interpolation.", 0, "", 0, FALSE]; -- There are only two lines in the bottom message window. BruceDefs.WarningCarat [ph.currentChar-tNumberOfDigits-2, ph.currentChar-2]; IF ~inD.Confirm[2] THEN ERROR ParseFault[" Change temperature value and compile again.", ph.currentChar-tNumberOfDigits-2, ph.currentChar-2]; END; FOR zo: BruceDefs.ZoneIndex IN BruceDefs.ZoneIndex DO table1: DescribeTable _ DESCRIPTOR[ptt[tn][R]]; table2: DescribeTable _ DESCRIPTOR[ptct[tn][R][zo]]; recordtable: Record _ [table1, table2]; TempCorrectArray[zo] _ Interpolation2 [temp, recordtable]; ENDLOOP; a _ TempCorrectArray[1]; b _ TempCorrectArray[2]; c _ TempCorrectArray[3]; END; -- of TempCorrection GetGasFlow: PROCEDURE [ ph:ParseHandle, gasName:STRING, gasRate: CARDINAL, gNumberOfDigits: CARDINAL] RETURNS [gasFlow: CARDINAL] = -- This procedure converts the gas rate in litres per minute (l/m) into -- percentages of the full flow. BEGIN k:CARDINAL _ 0; table1: DescribeTable _ DESCRIPTOR[cgrt]; table2: DescribeTable; recordtable: Record ; FOR i:GasTypeIndex IN GasTypeIndex DO IF String.EquivalentString[gasName,gtt[i]] THEN BEGIN l_i; -- l is a global variable defined at the beginning of this program. EXIT; END; ENDLOOP; FOR i: CalibratedGasRateIndex IN CalibratedGasRateIndex DO IF gasRate # cgrt[i] THEN k_i ELSE EXIT; ENDLOOP; IF k = NumberOfCalibratedGasRate THEN BEGIN exD.DisplayBothExceptionLines ["Gas rate not profiled. Program will proceed by interpolation.", 0, "", 0, FALSE]; -- There are only two lines in the bottom message window. BruceDefs.WarningCarat [ph.currentChar- gNumberOfDigits-4, ph.currentChar-4]; IF ~inD.Confirm[2] THEN ERROR ParseFault[" Change the gas rate value and compile again.", ph.currentChar- gNumberOfDigits-4, ph.currentChar-4]; END; table2 _ DESCRIPTOR[cgrct[l]]; recordtable _ [table1, table2]; gasFlow _ Interpolation2[gasRate, recordtable]; END; -- of GetGasFlow BoatRateConversion: PROCEDURE [ ph:ParseHandle, boatRate: CARDINAL, bNumberOfDigits: CARDINAL] RETURNS [boatRatePercent:CARDINAL] = -- This procedure convert the boat speed in inches per minute into -- percentages of the full speed which is inches per minute BEGIN k: CARDINAL _0; table1: DescribeTable _ DESCRIPTOR[cbrt]; table2: DescribeTable _ DESCRIPTOR[cbrct]; recordtable: Record _ [table1, table2]; FOR i: CalibratedboatRateIndex IN CalibratedboatRateIndex DO IF boatRate # cbrt[i] THEN k_i ELSE EXIT; ENDLOOP; IF k = NumberOfCalibratedboatRate THEN BEGIN exD.DisplayBothExceptionLines ["Boat rate not profiled. Program will proceed by interpolation.", 0, "", 0, FALSE]; -- There are only two lines in the bottom message window. BruceDefs.WarningCarat [ph.currentChar- bNumberOfDigits, ph.currentChar]; IF ~inD.Confirm[2] THEN ERROR ParseFault[" Change the boat rate value and compile again.", ph.currentChar- bNumberOfDigits, ph.currentChar]; END; boatRatePercent _ Interpolation2[boatRate, recordtable]; END; -- of BoatRateConversion: ParseTube: FieldParseProc= BEGIN ErrorMessage: STRING _ [100]; ch:CompileHandle _ ph.userData; IF ~ParseToLeadingCharOnLine[ph] THEN ERROR ParseFault["Tube number is missing.", ph.currentChar, ph.currentChar]; ch.tube _ ParseDecimal[ph,1,8]; IF InitTube[ch.tube] = FALSE THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage, "Go back to the constant table. Idle conditions for tube no. "]; String.AppendNumber[ErrorMessage, ch.tube, 10]; String.AppendString[ErrorMessage, " are missing."]; ERROR ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; ch.parsedTube _ TRUE; ParseToEndOfField[ph]; END; -- of ParseTube ParseRecipe: FieldParseProc= BEGIN ch:CompileHandle _ ph.userData; rp:BruceDefs.RecipePtr _ ch.brp; i:BruceDefs.IntervalIndex _ 0; t:CARDINAL _ 1; tt:CARDINAL _ 1; g:CARDINAL _ 1; prevCtl:CARDINAL; prevTemp:CARDINAL; prevReaction: Reaction; temp:CARDINAL; diffTemp: CARDINAL; diffTempLong : LONG CARDINAL; correctiveFactor: LONG CARDINAL _ 600; -- The correctiveFactor is 60 x 10. The number 60 came from the -- sixty seconds of a minute. The factor 10 came from the fact -- that we had to scale up the number so as to avoid -- truncation when we do a division. maxRampRate:CARDINAL ; time,hour,min,sec,m:CARDINAL; timeString1:STRING _ [100]; timeString2:STRING _ [100]; timeString3:STRING _ [100]; ErrorMessage: STRING _ [100]; KeyWord: STRING _ [30]; boatSpeedSafetyString: STRING _ [100]; gas: CARDINAL; newRow:BruceDefs.GasRow _ ALL[0]; tempnewRow:BruceDefs.TempRow _ ALL[0]; gasName:STRING _ [10]; pushed:BOOLEAN _ FALSE; pulled:BOOLEAN _ FALSE; curPosition: vmD.CharIndex; IF ~ch.parsedTube THEN ERROR ParseFault["Tube number must be specified before recipe",0,0]; --The following codes take care of the idle conditions. rp.temp[1] _ id.IdleTempTable[ch.tube]; rp.gas[1] _ id.IdleGasTable[ch.tube]; rp.interval[0].controlAlg _ 0; rp.interval[0].tempAlarm _ 13; -- disable temperature alarm prevCtl _ rp.interval[0].controlAlg; prevTemp _ id.IdleTempTable[ch.tube][4]; prevReaction _ id.IdleReaction[ch.tube]; rp.interval[0].gasAlarm _ 13; -- disable gas alarm rp.interval[0].controlCoeff _ 0; -- default the control coefficients rp.interval[0].abortGroup _ 0; -- don't allow any aborts rp.interval[0].gasTempControl _ 11; -- set temp and gas control row rp.interval[0].function1 _ id.IdleFunction1Table[ch.tube]; -- End of the idle conditions codes. WHILE ParseToLeadingChar[ph] DO curPosition _ ph.currentChar; i _ CheckAndInc[ph,i,30]; [rp.interval[i].hours, rp.interval[i].minutes, rp.interval[i].seconds] _ ParseTime[ph]; R _ GetReaction [ph]; -- The following codes detect whether the temperatuers of the -- dry or wet process of the tube have been profiled or not. IF MinProfiledTemp[ch.tube][Dry] = 0 AND MinProfiledTemp[ch.tube][Wet] = 0 THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage,"Temperatures for tube # "]; String.AppendNumber[ErrorMessage, ch.tube, 10]; String.AppendString [ErrorMessage, " dry and wet processes have not been profiled."]; ERROR ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; IF MinProfiledTemp[ch.tube][R] = 0 THEN BEGIN ErrorMessage.length _ 0; String.AppendString[ErrorMessage,"Tube # "]; String.AppendNumber[ErrorMessage, ch.tube, 10]; IF R = Dry THEN String.AppendString[ErrorMessage, " dry proc"] ELSE String.AppendString[ErrorMessage, " wet proc"]; String.AppendString[ErrorMessage, " not profiled."]; String.AppendString [ErrorMessage, "Can use the profiled temps from"]; IF R = Dry THEN String.AppendString [ErrorMessage, " wet proc instead."] ELSE String.AppendString[ErrorMessage, " dry proc instead."]; exD.DisplayBothExceptionLines[ErrorMessage, 0, "", 0, FALSE]; BruceDefs.WarningCarat[curPosition - 1, curPosition]; IF ~inD.Confirm[2] THEN ERROR ParseFault["Profile the process and fill in the temperature calibration table.", ph.currentChar, ph.currentChar]; IF R = Dry THEN R _ Wet ELSE R _ Dry; END;-- of detection of profiled temperatures. DO ParseWord[ph, KeyWord]; DO IF KeyWord.length = 0 THEN EXIT; IF KeyWord[KeyWord.length-1] IN ['0..'9] THEN BEGIN KeyWord.length _ KeyWord.length -1; ph.currentChar _ ph.currentChar - 1; END ELSE EXIT; ENDLOOP; IF KeyWord[0] IN ['0..'9] THEN BEGIN ph.currentChar _ ph.currentChar - KeyWord.length; KeyWord.length _ 0; EXIT; END ELSE KeyWord.length _ 0; ENDLOOP; MissingValueCheck[ph]; [temp,tNumberOfDigits] _ BruceDefs.ParseTemp [ph,MinProfiledTemp[ch.tube][R],MaxProfiledTemp[ch.tube][R]]; --The following codes take care of the temp ramp situation. IF temp # prevTemp THEN BEGIN timeString1.length _ 0; timeString2.length _ 0; timeString3.length _ 0; IF temp > prevTemp THEN BEGIN maxRampRate _ maxRampRateUp; diffTemp _ temp - prevTemp; String.AppendString[timeString1, "Up"]; String.AppendString[timeString3, "Up"]; END ELSE BEGIN maxRampRate _ maxRampRateDown; diffTemp _ prevTemp -temp; String.AppendString[timeString1, "Down"]; String.AppendString[timeString3, "Down"]; END; time _ rp.interval[i].hours*3660+rp.interval[i].minutes*60+rp.interval[i].seconds; diffTempLong _(LONG[diffTemp]*correctiveFactor)/LONG[time]; IF diffTempLong > maxRampRate*10 AND i > 1 THEN BEGIN -- the 10 in the maxRampRate*10 arised from the fact that the -- diffTempLong has a multipication factor 10 through the -- correctiveFactor time _ ((diffTemp)*10 / maxRampRate ); sec _ (time - (time/10)*10)*6; -- Because temperatures are scaled by a factor of 10, therfore -- time here is in minute, scaled also by a factor of 10. min _ (diffTemp/maxRampRate) MOD 60; hour _ ((diffTemp/maxRampRate)/60); String.AppendString[timeString1, "Ramp rate too high. Advise to change time to "]; String.AppendNumber[timeString2, hour, 10]; String.AppendString[timeString2, "hr "]; String.AppendNumber[timeString2, min, 10]; String.AppendString[timeString2, "min "]; String.AppendNumber[timeString2, sec, 10]; String.AppendString[timeString2, "sec."]; String.AppendString[timeString1, timeString2]; exD.DisplayBothExceptionLines[timeString1,0,"",0,FALSE]; BruceDefs.WarningCarat[curPosition - 1, curPosition]; String.AppendString[timeString3, " time interval to "]; String.AppendString[timeString3, timeString2]; IF ~inD.Confirm[2] THEN ERROR ParseFault[timeString3, ph.currentChar -16, ph.currentChar-16]; END; END;-- of temp ramp situation. --The following codes take care of the temperature. --IF ~(i>1 AND temp=prevTemp AND R=prevReaction AND prevCtl=8) THEN BEGIN --BEGIN --t _ CheckAndInc[ph,t,8]; --FOR h:BruceDefs.TempColIndex IN BruceDefs.TempColIndex DO --rp.temp[t][h] _ temp; --ENDLOOP; --[rp.temp[t][1] ,rp.temp[t][2],rp.temp[t][3]] --_ TempCorrection[ph,rp, t, ch.tube, R, temp, tNumberOfDigits]; --provide temp corrections for column 1 to 3 --END; t_CheckAndInc[ph,t,8]; FOR h:BruceDefs.TempColIndex IN BruceDefs.TempColIndex DO tempnewRow[h]_temp; ENDLOOP; [tempnewRow[1],tempnewRow[2],tempnewRow[3]] _ TempCorrection[ph,rp, t,ch.tube, R,temp, tNumberOfDigits]; FOR m IN [1..t) DO FOR n: BruceDefs.TempColIndex IN BruceDefs.TempColIndex DO IF rp.temp[m][n] # tempnewRow[n] THEN EXIT; REPEAT FINISHED => WriteTempRow _ FALSE; ENDLOOP; IF WriteTempRow = FALSE THEN EXIT; ENDLOOP; IF WriteTempRow= TRUE THEN BEGIN rp.temp[t] _ tempnewRow; tt _ t; END ELSE BEGIN tt _ m; t _ t-1; END; rp.interval[i].controlAlg _ IF temp=prevTemp THEN 8 ELSE 0; rp.interval[i].tempAlarm _ 13; -- disable temperature alarm prevCtl _ rp.interval[i].controlAlg; prevTemp _ temp; -- End of temperature related codes. -- The following codes take care of the gas table and -- the gas switches in the interval table. GasOneFlow _ 0; GasTwoFlow _ 0; tcaON _ FALSE; O2ON _ FALSE; POCl3ON _ FALSE; DO ParseWord[ph,gasName]; IF gasName[0] IN ['0..'9] OR gasName[0] ='. OR gasName[0] ='@ THEN ERROR ParseFault["Please specify the name of gas.", ph.currentChar-gasName.length -1, ph.currentChar-gasName.length -1]; FOR p:GasControllerIndex IN GasControllerIndex DO IF String.EquivalentString[gasName,gpt[ch.tube][p]] THEN BEGIN j_p; -- j is a global variable defined at the beginning of -- this program. EXIT; END; REPEAT FINISHED => ERROR ParseFault ["The system was not hooked up with the type of gas you specified.", ph.currentChar-gasName.length, ph.currentChar]; ENDLOOP; FOR q:GasTypeIndex IN GasTypeIndex DO IF String.EquivalentString[gasName,gtt[q]] THEN EXIT; REPEAT FINISHED => ERROR ParseFault ["The type of gas you specified has not been profiled at all.", ph.currentChar-gasName.length, ph.currentChar]; ENDLOOP; IF String.EquivalentString[gasName,"Ar"] THEN rp.interval[i].function1[2] _ 0; IF String.EquivalentString[gasName,"N2"] THEN rp.interval[i].function1[2] _ 0; ParseToNonWhite[ph]; [] _ ParseCharIfCharIs[ph,'@]; MissingValueCheck[ph]; [gas, gNumberOfDigits] _ BruceDefs.ParseGas[ph, MinGasFlowConversion,MaxGasFlowConversion]; IF String.EquivalentString[gasName,GasOne] THEN GasOneFlow _ gas; IF String.EquivalentString[gasName,GasTwo] THEN GasTwoFlow _ gas; IF String.EquivalentString[gasName,"tca"] THEN tcaON _ TRUE; IF String.EquivalentString[gasName,"O2"] THEN O2ON _ TRUE; IF String.EquivalentString[gasName,"POCl3"] THEN POCl3ON _ TRUE; IF String.EquivalentString[gasName,"N2"] AND ch.tube IN [1..4] THEN BEGIN rp.interval[i].function1[4] _ 1; j _ 4; END; IF String.EquivalentString[gasName,"N2"] AND ch.tube IN [5..6] THEN BEGIN rp.interval[i].function1[4] _ 1; j _ 3; END; IF String.EquivalentString[gasName,"N2"] AND ch.tube IN [7..8] THEN BEGIN rp.interval[i].function1[4] _ 1; j _ 1; END; newRow[j] _ GetGasFlow[ph, gasName, gas, gNumberOfDigits] ; rp.interval[i].function1[9-j] _ 1; -- The order of the switches in the table form and in the -- DDC microcontroller is opposite. 123456789 in the function1 format -- of the DDC microcontroller corresponds to 876543210 in the -- table format seen on the Alto after you click the word compile. IF ~ParseToLeadingCharOnLine[ph] THEN EXIT; IF ~ParseCharIfCharIs[ph,'+] THEN EXIT; ENDLOOP; prevReaction _ R; IF GasOneFlow # 0 AND GasTwoFlow # 0 THEN BEGIN IF (LONG[GasOneFlow] *LONG[100])/LONG[GasTwoFlow] >= LONG[GasOneToGasTwoSafetyRatio] THEN BEGIN GasOneFlow _ 0; GasTwoFlow _ 0; ErrorMessage.length _ 0; String.AppendString[ErrorMessage, " The ratio of "]; String.AppendString[ErrorMessage, GasOne]; String.AppendString[ErrorMessage, " to "]; String.AppendString[ErrorMessage, GasTwo]; String.AppendString[ErrorMessage, " >= "]; AppendScaleNumber[GasOneToGasTwoSafetyRatio, GasScaledFactor, ErrorMessage]; String.AppendString[ErrorMessage, ". EXPLOSION may occur. Process rejected. "]; ParseFault[ErrorMessage, ph.currentChar, ph.currentChar]; END; END; GasTwoFlow _ 0; IF tcaON = TRUE AND O2ON = TRUE THEN rp.interval[i].function1[2] _ 1; IF tcaON = TRUE AND O2ON = FALSE THEN BEGIN ParseFault ["You have your tca on without the O2. Please turn on the O2", ph.currentChar, ph.currentChar]; END; --tcaON _ FALSE; IF POCl3ON = TRUE AND O2ON = FALSE THEN BEGIN --POCl3ON _ FALSE; ParseFault ["You have your POCl3 on without the O2. Please turn on the O2", ph.currentChar, ph.currentChar]; END; --POCl3ON _ FALSE; --O2ON _ FALSE; IF ch.tube IN [1..4] THEN rp.interval[i].function1[3] _ 1; -- The above line of codes will cause the function switch # 6 in the --interval table to take on the value 1 if the tube specified in the -- recipe is either tube 1, 2, 3 or 4. -- End of taking care of the gas table and the gas switches -- in the interval table. -- The following codes take care of the temp and gas set in -- the interval table. g _ CheckAndInc[ph,g,8]; FOR m IN [1..g) DO FOR n: BruceDefs.GasColIndex IN BruceDefs.GasColIndex DO IF rp.gas[m][n]# newRow[n] THEN EXIT; REPEAT FINISHED => WriteGasRow _FALSE; ENDLOOP; IF WriteGasRow = FALSE THEN EXIT; ENDLOOP; IF WriteGasRow=TRUE THEN BEGIN rp.gas[g] _ newRow; rp.interval[i].gasTempControl _ 10*tt +g; -- set temp and gas control row END ELSE BEGIN rp.interval[i].gasTempControl _ 10*tt +m; -- set temp and gas control row g _ g -1; END; WriteGasRow _TRUE; WriteTempRow _TRUE; newRow _ ALL[0]; tempnewRow _ ALL[0]; -- End of temp and gas set. -- The following codes take care of the temp and gas alarm in -- the interval table. rp.interval[i].gasAlarm _ 13; -- disable gas alarm rp.interval[i].controlCoeff _ 0; -- default the control coefficients rp.interval[i].abortGroup _ 0; -- don't allow any aborts -- End of temp and gas alarm. -- The following codes take care of the boat conditions. IF ParseToLeadingCharOnLine[ph] THEN BEGIN w:STRING _ [10]; boatRate:CARDINAL; ParseWord[ph,w]; IF w[0] IN ['0..'9] OR w[0] ='. OR w[0] ='@ THEN ERROR ParseFault ["Please specify the boat condition here by the word Push or Pull.", ph.currentChar-w.length -1, ph.currentChar-w.length -1]; DO IF w[w.length-1] IN ['0..'9] THEN BEGIN w.length _ w.length -1; ph.currentChar _ ph.currentChar - 1; END ELSE EXIT; ENDLOOP; IF ~String.EquivalentString["Push"L,w] AND ~String.EquivalentString["Pull"L,w] THEN ERROR ParseFault ["Wrong word - Please specify the boat condition here by the word Push or Pull.", ph.currentChar-w.length, ph.currentChar]; IF String.EquivalentString["Push"L,w] THEN BEGIN IF pushed THEN ERROR ParseFault["Can't push more than once", ph.currentChar-4, ph.currentChar]; pushed _ TRUE; END ELSE BEGIN IF pulled THEN ERROR ParseFault["Can't pull more than once", ph.currentChar-4, ph.currentChar]; IF pulled = FALSE AND pushed = FALSE THEN ERROR ParseFault["You have to PUSH boat in FIRST then pull it out.", ph.currentChar-4,ph.currentChar]; pulled _ TRUE; END; -- Get boat speed and check for boat safety. ParseToNonWhite[ph]; [] _ ParseCharIfCharIs[ph, '@]; MissingValueCheck[ph]; [boatRate, bNumberOfDigits] _ ParseScaledNumber[ph, boatScaledFactor, boatSpeedLoBound, boatSpeedHiBound]; IF boatRate > boatSpeedSafetyLimit THEN BEGIN String.AppendString[boatSpeedSafetyString, "Boat speed is too fast -- > "]; AppendScaleNumber[boatSpeedSafetyLimit,boatScaledFactor, boatSpeedSafetyString]; String.AppendString[boatSpeedSafetyString, " inches per min. May destroy your wafers."]; exD.DisplayBothExceptionLines [boatSpeedSafetyString, 0, "", 0, FALSE]; -- There are only two lines in the bottom message window. BruceDefs.WarningCarat [ph.currentChar -bNumberOfDigits, ph.currentChar]; IF ~inD.Confirm[2] THEN ERROR ParseFault[" Change boat speed and compile again.", ph.currentChar -bNumberOfDigits, ph.currentChar]; boatSpeedSafetyString.length _ 0; END; --of boat speed and safety check. -- Set interval table for boat in and out and fill boat table. IF String.EquivalentString["Push"L,w] THEN BEGIN rp.boat.in [1][1].speed _ (BoatRateConversion[ ph, boatRate,bNumberOfDigits]+5)/10; rp.boat.in [2][1].speed _ (BoatRateConversion[ ph, boatRate,bNumberOfDigits]+5)/10; rp.boat.in [1][1].distance _ 99; rp.boat.in [2][1].distance _ 99; rp.interval[i].function2[2] _ 1; rp.interval[i].function2[1] _ 0; rp.interval[i].function2[3] _ 0; --This set function switch 10 to 1 when the boat is pushing in. END ELSE BEGIN rp.boat.out[1][1].speed _ (BoatRateConversion[ ph, boatRate,bNumberOfDigits]+5)/10; rp.boat.out[2][1].speed _ (BoatRateConversion[ ph, boatRate,bNumberOfDigits]+5)/10; rp.boat.out[1][1].distance _ 0; rp.interval[i].function2[2] _ 0; rp.interval[i].function2[1] _ 1; rp.interval[i].function2[3] _ 1; END;-- interval table for boat in and out and fill boat table. ParseToNonWhite[ph]; CheckChar[ph,'"]; ParseToNonWhite[ph]; CheckChar[ph,'/]; ParseWord[ph,w]; IF ~String.EquivalentString["min"L,w] THEN ERROR ParseFault["Boat rates must given as ""/min", ph.currentChar-w.length, ph.currentChar]; ParseToEndOfLine[ph]; END ELSE BEGIN rp.interval[i].function2[2] _ 0; rp.interval[i].function2[1] _ 0; END;-- of the codes that take care of the boat conditions. ENDLOOP; -- corresponds to the DO in the WHILE ParseToLeadingChar[ph] statement. -- Move Bruce Furnace Control Coefficients from this tube into recipe rp.control _ fct[ch.tube].controlTable; rp.tempRange _ fct[ch.tube].tempRangeTable; IF pulled = FALSE THEN BEGIN IF pushed = TRUE THEN ERROR ParseFault["You have forgotten to pull the boat out.", ph.currentChar, ph.currentChar] ELSE ERROR ParseFault ["You have forgotten to push the boat in AND pull the boat out.", ph.currentChar, ph.currentChar]; END; END; -- of ParseRecipe END.