<> <> << Enables to generate easily 21 pins Burndy connector parts for EXPERT.>> <<>> <> <<>> <> <<>> <<>> <> <<- all the pins stack 33>> <<>> DIRECTORY Commander USING [CommandProc, Register], Convert USING [Error, IntFromRope], Rope USING [ROPE, Equal, Cat], FS USING [Error, StreamOpen], IO USING [ card, Close, EndOfStream, GetTokenRope, int, Put, PutF, PutRope, RIS, rope, STREAM]; Backconn212: CEDAR PROGRAM IMPORTS IO, Commander, Convert, Rope, FS = BEGIN ROPE: TYPE = Rope.ROPE; LineRep: TYPE = RECORD[ name: ROPE, type: INTEGER, swap: INTEGER ]; Line: TYPE = REF LineRep; ConnRep: TYPE = ARRAY[0..212) OF Line; Conn: TYPE = REF ConnRep; BadFile: SIGNAL []; GetLine: PROC [in: IO.STREAM, display: IO.STREAM, i: CARD, file: ROPE] RETURNS [line: Line] ~ { temp1, temp2: ROPE; line _ NEW[LineRep]; line.name _ IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token; IF NOT Rope.Equal[line.name, "NC", FALSE] THEN { temp1 _ IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token; temp2 _ IO.GetTokenRope[in ! IO.EndOfStream => CONTINUE].token; IF line.name = NIL OR temp1 = NIL OR temp2 = NIL THEN { IO.PutF[display, "File %g is too short: line %g is missing or incomplete.\n", IO.rope[file], IO.card[i+1]]; SIGNAL BadFile[]; }; SELECT TRUE FROM Rope.Equal[temp1, "I", FALSE] => { line.type _ 1; }; Rope.Equal[temp1, "O", FALSE] => { line.type _ 2; }; Rope.Equal[temp1, "D", FALSE] => { line.type _ 3; }; ENDCASE => { IO.PutF[display, "In file %g the second word on line %g has to be I, O or D instead of %g\n", IO.rope[file], IO.card[i+1], IO.rope[temp1]]; SIGNAL BadFile[]; }; line.swap _ Convert.IntFromRope[temp2 ! Convert.Error =>{ IO.PutF[display, "In file %g the third word on line %g has to be numeric instead of %g\n", IO.rope[file], IO.card[i+1], IO.rope[temp2]]; SIGNAL BadFile[]; }]; }; }; InsertPin: PROC [i: INT, conn: Conn, out: IO.STREAM] ~ { x, y: INT; SELECT i FROM IN [0..53) => { x _ i*25; y _ ((i MOD 2)* 235); }; IN [53..106) => { x _ (i-53)*25; y _ -307-(((i+1) MOD 2)* 235); }; IN [106..159) => { x _ (i-106)*25+1600; y _ ((i MOD 2)* 235); }; IN [159..212) => { x _ (i-159)*25+1600; y _ -307-(((i+1) MOD 2)* 235); }; ENDCASE; IO.PutF[out, "%g %g ", IO.int[x], IO.int[y]]; IF Rope.Equal[conn[i].name, "NC", FALSE] THEN IO.PutF[out, "NC 1 0 256 0 33\n"] ELSE { IO.PutF[out, "%g %g 0 1 %g 33\n", IO.rope[conn[i].name], IO.int[conn[i].swap], IO.int[conn[i].type]]; }; }; Backconn212Proc: Commander.CommandProc = BEGIN i: CARD; in: IO.STREAM; out: IO.STREAM; fault: BOOLEAN _ FALSE; stream: IO.STREAM _ IO.RIS[cmd.commandLine]; conn: Conn _ NEW[ConnRep]; fileName: ROPE; fileName _ IO.GetTokenRope[stream ! IO.EndOfStream => CONTINUE].token; <<>> <> <<>> <<>> <> in _ FS.StreamOpen[Rope.Cat[fileName,".left"] ! FS.Error => { fault _ TRUE; IO.PutF[cmd.out, "The File %g is missing\n", IO.rope[Rope.Cat[fileName,".left"]]]; CONTINUE; }]; IF NOT fault THEN { FOR i IN [0..106) DO conn[i] _ GetLine[in, cmd.out, i, Rope.Cat[fileName,".left"] ! BadFile => { fault _ TRUE; CONTINUE; }]; IF fault THEN EXIT; ENDLOOP; }; <> in _ FS.StreamOpen[Rope.Cat[fileName,".right"] ! FS.Error => { fault _ TRUE; IO.PutF[cmd.out, "The File %g is missing\n", IO.rope[Rope.Cat[fileName,".right"]]]; CONTINUE; }]; IF NOT fault THEN { FOR i IN [0..106) DO conn[i+106] _ GetLine[in, cmd.out, i, Rope.Cat[fileName,".right"] ! BadFile => { fault _ TRUE; CONTINUE; }]; IF fault THEN EXIT; ENDLOOP; }; IF NOT fault THEN { <<>> <> <<>> out _ FS.StreamOpen[Rope.Cat[fileName,".part"],$create]; IO.Put[out, IO.rope[Rope.Cat["4096 2048 -100 -100 1500 1500 700 -100 ", fileName, " PARC-", fileName, " U\n"]]]; FOR i IN [0..106) DO InsertPin[i, conn, out]; ENDLOOP; FOR i IN [0..106) DO InsertPin[i+106, conn, out]; ENDLOOP; IO.Close[out]; cmd.out.PutRope[Rope.Cat["File ", fileName,".part Written\n"]]; }; END; Commander.Register[ key: "Backconn212", proc: Backconn212Proc, doc: "Transform the 2 input files: Filename.left, Filename.right into Filename.part (to be used by the NewPart program)."]; END.