ThymeOutput.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last Edited by:
Last Edited by: Jacobi June 10, 1986 7:02:05 pm PDT
Christian LeCocq February 13, 1987 10:32:15 am PST
Pradeep Sindhu April 9, 1986 10:30:00 am PST
Sweetsun Chen, November 26, 1985 1:04:00 pm PST
Christian Jacobi, June 10, 1986 7:01:22 pm PDT
DIRECTORY
BasicTime USING [GMT, Now],
Convert USING [RopeFromReal, RopeFromTime],
FS USING [StreamOpen],
Graph USING [Entity, EntityGroup, EntityHash, EntityHashSize, EntityList, EntityRec, GRAPH, GraphHandle, NestedEntities, NestedEntitiesList, NestedEntitiesRec, SegmentDataList, SegmentDataRec, ValueList],
GraphOps USING [AddCurve, AddText, AppendValues, Lock, NewGraph, Unlock],
GraphPrivate USING [PaintLegend, PaintTails, PaintAll],
GraphUtil USING [Almost, AppendX, AppendY],
IO USING [int, PutF, PutFR, real, Reset, rope, STREAM, time],
Labels USING [Set],
Process USING [Yield],
Rope USING [Concat, Cat, FromRefText, ROPE],
ThymeGlobals USING [argument, argumentPtr, branchPtr, conLinkPtr, Error, FindNodeOrBranch, FlushCloseNil, GetSignedNumber, Handle, instTreePtr, MakeStringNB, maxPlots, maxPrints, namePtr, Next, nodePtr, OutputFileRoot, plotBlkPtr, plotBlk, printBlk, printBlkPtr, RefC, RefCircuitRec, RefCktInstRec, RefI, RefL, RefR, RefV, version],
ViewerTools USING [GetContents];
ThymeOutput: CEDAR PROGRAM
IMPORTS
BasicTime,
Convert,
FS,
GraphOps,
GraphPrivate,
GraphUtil,
IO,
Labels,
Process,
Rope,
ThymeGlobals,
ViewerTools
EXPORTS
ThymeGlobals
= BEGIN
OPEN ThymeGlobals;
nodeComment: Rope.ROPE = ": node";
InitPP: PUBLIC PROC[handle: Handle, tMin, tMax: REAL] = {
OPEN handle.vars;
file: Rope.ROPE ← Rope.Concat[OutputFileRoot[handle], ".graph"];
tid: INT ← -1;
[graphHandle, ] ← GraphOps.NewGraph[
fileName: file,
comment: title,
xName: Rope.Cat["Time[", Unit[tUnit, "S"], "]"],
bounds: [tMin/tUnit, yMin, tMax/tUnit, yMax]
];
GraphOps.Lock[graphHandle];
graphHandle.chart.viewer.inhibitDestroy ← TRUE;
title, file, time, tunit, vunit, iunit
[] ← GraphOps.AddText[handle: graphHandle,
rope: title, place: [0.5, 1.1], fontIndex: 2, justifX: center, justifY: bottom];
[] ← GraphOps.AddText[handle: graphHandle,
rope: file, place: [0, -0.35], fontIndex: 1, justifX: left, justifY: bottom];
[] ← GraphOps.AddText[handle: graphHandle,
rope: Convert.RopeFromTime[from: simTime, includeDayOfWeek: TRUE],
place: [1.0, -0.35], fontIndex: 1, justifX: right, justifY: bottom];
[] ← GraphOps.AddText[handle: graphHandle,
rope: Rope.Cat["[", Unit[tUnit, "S"], "]"],
place: [1.01, 0.0], justifX: left, justifY: bottom];
[] ← GraphOps.AddText[handle: graphHandle,
rope: Rope.Cat["[", Unit[vUnit, "V"], ", ", Unit[iUnit, "A"], "]"],
place: [0.0, 1.01], justifX: left, justifY: bottom];
GraphOps.Unlock[graphHandle];
GraphPrivate.PaintAll[graphHandle, TRUE, FALSE, TRUE];
}; -- InitPP
Unit: PROC [unit: REAL, base: Rope.ROPE] RETURNS [Rope.ROPE] = {
dUnit: REALSELECT unit FROM
> 30.0 => 1.0e3,
> 30.0e-3 => 1.0,
> 30.0e-6 => 1.0e-3,
> 30.0e-9 => 1.0e-6,
ENDCASE => 1.0e-9;
mul: Rope.ROPESELECT dUnit FROM
1.0e3 => "k", 1.0 => "", 1.0e-3 => "m", 1.0e-6 => "u", ENDCASE => "n";
RETURN[Rope.Cat[
IF GraphUtil.Almost[unit, dUnit] THEN "" ELSE Convert.RopeFromReal[unit/dUnit],
mul, base]];
}; -- Unit
InitNE: PROC [handle: Handle, t: REAL] = {
EnlistTree: PROC[tree: instTreePtr, group: Graph.EntityGroup, parent: Graph.NestedEntities, hash: Graph.EntityHash, lastId: INT, graph: Graph.GRAPH] RETURNS [newLastId: INT, ne: Graph.NestedEntities ← NIL] = {
lastChild, nel: Graph.NestedEntitiesList ← NIL;
newLastId ← lastId;
ne ← NEW[Graph.NestedEntitiesRec ← [parent: parent]];
IF parent # NIL THEN {
cktInst: RefCktInstRec ← NARROW[tree.instance.details];
cktInstOfDetails: RefCircuitRec ← NARROW[cktInst.of.details];
ne.name ← tree.instance.name;
ne.comment ← IO.PutFR[": %g[%g]",
IO.rope[cktInst.of.name],
IO.rope[Arguments[cktInst.connections, cktInstOfDetails.fakeNodes]]
];
};
newLastId ← EnlistNB[tree, group, ne, hash, newLastId, graph];
FOR i: instTreePtr ← tree.sons, i.brothers UNTIL i=NIL DO
child: Graph.NestedEntities;
[newLastId, child] ← EnlistTree[i, group, ne, hash, newLastId, graph];
nel ← CONS[child, NIL];
IF lastChild = NIL THEN ne.children ← nel ELSE lastChild.rest ← nel;
lastChild ← nel;
ENDLOOP;
}; -- EnlistTree
EnlistNB: PROC[tree: instTreePtr, group: Graph.EntityGroup, parent: Graph.NestedEntities, hash: Graph.EntityHash, lastId: INT, graph: Graph.GRAPH] RETURNS [newLastId: INT] = {
PlotIt: PROC [entity: Graph.Entity] = {
enlist enity on graph.entityList, and initialize entity.segments.
lel: Graph.EntityList ← CONS[entity, NIL];
sdl: Graph.SegmentDataList ← CONS[
NEW[Graph.SegmentDataRec ← [end: entity.oldValues.first]], NIL];
entity.segments ← entity.lastSegment ← sdl;
IF graph.entityList = NIL THEN graph.entityList ← lel
ELSE FOR el: Graph.EntityList ← graph.entityList, el.rest UNTIL el = NIL DO
IF el.rest = NIL THEN {el.rest ← lel; EXIT};
ENDLOOP;
}; -- PlotIt
lastEL, el: Graph.EntityList ← NIL;
hashIndex: INT[0..Graph.EntityHashSize);
newLastId ← lastId;
FOR n: nodePtr ← tree.nodes, n.brotherNodes UNTIL n=NIL DO
entity: Graph.Entity ← NEW[Graph.EntityRec ← [
name: n.nodeName.name,
comment: nodeComment,
group: group,
parent: parent,
id: (newLastId ← newLastId+1)
]];
entity.oldValues ← entity.lastValue ← CONS[n.nHist.y/handle.vars.vUnit, NIL];
[] ← GraphUtil.AppendY[entity, n.nHist.y/handle.vars.vUnit, 0, 0];
n.entity ← entity;
hashIndex ← entity.id MOD Graph.EntityHashSize;
hash[hashIndex] ← CONS[entity, hash[hashIndex]];
el ← CONS[entity, NIL];
IF lastEL = NIL THEN parent.entityList ← lastEL ← el
ELSE {lastEL.rest ← el; lastEL ← el};
IF newLastId <= 6 THEN PlotIt[entity];
ENDLOOP;
FOR b: branchPtr ← tree.branches, b.brotherBranches UNTIL b=NIL DO
entity: Graph.Entity ← NEW[Graph.EntityRec ← [
name: b.branchName.name,
comment: IO.PutFR[": %g[%g, %g]",
IO.rope[BranchType[b]],
IO.rope[b.posNode.nodeName.name],
IO.rope[b.negNode.nodeName.name]
],
group: group,
parent: parent,
id: (newLastId ← newLastId+1)
]];
entity.oldValues ← entity.lastValue ← CONS[BranchCurrent[b]/handle.vars.iUnit, NIL];
[] ← GraphUtil.AppendY[entity, BranchCurrent[b]/handle.vars.iUnit, 0, 0];
b.entity ← entity;
hashIndex ← entity.id MOD Graph.EntityHashSize;
hash[hashIndex] ← CONS[entity, hash[hashIndex]];
el ← CONS[entity, NIL];
IF lastEL = NIL THEN parent.entityList ← lastEL ← el
ELSE {lastEL.rest ← el; lastEL ← el};
IF newLastId <= 6 THEN PlotIt[entity];
ENDLOOP;
}; -- EnlistNB
Arguments: PROC[conn: conLinkPtr, fakes: namePtr] RETURNS [r: Rope.ROPENIL] = {
FOR c: conLinkPtr ← conn, c.nextLink UNTIL c = NIL DO
r ← IF r = NIL THEN Rope.Cat[fakes.name, ": ", c.namedNode.name] ELSE Rope.Cat[fakes.name, ": ", c.namedNode.name, ", ", r];
fakes ← fakes.nextName;
ENDLOOP;
}; -- Arguments
BranchType: PROC[branch: branchPtr] RETURNS [Rope.ROPE] = {
RETURN[WITH branch.body SELECT FROM
r: RefR => "R",
c: RefC => "C",
v: RefV => "V",
i: RefI => "I",
l: RefL => "L",
ENDCASE => NIL -- (error. Will it happen?)
];
}; -- BranchType
gh: Graph.GraphHandle ← handle.vars.graphHandle;
group: Graph.EntityGroup ← gh.entityGroupList.first;
ne: Graph.NestedEntities;
[] ← GraphUtil.AppendX[group.x, t/handle.vars.tUnit];
group.length ← 1;
[handle.vars.lastEntityId, ne] ← EnlistTree[handle.vars.treeRoot, group, NIL, gh.entityHash, handle.vars.lastEntityId, gh.graph];
ne.name ← group.ys.name;
ne.comment ← group.ys.comment;
group.ys ← ne;
IF gh.graph.entityList # NIL THEN GraphPrivate.PaintLegend[gh, gh.graph.entityList.first, paint, FALSE]; -- just for legends.
}; -- InitNE
BranchCurrent: PROC [branch: branchPtr] RETURNS [REAL] = {
RETURN[WITH branch.body SELECT FROM
r: RefR => (branch.posNode.nHist.y - branch.negNode.nHist.y)/branch.comVal,
c: RefC => (branch.posNode.nHist.f0 - branch.negNode.nHist.f0)*branch.comVal,
v: RefV => v.vsCurrent,
i: RefI => branch.comVal,
l: RefL => l.iHist.y/branch.comVal,
ENDCASE => 0.0 -- (error. Will it happen?)
];
}; -- BranchCurrent
UpdatePP: PUBLIC PROC[handle: Handle, t: REAL] = {
firstTime: BOOL;
group: Graph.EntityGroup;
GraphOps.Lock[handle.vars.graphHandle];
group ← handle.vars.graphHandle.entityGroupList.first;
firstTime ← group.ys.entityList = NIL;
IF firstTime THEN InitNE[handle, t]
ELSE {
UpdateTree: PROC [tree: instTreePtr] = {
AppendIt: PROC [new: REAL, entity: Graph.Entity] = {
old: REAL ← GraphUtil.AppendY[entity, new, t1, t2];
IF entity.segments # NIL THEN {
v1 ← CONS[old, v1];
v2 ← CONS[new, v2];
pel ← CONS[entity, pel];
};
}; -- AppendIt
FOR n: nodePtr ← tree.nodes, n.brotherNodes UNTIL n=NIL DO
AppendIt[n.nHist.y/handle.vars.vUnit, n.entity];
ENDLOOP;
FOR b: branchPtr ← tree.branches, b.brotherBranches UNTIL b=NIL DO
AppendIt[BranchCurrent[b]/handle.vars.iUnit, b.entity];
ENDLOOP;
FOR i: instTreePtr ← tree.sons, i.brothers UNTIL i=NIL DO
UpdateTree[i];
ENDLOOP;
}; -- UpdateTree
t2: REAL ← t/handle.vars.tUnit;
t1: REAL ← GraphUtil.AppendX[group.x, t2];
pel: Graph.EntityList ← NIL;
v1, v2: Graph.ValueList ← NIL;
UpdateTree[handle.vars.treeRoot];
group.length ← group.length + 1;
GraphPrivate.PaintTails[handle.vars.graphHandle, t1, t2, v1, v2, pel, paint];
};
GraphOps.Unlock[handle.vars.graphHandle];
}; -- UpdatePP
InitPlot: PUBLIC PROC[handle: Handle, tMin, tMax: REAL]= {
OPEN handle.vars;
rope: Rope.ROPE;
pl: plotBlkPtr;
FOR i: NAT IN [0..numPlots) DO
OPEN plots[i];
file: Rope.ROPE ← Rope.Concat[OutputFileRoot[handle], IO.PutFR[".graph%g", IO.int[i]]];
time: Rope.ROPE ← Convert.RopeFromTime[from: simTime, includeDayOfWeek: TRUE];
xmin: REAL ← tMin/plots[i].plotTimeRelTo;
xmax: REAL ← tMax/plots[i].plotTimeRelTo;
[plotHandle, ] ← GraphOps.NewGraph[
fileName: file,
comment: title,
xName: Rope.Cat["Time[", Unit[plots[i].plotTimeRelTo, "S"], "]"],
bounds: [xmin, ymin, xmax, ymax]
];
GraphOps.Lock[plotHandle];
plotHandle.chart.viewer.inhibitDestroy ← TRUE;
plotHandle.userEditAllowed ← FALSE;
[] ← GraphOps.AddText[handle: plotHandle, rope: title, place: [0.5, 1.1], fontIndex: 2, justifX: center, justifY: bottom];
[] ← GraphOps.AddText[handle: plotHandle, rope: file, place: [0, -0.35], fontIndex: 1, justifX: left, justifY: bottom];
[] ← GraphOps.AddText[handle: plotHandle, rope: time, place: [1.0, -0.35], fontIndex: 1, justifX: right, justifY: bottom];
[] ← GraphOps.AddText[handle: plotHandle, rope: Rope.Cat["[", Unit[plots[i].plotTimeRelTo, "S"], "]"], place: [1.01, 0.0], justifX: left, justifY: bottom];
pl ← plotList;
UNTIL pl = NIL DO
heading: Rope.ROPESELECT TRUE FROM
pl.arg.getComVal => "Value of ",
pl.arg.current => "Current through ",
pl.arg.dvdt => "Derivative of ",
ENDCASE => "Voltage at ";
rope← heading.Concat[MakeStringNB[handle, pl.arg.node, pl.arg.branch]];
IF pl.relativeTo # 1.0 THEN rope ← IO.PutFR["%g/%g", IO.rope[rope], IO.real[pl.relativeTo]];
[] ← GraphOps.AddCurve[handle: plotHandle, groupId: 0, name: rope];
pl ← pl.nextBlk;
ENDLOOP;
GraphOps.Unlock[plotHandle];
GraphPrivate.PaintAll[plotHandle, TRUE, FALSE, TRUE];
ENDLOOP;
}; -- InitPlot
PlotFromList: PUBLIC PROC[handle: Handle, t: REAL] = {
OPEN handle.vars;
FOR iPlot: NAT IN [0..numPlots) DO
values: Graph.ValueList ← NIL;
p: plotBlkPtr← plots[iPlot].plotList;
time: REAL ← t/plots[iPlot].plotTimeRelTo;
UNTIL p = NIL DO
values ← CONS[EvaluateArgument[p.arg]/p.relativeTo, values];
p ← p.nextBlk;
ENDLOOP;
GraphOps.Lock[plots[iPlot].plotHandle];
GraphOps.AppendValues[plots[iPlot].plotHandle, 0, time, values];
GraphOps.Unlock[plots[iPlot].plotHandle];
ENDLOOP;
}; -- PlotFromList
GetPlotNum: PROC [handle: Handle] RETURNS[r: REAL← 1.0] = {
r← GetSignedNumber[handle];
IF handle.vars.item = comma THEN Next[handle] ELSE Error[handle, 603,, FALSE]
}; -- GetPlotNum
DirectMakePlotList: PUBLIC PROC[handle: Handle, cellType: CellType]= {
OPEN handle.vars;
I, D, cv: BOOL;
pb: plotBlkPtr;
n: nodePtr;
b: branchPtr;
IF numPlots >= maxPlots THEN {
Error[handle, 632, FALSE];
numPlots ← numPlots - 1
};
IF item = string THEN {
plots[numPlots].title ← Rope.FromRefText[newString];
};
IF item = colon THEN {
plots[numPlots].plotTimeRelTo← Scale[handle];
}
ELSE plots[numPlots].plotTimeRelTo ← 1.0;
plots[numPlots].ymin ← GetPlotNum[handle];
plots[numPlots].ymax ← GetPlotNum[handle];
IF plots[numPlots].ymin >= plots[numPlots].ymax THEN Error[handle, 630, FALSE];
plots[numPlots].plotList ← NIL;
UNTIL item # name DO
[n, b] ← FindNodeOrBranch[handle];
IF n = NIL AND b = NIL THEN Error[handle, 620]
ELSE {
I← b # NIL AND item = upArrow;
D← n # NIL AND item = quote;
cv← b # NIL AND item = atSign;
IF I OR D OR cv THEN Next[handle];
pb← NEW[plotBlk←
[nextBlk: plots[numPlots].plotList,
relativeTo: Scale[handle],
arg: NEW[argument← [FALSE, n, b, cv, D, I]]]
];
plots[numPlots].plotList← pb;
};
ENDLOOP;
}; -- MakePlotList
MakePlotList: PUBLIC PROC[handle: Handle]= {
OPEN handle.vars;
I, D, cv: BOOL;
pb: plotBlkPtr;
n: nodePtr;
b: branchPtr;
IF numPlots >= maxPlots THEN {
Error[handle, 632, FALSE];
numPlots ← numPlots - 1
};
IF item = leftB THEN Next[handle] ELSE Error[handle, 600];
IF item = string THEN {
plots[numPlots].title ← Rope.FromRefText[newString];
Next[handle];
IF item = comma THEN Next[handle] ELSE Error[handle, 603,, FALSE]
};
IF item = colon THEN {
plots[numPlots].plotTimeRelTo← Scale[handle];
IF item = comma THEN Next[handle] ELSE Error[handle, 603,, FALSE]
}
ELSE plots[numPlots].plotTimeRelTo ← 1.0;
plots[numPlots].ymin ← GetPlotNum[handle];
plots[numPlots].ymax ← GetPlotNum[handle];
IF plots[numPlots].ymin >= plots[numPlots].ymax THEN Error[handle, 630, FALSE];
plots[numPlots].plotList ← NIL;
UNTIL item # name DO
[n, b] ← FindNodeOrBranch[handle];
IF n = NIL AND b = NIL THEN Error[handle, 620]
ELSE {
I← b # NIL AND item = upArrow;
D← n # NIL AND item = quote;
cv← b # NIL AND item = atSign;
IF I OR D OR cv THEN Next[handle];
pb← NEW[plotBlk←
[nextBlk: plots[numPlots].plotList,
relativeTo: Scale[handle],
arg: NEW[argument← [FALSE, n, b, cv, D, I]]]
];
plots[numPlots].plotList← pb;
};
IF item = comma THEN Next[handle] ELSE EXIT;
ENDLOOP;
IF item = rightB THEN Next[handle] ELSE Error[handle, 601, TRUE];
numPlots ← numPlots + 1;
}; -- MakePlotList
PutMsgLine: PUBLIC PROC[handle: Handle, s: Rope.ROPE]= {
handle.msgStream.PutF["%g\n", IO.rope[s]];
Process.Yield[];
}; -- PutMsgLine
EvaluateArgument: PROC[a: argumentPtr] RETURNS[iv: REAL]= {
b: branchPtr;
IF a.getComVal THEN RETURN[a.branch.comVal];
IF a.node # NIL THEN
iv← IF a.dvdt THEN a.node.nHist.f0 ELSE a.node.nHist.y
ELSE {
b← a.branch;
IF a.current THEN
WITH b.body SELECT FROM
r: RefR =>
iv← (b.posNode.nHist.y - b.negNode.nHist.y)/b.comVal;
c: RefC =>
iv← (b.posNode.nHist.f0 - b.negNode.nHist.f0)*b.comVal;
l: RefL => iv← l.iHist.y/b.comVal;
v: RefV => iv← v.vsCurrent;
i: RefI => iv← b.comVal;
ENDCASE
ELSE iv← b.posNode.nHist.y - b.negNode.nHist.y;
};
}; -- EvaluateArgument
InitPrint: PUBLIC PROC[handle: Handle, time: BasicTime.GMT]= {
FOR i: NAT IN [0..handle.vars.numPrints) DO
output: IO.STREAM← handle.vars.prints[i].printStream;
output.PutF["* Simulation started at %g.\n", IO.time[time]];
ENDLOOP;
}; -- InitPrint
PrintFromList: PUBLIC PROC[handle: Handle, ni: INT, t: REAL, printStep: BOOL]= {
i: NAT;
p: printBlkPtr;
r, trel: REAL;
FOR i IN [0..handle.vars.numPrints) DO
output: IO.STREAM← handle.vars.prints[i].printStream;
p← handle.vars.prints[i].printList;
trel← t/handle.vars.prints[i].printTimeRelTo;
output.PutF["%10.3e", IO.real[trel]];
IF printStep THEN output.PutF["(%2d)", IO.int[ni]];
UNTIL p=NIL DO
r← EvaluateArgument[p.arg]/p.relativeTo;
output.PutF[" %10.3f", IO.real[r]];
p← p.nextBlk;
ENDLOOP;
output.PutF["\n"];
ENDLOOP;
}; -- PrintFromList
Scale: PROC[handle: Handle] RETURNS[s: REAL← 1.0]= {
IF handle.vars.item=colon THEN {Next[handle]; s← GetSignedNumber[handle]};
}; -- Scale
MakePrintList: PUBLIC PROC[handle: Handle]= {
OPEN handle.vars;
I, D, cv: BOOL;
pb, pb2, pb3: printBlkPtr;
n: nodePtr;
b: branchPtr;
outFileNameRoot, outFileName, outFiles: Rope.ROPE;
IF numPrints >= maxPrints THEN {
Error[handle, 631];
numPrints← numPrints - 1;
};
IF item=leftB THEN Next[handle] ELSE Error[handle, 600];
IF item=colon THEN {
prints[numPrints].printTimeRelTo← Scale[handle];
IF item=comma THEN Next[handle] ELSE Error[handle, 603,, FALSE];
}
ELSE prints[numPrints].printTimeRelTo← 1.0;
prints[numPrints].printList← NIL;
UNTIL item # name DO
[n, b]← FindNodeOrBranch[handle];
IF n=NIL AND b=NIL THEN Error[handle, 620]
ELSE {
I← (b # NIL) AND item=upArrow; -- branch current
D← (n # NIL) AND item=quote; -- derivative of node voltage
cv← (b # NIL) AND item=atSign; -- branch value
IF I OR D OR cv THEN Next[handle];
pb← NEW[printBlk←
[nextBlk: prints[numPrints].printList,
relativeTo: Scale[handle],
arg: NEW[argument← [FALSE, n, b, cv, D, I]] ] ];
prints[numPrints].printList← pb;
};
IF item=comma THEN Next[handle] ELSE EXIT;
ENDLOOP;
pb← NIL;
pb3← prints[numPrints].printList;
UNTIL pb3=NIL DO
pb2← pb3;
pb3← pb3.nextBlk;
pb2.nextBlk← pb;
pb← pb2;
ENDLOOP;
prints[numPrints].printList← pb;
outFileNameRoot← OutputFileRoot[handle];
outFileName← IO.PutFR["%g.out%g", IO.rope[outFileNameRoot], IO.int[numPrints]];
prints[numPrints].printStream←
FS.StreamOpen[fileName: outFileName, accessOptions: $create];
prints[numPrints].printStream.Reset[ ];
outFiles← IF numPrints=0 THEN outFileName
ELSE IO.PutFR["%g.out0...out%g", IO.rope[outFileNameRoot], IO.int[numPrints]];
Labels.Set[handle.output, outFiles];
prints[numPrints].printStream.PutF[
"** %g\n*\n* File: %g\n* Input: %g\n* Time: %g\n*\n",
IO.rope[version],
IO.rope[outFileName],
IO.rope[ViewerTools.GetContents[handle.input]],
IO.time[simTime]
];
numPrints← numPrints + 1;
IF item=rightB THEN Next[handle] ELSE Error[handle, 601, TRUE];
}; -- MakePrintList
DumpAll: PUBLIC PROC[handle: Handle, t: REAL]= {
OPEN handle.vars;
dname: Rope.ROPE;
dump: IO.STREAM;
nodes: nodePtr← nodeList;
inds: branchPtr← inductorList;
dname← IO.PutFR["%g.dump", IO.rope[OutputFileRoot[handle]]];
dump← FS.StreamOpen[fileName: dname, accessOptions: $create];
dump.Reset[];
dump.PutF["ic[%f,\n", IO.real[t]];
UNTIL nodes=NIL DO
dump.PutF["%g← %f",
IO.rope[MakeStringNB[handle, nodes, NIL, FALSE]],
IO.real[nodes.nHist.y]];
nodes← nodes.nextNode;
IF nodes # NIL THEN dump.PutF[",\n"] ELSE dump.PutF["\n"];
ENDLOOP;
UNTIL inds=NIL DO
indsBody: RefL← NARROW[inds.body];
dump.PutF["%g← %f",
IO.rope[MakeStringNB[handle, NIL, inds, FALSE]],
IO.real[indsBody.iHist.y]];
inds← indsBody.nextInductor;
IF inds # NIL THEN IO.PutF[dump, ",\n"] ELSE IO.PutF[dump, "\n"];
ENDLOOP;
dump.PutF["];\n"];
handle.msgStream.PutF["Dumped into file %g at %g.\n",
IO.rope[dname], IO.time[]];
dump ← FlushCloseNil[dump];
}; -- DumpAll
END.
CHANGE LOG
Wilhelm, April 6, 1982 11: 36 AM
Barth, 7-May-82 10: 45: 07 PDT
Chen, June 12, 1984 6:59:26 pm PDT, cedarized.
Chen, July 22, 1985 8:09:51 pm PDT, => Cedar6.0.
Chen, November 24, 1985 2:42:28 pm PST, added InitPP and UpdatePP and related procs for postprocessor. Also modified other plotting related codes to use the Graph package.
Christian Jacobi, June 10, 1986 7:00:30 pm PDT, Yield on messages, to avoid monopolizing cpu.