Parachute configuration preset input enhancements
Presets for selected parachute changes the Component Name to the parachute Description; input the parachute Cd; and input the override mass, checking the mass override box. The parachute packed values are also input, with the diameter of the parachute sized to the inner diameter of the parent component (where nose cones and transitions have inconsistent inner diameters, these components are sized to the largest diameter). Parachutes without a length and diameter (or without those fields) are sized using the default length and diameter. Once created, the parachute length and diameter do not automatically change if the parent diameter is changed, or the parachute is moved to a different component.
This commit is contained in:
parent
d1f419638b
commit
f33babc806
@ -153,6 +153,9 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
|
||||
ComponentPreset.DESCRIPTION,
|
||||
ComponentPreset.DIAMETER,
|
||||
ComponentPreset.SIDES,
|
||||
ComponentPreset.PARACHUTE_CD,
|
||||
ComponentPreset.PACKED_DIAMETER,
|
||||
ComponentPreset.PACKED_LENGTH,
|
||||
ComponentPreset.LINE_COUNT,
|
||||
ComponentPreset.LINE_LENGTH,
|
||||
ComponentPreset.LINE_MATERIAL,
|
||||
@ -208,6 +211,9 @@ 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> DIAMETER = new TypedKey<Double>("Diameter", Double.class, UnitGroup.UNITS_LENGTH);
|
||||
public final static TypedKey<Integer> SIDES = new TypedKey<Integer>("Sides", Integer.class);
|
||||
public static final TypedKey<Double> PARACHUTE_CD = new TypedKey<Double>("DragCoefficient", Double.class, UnitGroup.UNITS_COEFFICIENT);
|
||||
public final static TypedKey<Double> PACKED_LENGTH = new TypedKey<Double>("PackedLength", Double.class, UnitGroup.UNITS_LENGTH);
|
||||
public final static TypedKey<Double> PACKED_DIAMETER = new TypedKey<Double>("PackedDiameter", Double.class, UnitGroup.UNITS_LENGTH);
|
||||
public final static TypedKey<Integer> LINE_COUNT = new TypedKey<Integer>("LineCount", Integer.class);
|
||||
public final static TypedKey<Double> LINE_LENGTH = new TypedKey<Double>("LineLength", Double.class, UnitGroup.UNITS_LENGTH);
|
||||
public final static TypedKey<Material> LINE_MATERIAL = new TypedKey<Material>("LineMaterial", Material.class);
|
||||
@ -237,6 +243,11 @@ public class ComponentPreset implements Comparable<ComponentPreset>, Serializabl
|
||||
FILLED,
|
||||
DIAMETER,
|
||||
SIDES,
|
||||
/** DO NOT add new presets to this list without defining table.column
|
||||
PARACHUTE_CD,
|
||||
PACKED_LENGTH,
|
||||
PACKED_DIAMETER,
|
||||
*/
|
||||
LINE_COUNT,
|
||||
LINE_LENGTH,
|
||||
LINE_MATERIAL,
|
||||
|
@ -23,6 +23,12 @@ public class ParachuteDTO extends BaseComponentDTO {
|
||||
private AnnotatedLengthDTO diameter;
|
||||
@XmlElement(name = "Sides")
|
||||
private Integer sides;
|
||||
@XmlElement(name = "PackedDiameter")
|
||||
private AnnotatedLengthDTO PackedDiameter;
|
||||
@XmlElement(name = "PackedLength")
|
||||
private AnnotatedLengthDTO PackedLength;
|
||||
@XmlElement(name = "DragCoefficient")
|
||||
private AnnotatedLengthDTO DragCoefficient;
|
||||
@XmlElement(name = "LineCount")
|
||||
private Integer lineCount;
|
||||
@XmlElement(name = "LineLength")
|
||||
@ -57,6 +63,38 @@ public class ParachuteDTO extends BaseComponentDTO {
|
||||
this.sides = sides;
|
||||
}
|
||||
|
||||
|
||||
public double getPackedDiameter() {
|
||||
return PackedDiameter.getValue();
|
||||
}
|
||||
|
||||
public void setPackedDiameter(AnnotatedLengthDTO PackedDiameter) {
|
||||
this.PackedDiameter = PackedDiameter;
|
||||
}
|
||||
public void setPackedDiameter(double PackedDiameter) {
|
||||
this.PackedDiameter = new AnnotatedLengthDTO(PackedDiameter);
|
||||
}
|
||||
|
||||
public double getPackedLength() {
|
||||
return PackedLength.getValue();
|
||||
}
|
||||
|
||||
public void setPackedLength(AnnotatedLengthDTO PackedLength) {
|
||||
this.PackedLength = PackedLength;
|
||||
}
|
||||
public void setPackedLength(double PackedLength) {
|
||||
this.PackedLength = new AnnotatedLengthDTO(PackedLength);
|
||||
}
|
||||
|
||||
public double getDragCoefficient() {
|
||||
return DragCoefficient.getValue();
|
||||
}
|
||||
|
||||
public void setDragCoefficient(AnnotatedLengthDTO DragCoefficient) {
|
||||
this.DragCoefficient = DragCoefficient;
|
||||
}
|
||||
public void setDragCoefficient(double DragCoefficient) { this.DragCoefficient = new AnnotatedLengthDTO(DragCoefficient); }
|
||||
|
||||
public Integer getLineCount() {
|
||||
return lineCount;
|
||||
}
|
||||
@ -102,6 +140,15 @@ public class ParachuteDTO extends BaseComponentDTO {
|
||||
if ( preset.has(ComponentPreset.SIDES)) {
|
||||
setSides(preset.get(ComponentPreset.SIDES));
|
||||
}
|
||||
if ( preset.has(ComponentPreset.PACKED_DIAMETER)) {
|
||||
setPackedDiameter(preset.get(ComponentPreset.PACKED_DIAMETER));
|
||||
}
|
||||
if ( preset.has(ComponentPreset.PACKED_LENGTH)) {
|
||||
setPackedLength(preset.get(ComponentPreset.PACKED_LENGTH));
|
||||
}
|
||||
if ( preset.has(ComponentPreset.PARACHUTE_CD)) {
|
||||
setDragCoefficient(preset.get(ComponentPreset.PARACHUTE_CD));
|
||||
}
|
||||
if ( preset.has(ComponentPreset.LINE_MATERIAL)) {
|
||||
setLineMaterial(new AnnotatedMaterialDTO(preset.get(ComponentPreset.LINE_MATERIAL)));
|
||||
}
|
||||
@ -120,6 +167,15 @@ public class ParachuteDTO extends BaseComponentDTO {
|
||||
// need to fix the MATERIAL packed into the componentpreset.
|
||||
props.put(ComponentPreset.TYPE, type);
|
||||
props.put(ComponentPreset.DIAMETER, this.getDiameter());
|
||||
if ( this.PackedDiameter != null ) {
|
||||
props.put(ComponentPreset.PACKED_DIAMETER, this.getPackedDiameter());
|
||||
}
|
||||
if ( this.PackedLength != null ) {
|
||||
props.put(ComponentPreset.PACKED_LENGTH, this.getPackedLength());
|
||||
}
|
||||
if ( this.PackedLength != null ) {
|
||||
props.put(ComponentPreset.PARACHUTE_CD, this.getDragCoefficient());
|
||||
}
|
||||
props.put(ComponentPreset.LINE_COUNT, this.getLineCount());
|
||||
if ( this.lineLength != null ) {
|
||||
props.put(ComponentPreset.LINE_LENGTH, this.getLineLength());
|
||||
|
@ -18,6 +18,8 @@ import net.sf.openrocket.rocketcomponent.position.AxialMethod;
|
||||
|
||||
public abstract class BodyComponent extends ExternalComponent {
|
||||
|
||||
private double InnerRadius;
|
||||
|
||||
/**
|
||||
* Default constructor. Sets the relative position to POSITION_RELATIVE_AFTER,
|
||||
* i.e. body components come after one another.
|
||||
@ -82,4 +84,6 @@ public abstract class BodyComponent extends ExternalComponent {
|
||||
return true;
|
||||
}
|
||||
|
||||
public double getInnerRadius() {
|
||||
return InnerRadius; }
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import net.sf.openrocket.util.MathUtil;
|
||||
*/
|
||||
public abstract class MassObject extends InternalComponent {
|
||||
|
||||
private double radius;
|
||||
protected double radius;
|
||||
|
||||
private double radialPosition;
|
||||
private double radialDirection;
|
||||
|
@ -10,19 +10,19 @@ import net.sf.openrocket.util.MathUtil;
|
||||
public class Parachute extends RecoveryDevice {
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
public static final double DEFAULT_CD = 0.8;
|
||||
public static double DEFAULT_CD = 0.8;
|
||||
|
||||
private double diameter;
|
||||
private final double InitialPackedLength = this.length;
|
||||
private final double InitialPackedRadius = this.radius;
|
||||
|
||||
private Material lineMaterial;
|
||||
private int lineCount = 6;
|
||||
private double lineLength = 0.3;
|
||||
|
||||
|
||||
public Parachute() {
|
||||
this.diameter = 0.3;
|
||||
this.lineMaterial = Application.getPreferences().getDefaultComponentMaterial(Parachute.class, Material.Type.LINE);
|
||||
this.lineLength = 0.3;
|
||||
super.displayOrder_side = 11; // Order for displaying the component in the 2D side view
|
||||
super.displayOrder_back = 9; // Order for displaying the component in the 2D back view
|
||||
}
|
||||
@ -159,9 +159,121 @@ public class Parachute extends RecoveryDevice {
|
||||
|
||||
@Override
|
||||
protected void loadFromPreset(ComponentPreset preset) {
|
||||
|
||||
// BEGIN Substitute parachute description for component name
|
||||
if (preset.has(ComponentPreset.DESCRIPTION)) { // If the preset has a Description field
|
||||
String temporaryName = preset.get(ComponentPreset.DESCRIPTION);
|
||||
int size = temporaryName.length();
|
||||
if (size > 0) { // If the preset description => 1 character
|
||||
this.name = preset.get(ComponentPreset.DESCRIPTION);
|
||||
} else { // If the preset description = 0 characters
|
||||
this.name = getComponentName();
|
||||
}
|
||||
} else { // Fail safe - no preset description field
|
||||
this.name = getComponentName();
|
||||
}
|
||||
// END Substitute parachute description for component name
|
||||
|
||||
if (preset.has(ComponentPreset.DIAMETER)) {
|
||||
this.diameter = preset.get(ComponentPreset.DIAMETER);
|
||||
}
|
||||
|
||||
// BEGIN Implement parachute cd
|
||||
if (preset.has(ComponentPreset.PARACHUTE_CD)) { // If the preset has a DragCoefficient field
|
||||
if (preset.get(ComponentPreset.PARACHUTE_CD) > 0) { // If the preset DragCoefficient > 0
|
||||
cdAutomatic = false;
|
||||
cd = preset.get(ComponentPreset.PARACHUTE_CD);
|
||||
}
|
||||
else { // If the preset DragCoefficient <= 0
|
||||
cdAutomatic = true;
|
||||
cd = Parachute.DEFAULT_CD;
|
||||
}
|
||||
} else { // Fail-safe - no preset DragCoefficient field
|
||||
cdAutomatic = true;
|
||||
cd = Parachute.DEFAULT_CD;
|
||||
}
|
||||
// END Implement parachute cd
|
||||
|
||||
// BEGIN Implement parachute length, diameter, and volume
|
||||
//// BEGIN Implement parachute packed length
|
||||
if (preset.has(ComponentPreset.PACKED_LENGTH)) { // If the preset has a PackedLength field
|
||||
this.PackedLength = preset.get(ComponentPreset.PACKED_LENGTH);
|
||||
if (PackedLength > 0) { // If the preset PackedLength length > 0
|
||||
length = PackedLength;
|
||||
}
|
||||
if (PackedLength <= 0) { // If the preset PackedLength length <= 0
|
||||
length = InitialPackedLength;
|
||||
}
|
||||
} else { // fail-safe - no preset PackedLength field
|
||||
length = InitialPackedLength;
|
||||
}
|
||||
//// END Implement parachute packed length
|
||||
//// BEGIN Implement parachute packed diameter
|
||||
if (preset.has(ComponentPreset.PACKED_DIAMETER)) { // If the preset has a PackedDiameter field
|
||||
this.PackedDiameter = preset.get(ComponentPreset.PACKED_DIAMETER);
|
||||
if (PackedDiameter > 0) { // If the preset PackedDiameter length > 0
|
||||
radius = PackedDiameter / 2;
|
||||
}
|
||||
if (PackedDiameter <= 0) { // If the preset PackedDiameter length <= 0
|
||||
radius = InitialPackedRadius;
|
||||
}
|
||||
} else { // Fail safe - no preset PackedDiameter field
|
||||
radius = InitialPackedRadius;
|
||||
}
|
||||
//// END Implement parachute packed diameter
|
||||
//// BEGIN Size parachute packed diameter within parent inner diameter
|
||||
if (length > 0 && radius > 0) { // If preset parachute length & diameter
|
||||
double innerRadius;
|
||||
double parachuteVolume;
|
||||
double trimPackedRadius = .975;
|
||||
parachuteVolume = (Math.PI * Math.pow(radius, 2) * length);
|
||||
|
||||
if (parent instanceof BodyComponent) { // If parent is a body tube
|
||||
innerRadius = ((BodyComponent) parent).getInnerRadius();
|
||||
radius = innerRadius * trimPackedRadius;
|
||||
length = parachuteVolume / (Math.PI * Math.pow((radius), 2));
|
||||
}
|
||||
if (parent instanceof InnerTube) { // If parent is an inner tube
|
||||
innerRadius = ((InnerTube) parent).getInnerRadius();
|
||||
radius = innerRadius * trimPackedRadius;
|
||||
length = parachuteVolume / (Math.PI * Math.pow((radius), 2));
|
||||
}
|
||||
if (parent instanceof TubeCoupler) { // If parent is a tube coupler
|
||||
innerRadius = ((TubeCoupler) parent).getInnerRadius();
|
||||
radius = innerRadius * trimPackedRadius;
|
||||
length = parachuteVolume / (Math.PI * Math.pow((radius), 2));
|
||||
}
|
||||
if (parent instanceof NoseCone) { // If parent is nose cone
|
||||
innerRadius = ((NoseCone) parent).getAftRadius();
|
||||
radius = innerRadius * Math.pow((trimPackedRadius), 2);
|
||||
length = parachuteVolume / (Math.PI * Math.pow((radius), 2));
|
||||
}
|
||||
if (parent instanceof Transition) { // If parent is nose cone|transition
|
||||
double foreRadius = ((Transition) parent).getForeRadius();
|
||||
double aftRadius = ((Transition) parent).getAftRadius();
|
||||
innerRadius = (Math.max(foreRadius, aftRadius));
|
||||
radius = innerRadius * Math.pow((trimPackedRadius), 2);
|
||||
length = parachuteVolume / (Math.PI * Math.pow((radius), 2));
|
||||
}
|
||||
}
|
||||
//// END Size parachute packed diameter within parent inner diameter
|
||||
// END Implement parachute length, diameter, and volume
|
||||
|
||||
// BEGIN Activate Override Mass Preset
|
||||
if (preset.has(ComponentPreset.MASS)) { // If the preset has a mass field
|
||||
this.overrideMass = (preset.get(ComponentPreset.MASS));
|
||||
if (overrideMass > 0) { // If the preset mass value > 0
|
||||
massOverridden = true;
|
||||
} else { // If the preset mass value <= 0
|
||||
this.overrideMass = 0;
|
||||
massOverridden = false;
|
||||
}
|
||||
} else { // Fail safe - no mass value field
|
||||
this.overrideMass = 0;
|
||||
massOverridden = false;
|
||||
}
|
||||
// END Activate Override Mass Preset
|
||||
|
||||
if (preset.has(ComponentPreset.LINE_COUNT)) {
|
||||
this.lineCount = preset.get(ComponentPreset.LINE_COUNT);
|
||||
}
|
||||
@ -174,10 +286,8 @@ public class Parachute extends RecoveryDevice {
|
||||
super.loadFromPreset(preset);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Type getPresetType() {
|
||||
return ComponentPreset.Type.PARACHUTE;
|
||||
return Type.PARACHUTE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -19,9 +19,13 @@ import net.sf.openrocket.util.MathUtil;
|
||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||
*/
|
||||
public abstract class RecoveryDevice extends MassObject implements FlightConfigurableComponent {
|
||||
|
||||
private double cd = Parachute.DEFAULT_CD;
|
||||
private boolean cdAutomatic = true;
|
||||
////
|
||||
protected double DragCoefficient;
|
||||
protected double PackedDiameter;
|
||||
protected double PackedLength;
|
||||
////
|
||||
protected double cd = Parachute.DEFAULT_CD;
|
||||
protected boolean cdAutomatic = true;
|
||||
|
||||
private Material.Surface material;
|
||||
|
||||
|
@ -97,8 +97,8 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
|
||||
|
||||
// Override mass/CG
|
||||
private double overrideMass = 0;
|
||||
private boolean massOverridden = false;
|
||||
protected double overrideMass = 0;
|
||||
protected boolean massOverridden = false;
|
||||
private double overrideCGX = 0;
|
||||
private boolean cgOverridden = false;
|
||||
private double overrideCD = 0;
|
||||
@ -108,7 +108,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
|
||||
|
||||
// User-given name of the component
|
||||
private String name = null;
|
||||
protected String name = null;
|
||||
|
||||
// User-specified comment
|
||||
private String comment = "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user