EcadOpsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Christian LeCocq April 17, 1987 12:55:39 pm PDT
Last Edited by: Ross March 20, 1987 5:23:14 pm PST
DIRECTORY
Ascii, BridgeDriver, CedarProcess, Commander, EcadOps, FS, FSBackdoor, IO, Rope, UserCredentials, TiogaMenuOps, ThisMachine;
EcadOpsImpl: CEDAR PROGRAM
IMPORTS Ascii, BridgeDriver, CedarProcess, Commander, FS, FSBackdoor, IO, Rope, UserCredentials, TiogaMenuOps, ThisMachine
EXPORTS EcadOps
~ BEGIN
ROPE: TYPE = Rope.ROPE;
waitingProcess: CedarProcess.Process;
stop: BOOLFALSE;
magicString: ROPE ← "RBatch\ncd ecad ;/1f/datools/ecad/dracu ";
criterion: ROPE ← "*.SUM!*";
lock: BOOLEANFALSE;
Command Procs
ECADCmd: Commander.CommandProc ~ {
PROC [cmd: Handle] RETURNS [result: REFNIL, msg: ROPENIL]
fullCIFFName, fullRulesFName, cellName: ROPE;
ropeStream: IO.STREAMIO.RIS[cmd.commandLine];
IF lock THEN {
msg ← "\nWait for the previous DRC to finish !\nJob not sent.\n";
RETURN;
};
lock ← TRUE;
fullCIFFName ← FSExpandFromStream[ropeStream];
fullRulesFName ← FSExpandFromStream[ropeStream];
cellName ← IO.GetTokenRope[ropeStream, IO.IDProc ! IO.EndOfStream => CONTINUE].token;
msg ← ExecuteRemoteECAD[fullCIFFName, fullRulesFName, cellName];
};
ExecuteRemoteECAD: PUBLIC PROC [fullCIFFName, fullRulesFName, cellName: ROPE] RETURNS [errmsg: ROPE] ~ {
name, password, machine, ecadCmd, CIFFName, RulesFName: ROPE;
[name, password] ← UserCredentials.Get[];
name ← Rope.Substr[name, 0, Rope.Index[name, 0, "."]]; -- get rid of the ".pa"
name ← Rope.Translate[base: name, translator: MyLower];
machine ← Rope.Cat[ThisMachine.Name[], " "];
CIFFName ← PrepareFFName[fullCIFFName];
RulesFName ← PrepareFFName[fullRulesFName];
ecadCmd ← Rope.Cat[magicString, machine, CIFFName, RulesFName, cellName];
errmsg ← BridgeDriver.StartSession["vaxc", name, password, ecadCmd];
};
MyLower: Rope.TranslatorType ~ {RETURN[Ascii.Lower[old]]};
StartWatching: PUBLIC PROC ~ {
IF waitingProcess=NIL OR CedarProcess.GetStatus[waitingProcess]#busy THEN
waitingProcess ← CedarProcess.Fork[WaitForListings, criterion];
};
Internal Utilities
FSExpandFromStream: PROC [s: IO.STREAM] RETURNS [fullFName: ROPE] ~ {
fName: ROPE;
index: INT;
fName ← IO.GetTokenRope[s, IO.IDProc ! IO.EndOfStream => CONTINUE].token;
index ← Rope.Find[fName, ".cif", 0, FALSE];
IF index#-1 THEN fName ← Rope.Substr[fName, 0, index];
fullFName ← FS.ExpandName[fName].fullFName;
};
PrepareFFName: PROC [fullFName: ROPE] RETURNS [arg: ROPE] ~ {
arg ← Rope.Cat["\"", fullFName, "\" "];
};
WaitForListings: CedarProcess.ForkableProc ~ {
PROC [data: REF] RETURNS [results: REFNIL]
matchCriterion: ROPENARROW[data];
event: REF READONLY FSBackdoor.CreateEvent ← NIL;
UNTIL stop DO
event ← FSBackdoor.NextCreateEvent[event];
IF Rope.Match[pattern: matchCriterion, object: event.fName, case: FALSE] THEN {
viewer: TiogaMenuOps.Viewer ← TiogaMenuOps.Open[event.fName];
lock ← FALSE;
};
ENDLOOP;
};
Initialization
Commander.Register[key: "EcadOps", proc: ECADCmd, doc: "EcadOps CIFfileName rulesFileName TopLevelCellName\nSends CIF to Dracula"];
StartWatching[];
END.