-- File: LogDisplayHot.mesa, Pilot Version -- last edited by: -- Dave Redell, 19 May 81 -- Mark Johnson, 7-Jan-82 16:06:34 DIRECTORY Inline USING [LongDivMod, UDDivMod], LogDefs USING [], LogPrivateDefs USING [NumberHouse, NumberHouseObject], Process USING [Seconds, SecondsToTicks, SetTimeout], String USING [AppendChar, AppendLongNumber], Time USING [Packed], TTY USING [Handle, PutChar, PutDecimal, PutLine, PutString]; LogDisplayHot: MONITOR IMPORTS Inline, Process, String, TTY EXPORTS LogDefs, LogPrivateDefs = BEGIN OPEN LogPrivateDefs; -- Global Variables -- houses: PUBLIC DESCRIPTOR FOR ARRAY OF NumberHouseObject; startUpTime: PUBLIC Time.Packed; uptimeHouse: PUBLIC NumberHouseObject; typescriptOn: PUBLIC BOOLEAN; tty: PUBLIC TTY.Handle; -- Miscellaneous Declarations -- IllegalUseOfLog: PUBLIC ERROR = CODE; -- Statistics Display Procedures (exported to LogPrivateDefs) -- Displayer: PUBLIC ENTRY PROCEDURE [waitInterval: Process.Seconds] = -- expects to be FORKed. Loops until aborted, waiting for the argument interval, then updates -- the statistics display. BEGIN OPEN Process, String; sleep: CONDITION; SetTimeout[@sleep, SecondsToTicks[waitInterval]]; DO -- calculate new min/max -- FOR i: CARDINAL IN [0..LENGTH[houses]) DO h: NumberHouse = @houses[i]; WITH item: h SELECT FROM short => BEGIN IF item.max < item.p­ THEN item.max ¬ item.p­; IF item.p­ < item.min THEN item.min ¬ item.p­; END; long => BEGIN IF item.max < item.p­ THEN item.max ¬ item.p­; IF item.p­ < item.min THEN item.min ¬ item.p­; END; percent => BEGIN pct: CARDINAL ¬ MIN[item.p­, 100]; IF item.max < pct THEN item.max ¬ pct; IF pct < item.min THEN item.min ¬ pct; END; ENDCASE; ENDLOOP; WAIT sleep[ ! ABORTED => EXIT]; ENDLOOP; END; --Displayer AppendElapsedTime: PUBLIC PROCEDURE [s: STRING, et: LONG CARDINAL] = -- appends to 's' a time derived from 'et' of the form: 1314:35:28. BEGIN OPEN String; Append2: PROCEDURE [s: STRING, v: LONG CARDINAL] = BEGIN n, r: CARDINAL; [n, r] ¬ Inline.LongDivMod[v, 10]; AppendChar[s, n + '0]; AppendChar[s, r + '0]; END; -- Append2 n, mm, ss: LONG CARDINAL; [n, ss] ¬ Inline.UDDivMod[et, 60]; [n, mm] ¬ Inline.UDDivMod[n, 60]; AppendLongNumber[s, n, 10]; AppendChar[s, ':]; Append2[s, mm]; AppendChar[s, ':]; Append2[s, ss]; END; --AppendElapsedTime -- Typescript Procedures (exported to LogDefs) -- WriteChar: PUBLIC ENTRY PROCEDURE [char: CHARACTER] = -- writes the argument character into the typescript. Characters > 177C will be ignored and ASCII control characters (other than CR, TAB, SP, and BS) will be printed as though the sequence WriteChar['­]; WriteChar[char+100B] had been executed. CR, TAB, and SP cause appropriate white space to be introduced. WriteChar must be called after TypescriptOn. BEGIN TTY.PutChar[tty, char] END; --WriteChar WriteString: PUBLIC ENTRY PROCEDURE [s: STRING] = -- writes all characters of the string into the typescript using WriteChar. BEGIN TTY.PutString[tty, s] END; --WriteString WriteLine: PUBLIC ENTRY PROCEDURE [s: STRING] = -- equivalent to WriteString[s]; WriteChar[CR]. BEGIN TTY.PutLine[tty, s] END; --WriteLine WriteDecimal: PUBLIC ENTRY PROCEDURE [n: CARDINAL] = -- writes 'n' on the typescript as an unsigned, decimal quantity. BEGIN TTY.PutDecimal[tty, CARDINAL[n]] END; --WriteDecimal NULL; -- no main program END. Created by Levin on February 6, 1980 5:48 PM. Changed by Redell on 20-May-81 19:44:02, Pilot version.