netlist analyzer enhancements

This commit is contained in:
Bane Stojkovic
2025-03-26 18:04:47 +01:00
parent 3a5f4bdb67
commit 77cebc3911
9 changed files with 89 additions and 24 deletions
@@ -22,6 +22,7 @@
package org.diylc.common;
import java.util.List;
import java.util.Set;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.Node;
@@ -59,4 +60,9 @@ public interface INetlistAnalyzer {
* @return name of the font to be used for display.
*/
String getFontName();
/**
* @return ability to process netlists with or without switches included.
*/
Set<NetlistSwitchPreference> getSwitchPreference();
}
@@ -0,0 +1,5 @@
package org.diylc.common;
public enum NetlistSwitchPreference {
WITH, WITHOUT;
}
@@ -69,7 +69,7 @@ public class NetlistBuilder {
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
// extract nodes
if (!(c instanceof IContinuity) && !(c instanceof ICommonNode)) {
if (!(c instanceof IContinuity && !(c instanceof ISwitch)) && !(c instanceof ICommonNode)) {
// regular components, create a node per control point
for (int i = 0; i < c.getControlPointCount(); i++) {
String nodeName = c.getControlPointNodeName(i);
@@ -415,8 +415,10 @@ public class NetlistBuilder {
IDIYComponent<?> c = project.getComponents().get(z);
ComponentType type = ComponentProcessor.getInstance()
.extractComponentTypeFrom((Class<? extends IDIYComponent<?>>) c.getClass());
// handle direct connections
if (c instanceof IContinuity) {
// handle direct connections or connections through a switch
// when not using "includeSwitches" flag
if (c instanceof IContinuity &&
(!(c instanceof ISwitch) || switchPositions.isEmpty())) {
for (int i = 0; i < c.getControlPointCount() - 1; i++)
for (int j = i + 1; j < c.getControlPointCount(); j++)
if (((IContinuity) c).arePointsConnected(i, j))