From a6ee4f8ff3972c867222e555149258a39e57d68c Mon Sep 17 00:00:00 2001 From: Paul Falstad Date: Sat, 7 Dec 2024 22:58:21 -0800 Subject: [PATCH] fix relay coil and contacts to work in subcircuits (#127) --- .../lushprojects/circuitjs1/client/RelayCoilElm.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/com/lushprojects/circuitjs1/client/RelayCoilElm.java b/src/com/lushprojects/circuitjs1/client/RelayCoilElm.java index e3d3ee30..ddf20565 100644 --- a/src/com/lushprojects/circuitjs1/client/RelayCoilElm.java +++ b/src/com/lushprojects/circuitjs1/client/RelayCoilElm.java @@ -21,6 +21,7 @@ import com.google.gwt.user.client.ui.Button; import com.lushprojects.circuitjs1.client.util.Locale; +import java.util.Vector; class RelayCoilElm extends CircuitElm { double inductance; @@ -163,7 +164,8 @@ void draw(Graphics g) { setBbox(outline[0], outline[2], 0); adjustBbox(coilPosts[0], coilPosts[1]); - setSwitchPositions(); + // this never gets called for subcircuits + //setSwitchPositions(); } double getCurrentIntoNode(int n) { @@ -247,6 +249,7 @@ void stamp() { } else { switchingTimeOff = switchingTimeOn = switchingTime; } + setSwitchPositions(); } void startIteration() { @@ -290,10 +293,13 @@ else if (sim.t-lastTransition > switchingTimeOff) { setSwitchPositions(); } + Vector elmList; + void setParentList(Vector list) { elmList = list; } + void setSwitchPositions() { int i; - for (i = 0; i != sim.elmList.size(); i++) { - Object o = sim.elmList.elementAt(i); + for (i = 0; i != elmList.size(); i++) { + Object o = elmList.elementAt(i); if (o instanceof RelayContactElm) { RelayContactElm s2 = (RelayContactElm) o; if (s2.label.equals(label))