mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-10 17:22:09 +10:00
add support to map DIYLC pin indices to spice
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
package org.diylc.netlist;
|
||||||
|
|
||||||
|
public interface ISpiceMapper {
|
||||||
|
|
||||||
|
int mapToSpiceNode(int index);
|
||||||
|
}
|
||||||
@@ -72,7 +72,7 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
List<Group> groups = netlist.getSortedGroups();
|
List<Group> groups = netlist.getSortedGroups();
|
||||||
int unconnectedIndex = groups.size() + 1;
|
int unconnectedIndex = groups.size();
|
||||||
|
|
||||||
int maxLen = 0;
|
int maxLen = 0;
|
||||||
for (IDIYComponent<?> c : allComponents) {
|
for (IDIYComponent<?> c : allComponents) {
|
||||||
@@ -83,16 +83,33 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
|
|||||||
for (IDIYComponent<?> c : allComponents) {
|
for (IDIYComponent<?> c : allComponents) {
|
||||||
sb.append(fill(c.getName(), (int) (Math.ceil(maxLen / 5.0) * 5)));
|
sb.append(fill(c.getName(), (int) (Math.ceil(maxLen / 5.0) * 5)));
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
int[] nodeIndices = new int[c.getControlPointCount()];
|
||||||
|
|
||||||
|
// find node indices for each control point
|
||||||
for (int i = 0; i < c.getControlPointCount(); i++) {
|
for (int i = 0; i < c.getControlPointCount(); i++) {
|
||||||
int index = find(new Node(c, i), groups);
|
int pointIndex = i;
|
||||||
if (index < 0)
|
|
||||||
index = unconnectedIndex++;
|
int nodeIndex = find(new Node(c, pointIndex), groups);
|
||||||
else
|
if (nodeIndex < 0)
|
||||||
index++;
|
nodeIndex = unconnectedIndex++;
|
||||||
sb.append(fill(Integer.toString(index), 5));
|
|
||||||
|
// 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(" ");
|
||||||
}
|
}
|
||||||
sb.append(c.getValueForDisplay());
|
|
||||||
|
sb.append(c.getValue());
|
||||||
sb.append("<br>");
|
sb.append("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -2582,6 +2582,10 @@
|
|||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Ability to tag components and building blocks as favorites</description>
|
<description>Ability to tag components and building blocks as favorites</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>NEW_FEATURE</changeType>
|
||||||
|
<description>Generate SPICE-compatible netlist (still in beta stage)</description>
|
||||||
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description>
|
<description>When in "Highlight Connected Area" mode, the status bar shows useful information making it harder to forget what the mode does</description>
|
||||||
|
|||||||
Reference in New Issue
Block a user