StopWatch.mesa
Copyright Ó 1992 by Xerox Corporation. All rights reserved.
Buchanan, August 26, 1992 12:59 pm PDT
StopWatch:
CEDAR
DEFINITIONS = {
Milliseconds: TYPE ~ Process.Milliseconds;
Viewer: TYPE ~ ViewerClasses.Viewer;
ROPE: TYPE ~ Rope.ROPE;
VEC: TYPE ~ Imager.VEC;
HandData: TYPE ~ REF HandDataRep;
HandDataRep:
TYPE ~
RECORD [
width: INT ¬ 0,
length: REAL ¬ 0,
angle: REAL ¬ 0,
oldPos: VEC ¬ [0, 0]
];
WatchData: TYPE ~ REF WatchDataRep;
WatchDataRep:
TYPE ~
MONITORED
RECORD [
secondHand: HandData ¬ NIL,
minuteHand: HandData ¬ NIL,
hourHand: HandData ¬ NIL,
oldPosValid: BOOL ¬ FALSE,
startTime: REF ANY ¬ NIL,
frameCount: INT ¬ 0,
rate: Milliseconds ¬ STOPWATCHSLEEP,
resumed: CONDITION,
paused: BOOLEAN ¬ FALSE,
done: BOOLEAN ¬ FALSE,
cleanUp: BOOLEAN ¬ FALSE
];
Constants
STOPWATCHSLEEP:
INT = 1000;
At this rate, the stop watch shows 1 frame per second (i.e., it acts just like a real clock).
ShowStopWatch: PROC [v: Viewer, hours, minutes, seconds: INT, frames: INT];
ChangeRate: PROC [wd: WatchData, newRate: Milliseconds ¬ STOPWATCHSLEEP];
Pause: PROC [wd: WatchData];
Resume: PROC [wd: WatchData];
End: PROC [wd: WatchData];
CreateViewer: PROC [vName: ROPE] RETURNS [viewer: Viewer];
}.