<> <> <> <> DIRECTORY CD, Rope USING [ROPE]; CDSequencer: CEDAR DEFINITIONS = BEGIN <> <> <<>> <> <> Command: TYPE = REF CommandRec; CommandRec: TYPE = RECORD [ key: ATOM _ NIL, design: CD.Design _ NIL, pos: CD.Position _ [0, 0], -- final position of command sPos: CD.Position _ [0, 0], -- special position, start position, (exceptional: size) l: CD.Layer _ CD.undefLayer, b: BOOL _ FALSE, n: CD.Number _ 0, ref: REF _ NIL, --typically describes issuer the command (if interactive: viewer) data: REF _ NIL --reserved for command implementor ]; CommandProc: TYPE = PROC[Command]; QueueMethod: TYPE = {doQueueAndMark, doQueue, dontQueue, useDefault}; <<--doQueueAndMark: fork and queue, mark the design as changed>> <<--doQueue: fork and queue, don't mark the design as changed>> <<--dontQueue: don't fork, don't queue, don't mark (procedure call)>> <<--useDefault: use the commands default QueueMethod >> ExecuteProc: PROC [proc: CommandProc, design: CD.Design _ NIL, queue: QueueMethod _ doQueue, comm: CDSequencer.Command _ NIL]; <<--Executes a command procedure proc.>> <<--design#NIL: design replaces comm.design>> <<--queue: useDefault -> takes queueing method from registration; otherwise -> as stated>> <<--proc must be global >> <<--To transfer client data to proc, use: "comm: NEW[CommandRec _ [data: ..]]" >> <<--Might call CD.Error[designMutability] >> ExecuteCommand: PROC [key: ATOM _ NIL, design: CD.Design _ NIL, queue: QueueMethod _ useDefault, comm: CDSequencer.Command _ NIL]; <<--Fetches and executes a command.>> <<--queue: useDefault -> takes queueing method from registration; otherwise -> as stated>> <<--key#NIL: key replaces comm.a>> <<--design#NIL: design replaces comm.design>> <<--Might call CD.Error[designMutability]>> ImplementCommand: PROC [key: ATOM, proc: CommandProc, technology: CD.Technology_NIL, queue: QueueMethod _ doQueueAndMark, registrationData: REF_NIL]; <<--Registeres a command>> <<--technology=NIL: implements command for all technologies.>> <<--Re-using the same atom (in same technology) overwrites the command >> <<--queue: [dont use useDefault]>> <<--registrationData: for the command implementor: This data can be querried by >> <<-- calling FetchCommand >> FetchCommand: PROC [key: ATOM, technology: CD.Technology_NIL, load: BOOL_TRUE] RETURNS [proc: CommandProc, qm: QueueMethod, registrationData: REF]; <<--Fetches a commands registration>> <<--NIL proc if not defined>> <<>> <<--Edits>> MarkChanged: PROC [design: CD.Design]; <<--Mark the designs top level pushed in cell and the design as changed; >> <<--The design will be saved some time later again...>> <<--Might call CD.Error[designMutability]>> MarkChangedIOOnly: PROC [design: CD.Design]; <<--Marks the design as changed; it will be saved some time later again>> <<--But does not mark any pushed in cell>> <<--Might call CD.Error[designMutability]>> SetEdited: PRIVATE PROC [design: CD.Design, edited: BOOL_TRUE]; <<--Sets the designs edited boolean >> <<--Used by IO implementations to reset the designs edit mark. >> <<--Not for general clients. >> <<>> <<--Aborts>> <<-- Abortion does not absolutely guarantee the aborted process to stop, but long >> <<-- commands are strongly supposed to provide stop on abortion.>> <<-- Abortion of a command is also propagated using an event $Aborted.>> CheckAborted: PROC [design: CD.Design]; <<--The basic procedure to check the abort flag, but not the most efficient.>> <<--The procedure will simply abort if the abort flag was raised.>> <<--Like "IF Aborted[design] THEN Quit[]" but accurate always>> Aborted: PROC [design: CD.Design] RETURNS [BOOL]; <<--Checks whether the current command on design should be aborted [without doing it]>> <<--(Accurate only inside CDSequencer's lock of design)>> UseAbortFlag: PROC [design: CD.Design, flag: REF BOOL]; <<--Efficiency hack.>> <<--If while execution of the current command an abort is called>> <<-- the boolean flag^ will be set to TRUE; >> <<--Forgets flag after the command is finished. >> <<--(Accurate only inside CDSequencer's lock of design)>> Quit: PROC [message: Rope.ROPE_NIL]; <<--Conveniance. >> <<--Write message and terminates execution of the command of this process.>> <<--Never returns>> <<--(useful only from ChipNDale processes which have the CDSequencer lock of the design)>> AbortDesignsCommand: PROC [design: CD.Design, flush: BOOL_TRUE]; <<--Set the abort flag; Causes command process of design to stop at some time. >> <<-- (On return success is not yet known) >> <<--Called asynchronously! [and usually not from the process holding the lock...] >> <<--flush: flush commands not yet started >> END.