RavenConsoleImpl.mesa
Copyright (C) Xerox Corporation 1981, 1982, 1983, 1984, 1985, 1986. All rights reserved.
Last edited by Strickberger 19-Jul-85 0:09:18
Tim Diebert: October 1, 1986 12:22:22 pm PDT
DIRECTORY
Convert USING [CardFromRope],
Process USING [Detach],
RavenCodes USING [PrinterCommand],
RavenConsole USING [Character, DisplayCode, KeyPadCode],
RavenControl USING [ConsoleKey, SendEngineCommand, WaitConsoleKey, WaitEngineStatus],
RefText USING [AppendChar, TrustTextAsRope];
RavenConsoleImpl: CEDAR PROGRAM
IMPORTS Convert, Process, RavenControl, RefText EXPORTS RavenConsole = BEGIN
TYPEs:
DisplayCommand: TYPE = RavenCodes.PrinterCommand[displayF..displayBlank];
Variables:
displayBuffer: ARRAY BOOLEAN OF DisplayCommand ← [displayBlank, displayBlank];
commands used to display the character in each position
displayIndex: BOOLEANFIRST[BOOLEAN]; -- corresponds to left and right display character positions
echoingKeyPad: BOOLEANFALSE;
RavenConsole PUBLIC PROCEDUREs:
BlankDisplay: PUBLIC PROCEDURE = BEGIN
blank one of the positions and set displayIndex to the other position
called in MarkerControlImpl by Start and Queue
IF NOT echoingKeyPad THEN
BEGIN
RavenControl.SendEngineCommand[displayBuffer[displayIndex] ← displayBlank];
displayIndex ← NOT displayIndex;
END;
END;
UpdateDisplay: PUBLIC PROCEDURE [code: RavenConsole.DisplayCode] = BEGIN
display code.left in position for displayIndex, and code.right in ~displayIndex
called in MarkerControl by RavenStatusChangeWatcher
IF NOT echoingKeyPad THEN BEGIN
RavenControl.SendEngineCommand[
displayBuffer[displayIndex] ←
IF code.left = letterF
THEN displayF
done separately because F in ConsoleCharacter # zero + 15 (zero = 30H, F = 2FH)
ELSE LOOPHOLE[ORD[code.left] + ORD[RavenCodes.PrinterCommand[display0]]]];
displayIndex ← NOT displayIndex;
RavenControl.SendEngineCommand[
displayBuffer[displayIndex] ←
IF code.right = letterF
THEN displayF
ELSE LOOPHOLE[ORD[code.right] + ORD[RavenCodes.PrinterCommand[display0]]]];
displayIndex ← NOT displayIndex;
END;
END;
WaitKeyPadCode: PUBLIC PROCEDURE RETURNS [code: RavenConsole.KeyPadCode] = BEGIN
key: RavenControl.ConsoleKey;
string: REF TEXTNEW[TEXT[5]]; char: CHAR;
DO
key ← RavenControl.WaitConsoleKey[]; -- pops console queue, waiting till non-empty
SELECT key FROM
IN [key0..key9] => BEGIN
IF NOT echoingKeyPad THEN BEGIN -- display blank
RavenControl.SendEngineCommand[displayBuffer[displayIndex] ← displayBlank];
displayIndex ← NOT displayIndex;
echoingKeyPad ← TRUE;
END;
display numeral
RavenControl.SendEngineCommand[displayBuffer[displayIndex] ← LOOPHOLE[key]];
displayIndex ← NOT displayIndex;
IF string.length # string.maxLength THEN -- append numeral to string
char ← '0 + ORD[key] - ORD[RavenControl.ConsoleKey[key0]];
string ← RefText.AppendChar[string, char];
END;
keyClear => BEGIN -- blank display and return
echoingKeyPad ← FALSE;
RavenControl.SendEngineCommand[displayBuffer[displayIndex] ← displayBlank];
displayIndex ← NOT displayIndex;
RETURN[code: [clear]];
END;
keyTest => BEGIN -- convert numerals entered to number and return
echoingKeyPad ← FALSE;
IF string.length # FIRST[CARDINAL]
THEN RETURN[code: [test, Convert.CardFromRope[RefText.TrustTextAsRope[string]]]]
ELSE RETURN[code: [test]];
END;
ENDCASE;
ENDLOOP;
END;
RestoreDisplay: PUBLIC PROCEDURE = BEGIN
redisplay console characters which were up before error
RavenControl.SendEngineCommand[displayBuffer[displayIndex]];
displayIndex ← NOT displayIndex;
RavenControl.SendEngineCommand[displayBuffer[displayIndex]];
displayIndex ← NOT displayIndex;
END;
PRIVATE PROCEDUREs:
Initialize: PROCEDURE = TRUSTED {Process.Detach[FORK WatchEngineStatus]};
WatchEngineStatus: PROCEDURE = BEGIN
wait for a new status and if status indicates intervention is needed, waits till another status indicates things are ok
DO
IF RavenControl.WaitEngineStatus[] IN [tonerLow..doorOpen] THEN
something needs to be done externally
DO -- loop until status is okay
IF RavenControl.WaitEngineStatus[] = okay THEN {RestoreDisplay[]; EXIT};
ENDLOOP;
ENDLOOP;
END;
MAINLINE CODE:
Initialize[];
END.
LOG
When / Who / What
1981/Claude Pany/Created.
1-Oct-82 17:55:11 - Trowell - added documentation
9-Apr-85 23:20:37 - Strickberger - Update for Raven engine driver redesign. Add copyright.
19-Jul-85 0:09:18 - Strickberger - Update for Euclid.