File BansheeCounterImpl.mesa
Copyright (C) Xerox Corporation 1984, 1985, 1986. All rights reserved.
Last edited by Strickberger 12-Aug-85 18:59:10
Ruseli Binsol: October 10, 1986 11:15:26 am PDT
Tim Diebert: December 2, 1986 3:05:18 pm PST
DIRECTORY
BasicTime USING [Now, nullGMT],
BansheeCodes USING [PrinterCommand, PrinterStatus],
BansheeControl USING [LogItem, WaitLogItem],
BansheeCounter USING [Handle, Item, Object],
EngineLog USING [ForceOut, Map],
Process USING [Detach, priorityForeground, SetPriority];
BansheeCounterImpl: CEDAR PROGRAM
IMPORTS BasicTime, BansheeControl, EngineLog, Process
EXPORTS BansheeCounter = BEGIN
Constants:
currentLogVersion: CARDINAL = 1;
Variables:
log: BansheeCounter.Handle;
PUBLIC PROCEDUREs:
ForceOut: PUBLIC PROCEDURE = BEGIN
EngineLog.ForceOut[];
END;
force out the current log
Get: PUBLIC PROCEDURE RETURNS [dataBase: BansheeCounter.Handle] = BEGIN
ForceOut, then return a pointer to the BansheeCounter.Object in the log file
ForceOut[];
RETURN[dataBase: log];
END; -- Get
Reset: PUBLIC PROCEDURE = BEGIN
writes a log record with all counters set to zero
log.resetTime ← BasicTime.Now[];
log.counter ← ALL[0];
ForceOut[];
END; -- Reset
PRIVATE PROCEDUREs:
Initialize: PROCEDURE = TRUSTED BEGIN
log: BansheeCounter.Handle ← NEW[BansheeCounter.Object];
log^ ← LOOPHOLE[EngineLog.Map[ engineType: banshee, version: currentLogVersion], BansheeCounter.Handle]^;
IF log.resetTime = BasicTime.nullGMT THEN Reset[];
Process.Detach[FORK WatchLogItem];
END; -- Initialize
WatchLogItem: PROCEDURE = BEGIN
forked in Initialize
maintain internal counters for each event type recorded in the log(s)
itemIn: BansheeControl.LogItem;
itemOut: BansheeCounter.Item;
lastCommand: BansheeCodes.PrinterCommand ← VAL[0];
lastStatus: BansheeCodes.PrinterStatus ← VAL[0];
Process.SetPriority[Process.priorityForeground];
DO
TRUSTED {itemIn ← BansheeControl.WaitLogItem[]}; -- returns item for logging
WITH item: itemIn SELECT FROM
command => BEGIN
itemOut ← SELECT item.command FROM
feed => feed,
solicitStatus => solicitStatus,
chime => chime,
solicitPaperSize => solicitPaperSize,
enterLoopbackMode => enterLoopbackMode,
ENDCASE => null; -- others not logged
lastCommand ← item.command;
END;
printerStatus => BEGIN
itemOut ←
IF lastCommand = solicitStatus AND lastStatus = item.printerStatus THEN
null
ELSE
SELECT item.printerStatus FROM
noStatus => noStatus,
paperLetter => paperLetter,
paperA4 => paperA4,
paper215X330 => paper215X330,
paperLegal => paperLegal,
paperEnvelope10 => paperEnvelope10,
paperEnvelopeRX => paperEnvelopeRX,
preregistrationJam => preregistrationJam,
noPaper => noPaper,
callForService => callForService,
fuserJam => fuserJam,
noExit => noExit,
clamShellOpen => clamShellOpen,
feeding => null, -- transient response to inquiry only
readyToFeed => readyToFeed,
parityError => parityError,
feedRejected => feedRejected,
diagnosticMode => diagnosticMode,
feedTrayNotEngaged => feedTrayNotEngaged,
pageSync => pageSync,
pageDelivered => pageAtOutputTray,
keyOffLine => keyOffLine,
outputTrayFull => outputTrayFull,
noToner => noToner,
keyReset => keyReset,
keyLastPage => keyLastPage,
copyModeOn => copyMode,
revisionLevelPrefix => null, -- inconsequential
alternatePowerUp => null, -- not used
test36 => keyTest36,
test37 => keyTest37,
test38 => keyTest38,
test39 => keyTest39,
test40 => keyTest40,
test41 => keyTest41,
test42 => keyTest42,
test43 => keyTest43,
test44 => keyTest44,
test45 => keyTest45,
test46 => keyTest46,
test47Loopback => keyTest47Loopback,
testStop => keyTestStop,
testPrintRequest => testPrintRequest,
statusError => statusError,
statusOverRun => statusOverRun,
ENDCASE => undefinedStatus;
lastStatus ← item.printerStatus;
END;
softwareStatus => BEGIN
itemOut ← SELECT item.statusExtras FROM
communicationFault => communicationFault,
imageFault1 => imageFault1,
imageFault2 => imageFault2,
sequenceFault => sequenceFault,
ENDCASE => null;
END;
plateStatus => BEGIN
itemOut ← SELECT item.plateStatus FROM
bandOverrun => bandOverrun,
pageSyncMiss => pageSyncMiss,
ENDCASE => null;
END;
ENDCASE;
log.counter[itemOut] ← SUCC[log.counter[itemOut]];
ENDLOOP;
END; -- WatchLogItem
MAINLINE CODE:
Initialize[];
END.
LOG
When / Who / What.
11-Dec-84 1:54:16 / Strickberger / Created.
28-Jan-85 15:14:04 / Strickberger / Add processing for enterLoopbackMode and parityError items.
19-Feb-85 17:27:09 / Strickberger / Fix processing of unlogged items.
12-Aug-85 18:59:10 / Strickberger / Rewrite to use EngineLog. Log polled status once only. Update to Euclid interfaces. FixArrows.