From f2dc63e7e6afb936452146140c77fdb572eeba89 Mon Sep 17 00:00:00 2001 From: Bane Stojkovic Date: Sat, 27 Aug 2022 18:10:49 +0200 Subject: [PATCH] Added two DPDT ON/ON/ON variations to 'Mini Toggle Switch' component --- .../src/org/diylc/presenter/update.xml | 8 +++++ .../electromechanical/MiniToggleSwitch.java | 36 ++++++++++++++++--- .../electromechanical/ToggleSwitchType.java | 4 ++- .../test/org/diylc/netlist/SwitchTests.java | 18 ++++++++++ diylc/diylc-swing/dict.txt | 3 ++ 5 files changed, 63 insertions(+), 6 deletions(-) diff --git a/diylc/diylc-core/src/org/diylc/presenter/update.xml b/diylc/diylc-core/src/org/diylc/presenter/update.xml index a4aed0d5b..9b80f4fe9 100644 --- a/diylc/diylc-core/src/org/diylc/presenter/update.xml +++ b/diylc/diylc-core/src/org/diylc/presenter/update.xml @@ -3894,6 +3894,14 @@ 2022-07-09 00:00:00.000 CET + + NEW_FEATURE + Added 'Voltage Source' symbol. Thank you, JD! + + + NEW_FEATURE + Added two DPDT ON/ON/ON variations to 'Mini Toggle Switch' component + BUG_FIX The app crashes if there's a component that is reduced to 0 pixels with 'Cache Boost' enabled diff --git a/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java b/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java index 3ad978473..0e77b5d5a 100644 --- a/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java +++ b/diylc/diylc-library/src/org/diylc/components/electromechanical/MiniToggleSwitch.java @@ -98,7 +98,9 @@ private void updateControlPoints() { new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing)}; break; case DPDT: - case DPDT_off: + case DPDT_off: + case DPDT_ononon_1: + case DPDT_ononon_2: controlPoints = new Point2D[] {firstPoint, new Point2D.Double(firstPoint.getX(), firstPoint.getY() + spacing), new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing), @@ -336,7 +338,9 @@ public Shape getBody() { * spacing, margin, margin); break; case DPDT: - case DPDT_off: + case DPDT_off: + case DPDT_ononon_1: + case DPDT_ononon_2: body = new RoundRectangle2D.Double(firstPoint.getX() - margin, firstPoint.getY() - margin, 2 * margin + spacing, 2 * margin + 2 * spacing, margin, margin); @@ -441,13 +445,15 @@ public int getPositionCount() { case _3PDT_off: case _4PDT_off: case _5PDT_off: + case DPDT_ononon_1: + case DPDT_ononon_2: return 3; } return 2; } @Override - public String getPositionName(int position) { + public String getPositionName(int position) { if (switchType.name().endsWith("_off") && position == 2) return "OFF"; return "ON" + Integer.toString(position + 1); @@ -463,7 +469,7 @@ public boolean arePointsConnected(int index1, int index2, int position) { case _3PDT: case _4PDT: case _5PDT: - return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1; + return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1; case SPDT_off: case DPDT_off: case _3PDT_off: @@ -471,7 +477,27 @@ public boolean arePointsConnected(int index1, int index2, int position) { case _5PDT_off: return position != 2 && (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1; case _DP3T_mustang: - return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1; + return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1; + case DPDT_ononon_1: + switch (position) { + case 0: + return (index1 == 0 && index2 == 1) || (index1 == 3 && index2 == 4); + case 1: + return (index1 == 0 && index2 == 1) || (index1 == 4 && index2 == 5); + case 2: + return (index1 == 1 && index2 == 2) || (index1 == 4 && index2 == 5); + default: return false; + } + case DPDT_ononon_2: + switch (position) { + case 0: + return (index1 == 0 && index2 == 1) || (index1 == 3 && index2 == 4); + case 1: + return (index1 == 1 && index2 == 2) || (index1 == 3 && index2 == 4); + case 2: + return (index1 == 1 && index2 == 2) || (index1 == 4 && index2 == 5); + default: return false; + } } return false; } diff --git a/diylc/diylc-library/src/org/diylc/components/electromechanical/ToggleSwitchType.java b/diylc/diylc-library/src/org/diylc/components/electromechanical/ToggleSwitchType.java index 2f3947a4d..59f9132ff 100644 --- a/diylc/diylc-library/src/org/diylc/components/electromechanical/ToggleSwitchType.java +++ b/diylc/diylc-library/src/org/diylc/components/electromechanical/ToggleSwitchType.java @@ -23,7 +23,7 @@ DIY Layout Creator (DIYLC). public enum ToggleSwitchType { - SPST, SPDT, DPDT, _DP3T_mustang, _3PDT, _4PDT, _5PDT, SPDT_off, DPDT_off, _3PDT_off, _4PDT_off, _5PDT_off; + SPST, SPDT, DPDT, _DP3T_mustang, _3PDT, _4PDT, _5PDT, SPDT_off, DPDT_off, _3PDT_off, _4PDT_off, _5PDT_off, DPDT_ononon_1, DPDT_ononon_2; @Override public String toString() { @@ -33,6 +33,8 @@ public String toString() { name = name.replace("_", " "); name = name.replace("mustang", ""); name = name.replace("off", " (Center OFF)"); + name = name.replace("ononon_1", " On/On/On (Type 1)"); + name = name.replace("ononon_2", " On/On/On (Type 2)"); return name; } } diff --git a/diylc/diylc-library/test/org/diylc/netlist/SwitchTests.java b/diylc/diylc-library/test/org/diylc/netlist/SwitchTests.java index 37a21e4f3..87afe061b 100644 --- a/diylc/diylc-library/test/org/diylc/netlist/SwitchTests.java +++ b/diylc/diylc-library/test/org/diylc/netlist/SwitchTests.java @@ -3,8 +3,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import java.util.Arrays; +import org.diylc.components.electromechanical.MiniToggleSwitch; import org.diylc.components.electromechanical.SlideSwitch; import org.diylc.components.electromechanical.SlideSwitchType; +import org.diylc.components.electromechanical.ToggleSwitchType; import org.diylc.components.guitar.LPSwitch; import org.diylc.components.guitar.LeverSwitch; import org.diylc.components.guitar.LeverSwitch.LeverSwitchType; @@ -66,6 +68,22 @@ public void testSlideSwitchDP3T() { 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); } + + @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); + } private void testSwitch(ISwitch sw, String[] validCombinations) { Arrays.sort(validCombinations); diff --git a/diylc/diylc-swing/dict.txt b/diylc/diylc-swing/dict.txt index 0b09d65a8..e4f7a72a7 100644 --- a/diylc/diylc-swing/dict.txt +++ b/diylc/diylc-swing/dict.txt @@ -23,6 +23,7 @@ 5PDT 5PDT (Center OFF) A-O-I REGULATOR +AC AWG And B-C-E BJT @@ -31,6 +32,7 @@ D-G-S JFET D-G-S MOSFET D-S-G JFET D-S-G MOSFET +DC DFM A DFM B DIP @@ -81,6 +83,7 @@ SMD SPDT SPDT (Center OFF) SPST +SourceType Srpski Xnor Xor