Output SPICE node names in the "Nxxx" format

join all nodes connected to GND together
This commit is contained in:
Branislav Stojkovic
2019-03-13 19:23:35 +01:00
parent 92a2bb9809
commit 4de3b6d97c
9 changed files with 46 additions and 7 deletions
@@ -297,5 +297,9 @@ public abstract class AbstractComponent<T> implements IDIYComponent<T> {
public String[] getSectionNames(int pointIndex) { public String[] getSectionNames(int pointIndex) {
return null; return null;
} }
@Override
public String getCommonPointName(int pointIndex) {
return null;
}
} }
@@ -131,11 +131,17 @@ public interface IDIYComponent<T> extends Serializable {
String getInternalLinkName(int index1, int index2); String getInternalLinkName(int index1, int index2);
/** /**
* @param pointIndex name of the internal section containing the specified point, or null if the component does not have internal sections. * @param pointIndex
* One point can be shared between multiple sections, in which case, the result may contain more than one element. * @return name of the internal section containing the specified point, or null if the component does not have internal sections.
* @return * One point can be shared between multiple sections, in which case, the result may contain more than one element.
*/ */
String[] getSectionNames(int pointIndex); String[] getSectionNames(int pointIndex);
/**
* @param pointIndex
* @return name of the common point that joins all the other points with the same name together, e.g. GND
*/
String getCommonPointName(int pointIndex);
/** /**
* Draws the component onto the {@link Graphics2D}. * Draws the component onto the {@link Graphics2D}.
@@ -2824,10 +2824,14 @@ public class Presenter implements IPlugInPort {
Point2D point1 = node1.getComponent().getControlPoint(node1.getPointIndex()); Point2D point1 = node1.getComponent().getControlPoint(node1.getPointIndex());
Point2D point2 = node2.getComponent().getControlPoint(node2.getPointIndex()); Point2D point2 = node2.getComponent().getControlPoint(node2.getPointIndex());
String commonPoint1 = node1.getComponent().getCommonPointName(node1.getPointIndex());
String commonPoint2 = node2.getComponent().getCommonPointName(node2.getPointIndex());
// try both directions // try both directions
if (point1.distance(point2) < t || if (point1.distance(point2) < t ||
checkGraphConnection(point1, point2, connections, continuityAreas, new boolean[connections.size()]) || checkGraphConnection(point1, point2, connections, continuityAreas, new boolean[connections.size()]) ||
checkGraphConnection(point2, point1, connections, continuityAreas, new boolean[connections.size()])) { checkGraphConnection(point2, point1, connections, continuityAreas, new boolean[connections.size()]) ||
(commonPoint1 != null && commonPoint1.equalsIgnoreCase(commonPoint2))) {
boolean added = false; boolean added = false;
// add to an existing vertex if possible // add to an existing vertex if possible
for (Group g : netlist.getGroups()) for (Group g : netlist.getGroups())
Binary file not shown.
@@ -139,6 +139,11 @@ public class GroundSymbol extends AbstractComponent<Void> {
@Override @Override
public String getControlPointNodeName(int index) { public String getControlPointNodeName(int index) {
return getName(); return getName();
}
@Override
public String getCommonPointName(int pointIndex) {
return "GND";
} }
@Override @Override
@@ -113,7 +113,7 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
// output to spice // output to spice
for (int i = 0; i < c.getControlPointCount(); i++) { for (int i = 0; i < c.getControlPointCount(); i++) {
sb.append(fill(Integer.toString(nodeIndices[i]), 5)); sb.append(fill(formatSpiceNode(nodeIndices[i]), 5));
sb.append(" "); sb.append(" ");
} }
@@ -130,6 +130,10 @@ public class SpiceAnalyzer extends NetlistAnalyzer implements INetlistAnalyzer {
return new Summary(netlist, sb.toString()); return new Summary(netlist, sb.toString());
} }
private static String formatSpiceNode(int i) {
return String.format("N%03d" , i);
}
private String fill(String source, int desiredLength) { private String fill(String source, int desiredLength) {
String res = source; String res = source;
for (int i = 0; i < desiredLength - source.length(); i++) for (int i = 0; i < desiredLength - source.length(); i++)
Binary file not shown.
Binary file not shown.
+16
View File
@@ -2620,6 +2620,22 @@
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
</changes> </changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url> <url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version>
<org.diylc.appframework.update.Version>
<versionNumber>
<major>3</major>
<minor>57</minor>
<build>0</build>
</versionNumber>
<releaseDate>2019-03-10 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Output SPICE node names in the "Nxxx" format</description>
</org.diylc.appframework.update.Change>
</changes>
<url>https://github.com/bancika/diy-layout-creator/releases</url>
</org.diylc.appframework.update.Version> </org.diylc.appframework.update.Version>
</a> </a>
</java.util.Arrays_-ArrayList> </java.util.Arrays_-ArrayList>