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 list: LIST OF Event, --the ordered list of refs 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. pSchedule.mesa Copyright c 1986 by Xerox Corporation. All rights reserved. Christian LeCocq January 28, 1987 6:01:59 pm PST 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 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. Κ0˜codešœ ™ Kšœ Οmœ1™Kšœ™—šž œŸœŸœŸœ˜?Kšœa™a—š ‘œŸœ7ŸœŸœŸœ˜xKšœE™EKš œ ŸœŸœ ŸœŸœŸœŸœ˜J—š‘œŸœ ŸœŸœ ŸœŸœŸœ˜AKšœD™D——šœ™KšœŸœŸœ ˜š œ ŸœŸœŸ œŸœ˜,Kšœ -˜CKšœŸœŸœ %˜:Kšœ Ÿœ ˜+KšœŸœŸœ .˜K˜—š ‘ΠbnœŸœŸœŸœŸœ˜UKšœ7™7—š‘ œŸœ˜"Kšœ5™5—š’œŸœŸœŸœ ˜;K™—š‘ œŸœŸœ˜