DIRECTORY RedBlackTree; Schedule: CEDAR DEFINITIONS ~ BEGIN ps: TYPE = REAL; -- picosecond (1e-12 s) History: TYPE = LIST OF HistoryPt; --the event data representation. An History is time ordered. HistoryPt: TYPE = RECORD [t: ps, v: REAL]; CreateHistory: PROC [t: ps, v: REAL] RETURNS [newHistory: History]; KillHistory: PROC [history: History]; AddToHistory: PROC [oldHistory: History, t: ps, v: REAL] RETURNS [newHistory: History]; ForgetBeginings: PROC [oldHistory: History, t: ps] RETURNS [newHistory: History]; FirstTimeOfHistory: PROC [history: History] RETURNS [t: ps]; NextTimeOfHistory: PROC [history: History, t: ps] RETURNS [tnext: ps _ -1]; LastTimeOfHistory: PROC [history: History] RETURNS [t: ps]; LastValueOfHistory: PROC [history: History] RETURNS [v: REAL]; VFromHistory: PROC [history: History, t: ps] RETURNS [v: REAL]; EnumerateHistory: PROC [history: History, from, to: ps, action: HistoryProc] RETURNS [invalidEnumeration: BOOL _ FALSE]; HistoryProc: TYPE = PROC [t: ps, v: REAL] RETURNS [quit: BOOLEAN _ FALSE]; Schedule: PROC [hList: LIST OF History] RETURNS [lt: LIST OF ps]; Agenda: TYPE = REF AgendaRec; AgendaRec: PRIVATE TYPE = MONITORED RECORD [ execute: ExecuteProc, --the proc to call for each event of the list table: RedBlackTree.Table, --the tree of events to proceed nbOfEvents: INT _ 0, --statistical purposes data: REF ANY --whatever you want, I swear I won't touch it. ]; Event: TYPE = RECORD [ t: ps, ref: REF ANY ]; ExecuteProc: TYPE = PROC [ref: REF ANY, t: ps, data: REF ANY]; CreateAgenda: PROC [execute: ExecuteProc, data: REF ANY] RETURNS [newAgenda: Agenda]; KillAgenda: PROC [agenda: Agenda]; InsertInAgenda: PROC [agenda: Agenda, ref: REF ANY, t: ps]; ExecuteAgenda: PROC [agenda: Agenda] RETURNS [lastTime: ps]; END. ΰSchedule.mesa Copyright Σ 1986, 1987 by Xerox Corporation. All rights reserved. Bertrand Serlet April 15, 1987 4:24:55 pm PDT Christian Le Cocq October 13, 1987 4:46:57 pm PDT Schedule provides two sets of procs to deal with time oriented objects. One for lists of timed values, the other for lists of timed actions to do. UNITS History management package creates a one HistoryPt History. destroys the history structure in order to improve GC. adds a new HistoryPt to oldHistory, and erases any HistoryPt with larger t. If you add in the middle of an History the "old Future" is forgotten. destroys any HistoryPt with time less than t. returns the first time of history. returns the time of the HistoryPt following t in history. returns the last time of history returns the last v of history returns the interpolated value at t from history. ERROR if t is before the first time of history. applies action to each HistoryPt which time lies between from and to. returns the merged ordered list of all the times of all the History. Agenda Gestion list: LIST OF Event, --the ordered list of refs to proceed creates a new Agenda initialized with execute and data. destroys the agenda structure in order to improve GC. inserts a new event in place in the agenda. Avoids duplications. ERROR if t is before the first time of the event list, or if the agenda is NIL. executes and consumes the agenda.list. Returns the time of the last event executed. Pass the data field of the agenda to the ExecuteProc. ΚL˜codešœ ™ KšœB™BK™-K™1—šœ’™’K™—šΟk ˜ Jšœ ˜ J˜—šΠblœœ ˜K˜—š˜K™KšœœœΟc˜)—head™Kšœ œœœ Ÿ<˜_šœ œœ œ˜*K˜—šΟn œœ œœ˜CKšœ ™ —š  œœ˜%Kšœ6™6—š  œœ!œœ˜WKšœ‘™‘—š œœœ˜QKšœ-™-—š œœœ ˜Kšœ™—šΟb œœœœ˜?Kšœa™a—š  œœ7œœœ˜xKšœE™EKš œ œœ œœœœ˜J—š œœ œœ œœœ˜AKšœD™D——šœ™Kšœœœ ˜š œ œœ œœ˜,KšœŸ-˜CKšœœœŸ%™:KšœŸ˜:Kšœ œŸ˜+KšœœœŸ.˜K˜—š  Πbnœœœœœ˜UKšœ7™7—š  œœ˜"Kšœ5™5—š’œœœœ ˜;K™—š  œœœ˜