-- BruceDefs.mesa
-- last edited by Barth, December 6, 1981  5:51 PM
-- last edited by Chi Yung Fu,March 26, 1982  3:09 PM
-- last edited by Chi Yung Fu,April 30, 1982  2:38 PM
-- last edited by Chi Yung Fu,September 1, 1983  11:25 AM
-- last edited by JWhite, 25-Apr-85 12:29:05

DIRECTORY
  MachineParseDefs,
  vmD: FROM "VirtualMgrDefs";

BruceDefs: DEFINITIONS =
BEGIN

-- Types --

TubeNumber: TYPE = [1..8];
CommandType: TYPE = {AckAlarm,Abort,Start,Reset};
Bit: TYPE = [0..1];
Nibble: TYPE = [0..15];
Byte: TYPE = [0..255];
Recipe: TYPE = MACHINE DEPENDENT RECORD[
  interval(0): IntervalTable,
  alarm(155): AlarmTable,
  abortMultipliers(175): AbortMultiplierTable,
  boat(181): BoatTable,
  temp(193): TempTable,
  gas(241): GasTable,
  alert(297): AlertTable,
  control(310): ControlTable,
  tempRange(400): TempRangeTable];
RecipePtr: TYPE = POINTER TO Recipe;
IntervalIndex: TYPE = [0..30];
IntervalTable: TYPE = ARRAY IntervalIndex OF Interval;
Interval: TYPE = MACHINE DEPENDENT RECORD[
  hours(0:8..15): Byte,
  minutes(0:0..7): Byte,
  seconds(1:8..15): Byte,
  function1(1:0..7): Function1Bits,
  function2(2:12..15): Function2Bits,
  junk1(2:8..11): Bit,
  function3(2:2..7): Function3Bits,
  junk2(2:0..1): Bit,
  gasTempControl(3:8..15): Byte,
  tempAlarm(3:4..7): Nibble,
  gasAlarm(3:0..3): Nibble,
  controlAlg(4:12..15): Nibble,
  junk3(4:8..11): Nibble,
  controlCoeff(4:4..7): Nibble,
  abortGroup(4:0..3): Nibble];
Function1Bits: TYPE = PACKED ARRAY [1..8]OF Bit;
Function2Bits: TYPE = PACKED ARRAY [1..4]OF Bit;
Function3Bits: TYPE = PACKED ARRAY [1..6]OF Bit;
AlarmIndex: TYPE = [1..4];
AlarmTable: TYPE = ARRAY AlarmIndex OF Alarm;
Alarm: TYPE = MACHINE DEPENDENT RECORD[
  binaryMask(0:0..15): BinaryMaskBits,
  tempMask(1:8..15): TempMaskBits,
  junk1(1:0..7): Byte,
  gasMask(2:8..15): GasMaskBits,
  junk2(2:0..7): Byte,
  softMask(3:8..15): SoftMaskBits,
  junk3(3:0..7): Byte,
  destInterval(4:8..15): Byte,
  junk4(4:0..7): Byte];
BinaryMaskBits: TYPE = PACKED ARRAY [1..16]OF Bit;
TempMaskBits: TYPE = PACKED ARRAY [1..8]OF Bit;
GasMaskBits: TYPE = PACKED ARRAY [1..8]OF Bit;
SoftMaskBits: TYPE = PACKED ARRAY [1..8]OF Bit;
Multipliers: TYPE = ARRAY MultiplierIndex OF CARDINAL;
MultiplierIndex: TYPE = [1..3];
AbortMultiplierTable: TYPE=RECORD[
  temp: Multipliers,
  gas: Multipliers];
BoatSegment: TYPE = MACHINE DEPENDENT RECORD[
  speed(0:8..15): Byte,
  distance(0:0..7): Byte];
BoatSegments: TYPE = ARRAY BoatSegmentIndex OF BoatSegment;
BoatSegmentIndex: TYPE = [1..3];
BoatRows: TYPE = ARRAY BoatRowIndex OF BoatSegments;
BoatRowIndex: TYPE = [1..2];
BoatTable: TYPE = RECORD[
  in: BoatRows,
  out: BoatRows];
TempRow: TYPE = ARRAY TempColIndex OF CARDINAL;
TempColIndex: TYPE = [1..6];
TempTable: TYPE = ARRAY TempRowIndex OF TempRow;
TempRowIndex: TYPE = [1..8];
GasRow: TYPE = ARRAY GasColIndex OF CARDINAL;
GasColIndex: TYPE = [1..7];
GasTable: TYPE = ARRAY GasRowIndex OF GasRow;
GasRowIndex: TYPE = [1..8];
AlertTable: TYPE = RECORD[
  temp: TempRow,
  gas: GasRow];
Factors: TYPE = RECORD[
  proportionalBand: ARRAY ZoneIndex OF CARDINAL,
  reset: ARRAY ZoneIndex OF CARDINAL,
  rate: ARRAY ZoneIndex OF CARDINAL,
  outerLoopRate: ARRAY ZoneIndex OF CARDINAL,
  latency: ARRAY ZoneIndex OF CARDINAL,
  calibration: ARRAY ZoneIndex OF INTEGER];
ZoneIndex: TYPE = [1..3];
ControlTable: TYPE = RECORD[
  factorArray: ARRAY FactorIndex OF Factors,
  wierdStuff: ARRAY WierdIndex OF CARDINAL];
FactorIndex: TYPE = [1..4];
WierdIndex: TYPE = [1..18];
TempRangeTable: TYPE = ARRAY [1..4] OF CARDINAL;
  

-- Exported by BrucePacket --

Initialize: PROCEDURE;
Terminate: PROCEDURE;
DownLoad: PROCEDURE [tube:TubeNumber, brp:RecipePtr];
UpLoad: PROCEDURE [tube:TubeNumber, brp:RecipePtr];
Command: PROCEDURE [tube:TubeNumber, command:CommandType];
CommFailure: ERROR;

-- Exported by BruceToBinary --

AsciiToBinary: PROCEDURE [vmp:vmD.VirtualMessagePtr, brp:RecipePtr];
ParseTemp: PROCEDURE[ph:MachineParseDefs.ParseHandle, MinProfiledTemp:CARDINAL, MaxProfiledTemp:CARDINAL] RETURNS[t,tNumberOfDigits:CARDINAL];
ParseGas: PROCEDURE[ph:MachineParseDefs.ParseHandle,
MinGasFlowConversion: CARDINAL, MaxGasFlowConversion: CARDINAL] RETURNS[g,gNumberOfDigits:CARDINAL];

-- Exported by BruceCompiler --

InitTables: PROCEDURE[constants: vmD.VirtualMessagePtr];
SpecToBinary: PROCEDURE[data, spec: vmD.VirtualMessagePtr, brp:RecipePtr]
  RETURNS[tube:TubeNumber];

-- Exported by BruceToAscii --

BinaryToAscii: PROCEDURE [vmp:vmD.ComposedMessagePtr,
  brp:RecipePtr];

-- Exported by BruceTalker --

StartTalker: PROCEDURE;
InstallTalker: PROCEDURE;
ExecuteStep: PROCEDURE [data, spec: vmD.VirtualMessagePtr]
  RETURNS [result: STRING];
WarningCarat: PROCEDURE[pfBegin: vmD.CharIndex, pfEnd: vmD.CharIndex]; 

END.