fixes for netlist

This commit is contained in:
Bane Stojkovic
2025-03-11 23:18:36 +01:00
parent eedc370a6e
commit f966f8873a
5 changed files with 950 additions and 1025 deletions
@@ -29,9 +29,11 @@ import org.diylc.core.IDIYComponent;
public abstract class NetlistAnalyzer { public abstract class NetlistAnalyzer {
public NetlistAnalyzer() {} public NetlistAnalyzer() {
}
public List<Summary> summarize(List<Netlist> netlists, Node preferredOutput) throws TreeException { public List<Summary> summarize(List<Netlist> netlists, Node preferredOutput)
throws TreeException {
Map<String, Summary> summaries = new HashMap<String, Summary>(); Map<String, Summary> summaries = new HashMap<String, Summary>();
for (Netlist n : netlists) { for (Netlist n : netlists) {
Summary s = summarize(n, preferredOutput); Summary s = summarize(n, preferredOutput);
@@ -50,31 +52,20 @@ public abstract class NetlistAnalyzer {
public Tree constructTreeBetween(Netlist netlist, Node nodeA, Node nodeB) { public Tree constructTreeBetween(Netlist netlist, Node nodeA, Node nodeB) {
Tree tree = new Tree(TreeConnectionType.Parallel); Tree tree = new Tree(TreeConnectionType.Parallel);
connectNodes(netlist, nodeA, nodeB, tree.getChildren(), new Tree(TreeConnectionType.Series), new HashSet<Node>()); connectNodes(netlist, nodeA, nodeB, tree.getChildren(), new Tree(TreeConnectionType.Series),
new HashSet<Node>());
return tree; return tree;
} }
// protected Tree removeRedundantElements(Tree tree) { protected void connectNodes(Netlist netlist, Node nodeA, Node nodeB, List<Tree> concurrentPaths,
// List<Tree> children = tree.getChildren() Tree currentPath, Set<Node> visited) {
// .stream()
// .map(t -> removeRedundantElements(t))
// .collect(Collectors.toList());
// if (children.size() == 1) {
// Tree first = children.get(0);
// return first;
// }
// }
protected void connectNodes(Netlist netlist, Node nodeA, Node nodeB, List<Tree> concurrentPaths, Tree currentPath,
Set<Node> visited) {
if (nodeA == nodeB) { if (nodeA == nodeB) {
concurrentPaths.add(currentPath); concurrentPaths.add(currentPath);
return; return;
} }
Group groupA = findGroup(netlist, nodeA); Group groupA = findGroup(netlist, nodeA);
if (groupA == null) if (groupA == null)
return; return;
@@ -83,235 +74,147 @@ public abstract class NetlistAnalyzer {
return; return;
} }
// Only mark the current node as visited to allow proper path exploration Set<Node> pathVisited = new HashSet<>(visited);
visited.add(nodeA); pathVisited.add(nodeA);
List<Tree> newConcurrentPaths = new ArrayList<Tree>();
// Track processed connections to prevent duplicates from bidirectional links
Set<String> processedConnections = new HashSet<String>();
// First collect all immediate next nodes and their paths
Map<Node, List<Tree>> nextNodes = new HashMap<>();
for (Node n : groupA.getNodes()) { for (Node n : groupA.getNodes()) {
if (pathVisited.contains(n))
continue;
IDIYComponent<?> c = n.getComponent(); IDIYComponent<?> c = n.getComponent();
for (int i = 0; i < c.getControlPointCount(); i++) { for (int i = 0; i < c.getControlPointCount(); i++) {
int targetPoint = i; int targetPoint = i;
int sourcePoint = n.getPointIndex(); int sourcePoint = n.getPointIndex();
// Skip self-connections if (targetPoint == sourcePoint)
if (targetPoint == sourcePoint) continue;
// Check if there's a connection between these points
if (c.getInternalLinkName(targetPoint, sourcePoint) != null) {
// Create a unique identifier for this connection regardless of direction
String connectionId = c.getName() + "_" +
Math.min(sourcePoint, targetPoint) + "_" +
Math.max(sourcePoint, targetPoint);
// Skip if we've already processed this connection (prevents duplicate branches)
if (processedConnections.contains(connectionId)) continue;
processedConnections.add(connectionId);
TreeLeaf l = new TreeLeaf(c, targetPoint, sourcePoint);
Node newNodeA = new Node(c, targetPoint, n.getZIndex());
if (!visited.contains(newNodeA)) {
// visited.add(n);
Tree newCurrentPath = null;
try {
newCurrentPath = (Tree) currentPath.clone();
} catch (CloneNotSupportedException e) {
}
Tree newItem = new Tree(l);
if (!newCurrentPath.getChildren().contains(newItem))
newCurrentPath.getChildren().add(newItem);
// if (!currentPath.contains(l))
// newCurrentPath.add(l);
Set<Node> newVisited = new HashSet<Node>(visited);
connectNodes(netlist, newNodeA, nodeB, newConcurrentPaths, newCurrentPath, newVisited);
}
}
}
}
if (newConcurrentPaths.size() == 0)
return;
if (newConcurrentPaths.size() == 1) {
if (newConcurrentPaths.get(0).getConnectionType() == TreeConnectionType.Series) {
currentPath.getChildren().clear();
currentPath.getChildren().addAll(newConcurrentPaths.get(0).getChildren());
} else {
currentPath.getChildren().add(newConcurrentPaths.get(0));
}
concurrentPaths.add(currentPath);
return;
}
mergePaths(newConcurrentPaths, false);
concurrentPaths.addAll(newConcurrentPaths);
}
/**
* Merges paths that share common elements, taking into account bidirectional connections.
*
* @param paths List of paths to merge
* @param backward Direction for merging (forward/backward)
*/
protected void mergePaths(List<Tree> paths, boolean backward) {
// Skip if there are no paths or only one path
if (paths == null || paths.size() <= 1) {
return;
}
Map<Tree, Integer> uniques = new HashMap<Tree, Integer>();
for (Tree t : paths) {
if (t.getConnectionType() != TreeConnectionType.Series)
continue; continue;
Tree key = t.getChildren().get(backward ? t.getChildren().size() - 1 : 0);
Integer count = uniques.get(key); if (c.getInternalLinkName(targetPoint, sourcePoint) != null) {
uniques.put(key, count == null ? 1 : count + 1); Node newNodeA = new Node(c, targetPoint, n.getZIndex());
if (pathVisited.contains(newNodeA))
continue;
try {
Tree newPath = (Tree) currentPath.clone();
TreeLeaf leaf = new TreeLeaf(c, targetPoint, sourcePoint);
Tree newItem = new Tree(leaf);
if (!newPath.getChildren().contains(newItem)) {
newPath.getChildren().add(newItem);
nextNodes.computeIfAbsent(newNodeA, k -> new ArrayList<>()).add(newPath);
}
} catch (CloneNotSupportedException e) {
// Skip this path if clone fails
}
}
}
} }
List<Tree> unmerged = new ArrayList<Tree>(paths); // Now explore each next node
List<Tree> allPaths = new ArrayList<>();
for (Map.Entry<Tree, Integer> e : uniques.entrySet()) { for (Map.Entry<Node, List<Tree>> entry : nextNodes.entrySet()) {
if (e.getValue() > 1) { for (Tree path : entry.getValue()) {
List<Tree> pathsToMerge = new ArrayList<Tree>(); List<Tree> branchPaths = new ArrayList<>();
for (Tree t : paths) { connectNodes(netlist, entry.getKey(), nodeB, branchPaths, path, pathVisited);
Tree key = t.getChildren().get(backward ? t.getChildren().size() - 1 : 0); allPaths.addAll(branchPaths);
if (key.equals(e.getKey())) }
pathsToMerge.add(t);
} }
unmerged.removeAll(pathsToMerge);
Tree jointStart = new Tree(new ArrayList<Tree>(), TreeConnectionType.Series); if (allPaths.isEmpty())
Tree jointFinish = new Tree(new ArrayList<Tree>(), TreeConnectionType.Series); return;
Tree unique = e.getKey(); if (allPaths.size() > 1) {
// Find common prefix among all paths
List<Tree> commonPrefix = findCommonElements(allPaths, true, false);
for (int i = 0; i < pathsToMerge.get(0).getChildren().size(); i++) { // Create a new tree for the merged result
boolean canMerge = true; Tree mergedTree = new Tree(TreeConnectionType.Series);
unique = pathsToMerge.get(0).getChildren().get(backward ? pathsToMerge.get(0).getChildren().size() - i - 1 : i);
for (Tree t : pathsToMerge) { // Add common prefix elements
if (t.getChildren().size() <= i || !t.getChildren().get(backward ? t.getChildren().size() - i - 1 : i).equals(unique)) { for (Tree prefixElement : commonPrefix) {
canMerge = false; mergedTree.getChildren().add(prefixElement);
}
// Extract unique parts
List<Tree> uniqueParts = new ArrayList<>();
for (Tree path : allPaths) {
Tree uniquePart = extractUniquePart(path, commonPrefix.size(), 0);
if (uniquePart != null) {
if (uniquePart.getChildren().size() == 1) {
uniqueParts.add(uniquePart.getChildren().get(0));
} else {
uniqueParts.add(uniquePart);
}
}
}
// Create parallel section for unique parts
if (!uniqueParts.isEmpty()) {
Tree parallelSection = new Tree(TreeConnectionType.Parallel);
parallelSection.getChildren().addAll(uniqueParts);
// Add parallel section to series container
Tree parallelContainer = new Tree(TreeConnectionType.Series);
parallelContainer.getChildren().add(parallelSection);
mergedTree.getChildren().add(parallelContainer);
}
concurrentPaths.add(mergedTree);
} else {
concurrentPaths.add(allPaths.get(0));
}
}
private List<Tree> findCommonElements(List<Tree> paths, boolean fromStart, boolean backward) {
if (paths.isEmpty())
return new ArrayList<>();
List<Tree> common = new ArrayList<>();
Tree template = paths.get(0);
int maxLength = template.getChildren().size();
for (int i = 0; i < maxLength; i++) {
int index = fromStart ?
(backward ? template.getChildren().size() - i - 1 : i) :
(backward ? i : template.getChildren().size() - i - 1);
if (index < 0 || index >= template.getChildren().size())
break; break;
}
}
if (canMerge)
(backward ? jointFinish : jointStart).getChildren().add(unique);
else
break;
}
for (int i = 0; i < pathsToMerge.get(0).getChildren().size(); i++) { Tree element = template.getChildren().get(index);
boolean canMerge = true; boolean isCommon = true;
unique = pathsToMerge.get(0).getChildren().get(backward ? i : pathsToMerge.get(0).getChildren().size() - i - 1);
for (Tree t : pathsToMerge) {
// Fix: Correct index calculation to check the proper element in each path
if (t.getChildren().size() <= i || !t.getChildren().get(backward ? i : t.getChildren().size() - i - 1).equals(unique)) {
canMerge = false;
break;
}
}
if (canMerge)
(backward ? jointStart : jointFinish).getChildren().add(unique);
else
break;
}
if (!jointStart.getChildren().isEmpty() || !jointFinish.getChildren().isEmpty()) { for (int j = 1; j < paths.size(); j++) {
Tree mergedTree = new Tree(new ArrayList<Tree>(), TreeConnectionType.Series); Tree current = paths.get(j);
Tree parallelSection = new Tree(new ArrayList<Tree>(pathsToMerge), TreeConnectionType.Parallel); if (current.getChildren().size() <= i || index >= current.getChildren()
if (!jointStart.getChildren().isEmpty()) { .size() || !current.getChildren().get(index).equals(element)) {
mergedTree.getChildren().add(jointStart); isCommon = false;
for (Tree t : parallelSection.getChildren()) {
t.trimChildrenLeft(jointStart.getChildren().size());
}
}
mergedTree.getChildren().add(parallelSection);
if (!jointFinish.getChildren().isEmpty()) {
mergedTree.getChildren().add(jointFinish);
for (Tree t : parallelSection.getChildren()) {
t.trimChildrenRight(jointFinish.getChildren().size());
}
}
paths.removeAll(pathsToMerge);
paths.add(mergedTree);
}
}
}
// try in the opposite direction for paths we haven't merged
if (!backward && !unmerged.isEmpty()) {
paths.removeAll(unmerged);
mergePaths(unmerged, true);
paths.addAll(unmerged);
}
}
/**
* Creates a unique identifier for a connection between two points
* that is the same regardless of the direction of connection.
* This helps prevent duplicate paths in bidirectional connections.
*
* @param component The component containing the connection
* @param point1 First point index
* @param point2 Second point index
* @return A direction-agnostic connection identifier
*/
protected String createBidirectionalConnectionId(IDIYComponent<?> component, int point1, int point2) {
if (component == null) return null;
// Always use min/max to ensure the same ID regardless of direction
int minPoint = Math.min(point1, point2);
int maxPoint = Math.max(point1, point2);
return component.getName() + "_" + minPoint + "_" + maxPoint;
}
/**
* Compares two tree paths to check if they represent the same physical connection path
* but possibly in reverse directions. This helps identify paths that should be merged
* due to bidirectional connections.
*
* @param path1 First path to compare
* @param path2 Second path to compare
* @return true if the paths represent the same physical connection (possibly in reverse order)
*/
protected boolean arePathsEquivalent(Tree path1, Tree path2) {
if (path1 == null || path2 == null) return false;
if (path1 == path2) return true;
// Different connection types can't be equivalent
if (path1.getConnectionType() != path2.getConnectionType()) return false;
// Must have same number of elements
List<Tree> children1 = path1.getChildren();
List<Tree> children2 = path2.getChildren();
if (children1.size() != children2.size()) return false;
// Simple path with no children
if (children1.isEmpty()) return true;
// Check forward direction (standard comparison)
boolean forwardMatch = true;
for (int i = 0; i < children1.size(); i++) {
if (!children1.get(i).equals(children2.get(i))) {
forwardMatch = false;
break; break;
} }
} }
if (forwardMatch) return true; if (isCommon) {
common.add(element);
// Check reverse direction (bidirectional check) } else {
boolean reverseMatch = true;
for (int i = 0; i < children1.size(); i++) {
if (!children1.get(i).equals(children2.get(children2.size() - 1 - i))) {
reverseMatch = false;
break; break;
} }
} }
return reverseMatch; return common;
}
private Tree extractUniquePart(Tree path, int prefixSize, int suffixSize) {
if (path.getChildren().size() <= prefixSize + suffixSize)
return null;
Tree uniquePart = new Tree(TreeConnectionType.Series);
for (int i = prefixSize; i < path.getChildren().size() - suffixSize; i++) {
uniquePart.getChildren().add(path.getChildren().get(i));
}
return uniquePart.getChildren().isEmpty() ? null : uniquePart;
} }
protected Group findGroup(Netlist netlist, Node node) { protected Group findGroup(Netlist netlist, Node node) {
@@ -325,8 +228,9 @@ public abstract class NetlistAnalyzer {
List<Node> res = new ArrayList<Node>(); List<Node> res = new ArrayList<Node>();
for (Group g : netlist.getGroups()) { for (Group g : netlist.getGroups()) {
for (Node n : g.getNodes()) { for (Node n : g.getNodes()) {
if (typeNames.contains(n.getComponent().getClass().getCanonicalName()) if (typeNames.contains(n.getComponent().getClass()
&& (nodeName == null || n.getDisplayName().equalsIgnoreCase(nodeName))) { .getCanonicalName()) && (nodeName == null || n.getDisplayName()
.equalsIgnoreCase(nodeName))) {
res.add(n); res.add(n);
} }
} }
@@ -334,10 +238,6 @@ public abstract class NetlistAnalyzer {
return res; return res;
} }
protected String extractName(IDIYComponent<?> c) {
return c.getName() + " " + (c.getValueForDisplay() == null ? "" : c.getValueForDisplay());
}
public static List<Set<IDIYComponent<?>>> extractComponentGroups(List<Netlist> netlists) { public static List<Set<IDIYComponent<?>>> extractComponentGroups(List<Netlist> netlists) {
List<Set<IDIYComponent<?>>> res = new ArrayList<Set<IDIYComponent<?>>>(); List<Set<IDIYComponent<?>>> res = new ArrayList<Set<IDIYComponent<?>>>();
for (Netlist n : netlists) { for (Netlist n : netlists) {
@@ -115,7 +115,8 @@ public class Tree {
@Override @Override
public int compare(Tree o1, Tree o2) { public int compare(Tree o1, Tree o2) {
return o1.toString().compareToIgnoreCase(o2.toString()); return o1.toString().compareToIgnoreCase(o2.toString());
}}); }
});
return ordered; return ordered;
} }
@@ -124,13 +125,23 @@ public class Tree {
if (leaf != null) if (leaf != null)
return leaf.toString(); return leaf.toString();
// If we only have one child, no need for parentheses
if (children.size() == 1)
return children.get(0).toString();
StringBuilder sb = new StringBuilder("("); StringBuilder sb = new StringBuilder("(");
boolean first = true; boolean first = true;
for(Tree child : getOrderedChildren()) { for (Tree child : getOrderedChildren()) {
if (!first) if (!first)
sb.append(" " ).append(connectionType).append(" "); sb.append(" ").append(connectionType).append(" ");
first = false; first = false;
sb.append(child); // Only include child's parentheses if it has multiple children with a different connection type
String childStr = child.toString();
if (child.children != null && child.children.size() > 1 && child.connectionType != connectionType) {
sb.append(childStr);
} else {
sb.append(childStr.replaceAll("^\\((.*)\\)$", "$1"));
}
} }
sb.append(")"); sb.append(")");
return sb.toString(); return sb.toString();
@@ -146,7 +157,7 @@ public class Tree {
if (depth > 0 && children.size() > 1) if (depth > 0 && children.size() > 1)
sb.append("("); sb.append("(");
boolean first = true; boolean first = true;
for(Tree child : children) { for (Tree child : children) {
if (!first) { if (!first) {
sb.append("&nbsp;").append(connectionType.toHTML()).append("&nbsp;"); sb.append("&nbsp;").append(connectionType.toHTML()).append("&nbsp;");
if (depth == 0) if (depth == 0)
@@ -166,7 +177,8 @@ public class Tree {
private List<String> toAscii() { private List<String> toAscii() {
if (leaf != null) { if (leaf != null) {
return Arrays.asList(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1) + " " + leaf.toHTML() + " " + TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1)); return Arrays.asList(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH,
1) + " " + leaf.toHTML() + " " + TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1));
} }
List<Tree> children = getOrderedChildren(); List<Tree> children = getOrderedChildren();
@@ -175,7 +187,8 @@ public class Tree {
children.stream().map(c -> c.toAscii()).collect(Collectors.toList()); children.stream().map(c -> c.toAscii()).collect(Collectors.toList());
if (TreeConnectionType.Series.equals(connectionType)) { if (TreeConnectionType.Series.equals(connectionType)) {
return TreeAsciiUtil.concatenateMultiLineSerial(TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1), childrenAscii); return TreeAsciiUtil.concatenateMultiLineSerial(
TreeAsciiUtil.generateString(TreeAsciiUtil.BOXH, 1), childrenAscii);
} else { } else {
return TreeAsciiUtil.concatenateMultiLineParallel(childrenAscii); return TreeAsciiUtil.concatenateMultiLineParallel(childrenAscii);
} }
@@ -240,8 +253,8 @@ public class Tree {
for (Tree t : children) { for (Tree t : children) {
Tree childL = t.locate(l, forceDirection); Tree childL = t.locate(l, forceDirection);
if (childL != null) { if (childL != null) {
// if (t.getLeaf() != null) // if (t.getLeaf() != null)
// return this; // return this;
return childL; return childL;
} }
} }
@@ -277,9 +290,8 @@ public class Tree {
} }
public Tree findCommonParent(List<Tree> t) { public Tree findCommonParent(List<Tree> t) {
if (t.contains(null)) if (t.contains(null)) {
{ while (t.contains(null))
while(t.contains(null))
t.remove(null); t.remove(null);
return findCommonParent(t); return findCommonParent(t);
} }
@@ -300,8 +312,7 @@ public class Tree {
return null; return null;
if (children.contains(t)) if (children.contains(t))
return this; return this;
for (Tree c : children) for (Tree c : children) {
{
Tree p = c.findParent(t); Tree p = c.findParent(t);
if (p != null) if (p != null)
return p; return p;
@@ -137,27 +137,9 @@ public class Presenter implements IPlugInPort, IConfigListener {
private static final Logger LOG = Logger.getLogger(Presenter.class); private static final Logger LOG = Logger.getLogger(Presenter.class);
public static VersionNumber CURRENT_VERSION = new VersionNumber(4, 0, 0); public static VersionNumber CURRENT_VERSION = null;
public static List<Version> RECENT_VERSIONS = null; private static List<Version> RECENT_VERSIONS = null;
// Read the latest version from the local update.xml file
static {
try {
BufferedInputStream in = new BufferedInputStream(Presenter.class.getResourceAsStream("/update.xml"));
XStream xStream = new XStream(new DomDriver());
xStream.addPermission(AnyTypePermission.ANY);
@SuppressWarnings("unchecked")
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
CURRENT_VERSION = allVersions.get(allVersions.size() - 1).getVersionNumber();
LOG.info("Current DIYLC version: " + CURRENT_VERSION);
RECENT_VERSIONS = allVersions.stream()
.sorted(Comparator.comparing(x -> ((Version)x).getVersionNumber()).reversed())
.limit(10)
.collect(Collectors.toList());
in.close();
} catch (Exception e) {
LOG.error("Could not find version number, using default", e);
}
}
public static final String DEFAULTS_KEY_PREFIX = "default."; public static final String DEFAULTS_KEY_PREFIX = "default.";
public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList(); public static final List<IDIYComponent<?>> EMPTY_SELECTION = Collections.emptyList();
@@ -1091,11 +1073,39 @@ public class Presenter implements IPlugInPort, IConfigListener {
@Override @Override
public VersionNumber getCurrentVersionNumber() { public VersionNumber getCurrentVersionNumber() {
if (CURRENT_VERSION == null) {
List<Version> recentUpdates = getRecentUpdates();
CURRENT_VERSION = recentUpdates.stream()
.findFirst().map(v -> v.getVersionNumber())
.orElse(new VersionNumber(5, 0, 0));
LOG.info("Current DIYLC version: " + CURRENT_VERSION);
}
return CURRENT_VERSION; return CURRENT_VERSION;
} }
@Override @Override
public List<Version> getRecentUpdates() { public List<Version> getRecentUpdates() {
return getRecentVersions();
}
private static List<Version> getRecentVersions() {
if (RECENT_VERSIONS == null) {
try {
BufferedInputStream in =
new BufferedInputStream(Presenter.class.getResourceAsStream("/update.xml"));
XStream xStream = new XStream(new DomDriver());
xStream.addPermission(AnyTypePermission.ANY);
@SuppressWarnings("unchecked")
List<Version> allVersions = (List<Version>) xStream.fromXML(in);
RECENT_VERSIONS = allVersions.stream()
.sorted(Comparator.comparing(x -> ((Version) x).getVersionNumber()).reversed())
.limit(10).collect(Collectors.toList());
in.close();
} catch (Exception e) {
LOG.error("Could not load recent versions", e);
RECENT_VERSIONS = new ArrayList<>();
}
}
return RECENT_VERSIONS; return RECENT_VERSIONS;
} }
@@ -253,6 +253,10 @@
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Upgraded source code structure to modern standards and introduced Maven</description> <description>Upgraded source code structure to modern standards and introduced Maven</description>
</org.diylc.appframework.update.Change> </org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improved robustness of series/parallel graph construction code used in circuit analysis</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change> <org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType> <changeType>BUG_FIX</changeType>
<description>Moving selected components with a mouse doesn't register file modification action and doesn't enable Undo action</description> <description>Moving selected components with a mouse doesn't register file modification action and doesn't enable Undo action</description>
@@ -1,291 +1,291 @@
///* /*
// * *
// * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors. * DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
// * *
// * This file is part of DIYLC. * This file is part of DIYLC.
// * *
// * DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU * DIYLC is free software: you can redistribute it and/or modify it under the terms of the GNU
// * General Public License as published by the Free Software Foundation, either version 3 of the * General Public License as published by the Free Software Foundation, either version 3 of the
// * License, or (at your option) any later version. * License, or (at your option) any later version.
// * *
// * DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even * DIYLC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
// * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
// * Public License for more details. * Public License for more details.
// * *
// * You should have received a copy of the GNU General Public License along with DIYLC. If not, see * You should have received a copy of the GNU General Public License along with DIYLC. If not, see
// * <http://www.gnu.org/licenses/>. * <http://www.gnu.org/licenses/>.
// * *
// */ */
//package org.diylc.netlist; package org.diylc.netlist;
//
//import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
//import java.util.Arrays; import java.util.Arrays;
//
//import org.junit.Test; import org.junit.Test;
//
//import org.diylc.components.electromechanical.OpenJack1_4; import org.diylc.components.electromechanical.OpenJack1_4;
//import org.diylc.components.guitar.HumbuckerPickup; import org.diylc.components.guitar.HumbuckerPickup;
//import org.diylc.components.guitar.SingleCoilPickup; import org.diylc.components.guitar.SingleCoilPickup;
//import org.diylc.components.passive.PotentiometerPanel; import org.diylc.components.passive.PotentiometerPanel;
//import org.diylc.components.passive.RadialCeramicDiskCapacitor; import org.diylc.components.passive.RadialCeramicDiskCapacitor;
//import org.diylc.netlist.Group; import org.diylc.netlist.Group;
//import org.diylc.netlist.GuitarDiagramAnalyzer; import org.diylc.netlist.GuitarDiagramAnalyzer;
//import org.diylc.netlist.Netlist; import org.diylc.netlist.Netlist;
//import org.diylc.netlist.Tree; import org.diylc.netlist.Tree;
//import org.diylc.netlist.TreeException; import org.diylc.netlist.TreeException;
//
//public class GuitarNetlistAnalyzerTests { public class GuitarNetlistAnalyzerTests {
//
// @Test @Test
// public void testOneSinglePickup() throws TreeException { public void testOneSinglePickup() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// SingleCoilPickup pickup = new SingleCoilPickup(); SingleCoilPickup pickup = new SingleCoilPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup, 1); Group tipGroup = new Group().connect(jack, 0).connect(pickup, 1);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 2); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 2);
// netlist.add(tipGroup).add(sleeveGroup); netlist.add(tipGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup.North<-))", s); assertEquals("Pickup.North<-", s);
// } }
//
// @Test @Test
// public void testOneSinglePickupVolPot() throws TreeException { public void testOneSinglePickupVolPot() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// SingleCoilPickup pickup = new SingleCoilPickup(); SingleCoilPickup pickup = new SingleCoilPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// PotentiometerPanel vol = new PotentiometerPanel(); PotentiometerPanel vol = new PotentiometerPanel();
// vol.setName("Volume"); vol.setName("Volume");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup, vol)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup, vol));
// Group hotGroup = new Group().connect(pickup, 1).connect(vol, 0); Group hotGroup = new Group().connect(pickup, 1).connect(vol, 0);
// Group tipGroup = new Group().connect(jack, 0).connect(vol, 1); Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 2).connect(vol, 2); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 2).connect(vol, 2);
// netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup); netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Volume.1-2 + Pickup.North<-) || (Volume.2-3))", s); assertEquals("((Volume.1-2 + Pickup.North<-) || Volume.2-3)", s);
// } }
//
// @Test @Test
// public void testOneSinglePickupVolTonePot() throws TreeException { public void testOneSinglePickupVolTonePot() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// SingleCoilPickup pickup = new SingleCoilPickup(); SingleCoilPickup pickup = new SingleCoilPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// PotentiometerPanel vol = new PotentiometerPanel(); PotentiometerPanel vol = new PotentiometerPanel();
// vol.setName("Volume"); vol.setName("Volume");
// PotentiometerPanel tone = new PotentiometerPanel(); PotentiometerPanel tone = new PotentiometerPanel();
// tone.setName("Tone"); tone.setName("Tone");
// RadialCeramicDiskCapacitor cap = new RadialCeramicDiskCapacitor(); RadialCeramicDiskCapacitor cap = new RadialCeramicDiskCapacitor();
// cap.setName("Cap"); cap.setName("Cap");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup, vol, tone, cap)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup, vol, tone, cap));
// Group hotGroup = new Group().connect(pickup, 1).connect(vol, 0).connect(tone, 2); Group hotGroup = new Group().connect(pickup, 1).connect(vol, 0).connect(tone, 2);
// Group tipGroup = new Group().connect(jack, 0).connect(vol, 1); Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
// Group sleeveGroup = Group sleeveGroup =
// new Group().connect(jack, 1).connect(pickup, 2).connect(vol, 2).connect(cap, 0); new Group().connect(jack, 1).connect(pickup, 2).connect(vol, 2).connect(cap, 0);
// Group toneGroup = new Group().connect(tone, 1).connect(cap, 1); Group toneGroup = new Group().connect(tone, 1).connect(cap, 1);
// netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(toneGroup); netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(toneGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("(((Volume.1-2) + ((Pickup.North<-) || (Tone.2-3 + Cap))) || (Volume.2-3))", s); assertEquals("((Volume.1-2 + (Tone.2-3 + Cap) || Pickup.North<-) || Volume.2-3)", s);
// } }
//
// @Test @Test
// public void testTwoSinglePickupsMasterVolSeparateTone() throws TreeException { public void testTwoSinglePickupsMasterVolSeparateTone() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// SingleCoilPickup pickup1 = new SingleCoilPickup(); SingleCoilPickup pickup1 = new SingleCoilPickup();
// pickup1.setName("Pickup1"); pickup1.setName("Pickup1");
// SingleCoilPickup pickup2 = new SingleCoilPickup(); SingleCoilPickup pickup2 = new SingleCoilPickup();
// pickup2.setName("Pickup2"); pickup2.setName("Pickup2");
// PotentiometerPanel vol = new PotentiometerPanel(); PotentiometerPanel vol = new PotentiometerPanel();
// vol.setName("Volume"); vol.setName("Volume");
// PotentiometerPanel tone1 = new PotentiometerPanel(); PotentiometerPanel tone1 = new PotentiometerPanel();
// tone1.setName("Tone1"); tone1.setName("Tone1");
// PotentiometerPanel tone2 = new PotentiometerPanel(); PotentiometerPanel tone2 = new PotentiometerPanel();
// tone2.setName("Tone2"); tone2.setName("Tone2");
// RadialCeramicDiskCapacitor cap1 = new RadialCeramicDiskCapacitor(); RadialCeramicDiskCapacitor cap1 = new RadialCeramicDiskCapacitor();
// cap1.setName("Cap1"); cap1.setName("Cap1");
// RadialCeramicDiskCapacitor cap2 = new RadialCeramicDiskCapacitor(); RadialCeramicDiskCapacitor cap2 = new RadialCeramicDiskCapacitor();
// cap2.setName("Cap2"); cap2.setName("Cap2");
// Netlist netlist = Netlist netlist =
// new Netlist(Arrays.asList(jack, pickup1, pickup2, vol, tone1, tone2, cap1, cap2)); new Netlist(Arrays.asList(jack, pickup1, pickup2, vol, tone1, tone2, cap1, cap2));
// Group hotGroup = new Group().connect(pickup1, 1).connect(vol, 0).connect(tone1, 2) Group hotGroup = new Group().connect(pickup1, 1).connect(vol, 0).connect(tone1, 2)
// .connect(pickup2, 1).connect(tone2, 2); .connect(pickup2, 1).connect(tone2, 2);
// Group tipGroup = new Group().connect(jack, 0).connect(vol, 1); Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 2).connect(pickup2, 2) Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 2).connect(pickup2, 2)
// .connect(vol, 2).connect(cap1, 0).connect(cap2, 0); .connect(vol, 2).connect(cap1, 0).connect(cap2, 0);
// Group tone1Group = new Group().connect(tone1, 1).connect(cap1, 1); Group tone1Group = new Group().connect(tone1, 1).connect(cap1, 1);
// Group tone2Group = new Group().connect(tone2, 1).connect(cap2, 1); Group tone2Group = new Group().connect(tone2, 1).connect(cap2, 1);
// netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(tone1Group) netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(tone1Group)
// .add(tone2Group); .add(tone2Group);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals( assertEquals(
// "(((Volume.1-2) + ((Pickup1.North<-) || (Pickup2.North<-) || (Tone1.2-3 + Cap1) || (Tone2.2-3 + Cap2))) || (Volume.2-3))", "((Volume.1-2 + (Tone1.2-3 + Cap1) || (Tone2.2-3 + Cap2) || Pickup1.North<- || Pickup2.North<-) || Volume.2-3)",
// s); s);
// } }
//
// @Test @Test
// public void testOneSinglePickupReverse() throws TreeException { public void testOneSinglePickupReverse() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// SingleCoilPickup pickup = new SingleCoilPickup(); SingleCoilPickup pickup = new SingleCoilPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup, 2); Group tipGroup = new Group().connect(jack, 0).connect(pickup, 2);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1);
// netlist.add(tipGroup).add(sleeveGroup); netlist.add(tipGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup.North->))", s); assertEquals("Pickup.North->", s);
// } }
//
// @Test @Test
// public void testOneHumbuckerSeries() throws TreeException { public void testOneHumbuckerSeries() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup = new HumbuckerPickup(); HumbuckerPickup pickup = new HumbuckerPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0); Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0);
// Group coilTapGroup = new Group().connect(pickup, 1).connect(pickup, 2); Group coilTapGroup = new Group().connect(pickup, 1).connect(pickup, 2);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 3); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 3);
// netlist.add(tipGroup).add(coilTapGroup).add(sleeveGroup); netlist.add(tipGroup).add(coilTapGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup.North<- + Pickup.South<-))", s); assertEquals("(Pickup.North<- + Pickup.South<-)", s);
// } }
//
// @Test @Test
// public void testOneHumbuckerSeriesReverse() throws TreeException { public void testOneHumbuckerSeriesReverse() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup = new HumbuckerPickup(); HumbuckerPickup pickup = new HumbuckerPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup, 3); Group tipGroup = new Group().connect(jack, 0).connect(pickup, 3);
// Group coilTapGroup = new Group().connect(pickup, 1).connect(pickup, 2); Group coilTapGroup = new Group().connect(pickup, 1).connect(pickup, 2);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 0); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 0);
// netlist.add(tipGroup).add(coilTapGroup).add(sleeveGroup); netlist.add(tipGroup).add(coilTapGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup.South-> + Pickup.North->))", s); assertEquals("(Pickup.South-> + Pickup.North->)", s);
// } }
//
// @Test @Test
// public void testOneHumbuckerParallel() throws TreeException { public void testOneHumbuckerParallel() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup = new HumbuckerPickup(); HumbuckerPickup pickup = new HumbuckerPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0).connect(pickup, 2); Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0).connect(pickup, 2);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1).connect(pickup, 3); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1).connect(pickup, 3);
// netlist.add(tipGroup).add(sleeveGroup); netlist.add(tipGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup.North<-) || (Pickup.South<-))", s); assertEquals("(Pickup.North<- || Pickup.South<-)", s);
// } }
//
// @Test @Test
// public void testOneHumbuckerParallelOutOfPhase() throws TreeException { public void testOneHumbuckerParallelOutOfPhase() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup = new HumbuckerPickup(); HumbuckerPickup pickup = new HumbuckerPickup();
// pickup.setName("Pickup"); pickup.setName("Pickup");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0).connect(pickup, 3); Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0).connect(pickup, 3);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1).connect(pickup, 2); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1).connect(pickup, 2);
// netlist.add(tipGroup).add(sleeveGroup); netlist.add(tipGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup.North<-) || (Pickup.South->))", s); assertEquals("(Pickup.North<- || Pickup.South->)", s);
// } }
//
// @Test @Test
// public void testTwoHumbuckersSeries() throws TreeException { public void testTwoHumbuckersSeries() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup1 = new HumbuckerPickup(); HumbuckerPickup pickup1 = new HumbuckerPickup();
// pickup1.setName("Pickup1"); pickup1.setName("Pickup1");
// HumbuckerPickup pickup2 = new HumbuckerPickup(); HumbuckerPickup pickup2 = new HumbuckerPickup();
// pickup2.setName("Pickup2"); pickup2.setName("Pickup2");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0); Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0);
// Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2); Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
// Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2); Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
// Group joinGroup = new Group().connect(pickup1, 3).connect(pickup2, 0); Group joinGroup = new Group().connect(pickup1, 3).connect(pickup2, 0);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup2, 3); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup2, 3);
// netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(joinGroup).add(sleeveGroup); netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(joinGroup).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup1.North<- + Pickup1.South<- + Pickup2.North<- + Pickup2.South<-))", s); assertEquals("(Pickup1.North<- + Pickup1.South<- + Pickup2.North<- + Pickup2.South<-)", s);
// } }
//
// @Test @Test
// public void testTwoHumbuckersParallel() throws TreeException { public void testTwoHumbuckersParallel() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup1 = new HumbuckerPickup(); HumbuckerPickup pickup1 = new HumbuckerPickup();
// pickup1.setName("Pickup1"); pickup1.setName("Pickup1");
// HumbuckerPickup pickup2 = new HumbuckerPickup(); HumbuckerPickup pickup2 = new HumbuckerPickup();
// pickup2.setName("Pickup2"); pickup2.setName("Pickup2");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0).connect(pickup2, 0); Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0).connect(pickup2, 0);
// Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2); Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
// Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2); Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 3); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 3);
// netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(sleeveGroup); netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup1.North<- + Pickup1.South<-) || (Pickup2.North<- + Pickup2.South<-))", s); assertEquals("((Pickup1.North<- + Pickup1.South<-) || (Pickup2.North<- + Pickup2.South<-))", s);
// } }
//
// @Test @Test
// public void testTwoHumbuckersParallelOutOfPhase() throws TreeException { public void testTwoHumbuckersParallelOutOfPhase() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup1 = new HumbuckerPickup(); HumbuckerPickup pickup1 = new HumbuckerPickup();
// pickup1.setName("Pickup1"); pickup1.setName("Pickup1");
// HumbuckerPickup pickup2 = new HumbuckerPickup(); HumbuckerPickup pickup2 = new HumbuckerPickup();
// pickup2.setName("Pickup2"); pickup2.setName("Pickup2");
// Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2)); Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2));
// Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0).connect(pickup2, 3); Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0).connect(pickup2, 3);
// Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2); Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
// Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2); Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 0); Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 0);
// netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(sleeveGroup); netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(sleeveGroup);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals("((Pickup1.North<- + Pickup1.South<-) || (Pickup2.South-> + Pickup2.North->))", s); assertEquals("((Pickup1.North<- + Pickup1.South<-) || (Pickup2.South-> + Pickup2.North->))", s);
// } }
//
// @Test @Test
// public void testTwoHumbuckersMasterVolSeparateTone() throws TreeException { public void testTwoHumbuckersMasterVolSeparateTone() throws TreeException {
// OpenJack1_4 jack = new OpenJack1_4(); OpenJack1_4 jack = new OpenJack1_4();
// HumbuckerPickup pickup1 = new HumbuckerPickup(); HumbuckerPickup pickup1 = new HumbuckerPickup();
// pickup1.setName("Pickup1"); pickup1.setName("Pickup1");
// HumbuckerPickup pickup2 = new HumbuckerPickup(); HumbuckerPickup pickup2 = new HumbuckerPickup();
// pickup2.setName("Pickup2"); pickup2.setName("Pickup2");
// PotentiometerPanel vol = new PotentiometerPanel(); PotentiometerPanel vol = new PotentiometerPanel();
// vol.setName("Volume"); vol.setName("Volume");
// PotentiometerPanel tone1 = new PotentiometerPanel(); PotentiometerPanel tone1 = new PotentiometerPanel();
// tone1.setName("Tone1"); tone1.setName("Tone1");
// PotentiometerPanel tone2 = new PotentiometerPanel(); PotentiometerPanel tone2 = new PotentiometerPanel();
// tone2.setName("Tone2"); tone2.setName("Tone2");
// RadialCeramicDiskCapacitor cap1 = new RadialCeramicDiskCapacitor(); RadialCeramicDiskCapacitor cap1 = new RadialCeramicDiskCapacitor();
// cap1.setName("Cap1"); cap1.setName("Cap1");
// RadialCeramicDiskCapacitor cap2 = new RadialCeramicDiskCapacitor(); RadialCeramicDiskCapacitor cap2 = new RadialCeramicDiskCapacitor();
// cap2.setName("Cap2"); cap2.setName("Cap2");
// Netlist netlist = Netlist netlist =
// new Netlist(Arrays.asList(jack, pickup1, pickup2, vol, tone1, tone2, cap1, cap2)); new Netlist(Arrays.asList(jack, pickup1, pickup2, vol, tone1, tone2, cap1, cap2));
// Group hotGroup = new Group().connect(pickup1, 0).connect(vol, 0).connect(tone1, 2) Group hotGroup = new Group().connect(pickup1, 0).connect(vol, 0).connect(tone1, 2)
// .connect(pickup2, 0).connect(tone2, 2); .connect(pickup2, 0).connect(tone2, 2);
// Group tipGroup = new Group().connect(jack, 0).connect(vol, 1); Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
// Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 3) Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 3)
// .connect(vol, 2).connect(cap1, 0).connect(cap2, 0); .connect(vol, 2).connect(cap1, 0).connect(cap2, 0);
// Group tone1Group = new Group().connect(tone1, 1).connect(cap1, 1); Group tone1Group = new Group().connect(tone1, 1).connect(cap1, 1);
// Group tone2Group = new Group().connect(tone2, 1).connect(cap2, 1); Group tone2Group = new Group().connect(tone2, 1).connect(cap2, 1);
// Group coilTap1 = new Group().connect(pickup1, 1).connect(pickup1, 2); Group coilTap1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
// Group coilTap2 = new Group().connect(pickup2, 1).connect(pickup2, 2); Group coilTap2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
// netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(tone1Group) netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(tone1Group)
// .add(tone2Group).add(coilTap1).add(coilTap2); .add(tone2Group).add(coilTap1).add(coilTap2);
// Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist); Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
// String s = tree.toString(); String s = tree.toString();
// assertEquals( assertEquals(
// "(((Volume.1-2) + ((Pickup1.North<- + Pickup1.South<-) || (Pickup2.North<- + Pickup2.South<-) || (Tone1.2-3 + Cap1) || (Tone2.2-3 + Cap2))) || (Volume.2-3))", "((Volume.1-2 + (Pickup1.North<- + Pickup1.South<-) || (Pickup2.North<- + Pickup2.South<-) || (Tone1.2-3 + Cap1) || (Tone2.2-3 + Cap2)) || Volume.2-3)",
// s); s);
// } }
//} }