Skip to content

Commit

Permalink
fix relay coil and contacts to work in subcircuits (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalstad committed Dec 8, 2024
1 parent 58f00e1 commit a6ee4f8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/com/lushprojects/circuitjs1/client/RelayCoilElm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -247,6 +249,7 @@ void stamp() {
} else {
switchingTimeOff = switchingTimeOn = switchingTime;
}
setSwitchPositions();
}

void startIteration() {
Expand Down Expand Up @@ -290,10 +293,13 @@ else if (sim.t-lastTransition > switchingTimeOff) {
setSwitchPositions();
}

Vector<CircuitElm> elmList;
void setParentList(Vector<CircuitElm> 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))
Expand Down

0 comments on commit a6ee4f8

Please sign in to comment.