heat sink resistor

This commit is contained in:
Bane Stojkovic
2026-11-04 10:38:27 +01:00
parent 2ae30b9630
commit 0d2475d4f6
6 changed files with 232 additions and 163 deletions
@@ -40,6 +40,8 @@ import org.diylc.components.AbstractLeadedComponent;
import org.diylc.components.transform.SimpleComponentTransformer;
import org.diylc.core.CreationMethod;
import org.diylc.core.IDIYComponent;
import org.diylc.core.IDatasheetSupport;
import org.diylc.core.annotations.AiNote;
import org.diylc.core.annotations.ComponentDescriptor;
import org.diylc.core.annotations.EditableProperty;
import org.diylc.core.annotations.PositiveMeasureValidator;
@@ -54,11 +56,14 @@ import org.diylc.core.Project;
import org.diylc.core.Theme;
import org.diylc.utils.Constants;
@AiNote("A datasheet model is an Arcol HS part such as HS25 or HS100 and sets 'Power Rating' and the whole housing - body size, lips, mounting holes, lead length and diameter - but never the resistance; set 'Value' separately")
@ComponentDescriptor(name = "Heat Sink Resistor", author = "Branislav Stojkovic", category = "Passive",
creationMethod = CreationMethod.SINGLE_CLICK, instanceNamePrefix = "R",
description = "Power resistor with heatsink; similar to Arcol HS series",
zOrder = IDIYComponent.COMPONENT, transformer = SimpleComponentTransformer.class, enableCache = true)
public class HeatSinkResistor extends AbstractLeadedComponent<Resistance> implements IGerberComponentSimple {
zOrder = IDIYComponent.COMPONENT, transformer = SimpleComponentTransformer.class, enableCache = true,
enableDatasheet = true, datasheetCreationStepCount = 2, datasheetModelColumn = 1)
public class HeatSinkResistor extends AbstractLeadedComponent<Resistance>
implements IGerberComponentSimple, IDatasheetSupport {
private static final long serialVersionUID = 1L;
@@ -107,6 +112,37 @@ public class HeatSinkResistor extends AbstractLeadedComponent<Resistance> implem
leadLength = DEFAULT_LEAD_LENGTH;
}
public HeatSinkResistor(String[] model) {
this();
applyModel(model);
}
// columns: series, part, power, body length, total width, lead length, lip width, mounting holes,
// hole spacing, hole diameter, lead diameter; the resistance is not part of a row because the
// housing depends only on the part
@Override
public void applyModel(String[] model) {
setPower(Power.parseCapacitance(model[2]));
setLength(Size.parseSize(model[3]));
setWidth(Size.parseSize(model[4]));
setLeadLength(Size.parseSize(model[5]));
setLipSize(Size.parseSize(model[6]));
setMountingHoles(parseMountingHoles(model[7]));
setHorizontalHoleSpacing(Size.parseSize(model[8]));
setMountingHoleDiameter(Size.parseSize(model[9]));
setTerminalLeadDiameter(Size.parseSize(model[10]));
}
private static MountingHoleCount parseMountingHoles(String label) {
for (MountingHoleCount value : MountingHoleCount.values()) {
if (value.toString().equalsIgnoreCase(label)) {
return value;
}
}
throw new IllegalArgumentException("Unknown mounting holes: " + label);
}
private MountingHoleCount holeCount() {
return mountingHoles == null ? MountingHoleCount.TWO_DIAGONAL : mountingHoles;
}
@@ -0,0 +1,10 @@
Arcol HS,HS10,10 W,15.9 mm,16.5 mm,7.05 mm,4.1 mm,2 diagonal,11.3 mm,2.4 mm,2.0 mm
Arcol HS,HS15,15 W,19.9 mm,21.0 mm,8.3 mm,5.1 mm,2 diagonal,14.3 mm,2.4 mm,2.0 mm
Arcol HS,HS25,25 W,27.3 mm,28.0 mm,11.85 mm,8.2 mm,2 diagonal,18.3 mm,3.2 mm,2.0 mm
Arcol HS,HS50,50 W,49.1 mm,29.7 mm,11.7 mm,8.3 mm,2 diagonal,39.7 mm,3.2 mm,2.0 mm
Arcol HS,HS75,75 W,48.7 mm,47.5 mm,11.65 mm,10.5 mm,4 holes,29.0 mm,4.4 mm,3.2 mm
Arcol HS,HS100,100 W,65.2 mm,47.5 mm,11.4 mm,10.5 mm,4 holes,35.0 mm,4.4 mm,3.2 mm
Arcol HS,HS150,150 W,97.7 mm,47.5 mm,11.65 mm,10.5 mm,6 holes,29.0 mm,4.4 mm,3.2 mm
Arcol HS,HS200,200 W,89.7 mm,72.5 mm,28.0 mm,15.3 mm,6 holes,35.0 mm,5.1 mm,6.0 mm
Arcol HS,HS250,250 W,109.7 mm,72.5 mm,28.65 mm,15.3 mm,6 holes,44.5 mm,5.1 mm,6.0 mm
Arcol HS,HS300,300 W,127.7 mm,72.5 mm,28.35 mm,13.5 mm,6 holes,52.0 mm,6.6 mm,6.0 mm
@@ -0,0 +1,87 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2025 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.components.passive;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.diylc.components.passive.HeatSinkResistor.MountingHoleCount;
import org.diylc.core.measures.Power;
import org.diylc.core.measures.PowerUnit;
import org.diylc.core.measures.Resistance;
import org.diylc.core.measures.ResistanceUnit;
import org.diylc.core.measures.Size;
import org.diylc.core.measures.SizeUnit;
import org.diylc.presenter.DatasheetService;
import org.junit.Assert;
import org.junit.Test;
public class HeatSinkResistorDatasheetTest {
@Test
public void everyRowApplies() {
List<String[]> datasheet =
DatasheetService.getInstance().loadDatasheet(HeatSinkResistor.class);
Assert.assertNotNull(datasheet);
Assert.assertFalse(datasheet.isEmpty());
Set<String> parts = new HashSet<String>();
for (String[] row : datasheet) {
Assert.assertTrue("duplicate part " + row[1], parts.add(row[1]));
HeatSinkResistor resistor = new HeatSinkResistor(row);
Assert.assertNotNull(String.join(",", row), resistor.getPower());
Assert.assertNull("a row must not set the resistance", resistor.getValue());
}
}
@Test
public void appliesAllColumns() {
List<String[]> rows =
DatasheetService.getInstance().findSeries(HeatSinkResistor.class, "HS100");
Assert.assertEquals(1, rows.size());
HeatSinkResistor resistor = new HeatSinkResistor(rows.get(0));
Assert.assertEquals(new Power(100d, PowerUnit.W), resistor.getPower());
Assert.assertEquals(new Size(65.2d, SizeUnit.mm), resistor.getLength());
Assert.assertEquals(new Size(47.5d, SizeUnit.mm), resistor.getWidth());
Assert.assertEquals(new Size(11.4d, SizeUnit.mm), resistor.getLeadLength());
Assert.assertEquals(new Size(10.5d, SizeUnit.mm), resistor.getLipSize());
Assert.assertEquals(MountingHoleCount.FOUR, resistor.getMountingHoles());
Assert.assertEquals(new Size(35d, SizeUnit.mm), resistor.getHorizontalHoleSpacing());
Assert.assertEquals(new Size(4.4d, SizeUnit.mm), resistor.getMountingHoleDiameter());
Assert.assertEquals(new Size(3.2d, SizeUnit.mm), resistor.getTerminalLeadDiameter());
}
@Test
public void modelKeepsValue() {
HeatSinkResistor resistor = new HeatSinkResistor();
resistor.setValue(new Resistance(10d, ResistanceUnit.R));
DatasheetService service = DatasheetService.getInstance();
String[] model =
service.findModel(resistor, service.findSeries(HeatSinkResistor.class, "HS50"));
Assert.assertNotNull(model);
resistor.applyModel(model);
Assert.assertEquals(new Resistance(10d, ResistanceUnit.R), resistor.getValue());
Assert.assertEquals(new Power(50d, PowerUnit.W), resistor.getPower());
}
}