diff --git a/diylc/diylc-library/src/org/diylc/netlist/ISpiceMapper.java b/diylc/diylc-library/src/org/diylc/netlist/ISpiceMapper.java new file mode 100644 index 00000000..e662b2be --- /dev/null +++ b/diylc/diylc-library/src/org/diylc/netlist/ISpiceMapper.java @@ -0,0 +1,6 @@ +package org.diylc.netlist; + +public interface ISpiceMapper { + + int mapToSpiceNode(int index); +} diff --git a/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java b/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java index 9a2c173b..1b49852e 100644 --- a/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java +++ b/diylc/diylc-library/src/org/diylc/netlist/SpiceAnalyzer.java @@ -72,7 +72,7 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer { StringBuilder sb = new StringBuilder(); List groups = netlist.getSortedGroups(); - int unconnectedIndex = groups.size() + 1; + int unconnectedIndex = groups.size(); int maxLen = 0; for (IDIYComponent c : allComponents) { @@ -83,16 +83,33 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer { for (IDIYComponent c : allComponents) { sb.append(fill(c.getName(), (int) (Math.ceil(maxLen / 5.0) * 5))); sb.append(" "); + int[] nodeIndices = new int[c.getControlPointCount()]; + + // find node indices for each control point for (int i = 0; i < c.getControlPointCount(); i++) { - int index = find(new Node(c, i), groups); - if (index < 0) - index = unconnectedIndex++; - else - index++; - sb.append(fill(Integer.toString(index), 5)); + int pointIndex = i; + + int nodeIndex = find(new Node(c, pointIndex), groups); + if (nodeIndex < 0) + nodeIndex = unconnectedIndex++; + + // 1-based convention + nodeIndex++; + + // remap if needed + if (c instanceof ISpiceMapper) + pointIndex = ((ISpiceMapper)c).mapToSpiceNode(pointIndex); + + nodeIndices[pointIndex] = nodeIndex; + } + + // output to spice + for (int i = 0; i < c.getControlPointCount(); i++) { + sb.append(fill(Integer.toString(nodeIndices[i]), 5)); sb.append(" "); } - sb.append(c.getValueForDisplay()); + + sb.append(c.getValue()); sb.append("
"); } diff --git a/diylc/diylc-swing/library/main.jar b/diylc/diylc-swing/library/main.jar index fcb89f30..7a5a9cd3 100644 Binary files a/diylc/diylc-swing/library/main.jar and b/diylc/diylc-swing/library/main.jar differ diff --git a/diylc/diylc-swing/update.xml b/diylc/diylc-swing/update.xml index 7ffec6b6..0b2404e0 100644 --- a/diylc/diylc-swing/update.xml +++ b/diylc/diylc-swing/update.xml @@ -2582,6 +2582,10 @@ NEW_FEATURE Ability to tag components and building blocks as favorites + + NEW_FEATURE + Generate SPICE-compatible netlist (still in beta stage) + IMPROVEMENT When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does