CDSequencer.mesa (A ChipNDale module)
Copyright © 1983, 1986 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, June 29, 1983 2:34 pm
Last edited by: Christian Jacobi, October 23, 1986 10:27:23 am PDT
DIRECTORY
CD,
Rope USING [ROPE];
CDSequencer: CEDAR DEFINITIONS =
BEGIN
Implementation of interactive commands.
Monitoring asynchronous commands.
Since this module monitors asynchronous commands its implementation is the
right place to implement also the regular background saving process.
Command: TYPE = REF CommandRec;
CommandRec: TYPE = RECORD [
key: ATOMNIL,
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: BOOLFALSE,
n: CD.Number ← 0,
ref: REFNIL, --typically describes issuer the command (if interactive: viewer)
data: REFNIL --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
--proc must be global
--To transfer data to proc use: "comm: NEW[CommandRec ← [data: ..]]"
ExecuteCommand: PROC [key: ATOM NIL, design: CD.Design ← NIL, queue: QueueMethod ← useDefault, comm: CDSequencer.Command ← NIL];
--Fetches and executes a command.
--key#NIL: key replaces comm.a
--design#NIL: design replaces comm.design
ImplementCommand: PROC [key: ATOM, proc: CommandProc, technology: CD.Technology←NIL, queue: QueueMethod ← doQueueAndMark];
--Registeres a command
--technology=NIL: implement command for all technologies.
--Re-using the same atom (in same technology) overwrites the command
FetchCommand: PROC [key: ATOM, technology: CD.Technology←NIL] RETURNS [proc: CommandProc, qm: QueueMethod];
--Fetches a commands registration
--NIL proc if not defined
OpenDialogue: PROC [design: CD.Design];
--Initializes the command queue
--After the call, the design might be changed by interactive commands
--edited
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...
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
SetEdited: PROC [design: CD.Design, edited: BOOLTRUE];
--Sets the designs edited boolean
--Used by IO implementations to reset the designs edit mark.
--aborts
-- Abortion does not guarantee the aborted process to stop, but most long
-- commands are benevolent.
-- Abortion of a command is also propagated using an event $Aborted.
AbortDesignsCommand: PROC [design: CD.Design, flush: BOOLTRUE];
--Called from any process; tries to abort the designs current command
--flush: flush commands not yet started
--(On return success is not yet known)
Aborted: PROC [design: CD.Design] RETURNS [BOOL];
--Checks whether the current command on design has been aborted
--(Accurate only inside CDSequencer's lock of design)
UseAbortFlag: PROC [design: CD.Design, flag: REF BOOL];
--If while execution of the current command an abort is called
--the boolean will be set to TRUE;
--Forgets the flag when command is finished.
CheckAborted: PROC [design: CD.Design];
--Shortcut
--IF Aborted[design] THEN Quit[]
Quit: PROC [message: Rope.ROPE←NIL];
--Shortcut
--Write message and terminates execution of the command of this process
--Never returns
--(use only from ChipNDale processes which have the CDSequencer lock of the design)
END.