Refactor/maven (#889)

* mavenize

* mavenization

* mavenization

* mavenization

* mavenization

* mavenization

* mavenization

* mavenization

* mavenization

* fix

* app framework update

* fix lib

* lib

* fix mavenized

* fix mavenized

* fix mavenized

* fix mavenized

* fix mavenized

* fix mavenized

* fix mavenized

* fix mavenized

* building for win and linux

* Create run.bat

* fixes for netlist

* cleanup

* unit tests

* unit tests

* configurable high dpi

* performance upgrade

* performance upgrade

* rotate bug

* Omit boards, wires, traces, terminals, etc from Spice netlist output

* splash version update

* optimize libs

* optimize libs

* updates

* mac build maven

* ruler optimization, moved images

* cleanup

* notarization

* test workflow

* build

* Update pom.xml

* Update pom.xml

* Create README.md

* Create test.yml

* maven

* build
This commit is contained in:
Bane Stojkovic
2025-03-20 19:44:40 +01:00
committed by GitHub
parent ccb98d1953
commit 4093641b7e
1232 changed files with 17811 additions and 14965 deletions
@@ -0,0 +1,53 @@
package org.diylc.components.passive;
import org.junit.Assert;
import org.junit.Test;
import org.diylc.components.passive.AxialFilmCapacitor;
import org.diylc.components.passive.CapacitorDatasheetService;
import org.diylc.components.passive.CapacitorDatasheetService.CapacitorDatasheet;
import org.diylc.core.measures.Capacitance;
import org.diylc.core.measures.CapacitanceUnit;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.core.measures.Voltage;
import org.diylc.core.measures.VoltageUnit;
public class CapacitorDimensionServiceTests {
@Test
public void testMissingType() {
Assert.assertNull(CapacitorDatasheetService.getInstance().lookup(AxialFilmCapacitor.class,
"bla", new Voltage(100d, VoltageUnit.V), new Capacitance(10d, CapacitanceUnit.uF)));
}
@Test
public void testMissingCategory() {
Assert.assertNull(CapacitorDatasheetService.getInstance().lookup(AxialFilmCapacitor.class,
"Mallory 150", new Voltage(500d, VoltageUnit.V), new Capacitance(10d, CapacitanceUnit.nF)));
}
@Test
public void testMissingValue() {
Assert.assertNull(CapacitorDatasheetService.getInstance().lookup(AxialFilmCapacitor.class,
"Mallory 150", new Voltage(600d, VoltageUnit.V), new Capacitance(10d, CapacitanceUnit.uF)));
}
@Test
public void testExactValue63v() {
CapacitorDatasheet dim = CapacitorDatasheetService.getInstance().lookup(AxialFilmCapacitor.class,
"Mallory 150", new Voltage(63d, VoltageUnit.V), new Capacitance(0.22d, CapacitanceUnit.uF));
Assert.assertNotNull(dim);
Assert.assertEquals(new Size(16.5, SizeUnit.mm).convertToPixels(), dim.getLength().convertToPixels(), 0.0001);
Assert.assertEquals(new Size(6d, SizeUnit.mm).convertToPixels(), dim.getWidth().convertToPixels(), 0.0001);
}
@Test
public void testCloseValue() {
CapacitorDatasheet dim = CapacitorDatasheetService.getInstance().lookup(AxialFilmCapacitor.class,
"Mallory 150", new Voltage(63d, VoltageUnit.V), new Capacitance(0.23d, CapacitanceUnit.uF));
Assert.assertNotNull(dim);
Assert.assertEquals(new Size(16.5, SizeUnit.mm).convertToPixels(), dim.getLength().convertToPixels(), 0.0001);
Assert.assertEquals(new Size(6d, SizeUnit.mm).convertToPixels(), dim.getWidth().convertToPixels(), 0.0001);
}
}
@@ -0,0 +1,29 @@
package org.diylc.netlist;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Arrays;
import org.diylc.core.IDIYComponent;
import org.diylc.core.ISwitch;
public abstract class AbstractSwitchTests {
protected void testSwitch(ISwitch sw, String[] validCombinations) {
Arrays.sort(validCombinations);
int count = 0;
for (int p = 0; p < sw.getPositionCount(); p++)
for (int i = 0; i < ((IDIYComponent<?>) sw).getControlPointCount(); i++)
for (int j = 0; j < ((IDIYComponent<?>) sw).getControlPointCount(); j++) {
String test = p + "," + i + "," + j;
boolean isConnected = sw.arePointsConnected(i, j, p);
if (isConnected)
count++;
boolean isOk = (isConnected && Arrays.binarySearch(validCombinations, test) >= 0)
|| !isConnected && Arrays.binarySearch(validCombinations, test) < 0;
if (!isOk)
fail("Bad connection for p=" + p + ", i=" + i + ",j=" + j);
}
assertEquals(validCombinations.length, count);
}
}
@@ -0,0 +1,291 @@
/*
*
* DIY Layout Creator (DIYLC). Copyright (c) 2009-2018 held jointly by the individual authors.
*
* This file is part of DIYLC.
*
* 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
* 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
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*
* You should have received a copy of the GNU General Public License along with DIYLC. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
package org.diylc.netlist;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import org.junit.Test;
import org.diylc.components.electromechanical.OpenJack1_4;
import org.diylc.components.guitar.HumbuckerPickup;
import org.diylc.components.guitar.SingleCoilPickup;
import org.diylc.components.passive.PotentiometerPanel;
import org.diylc.components.passive.RadialCeramicDiskCapacitor;
import org.diylc.netlist.Group;
import org.diylc.netlist.GuitarDiagramAnalyzer;
import org.diylc.netlist.Netlist;
import org.diylc.netlist.Tree;
import org.diylc.netlist.TreeException;
public class GuitarNetlistAnalyzerTests {
@Test
public void testOneSinglePickup() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
SingleCoilPickup pickup = new SingleCoilPickup();
pickup.setName("Pickup");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
Group tipGroup = new Group().connect(jack, 0).connect(pickup, 1);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 2);
netlist.add(tipGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("Pickup.North<-", s);
}
@Test
public void testOneSinglePickupVolPot() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
SingleCoilPickup pickup = new SingleCoilPickup();
pickup.setName("Pickup");
PotentiometerPanel vol = new PotentiometerPanel();
vol.setName("Volume");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup, vol));
Group hotGroup = new Group().connect(pickup, 1).connect(vol, 0);
Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 2).connect(vol, 2);
netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("((Volume.1-2 + Pickup.North<-) || Volume.2-3)", s);
}
@Test
public void testOneSinglePickupVolTonePot() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
SingleCoilPickup pickup = new SingleCoilPickup();
pickup.setName("Pickup");
PotentiometerPanel vol = new PotentiometerPanel();
vol.setName("Volume");
PotentiometerPanel tone = new PotentiometerPanel();
tone.setName("Tone");
RadialCeramicDiskCapacitor cap = new RadialCeramicDiskCapacitor();
cap.setName("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 tipGroup = new Group().connect(jack, 0).connect(vol, 1);
Group sleeveGroup =
new Group().connect(jack, 1).connect(pickup, 2).connect(vol, 2).connect(cap, 0);
Group toneGroup = new Group().connect(tone, 1).connect(cap, 1);
netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(toneGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("((Volume.1-2 + (Tone.2-3 + Cap) || Pickup.North<-) || Volume.2-3)", s);
}
@Test
public void testTwoSinglePickupsMasterVolSeparateTone() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
SingleCoilPickup pickup1 = new SingleCoilPickup();
pickup1.setName("Pickup1");
SingleCoilPickup pickup2 = new SingleCoilPickup();
pickup2.setName("Pickup2");
PotentiometerPanel vol = new PotentiometerPanel();
vol.setName("Volume");
PotentiometerPanel tone1 = new PotentiometerPanel();
tone1.setName("Tone1");
PotentiometerPanel tone2 = new PotentiometerPanel();
tone2.setName("Tone2");
RadialCeramicDiskCapacitor cap1 = new RadialCeramicDiskCapacitor();
cap1.setName("Cap1");
RadialCeramicDiskCapacitor cap2 = new RadialCeramicDiskCapacitor();
cap2.setName("Cap2");
Netlist netlist =
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)
.connect(pickup2, 1).connect(tone2, 2);
Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 2).connect(pickup2, 2)
.connect(vol, 2).connect(cap1, 0).connect(cap2, 0);
Group tone1Group = new Group().connect(tone1, 1).connect(cap1, 1);
Group tone2Group = new Group().connect(tone2, 1).connect(cap2, 1);
netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(tone1Group)
.add(tone2Group);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals(
"((Volume.1-2 + (Tone1.2-3 + Cap1) || (Tone2.2-3 + Cap2) || Pickup1.North<- || Pickup2.North<-) || Volume.2-3)",
s);
}
@Test
public void testOneSinglePickupReverse() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
SingleCoilPickup pickup = new SingleCoilPickup();
pickup.setName("Pickup");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
Group tipGroup = new Group().connect(jack, 0).connect(pickup, 2);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 1);
netlist.add(tipGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("Pickup.North->", s);
}
@Test
public void testOneHumbuckerSeries() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup = new HumbuckerPickup();
pickup.setName("Pickup");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
Group tipGroup = new Group().connect(jack, 0).connect(pickup, 0);
Group coilTapGroup = new Group().connect(pickup, 1).connect(pickup, 2);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 3);
netlist.add(tipGroup).add(coilTapGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("(Pickup.North<- + Pickup.South<-)", s);
}
@Test
public void testOneHumbuckerSeriesReverse() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup = new HumbuckerPickup();
pickup.setName("Pickup");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
Group tipGroup = new Group().connect(jack, 0).connect(pickup, 3);
Group coilTapGroup = new Group().connect(pickup, 1).connect(pickup, 2);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup, 0);
netlist.add(tipGroup).add(coilTapGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("(Pickup.South-> + Pickup.North->)", s);
}
@Test
public void testOneHumbuckerParallel() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup = new HumbuckerPickup();
pickup.setName("Pickup");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
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);
netlist.add(tipGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("(Pickup.North<- || Pickup.South<-)", s);
}
@Test
public void testOneHumbuckerParallelOutOfPhase() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup = new HumbuckerPickup();
pickup.setName("Pickup");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup));
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);
netlist.add(tipGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("(Pickup.North<- || Pickup.South->)", s);
}
@Test
public void testTwoHumbuckersSeries() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup1 = new HumbuckerPickup();
pickup1.setName("Pickup1");
HumbuckerPickup pickup2 = new HumbuckerPickup();
pickup2.setName("Pickup2");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2));
Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0);
Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
Group joinGroup = new Group().connect(pickup1, 3).connect(pickup2, 0);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup2, 3);
netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(joinGroup).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("(Pickup1.North<- + Pickup1.South<- + Pickup2.North<- + Pickup2.South<-)", s);
}
@Test
public void testTwoHumbuckersParallel() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup1 = new HumbuckerPickup();
pickup1.setName("Pickup1");
HumbuckerPickup pickup2 = new HumbuckerPickup();
pickup2.setName("Pickup2");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2));
Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0).connect(pickup2, 0);
Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 3);
netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("((Pickup1.North<- + Pickup1.South<-) || (Pickup2.North<- + Pickup2.South<-))", s);
}
@Test
public void testTwoHumbuckersParallelOutOfPhase() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup1 = new HumbuckerPickup();
pickup1.setName("Pickup1");
HumbuckerPickup pickup2 = new HumbuckerPickup();
pickup2.setName("Pickup2");
Netlist netlist = new Netlist(Arrays.asList(jack, pickup1, pickup2));
Group tipGroup = new Group().connect(jack, 0).connect(pickup1, 0).connect(pickup2, 3);
Group coilTapGroup1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
Group coilTapGroup2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 0);
netlist.add(tipGroup).add(coilTapGroup1).add(coilTapGroup2).add(sleeveGroup);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals("((Pickup1.North<- + Pickup1.South<-) || (Pickup2.South-> + Pickup2.North->))", s);
}
@Test
public void testTwoHumbuckersMasterVolSeparateTone() throws TreeException {
OpenJack1_4 jack = new OpenJack1_4();
HumbuckerPickup pickup1 = new HumbuckerPickup();
pickup1.setName("Pickup1");
HumbuckerPickup pickup2 = new HumbuckerPickup();
pickup2.setName("Pickup2");
PotentiometerPanel vol = new PotentiometerPanel();
vol.setName("Volume");
PotentiometerPanel tone1 = new PotentiometerPanel();
tone1.setName("Tone1");
PotentiometerPanel tone2 = new PotentiometerPanel();
tone2.setName("Tone2");
RadialCeramicDiskCapacitor cap1 = new RadialCeramicDiskCapacitor();
cap1.setName("Cap1");
RadialCeramicDiskCapacitor cap2 = new RadialCeramicDiskCapacitor();
cap2.setName("Cap2");
Netlist netlist =
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)
.connect(pickup2, 0).connect(tone2, 2);
Group tipGroup = new Group().connect(jack, 0).connect(vol, 1);
Group sleeveGroup = new Group().connect(jack, 1).connect(pickup1, 3).connect(pickup2, 3)
.connect(vol, 2).connect(cap1, 0).connect(cap2, 0);
Group tone1Group = new Group().connect(tone1, 1).connect(cap1, 1);
Group tone2Group = new Group().connect(tone2, 1).connect(cap2, 1);
Group coilTap1 = new Group().connect(pickup1, 1).connect(pickup1, 2);
Group coilTap2 = new Group().connect(pickup2, 1).connect(pickup2, 2);
netlist.add(tipGroup).add(tipGroup).add(sleeveGroup).add(hotGroup).add(tone1Group)
.add(tone2Group).add(coilTap1).add(coilTap2);
Tree tree = new GuitarDiagramAnalyzer().constructTree(netlist);
String s = tree.toString();
assertEquals(
"((Volume.1-2 + (Pickup1.North<- + Pickup1.South<-) || (Pickup2.North<- + Pickup2.South<-) || (Tone1.2-3 + Cap1) || (Tone2.2-3 + Cap2)) || Volume.2-3)",
s);
}
}
@@ -0,0 +1,15 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.guitar.LPSwitch;
public class LPSwitchTests extends AbstractSwitchTests {
@Test
public void testLPSwitch() {
LPSwitch lpSwitch = new LPSwitch();
String[] validCombinations = new String[] {"0,1,2", "1,1,2", "1,2,3", "1,1,3", "2,2,3"};
testSwitch(lpSwitch, validCombinations);
}
}
@@ -0,0 +1,53 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.guitar.LeverSwitch;
import org.diylc.components.guitar.LeverSwitch.LeverSwitchType;
public class LeverSwitchTests extends AbstractSwitchTests {
@Test
public void testLeverSwitchDP5T() {
LeverSwitch leverSwitch = new LeverSwitch();
leverSwitch.setValue(LeverSwitchType.DP5T);
String[] validCombinations = new String[] {"0,0,1", "0,6,11", "1,0,2", "1,7,11", "2,0,3",
"2,8,11", "3,0,4", "3,9,11", "4,0,5", "4,10,11"};
testSwitch(leverSwitch, validCombinations);
}
@Test
public void testLeverSwitch4P5T() {
LeverSwitch leverSwitch = new LeverSwitch();
String[] validCombinations = new String[] {"0,0,1", "0,6,11", "0,12,13", "0,18,23", "1,0,2",
"1,7,11", "1,12,14", "1,19,23", "2,0,3", "2,8,11", "2,12,15", "2,20,23", "3,0,4", "3,9,11",
"3,12,16", "3,21,23", "4,0,5", "4,10,11", "4,12,17", "4,22,23"};
leverSwitch.setValue(LeverSwitchType._4P5T);
testSwitch(leverSwitch, validCombinations);
}
@Test
public void testLeverSwitchImport() {
LeverSwitch leverSwitch = new LeverSwitch();
String[] validCombinations = new String[] {"0,0,3", "0,4,5", "1,0,3", "1,4,5", "1,1,3",
"1,4,6", "2,1,3", "2,4,6", "3,1,3", "3,2,3", "3,4,6", "3,4,7", "4,2,3", "4,4,7"};
leverSwitch.setValue(LeverSwitchType.DP3T_5pos_Import);
testSwitch(leverSwitch, validCombinations);
}
@Test
public void testLeverSwitch6Way() {
LeverSwitch leverSwitch = new LeverSwitch();
String[] validCombinations = new String[] {"0,0,8", "0,1,3", "0,1,5", "1,0,8", "1,2,8", "1,1,5", "2,2,8", "2,1,5", "2,1,7",
"3,2,8", "3,4,8", "3,1,7", "4,4,8", "4,1,7", "4,1,9", "5,4,8", "5,6,8", "5,1,9"};
leverSwitch.setValue(LeverSwitchType._6_WAY_OG);
testSwitch(leverSwitch, validCombinations);
}
}
@@ -0,0 +1,25 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.electromechanical.MiniToggleSwitch;
import org.diylc.components.electromechanical.ToggleSwitchType;
public class MiniToggleSwitchTests extends AbstractSwitchTests {
@Test
public void testMiniToggleSwitchDPDTononon1() {
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_1);
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,0,1", "1,4,5", "2,1,2", "2,4,5"};
testSwitch(toggleSwitch, validCombinations);
}
@Test
public void testMiniToggleSwitchDPDTononon2() {
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_2);
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,1,2", "1,3,4", "2,1,2", "2,4,5"};
testSwitch(toggleSwitch, validCombinations);
}
}
@@ -0,0 +1,71 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.electromechanical.RotarySwitchOpen;
import org.diylc.components.electromechanical.RotarySwitchOpenType;
public class RotarySwitchOpenTests extends AbstractSwitchTests {
@Test
public void testRotarySwitch2P5T() {
RotarySwitchOpen sw = new RotarySwitchOpen();
String[] validCombinations = new String[] {
"0,5,11", "0,10,12",
"1,4,11", "1,9,12",
"2,3,11", "2,8,12",
"3,2,11", "3,7,12",
"4,1,11", "4,6,12"};
sw.setValue(RotarySwitchOpenType._2P5T);
testSwitch(sw, validCombinations);
}
@Test
public void testRotarySwitch2P6T() {
RotarySwitchOpen sw = new RotarySwitchOpen();
String[] validCombinations = new String[] {
"0,6,13", "0,12,14",
"1,5,13", "1,11,14",
"2,4,13", "2,10,14",
"3,3,13", "3,9,14",
"4,2,13", "4,8,14",
"5,1,13", "5,7,14"};
sw.setValue(RotarySwitchOpenType._2P6T);
testSwitch(sw, validCombinations);
}
@Test
public void testRotarySwitch4P5T() {
RotarySwitchOpen sw = new RotarySwitchOpen();
String[] validCombinations = new String[] {
"0,5,11", "0,10,12", "0,17,23", "0,22,24",
"1,4,11", "1,9,12", "1,16,23", "1,21,24",
"2,3,11", "2,8,12", "2,15,23", "2,20,24",
"3,2,11", "3,7,12", "3,14,23", "3,19,24",
"4,1,11", "4,6,12", "4,13,23", "4,18,24"};
sw.setValue(RotarySwitchOpenType._4P5T);
testSwitch(sw, validCombinations);
}
@Test
public void testRotarySwitch4P6T() {
RotarySwitchOpen sw = new RotarySwitchOpen();
String[] validCombinations = new String[] {
"0,6,13", "0,12,14", "0,20,27", "0,26,28",
"1,5,13", "1,11,14", "1,19,27", "1,25,28",
"2,4,13", "2,10,14", "2,18,27", "2,24,28",
"3,3,13", "3,9,14", "3,17,27", "3,23,28",
"4,2,13", "4,8,14", "4,16,27", "4,22,28",
"5,1,13", "5,7,14", "5,15,27", "5,21,28",};
sw.setValue(RotarySwitchOpenType._4P6T);
testSwitch(sw, validCombinations);
}
}
@@ -0,0 +1,59 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.electromechanical.RotarySwitchSealed;
import org.diylc.components.electromechanical.RotarySwitchSealedType;
public abstract class RotarySwitchSealedTests extends AbstractSwitchTests {
@Test
public void testRotarySwitchSP12T() {
RotarySwitchSealed sw = new RotarySwitchSealed();
String[] validCombinations = new String[] {"0,1,13", "1,2,13", "2,3,13", "3,4,13", "4,5,13", "5,6,13", "6,7,13", "7,8,13",
"8,9,13", "9,10,13", "10,11,13", "11,12,13"};
sw.setValue(RotarySwitchSealedType._1P12T);
testSwitch(sw, validCombinations);
}
@Test
public void testRotarySwitchDP6T() {
RotarySwitchSealed sw = new RotarySwitchSealed();
String[] validCombinations = new String[] {
"0,1,13", "1,2,13", "2,3,13", "3,4,13", "4,5,13", "5,6,13",
"0,7,14", "1,8,14", "2,9,14", "3,10,14", "4,11,14", "5,12,14"};
sw.setValue(RotarySwitchSealedType._2P6T);
testSwitch(sw, validCombinations);
}
@Test
public void testRotarySwitch3P4T() {
RotarySwitchSealed sw = new RotarySwitchSealed();
String[] validCombinations = new String[] {
"0,1,13", "1,2,13", "2,3,13", "3,4,13",
"0,5,14", "1,6,14", "2,7,14", "3,8,14",
"0,9,15", "1,10,15", "2,11,15", "3,12,15"};
sw.setValue(RotarySwitchSealedType._3P4T);
testSwitch(sw, validCombinations);
}
@Test
public void testRotarySwitch4P3T() {
RotarySwitchSealed sw = new RotarySwitchSealed();
String[] validCombinations = new String[] {
"0,1,13", "1,2,13", "2,3,13",
"0,4,14", "1,5,14", "2,6,14",
"0,7,15", "1,8,15", "2,9,15",
"0,10,16", "1,11,16", "2,12,16",};
sw.setValue(RotarySwitchSealedType._4P3T);
testSwitch(sw, validCombinations);
}
}
@@ -0,0 +1,17 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.guitar.S1Switch;
public class S1SwitchTests extends AbstractSwitchTests {
@Test
public void testS1Switch() {
S1Switch s1Switch = new S1Switch();
String[] validCombinations = new String[] {"0,1,2", "0,4,5", "0,7,8", "0,10,11", "1,2,3", "1,5,6", "1,8,9", "1,11,12"};
testSwitch(s1Switch, validCombinations);
}
}
@@ -0,0 +1,78 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.guitar.SchallerMegaSwitch;
import org.diylc.components.guitar.SchallerMegaSwitch.MegaSwitchType;
public class SchallerMegaSwitchTests extends AbstractSwitchTests {
@Test
public void testMegaSwitchE() {
SchallerMegaSwitch sw = new SchallerMegaSwitch();
sw.setType(MegaSwitchType.E);
String[] validCombinations = new String[] {"0,2,6", "1,3,5", "1,2,6", "1,0,2", "2,3,4",
"2,2,5", "2,1,2", "3,3,4", "3,0,2", "3,1,2", "4,1,2"};
testSwitch(sw, validCombinations);
}
@Test
public void testMegaSwitchEPlus() {
SchallerMegaSwitch sw = new SchallerMegaSwitch();
sw.setType(MegaSwitchType.E_PLUS);
String[] validCombinations = new String[] {"0,2,8", "1,3,6", "1,2,8", "1,0,2", "2,3,5",
"2,2,7", "2,1,2", "3,3,4", "3,0,2", "3,1,2", "4,1,2"};
testSwitch(sw, validCombinations);
}
@Test
public void testMegaSwitchP() {
SchallerMegaSwitch sw = new SchallerMegaSwitch();
sw.setType(MegaSwitchType.P);
String[] validCombinations = new String[] {"0,3,4", "0,1,6", "1,3,4", "1,1,2", "1,0,4", "1,1,5",
"2,0,2", "2,1,6", "3,0,1", "3,3,4", "3,2,4", "3,1,6", "4,1,5"};
testSwitch(sw, validCombinations);
}
@Test
public void testMegaSwitchS() {
SchallerMegaSwitch sw = new SchallerMegaSwitch();
sw.setType(MegaSwitchType.S);
String[] validCombinations = new String[] {"0,6,7", "0,2,3", "1,4,7", "1,6,7", "1,0,3", "1,2,3",
"2,4,7", "2,0,3", "3,4,7", "3,5,7", "3,0,3", "3,1,3", "4,5,7", "4,1,3"};
testSwitch(sw, validCombinations);
}
@Test
public void testMegaSwitchM() {
SchallerMegaSwitch sw = new SchallerMegaSwitch();
sw.setType(MegaSwitchType.M);
String[] validCombinations = new String[] {"0,4,5", "0,10,11", "0,16,17", "0,22,23",
"1,3,5", "1,9,11", "1,15,17", "1,21,23",
"2,2,5", "2,8,11", "2,14,17", "2,20,23",
"3,1,5", "3,7,11", "3,13,17", "3,19,23",
"4,0,5", "4,6,11", "4,12,17", "4,18,23"};
testSwitch(sw, validCombinations);
}
@Test
public void testMegaSwitchT() {
SchallerMegaSwitch sw = new SchallerMegaSwitch();
sw.setType(MegaSwitchType.T);
String[] validCombinations = new String[] {"0,6,7", "0,2,3", "1,4,7", "1,0,3",
"2,5,7", "2,1,3"};
testSwitch(sw, validCombinations);
}
}
@@ -0,0 +1,33 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.electromechanical.SlideSwitch;
import org.diylc.components.electromechanical.SlideSwitchType;
public abstract class SlideSwitchTests extends AbstractSwitchTests {
@Test
public void testSlideSwitchSPDT() {
SlideSwitch slideSwitch = new SlideSwitch();
slideSwitch.setValue(SlideSwitchType.SPDT);
String[] validCombinations = new String[] {"0,0,1", "1,1,2"};
testSwitch(slideSwitch, validCombinations);
}
@Test
public void testSlideSwitchDPDT() {
SlideSwitch slideSwitch = new SlideSwitch();
slideSwitch.setValue(SlideSwitchType.DPDT);
String[] validCombinations = new String[] {"0,0,2", "0,1,3", "1,2,4", "1,3,5"};
testSwitch(slideSwitch, validCombinations);
}
@Test
public void testSlideSwitchDP3T() {
SlideSwitch slideSwitch = new SlideSwitch();
slideSwitch.setValue(SlideSwitchType.DP3T);
String[] validCombinations = new String[] {"0,0,2", "0,1,3", "1,2,4", "1,3,5", "2,4,6", "2,5,7"};
testSwitch(slideSwitch, validCombinations);
}
}
@@ -0,0 +1,56 @@
package org.diylc.netlist;
import org.junit.Test;
import org.diylc.components.electromechanical.SwitchLatchingSymbol;
import org.diylc.components.electromechanical.SwitchLatchingSymbol.PoleCount;
public class SwitchLatchingTests extends AbstractSwitchTests {
@Test
public void testSPSTSwitch() {
SwitchLatchingSymbol sw = new SwitchLatchingSymbol();
String[] validCombinations =
new String[] {"0,0,1"};
sw.setValue(SwitchLatchingSymbol.SwitchConfiguration._1x2);
sw.setPoleCount(PoleCount.ONE);
testSwitch(sw, validCombinations);
}
@Test
public void test3PDTSwitch() {
SwitchLatchingSymbol sw = new SwitchLatchingSymbol();
String[] validCombinations =
new String[] {"0,0,1", "0,4,5", "0,8,9", "1,0,2", "1,4,6", "1,8,10", "2,0,3", "2,4,7", "2,8,11"};
sw.setValue(SwitchLatchingSymbol.SwitchConfiguration._3x3);
sw.setPoleCount(PoleCount.THREE);
testSwitch(sw, validCombinations);
}
@Test
public void testStratSwitch() {
SwitchLatchingSymbol sw = new SwitchLatchingSymbol();
String[] validCombinations = new String[] {"0,0,1", "0,4,5", "1,0,1", "1,4,5", "1,0,2", "1,4,6",
"2,0,2", "2,4,6", "3,0,2", "3,0,3", "3,4,6", "3,4,7", "4,0,3", "4,4,7"};
sw.setValue(SwitchLatchingSymbol.SwitchConfiguration._3x5xSHORT);
sw.setPoleCount(PoleCount.TWO);
testSwitch(sw, validCombinations);
}
@Test
public void testON_OFF_ON() {
SwitchLatchingSymbol sw = new SwitchLatchingSymbol();
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "2,0,2", "2,3,5"};
sw.setValue(SwitchLatchingSymbol.SwitchConfiguration._2x3xOFF);
sw.setPoleCount(PoleCount.TWO);
testSwitch(sw, validCombinations);
}
}
@@ -0,0 +1,94 @@
package org.diylc.netlist;
import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.diylc.netlist.NetlistParseException;
import org.diylc.netlist.ParsedNetlistEntry;
import org.diylc.netlist.TangoNetlistParser;
public class TangoParserTests {
@Test
public void testParse1() {
String content = "[\r\n" +
"R9\r\n" +
"RESISTOR\r\n" +
"100k\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"D4\r\n" +
"LED\r\n" +
"LED\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"C3\r\n" +
"CAP_FILM\r\n" +
"82n\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"C2\r\n" +
"CAP_ELECTRO_200\r\n" +
"1u\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"C1\r\n" +
"CAP_CERAMIC1\r\n" +
"820p\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"U2\r\n" +
"DIP14\r\n" +
"TL074\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"D1\r\n" +
"DIODE\r\n" +
"Zener 12V\r\n" +
"\r\n" +
"]\r\n" +
"[\r\n" +
"B1\r\n" +
"PADS2\r\n" +
"9V\r\n" +
"\r\n" +
"]\r\n" +
"(\r\n" +
"unnamed_net15\r\n" +
"U4-11\r\n" +
")\r\n" +
"(\r\n" +
"unnamed_net14\r\n" +
"U3-3\r\n" +
"U1-3\r\n" +
"R7-1\r\n" +
"R8-2\r\n" +
"U2-3\r\n" +
")\r\n" +
"(\r\n" +
"unnamed_net13\r\n" +
"R1-2\r\n" +
"B1-1\r\n" +
")";
List<String> outputWarnings = new ArrayList<String>();
try {
TangoNetlistParser parser = new TangoNetlistParser();
List<ParsedNetlistEntry> parsed = parser.parse(content, outputWarnings);
Assert.assertNotNull(parsed);
} catch (NetlistParseException e) {
fail("Unexpected error:" + e.getMessage());
}
}
}