-- DiagnosticsOps.mesa  -  edited by:
-- Poskanzer	 9-May-83 18:59:28
-- Paul		13-Jul-84 10:09:16

DIRECTORY
  CommOnlineDiagnostics USING [PatternType, WordsInPacket],
  GreenFace USING [Command, Status],
  OnlineDiagnostics USING [
    ErrorHandling, GetConfirmationProc, GetFloppyChoiceProc, GetYesOrNoProc,
    PutMessageProc, SectorLength],
  RS232C USING [LineSpeed],
  Window USING [Handle];

DiagnosticsOps: DEFINITIONS =
  BEGIN
  
  cmdMax: CARDINAL = 100;

  DataHandle: TYPE = LONG POINTER TO Data;
  Data: TYPE = MACHINE DEPENDENT RECORD [
    -- File subwindow stuff
    fileSW(0): Window.Handle ← NIL,
    -- Form subwindow stuff
    -- Note: enumerateds and booleans must be word boundary
    -- aligned as addresses for them must be generated
    confirmSW(2): Window.Handle ← NIL,
    latestConfirm(4): ConfirmIndex ← confirm,
    formSW(5): Window.Handle ← NIL,
    test(7): DiagnosticsOps.Tests ← none,
    floppyTest(8): FloppyTest ← clean,
    two90test(9): Two90Test ← command,
    doubleDensity(10): BOOLEAN ← TRUE,
    doubleSided(11): BOOLEAN ← FALSE,
    realFeedBack(12): BOOLEAN ← TRUE,
    waitResponse(13): BOOLEAN ← TRUE,
    displayServers(14): BOOLEAN ← TRUE,
    lineType(15): DiagnosticsOps.RS232LineType ← bitSynchronous,
    sectorsPerTrack(16): CARDINAL [8..26] ← 15,
    sectorLength(17): OnlineDiagnostics.SectorLength ← five12,
    errorHandling(18): OnlineDiagnostics.ErrorHandling ← stopOnError,
    dataPattern(19): CommOnlineDiagnostics.WordsInPacket ← incrWords,
    pattern(20): CommOnlineDiagnostics.PatternType ← byteIncr,
    lineSpeed(21): RS232C.LineSpeed ← bps4800,
    operation(22): Operation ← initialize,
    constant(23): CARDINAL ← 0,
    minPacketSize(24): CARDINAL ← 2,
    maxPacketSize(25): CARDINAL ← 512,
    delayBetween(26): CARDINAL ← 100,
    trackNumber(27): CARDINAL ← 1,
    startingSector(28): CARDINAL ← 1,
    sectorCount(29): CARDINAL ← 1,
    increment(30): INTEGER ← 0,
    dataWord(31): CARDINAL ← 177777B,
    loopCount(32): CARDINAL ← 65535,
    dataDisplayed(33): DataDisplayed ← status,
    confirming(34): BOOLEAN ← FALSE,--mode switch-only one formSW active at a time
    reDisplay(35): BOOLEAN ← FALSE,  -- used by the enumerated notify procs
    inALoop(36): BOOLEAN ← FALSE,  -- for the floppy command file test
    cmdCount(37): [0..cmdMax] ← 0,
    two90Command(38): GreenFace.Command ← null,
    two90Mode(39): Two90Mode ← plot,
    two90Plotter(40): DiagnosticsOps.PlotterType ← v80,
    two90Output(41): Two90Pattern ← plot,
    two90Status(42): GreenFace.Status ← null,
    cmdIndexes(43): ARRAY [0..cmdMax] OF CARDINAL ← ALL[0],--note unusual indexing
    strings(144): ARRAY DiagnosticsOps.StringIndex OF LONG STRING ← ALL[NIL]];
    
  
  ConfirmIndex: TYPE = {confirm, yes, no, continue, loop, display, exit};
  FloppyTest: TYPE = {clean, standard, summary, format, exercise, cmdFile};
  Operation: TYPE = {
    initialize, recalibrate, readStatus, readHeader, readSectors, writeSectors,
    writeDeletedSectors, verify, loop, displayData, clearLog, log};
  DataDisplayed: TYPE = {status, header, sector, summary};
  
  Two90Test: TYPE = {command, output};
  Two90Mode: TYPE = {plot, print};
  Two90Pattern: TYPE = {plot, print, screen};

  toolData: PUBLIC DataHandle;  -- Tool's data

  -- The following procedure is the only "public" entry - when you type "T" to Bye it calls this.

  DiagnosticsActivate: PROCEDURE;

  -- The rest are private to the various modules of the diagnostics.

  Tests: TYPE = {ethernet, RS232C, display, keyboard, floppy, two90, none};
  
  StringIndex: TYPE = {
    currOrganization, currDomain, thisEthernetID, thisProcessorID, listFS,
    listPS, listMS, testEthernetID, testProcessorID, cmdFile};
  
  -- Exported by DiagnosticsImplA:
  
  running: BOOLEAN;
  calledByBye: BOOLEAN;
  confirmation: CONDITION;
  diagnosticwh: Window.Handle;
  
  -- Exported by DiagnosticsImplB:
  
  KeyboardAndMouseTest: PROCEDURE;

  LFDisplayTest: PROCEDURE;

  -- Exported by DiagnosticsImplC:
  
  EchoUserTest: PROCEDURE [
    currDomain: LONG STRING, currOrganization: LONG STRING, usernet: LONG STRING,
    user: LONG STRING, targetnet: LONG STRING, target: LONG STRING,
    realFeedBack, waitResponse: BOOLEAN, 
    dataPattern: CommOnlineDiagnostics.WordsInPacket,
    minPacketSize, maxPacketSize, delayBetween: CARDINAL];

  -- Exported by DiagnosticsImplD:
  
  FloppyStandardTest: PROCEDURE;
  FloppyCleanReadWriteHeads: PROCEDURE;
  FloppyCommandFileTest: PROCEDURE [
    doubleDensity: BOOLEAN, doubleSided: BOOLEAN,
    sectorsPerTrack: CARDINAL [8..26],
    sectorLength: OnlineDiagnostics.SectorLength,
    errorHandling: OnlineDiagnostics.ErrorHandling, cmdFile: LONG STRING];
  FloppyDisplayErrorLog: PROCEDURE;
  FloppyExerciser: PROCEDURE;
  FloppyFormatDiskette: PROCEDURE;

  -- Exported by DiagnosticsImplE:
  
  Help: PROCEDURE [test: Tests];
  More: PROCEDURE RETURNS [okay: BOOLEAN];

  -- Exported by DiagnosticsImplF:
  
  HelpToo: PROCEDURE;

  -- Exported by DiagnosticsImplG:

  PutChar: PROCEDURE [ch: CHARACTER, minWidth: CARDINAL ← 0];
  PutCR: PROCEDURE;
  PutLine: PROCEDURE [text: LONG STRING];
  PutText: PROCEDURE [text: LONG STRING, minWidth: CARDINAL ← 0];
  PutMessage: OnlineDiagnostics.PutMessageProc;
  GetConfirmation: OnlineDiagnostics.GetConfirmationProc;
  GetYesOrNo: OnlineDiagnostics.GetYesOrNoProc;
  GetFloppyChoice: OnlineDiagnostics.GetFloppyChoiceProc;
  CheckForAbort: PROCEDURE;


  PutNumber: PROCEDURE [
    number: UNSPECIFIED, radix: CARDINAL, minWidth: CARDINAL ← 0];
  PutLongNumber: PROCEDURE [
    number: LONG UNSPECIFIED, radix: CARDINAL, minWidth: CARDINAL ← 0];
  PutTextCentered: PROCEDURE [text: LONG STRING, width: CARDINAL ← 0];
  
  AppendServers: PROCEDURE[
    strings: LONG DESCRIPTOR FOR ARRAY DiagnosticsOps.StringIndex OF LONG STRING, z: UNCOUNTED ZONE];
  
  -- Exported by DiagnosticsImplH:
  
  RS232CLoopBackTest: PROCEDURE [
    host: LONG STRING, hostNet: LONG STRING, lineType: RS232LineType, 
    lineSpeed: RS232C.LineSpeed, pattern: CommOnlineDiagnostics.PatternType, 
    constant, minPacketSize, maxPacketSize: CARDINAL];
    
  RS232LineType: TYPE = {bitSynchronous, asynchronous};
  
  -- Exported by DiagnosticsImplI:
  
  PlotterType: TYPE = {v80, v8222, v8224, v8236, v8242, v8272, pdq};
  
  PlotPattern: PROCEDURE [plotter: PlotterType];
  PlotScreen: PROCEDURE [plotter: PlotterType];
  PrintPattern: PROCEDURE [plotter: PlotterType];
  SendCommand: PROCEDURE [plotter: PlotterType, cmd: GreenFace.Command];
  
  --GetStatus should be local to this interface only!!!!
  --GetStatus: PROCEDURE [plotter: PlotterType] RETURNS [GreenFace.Status];
  
  END.