-- File: StatsStrings.mesa,  Last Edit: HGM  January 6, 1981  10:39 PM

DIRECTORY
  String USING [EquivalentString],
  StatsDefs USING [StatCounterIndex],
  StatsOps USING [];

StatsStrings: MONITOR IMPORTS String EXPORTS StatsDefs, StatsOps =
  BEGIN OPEN StatsDefs;


  statText: PUBLIC ARRAY StatCounterIndex OF STRING ←
    [

      -- General
      statMouseTrap: "***** MouseTrap *****", statTime: "MiliSeconds Wall Time",
      statSeconds: "Seconds", statHours: "Hours",

      -- Queue package
      statEnqueue: "Buffers Enqueued", statDequeue: "Buffers Dequeued",
      statXqueue: "Buffers extracted from a queue",
      statDequeueNIL: "Empty Dequeue calls",
      statXqueueNIL: "Empty ExtractFromQueue calls",

      statNoBuffer: "FreeQueue Empty", statBufferWaits: "Waits for a Buffer",
      statRecyclingZombieBuffersTime:
      "MilliSeconds wall time spent recycling inactive Buffers",

      -- Router
      statZappedP: "Zapped Packets", statJunkBroadcastPups: "Junk Broadcast Pups",
      statJunkBroadcastOis: "Junk Broadcast OIS Packets",
      statJunkPupsForUsNoLocalSocket: "Junk Pups For Us - No Local Socket",
      statJunkOisForUsNoLocalSocket: "Junk OIS Packets For Us - No Local Socket",
      statPacketsDiscarded: "Packets Discarded",
      statPupsDiscarded: "Pups Discarded",
      statOisDiscarded: "OIS Packets Discarded", statPupReceived: "Pups Received",
      statOisReceived: "OIS Packets Received", statPupForwarded: "Pups Forwarded",
      statOisForwarded: "OIS Packets Forwarded", statPupSent: "Pups Sent",
      statOisSent: "OIS Packets Sent", statPupBroadcast: "Pups Broadcast",
      statOisBroadcast: "OIS Packets Broadcast",
      statPupGatewayPacketsRecv: "Pup Gateway Info Packets Received",
      statOisGatewayPacketsRecv: "OIS Gateway Info Packets Received",
      statErrorPupsSent: "Error Pups sent",
      statOisErrorPacketsSent: "OIS Error Packets sent",
      statPupsSentNowhere: "Pups Sent to Unknown Network",
      statOisSentNowhere: "OIS Packets Sent to Unknown Network",
      statPupNotForwarded: "Pups Not Forwarded",
      statOisNotForwarded: "OIS Packets Not Forwarded",
      statPupInputQueueOverflow: "Pups recycled - Input Queue Full",
      statOisInputQueueOverflow: "OIS Packets recycled - Input Queue Full",
      pupTooShort: "Pups received with length less than 22 bytes ***",
      statReceivedBadPupChecksum: "Pups received with Bad Software Checksum ***",
      statReceivedBadOisChecksum:
      "OIS Packets received with Bad Software Checksum ***",

      -- Socket level debugging
      pupsEchoed: "Pups Echoed", pupsBadEchoed: "Pups Echoed with bad checksum",
      pupBytesEchoed: "Bytes in Pups Echoed", packetsEchoed: "Packets Echoed",
      packetsBadEchoed: "Packets Echoed with bad checksum",
      bytesEchoed: "Bytes Echoed",

      -- Ethernet Hardware Interface
      statEtherPacketsSent: "Ether Packets Sent",
      statEtherWordsSent: "Ether Words Sent",
      statEtherPacketsReceived: "Ether Packets Received",
      statEtherWordsReceived: "Ether Words Received",
      statEtherPacketsLocal: "Ether Packets copied Locally",
      statEtherWordsLocal: "Ether Words copied Locally",
      statEtherInUnderOut: "Ether Packets Received while Sending - InUnderOut",

      -- Collisions
      statEtherSendsCollision1: "Collisions - once",
      statEtherSendsCollision2: "Collisions - twice",
      statEtherSendsCollision3: "Collisions - 3",
      statEtherSendsCollision4: "Collisions - 4",
      statEtherSendsCollision5: "Collisions - 5",
      statEtherSendsCollision6: "Collisions - 6",
      statEtherSendsCollision7: "Collisions - 7",
      statEtherSendsCollision8: "Collisions - 8",
      statEtherSendsCollision9: "Collisions - 9",
      statEtherSendsCollision10: "Collisions - 10",
      statEtherSendsCollision11: "Collisions - 11",
      statEtherSendsCollision12: "Collisions - 12",
      statEtherSendsCollision13: "Collisions - 13",
      statEtherSendsCollision14: "Collisions - 14",
      statEtherSendsCollision15: "Collisions - 15",
      statEtherSendsCollisionLoadOverflow: "Collisions - too many",

      -- Ethernet driver Glitches
      statEtherLostInterrupts: "Lost Ethernet Interrupts  ************",
      statEtherMissingStatus: "Missing Ethernet Interrupt Status",
      statEtherInterruptDuringInterrupt: "Ethernet Interrupts during Interrupt",
      statResetDidntPost: "Ethernet Resets didn't Post  ************",
      statInterfaceReset: "Ethernet Interface Reset",
      statPacketsStuckInOutput: "Ethernet Packets Stuck in Output",
      statInputIdle: "Ethernet Input Idle too long",

      -- receiver funnys
      statEtherReceivedNot16: "Ethernet Receiver Not 16 and OK CRC ******",
      statEtherReceivedNot16BadCRC: "Ethernet Receiver Not 16 and Bad CRC",
      statEtherReceivedBadCRC: "Ethernet Receiver with Bad CRC ***",
      statEtherReceivedOverrun: "Ethernet Receiver Overran",
      statEtherReceivedBadStatus: "Ethernet Receiver Bad Status",
      statEtherReceivedTooLong: "Ethernet Packets received that were Too Long",
      statEtherReceivedKlobberedByReset:
      "Ethernet Packets Klobbered by Reset (to Send)",
      statEtherEmptyFreeQueue: "Ethernet Packets Recycled - FreeQueue Empty",
      statEtherEmptyNoBuffer: "Ethernet Packets Missed - No Buffer ready",
      statEtherEmptyInputChain: "Ethernet Input Chain was Empty",

      -- transmitter funnys
      statEtherSendWhileReceiving: "Ethernet Packets Sent while Pouring In",
      statEtherSendOverrun: "Ethernet Transmitter Overrun",
      statEtherSendBadStatus: "Ethernet Transmitter Bad Status",
      statEtherSendFromOutputQueue: "Ethernet Packets sent from Output Queue",

      -- 8/32/48 translation things
      cacheFault: "Translation cache faults",
      unsuccessfulTranslation: "Translation failures",
      translationRetries: "Translation retries",
      requestsForMe: "Translation requests for ME",
      cacheDepth: "Translation cache hops",

      -- Streams
      statDataPacketsSent: "Data Packets Sent",
      statDataBytesSent: "Data Bytes Sent",
      statDataPacketsReceived: "Data Packets Received",
      statDataBytesReceived: "Data Bytes Received", statMarksSent: "Marks Sent",
      statMarksReceived: "Marks Received",
      statAckRequestsSent: "Ack Requests Sent",
      statAckRequestsReceived: "Ack Requests Received", statAcksSent: "Acks Sent",
      statAcksReceived: "Acks Received",
      statSystemPacketsSent: "System Packets Sent",
      statSystemPacketsReceived: "System Packets Received",
      statAttentionsSent: "Attentions Sent",
      statAttentionsReceived: "Attentions Received",

      statDataPacketsRetransmitted: "Data Packets Retransmitted",
      statErrorPacketsSent: "Error Packets Sent",
      statErrorPacketsReceived: "Error Packets Received",

      statDataPacketsReceivedAgain: "Data Packets Received Again",
      statDataPacketsReceivedEarly: "Data Packets Received Early",
      statDataPacketsReceivedVeryLate: "Data Packets Received Very Late",

      statProbesSent: "Probes Sent", statProbesReceived: "Probes Received",
      statEmptyFunnys: "Funny Empty Packets", statEmptyAlloc: "Empty Allocates",
      statDuplicateAcks: "Duplicate Acks",

      statPacketsRejectedBadID: "Packets Rejected - Bad ID",
      statPacketsRejectedBadSource: "Packets Rejected - Bad Source",
      statPacketsRejectedBadType: "Packets Rejected - Bad Type",



      -- spares for user use
      statSpares0: NIL, statSpares1: NIL, statSpares2: NIL, statSpares3: NIL,
      statSpares4: NIL, statSpares5: NIL, statSpares6: NIL, statSpares7: NIL,
      statSpares8: NIL, statSpares9: NIL, statSpares10: NIL, statSpares11: NIL,
      statSpares12: NIL, statSpares13: NIL, statSpares14: NIL, statSpares15: NIL,
      statSpares16: NIL, statSpares17: NIL, statSpares18: NIL, statSpares19: NIL,
      statSpares20: NIL, statSpares21: NIL, statSpares22: NIL, statSpares23: NIL,
      statSpares24: NIL, statSpares25: NIL, statSpares26: NIL, statSpares27: NIL,
      statSpares28: NIL, statSpares29: NIL, statSpares30: NIL, statSpares31: NIL,
      statSpares32: NIL, statSpares33: NIL, statSpares34: NIL, statSpares35: NIL,
      statSpares36: NIL, statSpares37: NIL, statSpares38: NIL, statSpares39: NIL,
      statSpares40: NIL, statSpares41: NIL, statSpares42: NIL, statSpares43: NIL,
      statSpares44: NIL, statSpares45: NIL, statSpares46: NIL, statSpares47: NIL,
      statSpares48: NIL, statSpares49: NIL, statSpares50: NIL, statSpares51: NIL,
      statSpares52: NIL, statSpares53: NIL, statSpares54: NIL, statSpares55: NIL,
      statSpares56: NIL, statSpares57: NIL, statSpares58: NIL, statSpares59: NIL,
      statSpares60: NIL, statSpares61: NIL, statSpares62: NIL, statSpares63: NIL,
      statSpares64: NIL, statSpares65: NIL, statSpares66: NIL, statSpares67: NIL,
      statSpares68: NIL, statSpares69: NIL, statSpares70: NIL, statSpares71: NIL,
      statSpares72: NIL, statSpares73: NIL, statSpares74: NIL, statSpares75: NIL,
      statSpares76: NIL, statSpares77: NIL, statSpares78: NIL, statSpares79: NIL,
      statSpares80: NIL, statSpares81: NIL, statSpares82: NIL, statSpares83: NIL,
      statSpares84: NIL, statSpares85: NIL, statSpares86: NIL, statSpares87: NIL,
      statSpares88: NIL, statSpares89: NIL, statSpares90: NIL, statSpares91: NIL,
      statSpares92: NIL, statSpares93: NIL, statSpares94: NIL, statSpares95: NIL,
      statSpares96: NIL, statSpares97: NIL, statSpares98: NIL, statSpares99: NIL];

  StatsStringsFull: PUBLIC ERROR = CODE;

  StatsStringToIndex: PUBLIC ENTRY PROCEDURE [s: STRING]
    RETURNS [i: StatCounterIndex] =
    BEGIN
    -- first, check for the string already existing
    FOR i IN StatCounterIndex DO
      IF statText[i] # NIL AND String.EquivalentString[s, statText[i]] THEN
	RETURN;
      ENDLOOP;
    -- its not here yet, find a slot for it
    FOR i IN StatCounterIndex DO
      IF statText[i] = NIL THEN EXIT;
      REPEAT FINISHED => ERROR StatsStringsFull;
      ENDLOOP;
    statText[i] ← s; -- NB: Not copied over

    END;

  StatsGetText: PUBLIC PROCEDURE
    RETURNS [POINTER TO ARRAY StatCounterIndex OF STRING] =
    BEGIN RETURN[@statText]; END;

  -- initialization

  END.