Oberon || Library || Module Index || Search Engine || Definition || Module
TYPE Clock = POINTER TO ClockRec; TYPE ClockRec = RECORD (Services.ObjectRec) END; CONST settime = 0; timer = 1; passed = 2; TYPE CapabilitySet = SET; (* OF [settime..passed] *) TYPE GetTimeProc = PROCEDURE (clock: Clock; VAR time: Times.Time); TYPE SetTimeProc = PROCEDURE (clock: Clock; time: Times.Time); TYPE PassedProc = PROCEDURE (clock: Clock; time: Times.Time) : BOOLEAN; TYPE TimerOnProc = PROCEDURE (clock: Clock; time: Times.Time; event: Events.Event); TYPE TimerOffProc = PROCEDURE (clock: Clock); TYPE GetPriorityProc = PROCEDURE (clock: Clock; VAR priority: Priorities.Priority); TYPE Interface = POINTER TO InterfaceRec; TYPE InterfaceRec = RECORD (Objects.ObjectRec) gettime: GetTimeProc; settime: SetTimeProc; passed: PassedProc; timeron: TimerOnProc; timeroff: TimerOffProc; getpriority: GetPriorityProc; END;
VAR system: Clock; (* the clock of the operating system *)
CONST cannotSetTime = 0; (* SetTime not implemented *) CONST cannotSetTimer = 1; (* timer not implemented *) CONST errorcodes = 2; TYPE ErrorEvent = POINTER TO ErrorEventRec; TYPE ErrorEventRec = RECORD (Events.EventRec) errorcode: SHORTINT; END; VAR errormsg: ARRAY errorcodes OF Events.Message; VAR error: Events.EventType;
PROCEDURE Init(clock: Clock; if: Interface; caps: CapabilitySet); PROCEDURE Capabilities(clock: Clock) : CapabilitySet; PROCEDURE CreateStaticClock(VAR clock: Clock); PROCEDURE GetTime(clock: Clock; VAR time: Times.Time); PROCEDURE SetTime(clock: Clock; time: Times.Time); PROCEDURE Passed(clock: Clock; time: Times.Time) : BOOLEAN; PROCEDURE TimerOn(clock: Clock; time: Times.Time; event: Events.Event); PROCEDURE TimerOff(clock: Clock); PROCEDURE GetPriority(clock: Clock; VAR priority: Priorities.Priority);
Init initializes a newly created clock and associates it with the given interface if and caps. The interface procedures are expected to meet the specifications following:
Capabilities returns the set of capabilities of clock. Note that Passed can be called in any case whether passed is set or not.
CreateStaticClock creates and initializes a static clock. Static clocks return the last time setting of SetTime.
GetTime returns the current time of clock. SetTime sets the current time of clock to time. Passed returns TRUE if time has already been passed.
TimerOn causes clock to raise event if time is reached. Multiple calls override previous settings. TimerOff switches off the timer. GetPriority returns the priority of the associated timer. This is the minimal priority when events which has been passed to TimerOn are raised.
Clocks exports system which is expected to be initialized by a system dependent module to represent the clock of the operating system. Initially, system is initialized as a static clock.
An assertion of Init fails if the given clock has not been initialized by Services.Init. Various assertions that verify that all required interface procedures passed to Init are non-NIL.
Oberon || Library || Module Index || Search Engine || Definition || Module