done
-java -cp bin/:lib/miglayout15-swing.jar:lib/jcommon-1.0.16.jar:lib/jfreechart-1.0.13.jar:lib/iText-5.0.2.jar:. $JAVAOPTS net.sf.openrocket.startup.Startup "$@"
+java -cp bin/:lib/miglayout15-swing.jar:lib/jcommon-1.0.16.jar:lib/jfreechart-1.0.13.jar:lib/iText-5.0.2.jar $JAVAOPTS net.sf.openrocket.startup.Startup "$@"
public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
-
-
+
+
@Override
protected Charset getDefaultCharset() {
return CHARSET;
motorDigest.update(DataType.MASS_SPECIFIC, totalW, totalW - propW);
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
final String digest = motorDigest.getDigest();
-
+
try {
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
-
+
/** Any delay longer than this will be interpreted as a plugged motor. */
private static final int DELAY_LIMIT = 90;
-
+
@Override
protected Charset getDefaultCharset() {
return CHARSET;
}
-
+
/**
* Load a <code>Motor</code> from a RockSim motor definition file specified by the
* <code>Reader</code>. The <code>Reader</code> is responsible for using the correct
}
-
+
/**
* Initial handler for the RockSim engine files.
*/
// Motor type
str = attributes.get("Type");
- type = Motor.Type.fromName(str);
+ if ("single-use".equalsIgnoreCase(str)) {
+ type = Motor.Type.SINGLE;
+ } else if ("hybrid".equalsIgnoreCase(str)) {
+ type = Motor.Type.HYBRID;
+ } else if ("reloadable".equalsIgnoreCase(str)) {
+ type = Motor.Type.RELOAD;
+ } else {
+ type = Motor.Type.UNKNOWN;
+ }
// Calculate mass
str = attributes.get("auto-calc-mass");
if (time == null || time.size() == 0)
throw new SAXException("Illegal motor data");
-
+
finalizeThrustCurve(time, force, mass, cg);
final int n = time.size();
cgArray[i] = new Coordinate(cg.get(i), 0, 0, mass.get(i));
}
-
+
// Create the motor digest from all data available in the file
MotorDigest motorDigest = new MotorDigest();
motorDigest.update(DataType.TIME_ARRAY, timeArray);
if (!calculateCG) {
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
}
+ // FIXME: Should this use CG_SPECIFIC ???
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
final String digest = motorDigest.getDigest();
-
+
try {
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
Motor.Type t = type;
}
-
+
private static boolean hasIllegalValue(List<Double> list) {
for (Double d : list) {
if (d == null || d.isNaN() || d.isInfinite()) {
import net.sf.openrocket.util.Coordinate;
public interface Motor {
-
+
/**
* Enum of rocket motor types.
*
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/
public enum Type {
- SINGLE("Single-use", "Single-use solid propellant motor"),
- RELOAD("Reloadable", "Reloadable solid propellant motor"),
- HYBRID("Hybrid", "Hybrid rocket motor engine"),
+ SINGLE("Single-use", "Single-use solid propellant motor"),
+ RELOAD("Reloadable", "Reloadable solid propellant motor"),
+ HYBRID("Hybrid", "Hybrid rocket motor engine"),
UNKNOWN("Unknown", "Unknown motor type");
private final String name;
this.description = description;
}
- public static Type fromName( String name ) {
- if ( name == null ) {
- return UNKNOWN;
- }
- if ("single-use".equalsIgnoreCase(name)) {
- return SINGLE;
- } else if ("hybrid".equalsIgnoreCase(name)) {
- return HYBRID;
- } else if ("reloadable".equalsIgnoreCase(name)) {
- return RELOAD;
- } else {
- return UNKNOWN;
- }
- }
-
+
/**
* Return a short name of this motor type.
* @return a short name of the motor type.
*/
public static final double MARGINAL_THRUST = 0.05;
-
-
+
+
/**
* Return the motor type.
*
* @return the motorType
*/
public Type getMotorType();
-
-
+
+
/**
* Return the designation of the motor.
*
*/
public String getDesignation(double delay);
-
+
/**
* Return extra description for the motor. This may include for example
* comments on the source of the thrust curve. The returned <code>String</code>
* @return the diameter
*/
public double getDiameter();
-
+
/**
* Return the length of the motor. This should be a "characteristic" length,
* and the exact definition may depend on the motor type. Typically this should
public double getLength();
public String getDigest();
-
+
public MotorInstance getInstance();
public Coordinate getLaunchCG();
+
public Coordinate getEmptyCG();
+ /**
+ * Return an estimate of the burn time of this motor, or NaN if an estimate is unavailable.
+ */
public double getBurnTimeEstimate();
+
+ /**
+ * Return an estimate of the average thrust of this motor, or NaN if an estimate is unavailable.
+ */
public double getAverageThrustEstimate();
+
+ /**
+ * Return an estimate of the maximum thrust of this motor, or NaN if an estimate is unavailable.
+ */
public double getMaxThrustEstimate();
- public double getTotalImpulseEstimate();
- public double[] getTimePoints();
- public double[] getThrustPoints();
- public Coordinate[] getCGPoints();
+ /**
+ * Return an estimate of the total impulse of this motor, or NaN if an estimate is unavailable.
+ */
+ public double getTotalImpulseEstimate();
}
}
- public void update(DataType type, int... values) {
+
+ public void update(DataType type, double... values) {
+ int multiplier = type.getMultiplier();
+
+ int[] intValues = new int[values.length];
+ for (int i = 0; i < values.length; i++) {
+ double v = values[i];
+ v = next(v);
+ v *= multiplier;
+ v = next(v);
+ intValues[i] = (int) Math.round(v);
+ }
+ update(type, intValues);
+ }
+
+
+ private void update(DataType type, int... values) {
// Check for correct order
if (lastOrder >= type.getOrder()) {
}
- private void update(DataType type, int multiplier, double... values) {
-
- int[] intValues = new int[values.length];
- for (int i = 0; i < values.length; i++) {
- double v = values[i];
- v = next(v);
- v *= multiplier;
- v = next(v);
- intValues[i] = (int) Math.round(v);
- }
- update(type, intValues);
- }
-
- public void update(DataType type, double... values) {
- update(type, type.getMultiplier(), values);
- }
-
private static double next(double v) {
return v + Math.signum(v) * EPSILON;
}
}
-
+
private byte[] bytes(int value) {
return new byte[] {
(byte) ((value >>> 24) & 0xFF), (byte) ((value >>> 16) & 0xFF),
* @param m the motor to digest
* @return the digest
*/
- public static String digestMotor(Motor m) {
+ public static String digestMotor(ThrustCurveMotor m) {
// Create the motor digest from data available in RASP files
MotorDigest motorDigest = new MotorDigest();
--- /dev/null
+package net.sf.openrocket.motor;
+
+import net.sf.openrocket.util.BugException;
+import net.sf.openrocket.util.Coordinate;
+
+public class ThrustCurveMotorPlaceholder implements Motor {
+
+ private final Motor.Type type;
+ private final String manufacturer;
+ private final String designation;
+ private final double diameter;
+ private final double length;
+ private final String digest;
+ private final double delay;
+ private final double launchMass;
+ private final double emptyMass;
+
+
+ public ThrustCurveMotorPlaceholder(Type type, String manufacturer, String designation, double diameter, double length,
+ String digest, double delay, double launchMass, double emptyMass) {
+ this.type = type;
+ this.manufacturer = manufacturer;
+ this.designation = designation;
+ this.diameter = diameter;
+ this.length = length;
+ this.digest = digest;
+ this.delay = delay;
+ this.launchMass = launchMass;
+ this.emptyMass = emptyMass;
+ }
+
+
+ @Override
+ public Type getMotorType() {
+ return type;
+ }
+
+ public String getManufacturer() {
+ return manufacturer;
+ }
+
+ @Override
+ public String getDesignation() {
+ return designation;
+ }
+
+ @Override
+ public String getDesignation(double designationDelay) {
+ return designation + "-" + ThrustCurveMotor.getDelayString(designationDelay);
+ }
+
+ @Override
+ public String getDescription() {
+ return "";
+ }
+
+ @Override
+ public double getDiameter() {
+ return diameter;
+ }
+
+ @Override
+ public double getLength() {
+ return length;
+ }
+
+ @Override
+ public String getDigest() {
+ return digest;
+ }
+
+ public double getDelay() {
+ return delay;
+ }
+
+ @Override
+ public MotorInstance getInstance() {
+ throw new BugException("Called getInstance on PlaceholderMotor");
+ }
+
+ @Override
+ public Coordinate getLaunchCG() {
+ return new Coordinate(length / 2, 0, 0, launchMass);
+ }
+
+ @Override
+ public Coordinate getEmptyCG() {
+ return new Coordinate(length / 2, 0, 0, emptyMass);
+ }
+
+ @Override
+ public double getBurnTimeEstimate() {
+ return Double.NaN;
+ }
+
+ @Override
+ public double getAverageThrustEstimate() {
+ return Double.NaN;
+ }
+
+ @Override
+ public double getMaxThrustEstimate() {
+ return Double.NaN;
+ }
+
+ @Override
+ public double getTotalImpulseEstimate() {
+ return Double.NaN;
+ }
+
+
+}