mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
switch fixes
This commit is contained in:
@@ -45,7 +45,8 @@ public class SwitchUtils {
|
|||||||
for (int i = 0; i < numPoints; i++) {
|
for (int i = 0; i < numPoints; i++) {
|
||||||
final int finalI = i;
|
final int finalI = i;
|
||||||
if (switchingMatrix.stream().allMatch(
|
if (switchingMatrix.stream().allMatch(
|
||||||
l -> l.stream().anyMatch(
|
l -> l.isEmpty() ||
|
||||||
|
l.stream().anyMatch(
|
||||||
s -> s.contains(finalI)))) {
|
s -> s.contains(finalI)))) {
|
||||||
markers[i] = String.valueOf((char)((int)'A' + commonPoints.size()));
|
markers[i] = String.valueOf((char)((int)'A' + commonPoints.size()));
|
||||||
commonPoints.add(i);
|
commonPoints.add(i);
|
||||||
|
|||||||
@@ -331,7 +331,7 @@
|
|||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>NEW_FEATURE</changeType>
|
<changeType>NEW_FEATURE</changeType>
|
||||||
<description>Added ability to highlight connected switch lugs in selected position in order to illustrate how it works internally.</description>
|
<description>Added ability to display switch lug markings in order to illustrate how it works internally.</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
<org.diylc.appframework.update.Change>
|
<org.diylc.appframework.update.Change>
|
||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
@@ -345,6 +345,10 @@
|
|||||||
<changeType>IMPROVEMENT</changeType>
|
<changeType>IMPROVEMENT</changeType>
|
||||||
<description>Fully configurable colors for 'Mini Toggle Switch' components</description>
|
<description>Fully configurable colors for 'Mini Toggle Switch' components</description>
|
||||||
</org.diylc.appframework.update.Change>
|
</org.diylc.appframework.update.Change>
|
||||||
|
<org.diylc.appframework.update.Change>
|
||||||
|
<changeType>IMPROVEMENT</changeType>
|
||||||
|
<description>Removed 'DP3T' options from 'Mini Toggle Switch' because that is covered by 'Slide Switch' component and does not belong here</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>Applying a variant to a 'Hookup Wire' or 'Curved Trace' makes it lose its shape</description>
|
<description>Applying a variant to a 'Hookup Wire' or 'Curved Trace' makes it lose its shape</description>
|
||||||
|
|||||||
+47
-56
@@ -31,15 +31,11 @@ import java.awt.geom.Area;
|
|||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
import java.awt.geom.Rectangle2D;
|
||||||
import java.awt.geom.RoundRectangle2D;
|
import java.awt.geom.RoundRectangle2D;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import org.diylc.appframework.miscutils.ConfigurationManager;
|
import org.diylc.appframework.miscutils.ConfigurationManager;
|
||||||
|
|
||||||
import org.diylc.common.IPlugInPort;
|
import org.diylc.awt.StringUtils;
|
||||||
import org.diylc.common.ObjectCache;
|
import org.diylc.common.*;
|
||||||
import org.diylc.common.OrientationHV;
|
|
||||||
import org.diylc.components.AbstractTransparentComponent;
|
import org.diylc.components.AbstractTransparentComponent;
|
||||||
import org.diylc.components.guitar.ToggleSwitchPositionPropertyValueSource;
|
import org.diylc.components.guitar.ToggleSwitchPositionPropertyValueSource;
|
||||||
import org.diylc.components.transform.MiniToggleSwitchTransformer;
|
import org.diylc.components.transform.MiniToggleSwitchTransformer;
|
||||||
@@ -59,8 +55,7 @@ import org.diylc.core.gerber.IGerberComponentSimple;
|
|||||||
import org.diylc.core.measures.Size;
|
import org.diylc.core.measures.Size;
|
||||||
import org.diylc.core.measures.SizeUnit;
|
import org.diylc.core.measures.SizeUnit;
|
||||||
import org.diylc.utils.Constants;
|
import org.diylc.utils.Constants;
|
||||||
|
import org.diylc.utils.SwitchUtils;
|
||||||
import static org.diylc.utils.SwitchUtils.getConnectedTerminals;
|
|
||||||
|
|
||||||
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
@ComponentDescriptor(name = "Mini Toggle Switch", category = "Electro-Mechanical", author = "Branislav Stojkovic",
|
||||||
description = "Panel mounted mini toggle switch", zOrder = IDIYComponent.COMPONENT,
|
description = "Panel mounted mini toggle switch", zOrder = IDIYComponent.COMPONENT,
|
||||||
@@ -74,11 +69,14 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
private static Size CIRCLE_SIZE = new Size(0.09d, SizeUnit.in);
|
private static Size CIRCLE_SIZE = new Size(0.09d, SizeUnit.in);
|
||||||
private static Size LUG_WIDTH = new Size(0.060d, SizeUnit.in);
|
private static Size LUG_WIDTH = new Size(0.060d, SizeUnit.in);
|
||||||
private static Size LUG_THICKNESS = new Size(0.02d, SizeUnit.in);
|
private static Size LUG_THICKNESS = new Size(0.02d, SizeUnit.in);
|
||||||
|
private static Size MARKER_OFFSET = new Size(0.07d, SizeUnit.in);
|
||||||
|
|
||||||
private static Color BODY_COLOR = Color.decode("#3299CC");
|
private static Color BODY_COLOR = Color.decode("#3299CC");
|
||||||
private static Color BORDER_COLOR = BODY_COLOR.darker();
|
private static Color BORDER_COLOR = BODY_COLOR.darker();
|
||||||
private static Color CIRCLE_COLOR = Color.decode("#287ba4");
|
private static Color CIRCLE_COLOR = Color.decode("#287ba4");
|
||||||
private static Color TERMINAL_COLOR = LIGHT_METAL_COLOR;
|
private static Color TERMINAL_COLOR = LIGHT_METAL_COLOR;
|
||||||
|
private static Color MARKER_COLOR = LIGHT_METAL_COLOR;
|
||||||
|
|
||||||
|
|
||||||
protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
|
protected Point2D[] controlPoints = new Point2D[] {new Point2D.Double(0, 0)};
|
||||||
transient protected Shape body;
|
transient protected Shape body;
|
||||||
@@ -92,7 +90,7 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
private Color terminalColor = TERMINAL_COLOR;
|
private Color terminalColor = TERMINAL_COLOR;
|
||||||
|
|
||||||
private Integer selectedPosition;
|
private Integer selectedPosition;
|
||||||
private Boolean highlightConnectedTerminals;
|
private Boolean showMarkers;
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
protected String name;
|
protected String name;
|
||||||
@@ -126,17 +124,6 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + spacing),
|
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + spacing),
|
||||||
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + 2 * spacing)};
|
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + 2 * spacing)};
|
||||||
break;
|
break;
|
||||||
case _DP3T_mustang:
|
|
||||||
controlPoints =
|
|
||||||
new Point2D[] {firstPoint,
|
|
||||||
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + spacing),
|
|
||||||
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 2 * spacing),
|
|
||||||
new Point2D.Double(firstPoint.getX(), firstPoint.getY() + 3 * spacing),
|
|
||||||
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY()),
|
|
||||||
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + spacing),
|
|
||||||
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + 2 * spacing),
|
|
||||||
new Point2D.Double(firstPoint.getX() + spacing, firstPoint.getY() + 3 * spacing)};
|
|
||||||
break;
|
|
||||||
case _3PDT:
|
case _3PDT:
|
||||||
case _3PDT_off:
|
case _3PDT_off:
|
||||||
controlPoints =
|
controlPoints =
|
||||||
@@ -328,8 +315,6 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
lugHeight = getClosestOdd((int) LUG_THICKNESS.convertToPixels());
|
lugHeight = getClosestOdd((int) LUG_THICKNESS.convertToPixels());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Set<Integer>> connectedTerminals = getConnectedTerminals(this, controlPoints.length);
|
|
||||||
|
|
||||||
for (int i = 0; i < controlPoints.length; i++) {
|
for (int i = 0; i < controlPoints.length; i++) {
|
||||||
Point2D p = controlPoints[i];
|
Point2D p = controlPoints[i];
|
||||||
if (outlineMode) {
|
if (outlineMode) {
|
||||||
@@ -341,36 +326,44 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
g2d.setColor(theme.getOutlineColor());
|
g2d.setColor(theme.getOutlineColor());
|
||||||
g2d.drawRect((int)(p.getX() - lugWidth / 2d), (int)(p.getY() - lugHeight / 2d), lugWidth, lugHeight);
|
g2d.drawRect((int)(p.getX() - lugWidth / 2d), (int)(p.getY() - lugHeight / 2d), lugWidth, lugHeight);
|
||||||
} else {
|
} else {
|
||||||
int finalI = i;
|
|
||||||
int groupIndex = IntStream.range(0, connectedTerminals.size())
|
|
||||||
.filter(j -> connectedTerminals.get(j).contains(finalI))
|
|
||||||
.findFirst().orElse(-1);
|
|
||||||
|
|
||||||
if (groupIndex < 0) {
|
|
||||||
g2d.setColor(getTerminalPadColor().darker());
|
g2d.setColor(getTerminalPadColor().darker());
|
||||||
} else {
|
|
||||||
g2d.setColor(ISwitch.POLE_COLORS[groupIndex].darker());
|
|
||||||
}
|
|
||||||
|
|
||||||
g2d.drawOval((int)(p.getX() - circleDiameter / 2d), (int)(p.getY() - circleDiameter / 2d), circleDiameter, circleDiameter);
|
g2d.drawOval((int)(p.getX() - circleDiameter / 2d), (int)(p.getY() - circleDiameter / 2d), circleDiameter, circleDiameter);
|
||||||
|
|
||||||
|
|
||||||
if (groupIndex < 0) {
|
|
||||||
g2d.setColor(getTerminalPadColor());
|
g2d.setColor(getTerminalPadColor());
|
||||||
} else {
|
|
||||||
g2d.setColor(ISwitch.POLE_COLORS[groupIndex]);
|
|
||||||
}
|
|
||||||
g2d.fillOval((int)(p.getX() - circleDiameter / 2d), (int)(p.getY() - circleDiameter / 2d), circleDiameter, circleDiameter);
|
g2d.fillOval((int)(p.getX() - circleDiameter / 2d), (int)(p.getY() - circleDiameter / 2d), circleDiameter, circleDiameter);
|
||||||
if (groupIndex < 0) {
|
|
||||||
g2d.setColor(getTerminalColor());
|
g2d.setColor(getTerminalColor());
|
||||||
} else {
|
|
||||||
g2d.setColor(getTerminalColor().darker());
|
|
||||||
}
|
|
||||||
// drawingObserver.startTrackingContinuityArea(true);
|
// drawingObserver.startTrackingContinuityArea(true);
|
||||||
g2d.fillRect((int)(p.getX() - lugWidth / 2d), (int)(p.getY() - lugHeight / 2d), lugWidth, lugHeight);
|
g2d.fillRect((int)(p.getX() - lugWidth / 2d), (int)(p.getY() - lugHeight / 2d), lugWidth, lugHeight);
|
||||||
// drawingObserver.stopTrackingContinuityArea();
|
// drawingObserver.stopTrackingContinuityArea();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getShowMarkers()) {
|
||||||
|
String[] markers =
|
||||||
|
SwitchUtils.getSwitchingMarkers(this, getControlPointCount(), false);
|
||||||
|
|
||||||
|
g2d.setColor(MARKER_COLOR);
|
||||||
|
|
||||||
|
double offset = MARKER_OFFSET.convertToPixels();
|
||||||
|
for (int i = 0; i < getControlPointCount(); i++) {
|
||||||
|
if (markers[i] == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Point2D p = getControlPoint(i);
|
||||||
|
Point2D labelPoint = new Point2D.Double(offset, 0);
|
||||||
|
|
||||||
|
AffineTransform tx = null;
|
||||||
|
if (getOrientation() == OrientationHV.HORIZONTAL) {
|
||||||
|
tx = AffineTransform.getRotateInstance(-Math.PI / 2, 0, 0);
|
||||||
|
}
|
||||||
|
if (tx != null) {
|
||||||
|
tx.transform(labelPoint, labelPoint);
|
||||||
|
}
|
||||||
|
StringUtils.drawCenteredText(g2d, markers[i], p.getX() + labelPoint.getX(), p.getY() + labelPoint.getY(),
|
||||||
|
HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Shape getBody() {
|
public Shape getBody() {
|
||||||
@@ -398,11 +391,6 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
new RoundRectangle2D.Double(firstPoint.getX() - margin, firstPoint.getY() - margin, 2 * margin + spacing, 2
|
new RoundRectangle2D.Double(firstPoint.getX() - margin, firstPoint.getY() - margin, 2 * margin + spacing, 2
|
||||||
* margin + 2 * spacing, margin, margin);
|
* margin + 2 * spacing, margin, margin);
|
||||||
break;
|
break;
|
||||||
case _DP3T_mustang:
|
|
||||||
body =
|
|
||||||
new RoundRectangle2D.Double(firstPoint.getX() - margin, firstPoint.getY() - margin, 2 * margin + spacing, 2
|
|
||||||
* margin + 3 * spacing, margin, margin);
|
|
||||||
break;
|
|
||||||
case _3PDT:
|
case _3PDT:
|
||||||
case _3PDT_off:
|
case _3PDT_off:
|
||||||
body =
|
body =
|
||||||
@@ -529,24 +517,25 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
|
|
||||||
public void setSelectedPosition(Integer selectedPosition) {
|
public void setSelectedPosition(Integer selectedPosition) {
|
||||||
this.selectedPosition = selectedPosition;
|
this.selectedPosition = selectedPosition;
|
||||||
this.body = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EditableProperty(name = "Highlight Connected")
|
@EditableProperty(name = "Markers")
|
||||||
public Boolean getShowMarkers() {
|
public Boolean getShowMarkers() {
|
||||||
if (highlightConnectedTerminals == null) {
|
if (showMarkers == null) {
|
||||||
highlightConnectedTerminals = false;
|
showMarkers = false;
|
||||||
}
|
}
|
||||||
return highlightConnectedTerminals;
|
return showMarkers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHighlightConnectedTerminals(Boolean highlightConnectedTerminals) {
|
public void setShowMarkers(Boolean showMarkers) {
|
||||||
this.highlightConnectedTerminals = highlightConnectedTerminals;
|
this.showMarkers = showMarkers;
|
||||||
this.body = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean arePointsConnected(int index1, int index2, int position) {
|
public boolean arePointsConnected(int index1, int index2, int position) {
|
||||||
|
if (index1 >= index2)
|
||||||
|
return false;
|
||||||
|
|
||||||
switch (switchType) {
|
switch (switchType) {
|
||||||
case SPST:
|
case SPST:
|
||||||
return position == 0;
|
return position == 0;
|
||||||
@@ -561,9 +550,11 @@ public class MiniToggleSwitch extends AbstractTransparentComponent<ToggleSwitchT
|
|||||||
case _3PDT_off:
|
case _3PDT_off:
|
||||||
case _4PDT_off:
|
case _4PDT_off:
|
||||||
case _5PDT_off:
|
case _5PDT_off:
|
||||||
return position != 2 && (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
|
if (position == 1)
|
||||||
case _DP3T_mustang:
|
return false;
|
||||||
return (index2 - index1) < 3 && index1 % 3 == 0 && index2 % 3 == position + 1;
|
if (position == 2)
|
||||||
|
position = 1;
|
||||||
|
return (index2 - index1) < 3 && index1 % 3 == position && index2 % 3 == position + 1;
|
||||||
case DPDT_ononon_1:
|
case DPDT_ononon_1:
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|||||||
-1
@@ -30,7 +30,6 @@ public enum ToggleSwitchType {
|
|||||||
DPDT_off("DPDT (On/Off/On)", 3),
|
DPDT_off("DPDT (On/Off/On)", 3),
|
||||||
DPDT_ononon_1("DPDT (On/On/On Type 1)", 3),
|
DPDT_ononon_1("DPDT (On/On/On Type 1)", 3),
|
||||||
DPDT_ononon_2("DPDT (On/On/On Type 2)", 3),
|
DPDT_ononon_2("DPDT (On/On/On Type 2)", 3),
|
||||||
_DP3T_mustang("DP3T", 3),
|
|
||||||
_3PDT("3PDT", 2),
|
_3PDT("3PDT", 2),
|
||||||
_3PDT_off("3PDT (On/Off/On)", 3),
|
_3PDT_off("3PDT (On/Off/On)", 3),
|
||||||
_4PDT("4PDT", 2),
|
_4PDT("4PDT", 2),
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ public class LeverSwitch extends AbstractAngledComponent<LeverSwitch.LeverSwitch
|
|||||||
SwitchUtils.getSwitchingMarkers(this, getControlPointCount(), false);
|
SwitchUtils.getSwitchingMarkers(this, getControlPointCount(), false);
|
||||||
double theta = getAngle().getValueRad();
|
double theta = getAngle().getValueRad();
|
||||||
g2d.setColor(MARKER_COLOR);
|
g2d.setColor(MARKER_COLOR);
|
||||||
double x = controlPoints[0].getX();
|
|
||||||
double y = controlPoints[0].getY();
|
|
||||||
|
|
||||||
double offset = MARKER_OFFSET.convertToPixels();
|
double offset = MARKER_OFFSET.convertToPixels();
|
||||||
for (int i = 0; i < getControlPointCount(); i++) {
|
for (int i = 0; i < getControlPointCount(); i++) {
|
||||||
|
|||||||
@@ -8,18 +8,168 @@ import org.diylc.components.electromechanical.ToggleSwitchType;
|
|||||||
public class MiniToggleSwitchTests extends AbstractSwitchTests {
|
public class MiniToggleSwitchTests extends AbstractSwitchTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMiniToggleSwitchDPDTononon1() {
|
public void testMiniToggleSwitchSPST() {
|
||||||
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_1);
|
toggleSwitch.setValue(ToggleSwitchType.SPST);
|
||||||
String[] validCombinations = new String[] {"0,0,1", "0,3,4", "1,0,1", "1,4,5", "2,1,2", "2,4,5"};
|
String[] validCombinations = new String[] {"0,0,1"};
|
||||||
testSwitch(toggleSwitch, validCombinations);
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMiniToggleSwitchDPDTononon2() {
|
public void testMiniToggleSwitchSPDT() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType.SPDT);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1",
|
||||||
|
"1,1,2"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitchSPDT_off() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType.SPDT_off);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1",
|
||||||
|
"2,1,2"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitchDPDT() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType.DPDT);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4",
|
||||||
|
"1,1,2", "1,4,5"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitchDPDT_off() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType.DPDT_off);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4",
|
||||||
|
"2,1,2", "2,4,5"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitchDPDT_ononon1() {
|
||||||
|
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 testMiniToggleSwitchDPDT_ononon2() {
|
||||||
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
toggleSwitch.setValue(ToggleSwitchType.DPDT_ononon_2);
|
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"};
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_3PDT() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._3PDT);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7",
|
||||||
|
"1,1,2", "1,4,5", "1,7,8"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_3PDT_off() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._3PDT_off);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7",
|
||||||
|
"2,1,2", "2,4,5", "2,7,8"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_4PDT() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._4PDT);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7", "0,9,10",
|
||||||
|
"1,1,2", "1,4,5", "1,7,8", "1,10,11"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_4PDT_off() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._4PDT_off);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7", "0,9,10",
|
||||||
|
"2,1,2", "2,4,5", "2,7,8", "2,10,11"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_4PDT_ononon1() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._4PDT_ononon_1);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7", "0,9,10",
|
||||||
|
"1,0,1", "1,4,5", "1,6,7", "1,10,11",
|
||||||
|
"2,1,2", "2,4,5", "2,7,8", "2,10,11"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_4PDT_ononon2() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._4PDT_ononon_2);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7", "0,9,10",
|
||||||
|
"1,1,2", "1,3,4", "1,7,8", "1,9,10",
|
||||||
|
"2,1,2", "2,4,5", "2,7,8", "2,10,11"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_5PDT() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._5PDT);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7", "0,9,10", "0,12,13",
|
||||||
|
"1,1,2", "1,4,5", "1,7,8", "1,10,11", "1,13,14"
|
||||||
|
};
|
||||||
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMiniToggleSwitch_5PDT_off() {
|
||||||
|
MiniToggleSwitch toggleSwitch = new MiniToggleSwitch();
|
||||||
|
toggleSwitch.setValue(ToggleSwitchType._5PDT_off);
|
||||||
|
String[] validCombinations = new String[] {
|
||||||
|
"0,0,1", "0,3,4", "0,6,7", "0,9,10", "0,12,13",
|
||||||
|
"2,1,2", "2,4,5", "2,7,8", "2,10,11", "2,13,14"
|
||||||
|
};
|
||||||
testSwitch(toggleSwitch, validCombinations);
|
testSwitch(toggleSwitch, validCombinations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user