fix: When a switch position is selected (i.e. set to a value other than None), DIYLC will treat the terminals that are internally connected in that switching logic as connected in analysis tools

This commit is contained in:
Bane Stojkovic
2025-06-06 23:52:28 +02:00
parent 4bd3943345
commit cb9cd46261
2 changed files with 27 additions and 18 deletions
@@ -101,23 +101,7 @@ public class NetlistBuilder {
// if there are no switches, make one with 1 position so we get 1 result back
if (switches.isEmpty())
switches.add(new ISwitch() {
@Override
public String getPositionName(int position) {
return "Default";
}
@Override
public int getPositionCount() {
return 1;
}
@Override
public boolean arePointsConnected(int index1, int index2, int position) {
return false;
}
});
switches.add(new TrivialSwitch());
// construct all possible combinations
int[] positions = new int[switches.size()];
@@ -418,7 +402,9 @@ public class NetlistBuilder {
// handle direct connections or connections through a switch
// when not using "includeSwitches" flag
if (c instanceof IContinuity &&
(!(c instanceof ISwitch) || switchPositions.isEmpty())) {
// ugly way to check if running in "exclude switches" mode.
(!(c instanceof ISwitch) || (switchPositions.size() == 1 &&
switchPositions.keySet().stream().findFirst().get() instanceof TrivialSwitch))) {
for (int i = 0; i < c.getControlPointCount() - 1; i++)
for (int j = i + 1; j < c.getControlPointCount(); j++)
if (((IContinuity) c).arePointsConnected(i, j))
@@ -493,4 +479,23 @@ public class NetlistBuilder {
return area;
}
}
private static class TrivialSwitch implements ISwitch {
@Override
public String getPositionName(int position) {
return "Default";
}
@Override
public int getPositionCount() {
return 1;
}
@Override
public boolean arePointsConnected(int index1, int index2, int position) {
return false;
}
}
}
@@ -357,6 +357,10 @@
<changeType>IMPROVEMENT</changeType>
<description>Improved project search algorithm in DIYLC cloud</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>When a switch position is selected (i.e. set to a value other than None), DIYLC will treat the terminals that are internally connected in that switching logic as connected in analysis tools</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>