Merge pull request #1540 from SiboVG/railbutton-database

Incorporate rail button database items
This commit is contained in:
Joe Pfeiffer 2022-07-31 15:10:13 -06:00 committed by GitHub
commit c0ba04edac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 337 additions and 63 deletions

View File

@ -2119,19 +2119,23 @@ table.column.AftShoulderDiameter = Aft Shoulder Diameter
table.column.ForeShoulderLength = Fore Shoulder Length table.column.ForeShoulderLength = Fore Shoulder Length
table.column.ForeShoulderDiameter = Fore Shoulder Diameter table.column.ForeShoulderDiameter = Fore Shoulder Diameter
table.column.ForeOuterDiameter = Fore Outer Diameter table.column.ForeOuterDiameter = Fore Outer Diameter
table.column.StandoffHeight = Standoff Height table.column.BaseHeight = Base Height
table.column.FlangeHeight = Flange Height table.column.FlangeHeight = Flange Height
table.column.ScrewHeight = Screw Height
table.column.Shape = Shape table.column.Shape = Shape
table.column.Material = Material table.column.Material = Material
table.column.Finish = Finish table.column.Finish = Finish
table.column.Thickness = Thickness table.column.Thickness = Thickness
table.column.Filled = Filled table.column.Filled = Filled
table.column.Mass = Mass table.column.Mass = Mass
table.column.ScrewMass = Screw Mass
table.column.NutMass = Nut Mass
table.column.Diameter = Diameter table.column.Diameter = Diameter
table.column.Sides = Sides table.column.Sides = Sides
table.column.LineCount = Line Count table.column.LineCount = Line Count
table.column.LineLength = Line Length table.column.LineLength = Line Length
table.column.LineMaterial = Line Material table.column.LineMaterial = Line Material
table.column.CD = Drag Coefficient
! Edit Decal Dialog ! Edit Decal Dialog
EditDecalDialog.title = Edit decal EditDecalDialog.title = Edit decal

View File

@ -2003,7 +2003,7 @@ table.column.AftShoulderDiameter = Achteste Schouderdiameter
table.column.ForeShoulderLength = Voorste Schouderlengte table.column.ForeShoulderLength = Voorste Schouderlengte
table.column.ForeShoulderDiameter = Voorste Schouderdiameter table.column.ForeShoulderDiameter = Voorste Schouderdiameter
table.column.ForeOuterDiameter = Voorste Buitendiameter table.column.ForeOuterDiameter = Voorste Buitendiameter
table.column.StandoffHeight = Standoff Hoogte table.column.BaseHeight = Standoff Hoogte
table.column.FlangeHeight = Flens Hoogte table.column.FlangeHeight = Flens Hoogte
table.column.Shape = Vorm table.column.Shape = Vorm
table.column.Material = Materiaal table.column.Material = Materiaal

View File

@ -2120,7 +2120,7 @@ table.column.AftShoulderDiameter = \u0414\u0438\u0430\u043C\u0435\u0442\u0440 \u
table.column.ForeShoulderLength = \u0414\u043B\u0438\u043D\u0430 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B table.column.ForeShoulderLength = \u0414\u043B\u0438\u043D\u0430 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B
table.column.ForeShoulderDiameter = \u0414\u0438\u0430\u043C\u0435\u0442\u0440 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B table.column.ForeShoulderDiameter = \u0414\u0438\u0430\u043C\u0435\u0442\u0440 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B
table.column.ForeOuterDiameter = \u0412\u043D\u0435\u0448\u043D\u0438\u0439 \u0434\u0438\u0430\u043C\u0435\u0442\u0440 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B table.column.ForeOuterDiameter = \u0412\u043D\u0435\u0448\u043D\u0438\u0439 \u0434\u0438\u0430\u043C\u0435\u0442\u0440 \u043F\u0435\u0440\u0435\u0434\u043D\u0435\u0439 \u043C\u0443\u0444\u0442\u044B
table.column.StandoffHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0437\u0430\u0437\u043E\u0440\u0430 table.column.BaseHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0437\u0430\u0437\u043E\u0440\u0430
table.column.FlangeHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0444\u043B\u0430\u043D\u0446\u0430 table.column.FlangeHeight = \u0412\u044B\u0441\u043E\u0442\u0430 \u0444\u043B\u0430\u043D\u0446\u0430
table.column.Shape = \u0424\u043E\u0440\u043C\u0430 table.column.Shape = \u0424\u043E\u0440\u043C\u0430
table.column.Material = \u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B table.column.Material = \u041C\u0430\u0442\u0435\u0440\u0438\u0430\u043B

View File

@ -129,12 +129,16 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
ComponentPreset.MANUFACTURER, ComponentPreset.MANUFACTURER,
ComponentPreset.PARTNO, ComponentPreset.PARTNO,
ComponentPreset.DESCRIPTION, ComponentPreset.DESCRIPTION,
// these are optional / secondary parameters. Probably not necessary to include. ComponentPreset.BASE_HEIGHT,
//ComponentPreset.BASE_HEIGHT, ComponentPreset.FLANGE_HEIGHT,
//ComponentPreset.FLANGE_HEIGHT, //ComponentPreset.SCREW_HEIGHT, // Add this later when we implement screws in the rail button
//ComponentPreset.INNER_DIAMETER, ComponentPreset.HEIGHT,
ComponentPreset.INNER_DIAMETER,
ComponentPreset.OUTER_DIAMETER, ComponentPreset.OUTER_DIAMETER,
ComponentPreset.HEIGHT }), ComponentPreset.MASS,
ComponentPreset.SCREW_MASS,
ComponentPreset.NUT_MASS,
ComponentPreset.CD }),
STREAMER(new TypedKey<?>[] { STREAMER(new TypedKey<?>[] {
ComponentPreset.LEGACY, ComponentPreset.LEGACY,
@ -160,7 +164,7 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
ComponentPreset.LINE_COUNT, ComponentPreset.LINE_COUNT,
ComponentPreset.LINE_LENGTH, ComponentPreset.LINE_LENGTH,
ComponentPreset.LINE_MATERIAL, ComponentPreset.LINE_MATERIAL,
ComponentPreset.PARACHUTE_CD, ComponentPreset.CD,
ComponentPreset.PACKED_DIAMETER, ComponentPreset.PACKED_DIAMETER,
ComponentPreset.PACKED_LENGTH }); ComponentPreset.PACKED_LENGTH });
@ -206,6 +210,7 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
public final static TypedKey<Double> AFT_SHOULDER_LENGTH = new TypedKey<Double>("AftShoulderLength", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> AFT_SHOULDER_LENGTH = new TypedKey<Double>("AftShoulderLength", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> AFT_SHOULDER_DIAMETER = new TypedKey<Double>("AftShoulderDiameter", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> AFT_SHOULDER_DIAMETER = new TypedKey<Double>("AftShoulderDiameter", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> AFT_OUTER_DIAMETER = new TypedKey<Double>("AftOuterDiameter", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> AFT_OUTER_DIAMETER = new TypedKey<Double>("AftOuterDiameter", Double.class, UnitGroup.UNITS_LENGTH);
public static final TypedKey<Double> CD = new TypedKey<Double>("DragCoefficient", Double.class, UnitGroup.UNITS_COEFFICIENT);
public final static TypedKey<Shape> SHAPE = new TypedKey<Shape>("Shape", Shape.class); public final static TypedKey<Shape> SHAPE = new TypedKey<Shape>("Shape", Shape.class);
public final static TypedKey<Material> MATERIAL = new TypedKey<Material>("Material", Material.class); public final static TypedKey<Material> MATERIAL = new TypedKey<Material>("Material", Material.class);
public final static TypedKey<Finish> FINISH = new TypedKey<Finish>("Finish", Finish.class); public final static TypedKey<Finish> FINISH = new TypedKey<Finish>("Finish", Finish.class);
@ -214,8 +219,13 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
public final static TypedKey<Double> MASS = new TypedKey<Double>("Mass", Double.class, UnitGroup.UNITS_MASS); public final static TypedKey<Double> MASS = new TypedKey<Double>("Mass", Double.class, UnitGroup.UNITS_MASS);
public final static TypedKey<Double> DIAMETER = new TypedKey<Double>("Diameter", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> DIAMETER = new TypedKey<Double>("Diameter", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<byte[]> IMAGE = new TypedKey<byte[]>("Image", byte[].class); public final static TypedKey<byte[]> IMAGE = new TypedKey<byte[]>("Image", byte[].class);
public final static TypedKey<Double> STANDOFF_HEIGHT = new TypedKey<Double>("StandoffHeight", Double.class, UnitGroup.UNITS_LENGTH);
// RAIL BUTTON SPECIFIC
public final static TypedKey<Double> BASE_HEIGHT = new TypedKey<Double>("BaseHeight", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> FLANGE_HEIGHT = new TypedKey<Double>("FlangeHeight", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> FLANGE_HEIGHT = new TypedKey<Double>("FlangeHeight", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> SCREW_HEIGHT = new TypedKey<Double>("ScrewHeight", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> SCREW_MASS = new TypedKey<Double>("ScrewMass", Double.class, UnitGroup.UNITS_MASS);
public final static TypedKey<Double> NUT_MASS = new TypedKey<Double>("NutMass", Double.class, UnitGroup.UNITS_MASS);
// PARACHUTE SPECIFIC // PARACHUTE SPECIFIC
// Parachute Manufacturer declaration see: MANUFACTURER // Parachute Manufacturer declaration see: MANUFACTURER
@ -225,7 +235,7 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
// Parachute diameter declaration see: DIAMETER // Parachute diameter declaration see: DIAMETER
public final static TypedKey<Double> SPILL_DIA = new TypedKey<Double>("SpillDia", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> SPILL_DIA = new TypedKey<Double>("SpillDia", Double.class, UnitGroup.UNITS_LENGTH);
public final static TypedKey<Double> SURFACE_AREA = new TypedKey<Double>("SurfaceArea", Double.class, UnitGroup.UNITS_LENGTH); public final static TypedKey<Double> SURFACE_AREA = new TypedKey<Double>("SurfaceArea", Double.class, UnitGroup.UNITS_LENGTH);
public static final TypedKey<Double> PARACHUTE_CD = new TypedKey<Double>("DragCoefficient", Double.class, UnitGroup.UNITS_COEFFICIENT);
// Parachute canopy material declaration see: MATERIAL // Parachute canopy material declaration see: MATERIAL
public final static TypedKey<Integer> SIDES = new TypedKey<Integer>("Sides", Integer.class); public final static TypedKey<Integer> SIDES = new TypedKey<Integer>("Sides", Integer.class);
public final static TypedKey<Integer> LINE_COUNT = new TypedKey<Integer>("LineCount", Integer.class); public final static TypedKey<Integer> LINE_COUNT = new TypedKey<Integer>("LineCount", Integer.class);
@ -251,8 +261,9 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
AFT_SHOULDER_LENGTH, AFT_SHOULDER_LENGTH,
FORE_SHOULDER_DIAMETER, FORE_SHOULDER_DIAMETER,
FORE_SHOULDER_LENGTH, FORE_SHOULDER_LENGTH,
STANDOFF_HEIGHT, BASE_HEIGHT,
FLANGE_HEIGHT, FLANGE_HEIGHT,
SCREW_HEIGHT,
SHAPE, SHAPE,
THICKNESS, THICKNESS,
FILLED, FILLED,
@ -262,6 +273,8 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
LINE_LENGTH, LINE_LENGTH,
LINE_MATERIAL, LINE_MATERIAL,
MASS, MASS,
SCREW_MASS,
NUT_MASS,
FINISH, FINISH,
MATERIAL MATERIAL
)); ));
@ -411,6 +424,9 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
os.writeDouble(d); os.writeDouble(d);
} else if (key.getType() == String.class) { } else if (key.getType() == String.class) {
String s = (String) value; String s = (String) value;
if (s == null) {
s = "";
}
os.writeBytes(s); os.writeBytes(s);
} else if (key.getType() == Manufacturer.class) { } else if (key.getType() == Manufacturer.class) {
String s = ((Manufacturer) value).getSimpleName(); String s = ((Manufacturer) value).getSimpleName();

View File

@ -113,13 +113,13 @@ public abstract class ComponentPresetFactory {
} }
private static void makeRailButton(InvalidComponentPresetException exceptions, ComponentPreset preset) throws InvalidComponentPresetException { private static void makeRailButton(InvalidComponentPresetException exceptions, ComponentPreset preset) {
checkRequiredFields(exceptions, preset, HEIGHT); checkRequiredFields(exceptions, preset, HEIGHT);
checkRequiredFields(exceptions, preset, OUTER_DIAMETER); checkRequiredFields(exceptions, preset, OUTER_DIAMETER);
checkRequiredFields(exceptions, preset, INNER_DIAMETER); checkRequiredFields(exceptions, preset, INNER_DIAMETER);
checkRequiredFields(exceptions, preset, FLANGE_HEIGHT); checkRequiredFields(exceptions, preset, FLANGE_HEIGHT);
checkRequiredFields(exceptions, preset, STANDOFF_HEIGHT); checkRequiredFields(exceptions, preset, BASE_HEIGHT);
if (preset.has(MASS)) { if (preset.has(MASS)) {
double mass = preset.get(MASS); double mass = preset.get(MASS);
@ -271,7 +271,6 @@ public abstract class ComponentPresetFactory {
if (hasOd) { if (hasOd) {
outerRadius = preset.get(OUTER_DIAMETER) / 2.0; outerRadius = preset.get(OUTER_DIAMETER) / 2.0;
thickness = 0;
if (hasId) { if (hasId) {
innerRadius = preset.get(INNER_DIAMETER) / 2.0; innerRadius = preset.get(INNER_DIAMETER) / 2.0;
thickness = outerRadius - innerRadius; thickness = outerRadius - innerRadius;

View File

@ -13,7 +13,7 @@ public class RailButtonLoader extends BaseComponentLoader {
fileColumns.add(new DoubleUnitColumnParser("OD","Units",ComponentPreset.OUTER_DIAMETER)); fileColumns.add(new DoubleUnitColumnParser("OD","Units",ComponentPreset.OUTER_DIAMETER));
fileColumns.add(new DoubleUnitColumnParser("Height","Units",ComponentPreset.HEIGHT)); fileColumns.add(new DoubleUnitColumnParser("Height","Units",ComponentPreset.HEIGHT));
fileColumns.add(new DoubleUnitColumnParser("Flange Height", "Units", ComponentPreset.FLANGE_HEIGHT)); fileColumns.add(new DoubleUnitColumnParser("Flange Height", "Units", ComponentPreset.FLANGE_HEIGHT));
fileColumns.add(new DoubleUnitColumnParser("Standoff Height", "Units", ComponentPreset.STANDOFF_HEIGHT)); fileColumns.add(new DoubleUnitColumnParser("Standoff Height", "Units", ComponentPreset.BASE_HEIGHT));
} }

View File

@ -34,9 +34,7 @@ public class OpenRocketComponentLoader implements Loader<ComponentPreset> {
presets = (new OpenRocketComponentSaver().unmarshalFromOpenRocketComponent( new InputStreamReader (stream))).asComponentPresets(); presets = (new OpenRocketComponentSaver().unmarshalFromOpenRocketComponent( new InputStreamReader (stream))).asComponentPresets();
log.debug("ComponentPreset file " + filename + " contained " + presets.size() + " presets"); log.debug("ComponentPreset file " + filename + " contained " + presets.size() + " presets");
return presets; return presets;
} catch (JAXBException e) { } catch (JAXBException | InvalidComponentPresetException e) {
throw new BugException("Unable to parse file: "+ filename, e);
} catch (InvalidComponentPresetException e) {
throw new BugException("Unable to parse file: "+ filename, e); throw new BugException("Unable to parse file: "+ filename, e);
} }

View File

@ -146,8 +146,8 @@ public class ParachuteDTO extends BaseComponentDTO {
if ( preset.has(ComponentPreset.PACKED_LENGTH)) { if ( preset.has(ComponentPreset.PACKED_LENGTH)) {
setPackedLength(preset.get(ComponentPreset.PACKED_LENGTH)); setPackedLength(preset.get(ComponentPreset.PACKED_LENGTH));
} }
if ( preset.has(ComponentPreset.PARACHUTE_CD)) { if ( preset.has(ComponentPreset.CD)) {
setDragCoefficient(preset.get(ComponentPreset.PARACHUTE_CD)); setDragCoefficient(preset.get(ComponentPreset.CD));
} }
if ( preset.has(ComponentPreset.LINE_MATERIAL)) { if ( preset.has(ComponentPreset.LINE_MATERIAL)) {
setLineMaterial(new AnnotatedMaterialDTO(preset.get(ComponentPreset.LINE_MATERIAL))); setLineMaterial(new AnnotatedMaterialDTO(preset.get(ComponentPreset.LINE_MATERIAL)));
@ -174,7 +174,7 @@ public class ParachuteDTO extends BaseComponentDTO {
props.put(ComponentPreset.PACKED_LENGTH, this.getPackedLength()); props.put(ComponentPreset.PACKED_LENGTH, this.getPackedLength());
} }
if ( this.dragCoefficient != null ) { if ( this.dragCoefficient != null ) {
props.put(ComponentPreset.PARACHUTE_CD, this.getDragCoefficient()); props.put(ComponentPreset.CD, this.getDragCoefficient());
} }
props.put(ComponentPreset.LINE_COUNT, this.getLineCount()); props.put(ComponentPreset.LINE_COUNT, this.getLineCount());
if ( this.lineLength != null ) { if ( this.lineLength != null ) {

View File

@ -19,16 +19,22 @@ import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
public class RailButtonDTO extends BaseComponentDTO { public class RailButtonDTO extends BaseComponentDTO {
@XmlElement(name = "InsideDiameter") @XmlElement(name = "InnerDiameter")
private AnnotatedLengthDTO insideDiameter; private AnnotatedLengthDTO innerDiameter;
@XmlElement(name = "OutsideDiameter") @XmlElement(name = "OuterDiameter")
private AnnotatedLengthDTO outsideDiameter; private AnnotatedLengthDTO outerDiameter;
@XmlElement(name = "Height") @XmlElement(name = "Height")
private AnnotatedLengthDTO height; private AnnotatedLengthDTO height;
@XmlElement(name = "StandoffHeight") @XmlElement(name = "BaseHeight")
private AnnotatedLengthDTO standoffHeight; private AnnotatedLengthDTO baseHeight;
@XmlElement(name = "FlangeHeight") @XmlElement(name = "FlangeHeight")
private AnnotatedLengthDTO flangeHeight; private AnnotatedLengthDTO flangeHeight;
@XmlElement(name = "ScrewHeight")
private AnnotatedLengthDTO screwHeight;
@XmlElement(name = "ScrewMass")
private AnnotatedMassDTO screwMass;
@XmlElement(name = "NutMass")
private AnnotatedMassDTO nutMass;
/** /**
* Default constructor. * Default constructor.
@ -48,32 +54,35 @@ public class RailButtonDTO extends BaseComponentDTO {
setInsideDiameter(preset.get(ComponentPreset.INNER_DIAMETER)); setInsideDiameter(preset.get(ComponentPreset.INNER_DIAMETER));
setOutsideDiameter(preset.get(ComponentPreset.OUTER_DIAMETER)); setOutsideDiameter(preset.get(ComponentPreset.OUTER_DIAMETER));
setHeight(preset.get(ComponentPreset.HEIGHT)); setHeight(preset.get(ComponentPreset.HEIGHT));
setStandoffHeight(preset.get(ComponentPreset.STANDOFF_HEIGHT)); setBaseHeight(preset.get(ComponentPreset.BASE_HEIGHT));
setFlangeHeight(preset.get(ComponentPreset.FLANGE_HEIGHT)); setFlangeHeight(preset.get(ComponentPreset.FLANGE_HEIGHT));
setScrewHeight(preset.get(ComponentPreset.SCREW_HEIGHT));
setScrewMass(preset.get(ComponentPreset.SCREW_MASS));
setNutMass(preset.get(ComponentPreset.NUT_MASS));
} }
public double getInsideDiameter() { public double getInnerDiameter() {
return insideDiameter.getValue(); return innerDiameter.getValue();
} }
public void setInsideDiameter( final AnnotatedLengthDTO theLength ) { public void setInnerDiameter(final AnnotatedLengthDTO theLength ) {
insideDiameter = theLength; innerDiameter = theLength;
} }
public void setInsideDiameter(final double theId) { public void setInsideDiameter(final double theId) {
insideDiameter = new AnnotatedLengthDTO(theId); innerDiameter = new AnnotatedLengthDTO(theId);
} }
public double getOutsideDiameter() { public double getOuterDiameter() {
return outsideDiameter.getValue(); return outerDiameter.getValue();
} }
public void setOutsideDiameter(final AnnotatedLengthDTO theOd) { public void setOuterDiameter(final AnnotatedLengthDTO theOd) {
outsideDiameter = theOd; outerDiameter = theOd;
} }
public void setOutsideDiameter(final double theOd) { public void setOutsideDiameter(final double theOd) {
outsideDiameter = new AnnotatedLengthDTO(theOd); outerDiameter = new AnnotatedLengthDTO(theOd);
} }
public double getHeight() { public double getHeight() {
@ -88,16 +97,12 @@ public class RailButtonDTO extends BaseComponentDTO {
height = new AnnotatedLengthDTO(theHeight); height = new AnnotatedLengthDTO(theHeight);
} }
public double getStandoffHeight() { public double getBaseHeight() {
return standoffHeight.getValue(); return baseHeight.getValue();
} }
public void setStandoffHeight(final AnnotatedLengthDTO theStandoffHeight) { public void setBaseHeight(final double theBaseHeight) {
standoffHeight = theStandoffHeight; baseHeight = new AnnotatedLengthDTO(theBaseHeight);
}
public void setStandoffHeight(final double theStandoffHeight) {
standoffHeight = new AnnotatedLengthDTO(theStandoffHeight);
} }
public double getFlangeHeight() { public double getFlangeHeight() {
@ -112,6 +117,30 @@ public class RailButtonDTO extends BaseComponentDTO {
flangeHeight = new AnnotatedLengthDTO(theFlangeHeight); flangeHeight = new AnnotatedLengthDTO(theFlangeHeight);
} }
public double getScrewHeight() {
return screwHeight.getValue();
}
public void setScrewHeight(final double screwHeight) {
this.screwHeight = new AnnotatedLengthDTO(screwHeight);
}
public double getScrewMass() {
return screwMass.getValue();
}
public void setScrewMass(double screwMass) {
this.screwMass = new AnnotatedMassDTO(screwMass);
}
public double getNutMass() {
return nutMass.getValue();
}
public void setNutMass(double nutMass) {
this.nutMass = new AnnotatedMassDTO(nutMass);
}
@Override @Override
public ComponentPreset asComponentPreset(Boolean legacy, java.util.List<MaterialDTO> materials) throws InvalidComponentPresetException { public ComponentPreset asComponentPreset(Boolean legacy, java.util.List<MaterialDTO> materials) throws InvalidComponentPresetException {
return asComponentPreset(legacy, ComponentPreset.Type.RAIL_BUTTON, materials); return asComponentPreset(legacy, ComponentPreset.Type.RAIL_BUTTON, materials);
@ -121,11 +150,14 @@ public class RailButtonDTO extends BaseComponentDTO {
TypedPropertyMap props = new TypedPropertyMap(); TypedPropertyMap props = new TypedPropertyMap();
props.put(ComponentPreset.LEGACY, legacy); props.put(ComponentPreset.LEGACY, legacy);
addProps(props, materials); addProps(props, materials);
props.put(ComponentPreset.INNER_DIAMETER, this.getInsideDiameter()); props.put(ComponentPreset.INNER_DIAMETER, this.getInnerDiameter());
props.put(ComponentPreset.OUTER_DIAMETER, this.getOutsideDiameter()); props.put(ComponentPreset.OUTER_DIAMETER, this.getOuterDiameter());
props.put(ComponentPreset.HEIGHT, this.getHeight()); props.put(ComponentPreset.HEIGHT, this.getHeight());
props.put(ComponentPreset.STANDOFF_HEIGHT, this.getStandoffHeight()); props.put(ComponentPreset.BASE_HEIGHT, this.getBaseHeight());
props.put(ComponentPreset.FLANGE_HEIGHT, this.getFlangeHeight()); props.put(ComponentPreset.FLANGE_HEIGHT, this.getFlangeHeight());
props.put(ComponentPreset.SCREW_HEIGHT, this.getScrewHeight());
props.put(ComponentPreset.SCREW_MASS, this.getScrewMass());
props.put(ComponentPreset.NUT_MASS, this.getNutMass());
props.put(ComponentPreset.TYPE, type); props.put(ComponentPreset.TYPE, type);
return ComponentPresetFactory.create(props); return ComponentPresetFactory.create(props);

View File

@ -144,7 +144,9 @@ public abstract class ExternalComponent extends RocketComponent {
protected void loadFromPreset(ComponentPreset preset) { protected void loadFromPreset(ComponentPreset preset) {
super.loadFromPreset(preset); super.loadFromPreset(preset);
// Surface finish is left unchanged if (preset.has(ComponentPreset.FINISH)) {
setFinish(preset.get(ComponentPreset.FINISH));
}
if (preset.has(ComponentPreset.MATERIAL)) { if (preset.has(ComponentPreset.MATERIAL)) {
Material mat = preset.get(ComponentPreset.MATERIAL); Material mat = preset.get(ComponentPreset.MATERIAL);

View File

@ -178,9 +178,9 @@ public class Parachute extends RecoveryDevice {
this.diameter = DEFAULT_DIAMETER; this.diameter = DEFAULT_DIAMETER;
} }
// // Set preset parachute drag coefficient // // Set preset parachute drag coefficient
if ((preset.has(ComponentPreset.PARACHUTE_CD)) && preset.get(ComponentPreset.PARACHUTE_CD) > 0){ if ((preset.has(ComponentPreset.CD)) && preset.get(ComponentPreset.CD) > 0){
cdAutomatic = false; cdAutomatic = false;
cd = preset.get(ComponentPreset.PARACHUTE_CD); cd = preset.get(ComponentPreset.CD);
} else { } else {
cdAutomatic = true; cdAutomatic = true;
cd = Parachute.DEFAULT_CD; cd = Parachute.DEFAULT_CD;

View File

@ -51,6 +51,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
protected double totalHeight_m; protected double totalHeight_m;
protected double flangeHeight_m; protected double flangeHeight_m;
protected double baseHeight_m; protected double baseHeight_m;
protected double screwHeight_m; // This has no effect at the moment; is for future use.
private double radialDistance_m=0; private double radialDistance_m=0;
@ -120,7 +121,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
return rb1010; return rb1010;
} }
public double getBaseHeight(){ public double getBaseHeight(){
return this.baseHeight_m; return this.baseHeight_m;
} }
@ -144,7 +145,11 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
public double getFlangeHeight() { public double getFlangeHeight() {
return this.flangeHeight_m; return this.flangeHeight_m;
} }
public double getScrewHeight() {
return this.screwHeight_m;
}
public void setBaseHeight(double newBaseHeight){ public void setBaseHeight(double newBaseHeight){
for (RocketComponent listener : configListeners) { for (RocketComponent listener : configListeners) {
@ -155,6 +160,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
this.baseHeight_m = Math.max(newBaseHeight, 0); this.baseHeight_m = Math.max(newBaseHeight, 0);
this.baseHeight_m = Math.min(this.baseHeight_m, this.totalHeight_m - this.flangeHeight_m); this.baseHeight_m = Math.min(this.baseHeight_m, this.totalHeight_m - this.flangeHeight_m);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -167,6 +173,19 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
this.flangeHeight_m = Math.max(newFlangeHeight, 0); this.flangeHeight_m = Math.max(newFlangeHeight, 0);
this.flangeHeight_m = Math.min(this.flangeHeight_m, this.totalHeight_m - this.baseHeight_m); this.flangeHeight_m = Math.min(this.flangeHeight_m, this.totalHeight_m - this.baseHeight_m);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
public void setScrewHeight(double height) {
for (RocketComponent listener : configListeners) {
if (listener instanceof RailButton) {
((RailButton) listener).setScrewHeight(height);
}
}
this.screwHeight_m = Math.max(height, 0);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -178,6 +197,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
} }
this.innerDiameter_m = Math.min(newID, this.outerDiameter_m); this.innerDiameter_m = Math.min(newID, this.outerDiameter_m);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -192,6 +212,7 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
this.outerDiameter_m = newOD; this.outerDiameter_m = newOD;
setInnerDiameter(this.innerDiameter_m); setInnerDiameter(this.innerDiameter_m);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@ -204,9 +225,10 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
this.totalHeight_m = Math.max(newHeight, this.flangeHeight_m + this.baseHeight_m); this.totalHeight_m = Math.max(newHeight, this.flangeHeight_m + this.baseHeight_m);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
@Override @Override
public boolean isAerodynamic(){ public boolean isAerodynamic(){
// TODO: implement aerodynamics // TODO: implement aerodynamics
@ -418,4 +440,48 @@ public class RailButton extends ExternalComponent implements AnglePositionable,
return false; return false;
} }
@Override
protected void loadFromPreset(ComponentPreset preset) {
super.loadFromPreset(preset);
if (preset.has(ComponentPreset.OUTER_DIAMETER)) {
this.outerDiameter_m = preset.get(ComponentPreset.OUTER_DIAMETER);
}
if (preset.has(ComponentPreset.INNER_DIAMETER)) {
this.innerDiameter_m = preset.get(ComponentPreset.INNER_DIAMETER);
}
if (preset.has(ComponentPreset.HEIGHT)) {
this.totalHeight_m = preset.get(ComponentPreset.HEIGHT);
}
if (preset.has(ComponentPreset.FLANGE_HEIGHT)) {
this.flangeHeight_m = preset.get(ComponentPreset.FLANGE_HEIGHT);
}
if (preset.has(ComponentPreset.BASE_HEIGHT)) {
this.baseHeight_m = preset.get(ComponentPreset.BASE_HEIGHT);
}
if (preset.has(ComponentPreset.CD) && preset.get(ComponentPreset.CD) > 0) {
setCDOverridden(true);
setOverrideCD(preset.get(ComponentPreset.CD));
}
double totalMass = 0;
boolean massOverridden = false;
if (preset.has(ComponentPreset.MASS)) {
massOverridden = true;
totalMass += preset.get(ComponentPreset.MASS);
}
if (preset.has(ComponentPreset.SCREW_MASS)) {
massOverridden = true;
totalMass += preset.get(ComponentPreset.SCREW_MASS);
}
if (preset.has(ComponentPreset.NUT_MASS)) {
massOverridden = true;
totalMass += preset.get(ComponentPreset.NUT_MASS);
}
if (massOverridden) {
setMassOverridden(true);
setOverrideMass(totalMass);
}
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
} }

View File

@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OpenRocketComponent>
<Version>0.1</Version>
<Materials>
<Material UnitsOfMeasure="kg/m">
<Name>Delrin</Name>
<Density>1420</Density>
<Type>BULK</Type>
</Material>
<Material UnitsOfMeasure="kg/m">
<Name>Nylon</Name>
<Density>1150</Density>
<Type>BULK</Type>
</Material>
</Materials>
<Components>
<RailButton>
<Manufacturer>Binder Design-Rail Button Supply House</Manufacturer>
<PartNumber>Std 1010 RB</PartNumber>
<Description>Standard 1010 Rail Button, Countersunk 8-32 Screw, and T-Nut</Description>
<Material Type="BULK">Delrin</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">0.4375</OuterDiameter>
<InnerDiameter Unit="in">0.2285</InnerDiameter>
<Height Unit="in">0.2975</Height>
<BaseHeight Unit="in">0.0730</BaseHeight>
<FlangeHeight Unit="in">0.0730</FlangeHeight>
<ScrewHeight Unit="in">0.0000</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">0.445</Mass>
<ScrewMass Unit="g">1.395</ScrewMass>
<NutMass Unit="g">1.025</NutMass>
</RailButton>
<RailButton>
<Manufacturer>Binder Design-Rail Button Supply House</Manufacturer>
<PartNumber>Std 1515 RB</PartNumber>
<Description>Standard 1515 Rail Button, Countersunk 10-32 Screw, and T-Nut</Description>
<Material Type="BULK">Delrin</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">0.6200</OuterDiameter>
<InnerDiameter Unit="in">0.2995</InnerDiameter>
<Height Unit="in">.4495</Height>
<BaseHeight Unit="in">0.125</BaseHeight>
<FlangeHeight Unit="in">0.125</FlangeHeight>
<ScrewHeight Unit="in">0.0000</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">1.465</Mass>
<ScrewMass Unit="g">3.365</ScrewMass>
<NutMass Unit="g">2.675</NutMass>
</RailButton>
<RailButton>
<Manufacturer>Rail-Buttons.com</Manufacturer>
<PartNumber>RB-Micro</PartNumber>
<Description>2 Piece Micro Rail Button with 2-56 Screw (10mm Rail)</Description>
<Material Type="BULK">Nylon</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">.1650</OuterDiameter>
<InnerDiameter Unit="in">.1195</InnerDiameter>
<Height Unit="in">0.1595</Height>
<BaseHeight Unit="in">0.041</BaseHeight>
<FlangeHeight Unit="in">0.0000</FlangeHeight>
<ScrewHeight Unit="in">0.0465</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">0.01</Mass>
<ScrewMass Unit="g">0.04</ScrewMass>
<NutMass Unit="g"></NutMass>
</RailButton>
<RailButton>
<Manufacturer>Rail-Buttons.com</Manufacturer>
<PartNumber>1PMB</PartNumber>
<Description>1 Piece Mini Rail Button with Countersunk 6-32 Screw</Description>
<Material Type="BULK">Delrin</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">.249</OuterDiameter>
<InnerDiameter Unit="in">.193</InnerDiameter>
<Height Unit="in">0.205</Height>
<BaseHeight Unit="in">0.0380</BaseHeight>
<FlangeHeight Unit="in">0.0380</FlangeHeight>
<ScrewHeight Unit="in">0.0000</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">0.090</Mass>
<ScrewMass Unit="g">0.415</ScrewMass>
<NutMass Unit="g"></NutMass>
</RailButton>
<RailButton>
<Manufacturer>Rail-Buttons.com</Manufacturer>
<PartNumber>RB-10-D</PartNumber>
<Description>3 Piece 1010 Rail Button with 8-32 Screw</Description>
<Material Type="BULK">Delrin</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">.278</OuterDiameter>
<InnerDiameter Unit="in">.154</InnerDiameter>
<Height Unit="in">0.270</Height>
<BaseHeight Unit="in">0.060</BaseHeight>
<FlangeHeight Unit="in">0.060</FlangeHeight>
<ScrewHeight Unit="in">0.115</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">0.305</Mass>
<ScrewMass Unit="g">1.715</ScrewMass>
<NutMass Unit="g"></NutMass>
</RailButton>
<RailButton>
<Manufacturer>Rail-Buttons.com</Manufacturer>
<PartNumber>1P1010DLX</PartNumber>
<Description>1 Piece 1010 Rail Button with Countersunk 8-32 Screw</Description>
<Material Type="BULK">Delrin</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">.3725</OuterDiameter>
<InnerDiameter Unit="in">.2480</InnerDiameter>
<Height Unit="in">0.305</Height>
<BaseHeight Unit="in">0.078</BaseHeight>
<FlangeHeight Unit="in">0.078</FlangeHeight>
<ScrewHeight Unit="in">0.0000</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">0.320</Mass>
<ScrewMass Unit="g">1.235</ScrewMass>
<NutMass Unit="g"></NutMass>
</RailButton>
<RailButton>
<Manufacturer>Rail-Buttons.com</Manufacturer>
<PartNumber>RB1515S</PartNumber>
<Description>1 Piece 1515 Rail Button, Countersunk 10-32 Screw, and T-Nut</Description>
<Material Type="BULK">Delrin</Material>
<Finish>Polished</Finish>
<OuterDiameter Unit="in">0.49</OuterDiameter>
<InnerDiameter Unit="in">0.29</InnerDiameter>
<Height Unit="in">0.56</Height>
<BaseHeight Unit="in">0.1875</BaseHeight>
<FlangeHeight Unit="in">0.1875</FlangeHeight>
<ScrewHeight Unit="in">0.0000</ScrewHeight>
<DragCoefficient></DragCoefficient>
<Mass Unit="g">1.355</Mass>
<ScrewMass Unit="g">2.720</ScrewMass>
<NutMass Unit="g"></NutMass>
</RailButton>
</Components>
</OpenRocketComponent>

View File

@ -401,7 +401,11 @@ public class RocketComponentConfig extends JPanel {
separationSpinner.setEditor(new SpinnerEditor(separationSpinner)); separationSpinner.setEditor(new SpinnerEditor(separationSpinner));
panel.add(separationSpinner, "growx"); panel.add(separationSpinner, "growx");
panel.add(new UnitSelector(separationModel), "growx"); panel.add(new UnitSelector(separationModel), "growx");
panel.add(new BasicSlider(separationModel.getSliderModel(0, 0.001, 0.02)), "w 100lp, wrap para"); double maxSeparationDistance = 0.1;
if (component.getParent() != null && component.getParent().getLength() > 0) {
maxSeparationDistance = component.getParent().getLength();
}
panel.add(new BasicSlider(separationModel.getSliderModel(0, 0.001, maxSeparationDistance)), "w 100lp, wrap para");
} }
return panel; return panel;
} }

View File

@ -1582,8 +1582,8 @@ public class PresetEditorDialog extends JDialog implements ItemListener {
rbHeight.setValue(preset.get(ComponentPreset.HEIGHT)); rbHeight.setValue(preset.get(ComponentPreset.HEIGHT));
rbHeight.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit()); rbHeight.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit());
} }
if (preset.has(ComponentPreset.STANDOFF_HEIGHT)) { if (preset.has(ComponentPreset.BASE_HEIGHT)) {
rbStandoffHeight.setValue(preset.get(ComponentPreset.STANDOFF_HEIGHT)); rbStandoffHeight.setValue(preset.get(ComponentPreset.BASE_HEIGHT));
rbStandoffHeight.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit()); rbStandoffHeight.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit());
} }
if (preset.has(ComponentPreset.FLANGE_HEIGHT)) { if (preset.has(ComponentPreset.FLANGE_HEIGHT)) {
@ -1610,8 +1610,8 @@ public class PresetEditorDialog extends JDialog implements ItemListener {
pcDiameter.setValue(preset.get(ComponentPreset.DIAMETER)); pcDiameter.setValue(preset.get(ComponentPreset.DIAMETER));
pcDiameter.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit()); pcDiameter.setCurrentUnit(UnitGroup.UNITS_LENGTH.getDefaultUnit());
} }
if (preset.has(ComponentPreset.PARACHUTE_CD)) { if (preset.has(ComponentPreset.CD)) {
pcDragCoefficient.setValue(preset.get(ComponentPreset.PARACHUTE_CD)); pcDragCoefficient.setValue(preset.get(ComponentPreset.CD));
pcDragCoefficient.setCurrentUnit(UnitGroup.UNITS_COEFFICIENT.getDefaultUnit()); pcDragCoefficient.setCurrentUnit(UnitGroup.UNITS_COEFFICIENT.getDefaultUnit());
} }
setMaterial(materialChooser, preset, matHolder, Material.Type.SURFACE, ComponentPreset.MATERIAL); setMaterial(materialChooser, preset, matHolder, Material.Type.SURFACE, ComponentPreset.MATERIAL);
@ -2132,7 +2132,7 @@ public class PresetEditorDialog extends JDialog implements ItemListener {
props.put(ComponentPreset.TYPE, ComponentPreset.Type.RAIL_BUTTON); props.put(ComponentPreset.TYPE, ComponentPreset.Type.RAIL_BUTTON);
props.put(ComponentPreset.OUTER_DIAMETER, rbOuterDia.getValue()); props.put(ComponentPreset.OUTER_DIAMETER, rbOuterDia.getValue());
props.put(ComponentPreset.INNER_DIAMETER, rbInnerDia.getValue()); props.put(ComponentPreset.INNER_DIAMETER, rbInnerDia.getValue());
props.put(ComponentPreset.STANDOFF_HEIGHT, rbStandoffHeight.getValue()); props.put(ComponentPreset.BASE_HEIGHT, rbStandoffHeight.getValue());
props.put(ComponentPreset.FLANGE_HEIGHT, rbFlangeHeight.getValue()); props.put(ComponentPreset.FLANGE_HEIGHT, rbFlangeHeight.getValue());
props.put(ComponentPreset.DESCRIPTION, rbDescTextField.getText()); props.put(ComponentPreset.DESCRIPTION, rbDescTextField.getText());
props.put(ComponentPreset.PARTNO, rbPartNoTextField.getText()); props.put(ComponentPreset.PARTNO, rbPartNoTextField.getText());
@ -2179,7 +2179,7 @@ public class PresetEditorDialog extends JDialog implements ItemListener {
props.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer(mfgTextField.getText())); props.put(ComponentPreset.MANUFACTURER, Manufacturer.getManufacturer(mfgTextField.getText()));
props.put(ComponentPreset.PARTNO, pcPartNoTextField.getText()); props.put(ComponentPreset.PARTNO, pcPartNoTextField.getText());
props.put(ComponentPreset.DESCRIPTION, pcDescTextField.getText()); props.put(ComponentPreset.DESCRIPTION, pcDescTextField.getText());
props.put(ComponentPreset.PARACHUTE_CD, pcDragCoefficient.getValue()); props.put(ComponentPreset.CD, pcDragCoefficient.getValue());
Material material = (Material) materialChooser.getSelectedItem(); Material material = (Material) materialChooser.getSelectedItem();
if (material != null) { if (material != null) {
props.put(ComponentPreset.MATERIAL, material); props.put(ComponentPreset.MATERIAL, material);