+2012-04-19 Sampo Niskanen
+
+ * Allow opening recovery device on stage separation
+
2012-04-11 Doug Pedrick
- * [BUG] Printed simulation did not honor launch conditions
+ * [BUG] Printed simulation did not honor launch conditions
2012-04-09 Sampo Niskanen
2012-03-25 Doug Pedrick
- * Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
+ * Printed rocket figure in design report now honors rotation angle of main figure; fixed bug in layout where the
figure was clipped in the page margin.
2012-03-18 Jason Blood
digesting algorithm was changed. Adds <separationevent> and
<separationdelay> elements to stage components (except sustainer).
-1.5: Introduced with OpenRocket 12.xx. Added ComponentPresets.
\ No newline at end of file
+1.5: Introduced with OpenRocket 12.xx. Added ComponentPresets.
+ Added lowerstageseparation as recovery device deployment event.
\ No newline at end of file
RecoveryDevice.DeployEvent.EJECTION = First ejection charge of this stage
RecoveryDevice.DeployEvent.APOGEE = Apogee
RecoveryDevice.DeployEvent.ALTITUDE = Specific altitude during descent
+RecoveryDevice.DeployEvent.CURRENT_STAGE_SEPARATION = Current stage separation
+RecoveryDevice.DeployEvent.LOWER_STAGE_SEPARATION = Lower stage separation
RecoveryDevice.DeployEvent.NEVER = Never
! FlightEvent
import net.sf.openrocket.logging.LogHelper;
import net.sf.openrocket.rocketcomponent.FinSet;
import net.sf.openrocket.rocketcomponent.MotorMount;
+import net.sf.openrocket.rocketcomponent.RecoveryDevice;
+import net.sf.openrocket.rocketcomponent.RecoveryDevice.DeployEvent;
import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.TubeCoupler;
/*
* File version 1.5 is requires for:
* - saving designs using ComponentPrests
+ * - recovery device deployment on lower stage separation
*
* File version 1.4 is required for:
* - saving simulation data
* Otherwise use version 1.0.
*/
- // Search the rocket for any ComponentPrests
- {
- Rocket r = document.getRocket();
- Iterator<RocketComponent> componentIterator = r.iterator();
- boolean usesComponentPreset = false;
- while ( !usesComponentPreset && componentIterator.hasNext() ) {
- RocketComponent c = componentIterator.next();
- if ( c.getPresetComponent() != null ) {
- usesComponentPreset = true;
- }
- }
- if ( usesComponentPreset ) {
+ // Search the rocket for any ComponentPresets (version 1.5)
+ for (RocketComponent c : document.getRocket()) {
+ if (c.getPresetComponent() != null) {
return FILE_VERSION_DIVISOR + 5;
}
}
+ // Search for recovery device deployment type LOWER_STAGE_SEPARATION (version 1.5)
+ for (RocketComponent c : document.getRocket()) {
+ if (c instanceof RecoveryDevice) {
+ if (((RecoveryDevice) c).getDeployEvent() == DeployEvent.LOWER_STAGE_SEPARATION) {
+ return FILE_VERSION_DIVISOR + 5;
+ }
+ }
+ }
+
// Check if design has simulations defined (version 1.4)
if (document.getSimulationCount() > 0) {
return FILE_VERSION_DIVISOR + 4;
}
// Check for motor definitions (version 1.4)
- Iterator<RocketComponent> iterator = document.getRocket().iterator();
- while (iterator.hasNext()) {
- RocketComponent c = iterator.next();
+ for (RocketComponent c : document.getRocket()) {
if (!(c instanceof MotorMount))
continue;
}
// Check for fin tabs (version 1.1)
- iterator = document.getRocket().iterator();
- while (iterator.hasNext()) {
- RocketComponent c = iterator.next();
-
+ for (RocketComponent c : document.getRocket()) {
// Check for fin tabs
if (c instanceof FinSet) {
FinSet fin = (FinSet) c;
else
elements.add("<cd>" + dev.getCD() + "</cd>");
- elements.add("<deployevent>" + dev.getDeployEvent().name().toLowerCase(Locale.ENGLISH) + "</deployevent>");
+ elements.add("<deployevent>" + dev.getDeployEvent().name().toLowerCase(Locale.ENGLISH).replace("_", "") + "</deployevent>");
elements.add("<deployaltitude>" + dev.getDeployAltitude() + "</deployaltitude>");
elements.add("<deploydelay>" + dev.getDeployDelay() + "</deploydelay>");
elements.add(materialParam(dev.getMaterial()));
*/
public abstract class RecoveryDevice extends MassObject {
private static final Translator trans = Application.getTranslator();
-
+
public static enum DeployEvent {
- //// Launch (plus NN seconds)
LAUNCH(trans.get("RecoveryDevice.DeployEvent.LAUNCH")) {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return e.getType() == FlightEvent.Type.LAUNCH;
}
},
- //// First ejection charge of this stage
EJECTION(trans.get("RecoveryDevice.DeployEvent.EJECTION")) {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return charge.getStageNumber() == source.getStageNumber();
}
},
- //// Apogee
APOGEE(trans.get("RecoveryDevice.DeployEvent.APOGEE")) {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return e.getType() == FlightEvent.Type.APOGEE;
}
},
- //// Specific altitude during descent
ALTITUDE(trans.get("RecoveryDevice.DeployEvent.ALTITUDE")) {
@SuppressWarnings("unchecked")
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
if (e.getType() != FlightEvent.Type.ALTITUDE)
return false;
-
- double alt = ((RecoveryDevice)source).getDeployAltitude();
- Pair<Double,Double> altitude = (Pair<Double,Double>)e.getData();
+
+ double alt = ((RecoveryDevice) source).getDeployAltitude();
+ Pair<Double, Double> altitude = (Pair<Double, Double>) e.getData();
return (altitude.getU() >= alt) && (altitude.getV() <= alt);
}
},
- //// Never
+ LOWER_STAGE_SEPARATION(trans.get("RecoveryDevice.DeployEvent.LOWER_STAGE_SEPARATION")) {
+ @Override
+ public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
+ if (e.getType() != FlightEvent.Type.STAGE_SEPARATION)
+ return false;
+
+ int separation = e.getSource().getStageNumber();
+ int current = source.getStageNumber();
+ return (current + 1 == separation);
+ }
+ },
NEVER(trans.get("RecoveryDevice.DeployEvent.NEVER")) {
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
return false;
}
- }
- ;
+ };
private final String description;
public String toString() {
return description;
}
-
+
}
private Material.Surface material;
-
+
public RecoveryDevice() {
this(Application.getPreferences().getDefaultComponentMaterial(RecoveryDevice.class, Material.Type.SURFACE));
super();
setMaterial(material);
}
-
+
public RecoveryDevice(double length, double radius, Material material) {
super(length, radius);
setMaterial(material);
}
-
+
public abstract double getArea();
public abstract double getComponentCD(double mach);
-
+
public double getCD() {
cd = getComponentCD(mach);
return cd;
}
-
+
public void setCD(double cd) {
if (MathUtil.equals(this.cd, cd) && !isCDAutomatic())
return;
this.cdAutomatic = false;
fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
}
-
+
public boolean isCDAutomatic() {
return cdAutomatic;
public final void setMaterial(Material mat) {
if (!(mat instanceof Material.Surface)) {
- throw new IllegalArgumentException("Attempted to set non-surface material "+mat);
+ throw new IllegalArgumentException("Attempted to set non-surface material " + mat);
}
if (mat.equals(material))
return;
- this.material = (Material.Surface)mat;
+ this.material = (Material.Surface) mat;
fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
}
public DeployEvent getDeployEvent() {
return deployEvent;
}
-
+
public void setDeployEvent(DeployEvent deployEvent) {
if (this.deployEvent == deployEvent)
return;
fireComponentChangeEvent(ComponentChangeEvent.EVENT_CHANGE);
}
-
+
public double getDeployAltitude() {
return deployAltitude;
}
-
+
public void setDeployAltitude(double deployAltitude) {
if (MathUtil.equals(this.deployAltitude, deployAltitude))
return;
}
-
+
@Override
public double getComponentMass() {
return getArea() * getMaterial().getDensity();
}
-
+
}