Added switch (latching) symbol

This commit is contained in:
Bane Stojkovic
2022-10-30 23:04:54 +01:00
parent 5d6b77f259
commit 86acda3f46
3 changed files with 90 additions and 15 deletions
@@ -4061,19 +4061,31 @@
</versionNumber>
<releaseDate>2022-10-23 00:00:00.000 CET</releaseDate>
<name></name>
<changes>
<changes>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added "Switch (Latching)" schematic symbol with many variations</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Added "Common Node" component that ties all nodes with the same label together, e.g. B+, V+, GND, etc</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>NEW_FEATURE</changeType>
<description>Ground symbol ties all grounded points together for circuit analysis</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>"Snap to Components" features now works when creating new components as well as when moving existing ones</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Increase the opacity of locked components</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>IMPROVEMENT</changeType>
<description>Improved ground symbol mouse selection tracking and added stroke width as a parameter</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Ground symbol ties all grounded points together for circuit analysis</description>
</org.diylc.appframework.update.Change>
<org.diylc.appframework.update.Change>
<changeType>BUG_FIX</changeType>
<description>Printed projects are sometimes missing parts of components or text</description>
@@ -39,7 +39,6 @@ import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.KeywordPolicy;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.utils.Constants;
@ComponentDescriptor(name = "Switch (Latching)", author = "Branislav Stojkovic",
category = "Schematic Symbols", instanceNamePrefix = "SW",
@@ -55,7 +54,7 @@ public class SwitchLatchingSymbol
public static Size SIZE = new Size(0.15d, SizeUnit.in);
public static Size THROW_SPACING = new Size(0.1d, SizeUnit.in);
public static Size SPACING = new Size(0.3d, SizeUnit.in);
public static Size TERMINAL_SIZE = new Size(0.05d, SizeUnit.in);
public static Size TERMINAL_SIZE = new Size(0.04d, SizeUnit.in);
public static int ARC_ANGLE = 24;
private Orientation orientation = Orientation.DEFAULT;
@@ -77,20 +76,19 @@ public class SwitchLatchingSymbol
g2d.setStroke(ObjectCache.getInstance().fetchBasicStroke((float) (terminalSize / 4)));
drawingObserver.startTrackingContinuityArea(true);
for (int i = 0; i < controlPoints.length; i++) {
Ellipse2D.Double terminal = new Ellipse2D.Double(controlPoints[i].getX() - terminalSize / 2,
controlPoints[i].getY() - terminalSize / 2, terminalSize, terminalSize);
g2d.setColor(Constants.TRANSPARENT_COLOR);
g2d.fill(terminal);
g2d.setColor(
componentState == ComponentState.SELECTED || componentState == ComponentState.DRAGGING
? SELECTION_COLOR
: COLOR);
g2d.draw(terminal);
g2d.fill(terminal);
}
drawingObserver.stopTrackingContinuityArea();
double theta = orientation.toRadians();
@@ -276,17 +274,27 @@ public class SwitchLatchingSymbol
@Override
public String getPositionName(int position) {
return Integer.toString(position);
return Integer.toString(position + 1);
}
@Override
public boolean arePointsConnected(int index1, int index2, int position) {
// TODO Auto-generated method stub
return false;
if ("OFF".equals(configuration.getInBetween())) {
if (position % 2 == 1)
return false;
return index1 % (configuration.getThrowCount() + 1) == 0 && index2 == index1 + position / 2 + 1;
} else if ("SHORT".equals(configuration.getInBetween())) {
if (position % 2 == 1)
return index1 % (configuration.getThrowCount() + 1) == 0 && (index2 == index1 + position / 2 + 1 || index2 == index1 + position / 2 + 2);
return index1 % (configuration.getThrowCount() + 1) == 0 && index2 == index1 + position / 2 + 1;
}
return index1 % (configuration.getThrowCount() + 1) == 0 && index2 == index1 + position + 1;
}
public static enum SwitchConfiguration {
_1x1, _2x2, _2x3xOFF, _3x3, _3x5xSHORT, _4x4, _5x5, _6x6, _7x7, _8x8, _9x9, _10x10, _11x11, _12x12;
_1x2, _2x2, _2x3xOFF, _3x3, _3x5xSHORT, _4x4, _5x5, _6x6, _7x7, _8x8, _9x9, _10x10, _11x11, _12x12;
private int throwCount;
private int positionCount;
@@ -0,0 +1,55 @@
package org.diylc.netlist;
import org.diylc.components.electromechanical.SwitchLatchingSymbol;
import org.diylc.components.electromechanical.SwitchLatchingSymbol.PoleCount;
import org.junit.Test;
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);
}
}