motor updates
This commit is contained in:
parent
b5642117ce
commit
7eca17a372
@ -14,5 +14,5 @@ while echo "$1" | grep -q "^-" ; do
|
|||||||
done
|
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 "$@"
|
||||||
|
|
||||||
|
@ -22,8 +22,8 @@ public class RASPMotorLoader extends AbstractMotorLoader {
|
|||||||
public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
|
public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Charset getDefaultCharset() {
|
protected Charset getDefaultCharset() {
|
||||||
return CHARSET;
|
return CHARSET;
|
||||||
@ -197,7 +197,7 @@ public class RASPMotorLoader extends AbstractMotorLoader {
|
|||||||
motorDigest.update(DataType.MASS_SPECIFIC, totalW, totalW - propW);
|
motorDigest.update(DataType.MASS_SPECIFIC, totalW, totalW - propW);
|
||||||
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
|
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
|
||||||
final String digest = motorDigest.getDigest();
|
final String digest = motorDigest.getDigest();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
|
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
|
||||||
|
@ -32,19 +32,19 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
|
|
||||||
public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
|
public static final Charset CHARSET = Charset.forName(CHARSET_NAME);
|
||||||
|
|
||||||
|
|
||||||
/** Any delay longer than this will be interpreted as a plugged motor. */
|
/** Any delay longer than this will be interpreted as a plugged motor. */
|
||||||
private static final int DELAY_LIMIT = 90;
|
private static final int DELAY_LIMIT = 90;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Charset getDefaultCharset() {
|
protected Charset getDefaultCharset() {
|
||||||
return CHARSET;
|
return CHARSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a <code>Motor</code> from a RockSim motor definition file specified by the
|
* 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
|
* <code>Reader</code>. The <code>Reader</code> is responsible for using the correct
|
||||||
@ -73,7 +73,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initial handler for the RockSim engine files.
|
* Initial handler for the RockSim engine files.
|
||||||
*/
|
*/
|
||||||
@ -234,7 +234,15 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
|
|
||||||
// Motor type
|
// Motor type
|
||||||
str = attributes.get("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
|
// Calculate mass
|
||||||
str = attributes.get("auto-calc-mass");
|
str = attributes.get("auto-calc-mass");
|
||||||
@ -315,7 +323,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
if (time == null || time.size() == 0)
|
if (time == null || time.size() == 0)
|
||||||
throw new SAXException("Illegal motor data");
|
throw new SAXException("Illegal motor data");
|
||||||
|
|
||||||
|
|
||||||
finalizeThrustCurve(time, force, mass, cg);
|
finalizeThrustCurve(time, force, mass, cg);
|
||||||
final int n = time.size();
|
final int n = time.size();
|
||||||
|
|
||||||
@ -340,7 +348,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
cgArray[i] = new Coordinate(cg.get(i), 0, 0, mass.get(i));
|
cgArray[i] = new Coordinate(cg.get(i), 0, 0, mass.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create the motor digest from all data available in the file
|
// Create the motor digest from all data available in the file
|
||||||
MotorDigest motorDigest = new MotorDigest();
|
MotorDigest motorDigest = new MotorDigest();
|
||||||
motorDigest.update(DataType.TIME_ARRAY, timeArray);
|
motorDigest.update(DataType.TIME_ARRAY, timeArray);
|
||||||
@ -352,10 +360,11 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
if (!calculateCG) {
|
if (!calculateCG) {
|
||||||
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
|
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
|
||||||
}
|
}
|
||||||
|
// FIXME: Should this use CG_SPECIFIC ???
|
||||||
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
|
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
|
||||||
final String digest = motorDigest.getDigest();
|
final String digest = motorDigest.getDigest();
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
|
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
|
||||||
Motor.Type t = type;
|
Motor.Type t = type;
|
||||||
@ -451,7 +460,7 @@ public class RockSimMotorLoader extends AbstractMotorLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static boolean hasIllegalValue(List<Double> list) {
|
private static boolean hasIllegalValue(List<Double> list) {
|
||||||
for (Double d : list) {
|
for (Double d : list) {
|
||||||
if (d == null || d.isNaN() || d.isInfinite()) {
|
if (d == null || d.isNaN() || d.isInfinite()) {
|
||||||
|
@ -3,16 +3,16 @@ package net.sf.openrocket.motor;
|
|||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
|
|
||||||
public interface Motor {
|
public interface Motor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum of rocket motor types.
|
* Enum of rocket motor types.
|
||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
public enum Type {
|
public enum Type {
|
||||||
SINGLE("Single-use", "Single-use solid propellant motor"),
|
SINGLE("Single-use", "Single-use solid propellant motor"),
|
||||||
RELOAD("Reloadable", "Reloadable solid propellant motor"),
|
RELOAD("Reloadable", "Reloadable solid propellant motor"),
|
||||||
HYBRID("Hybrid", "Hybrid rocket motor engine"),
|
HYBRID("Hybrid", "Hybrid rocket motor engine"),
|
||||||
UNKNOWN("Unknown", "Unknown motor type");
|
UNKNOWN("Unknown", "Unknown motor type");
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
@ -23,21 +23,7 @@ public interface Motor {
|
|||||||
this.description = description;
|
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 this motor type.
|
||||||
* @return a short name of the motor type.
|
* @return a short name of the motor type.
|
||||||
@ -75,16 +61,16 @@ public interface Motor {
|
|||||||
*/
|
*/
|
||||||
public static final double MARGINAL_THRUST = 0.05;
|
public static final double MARGINAL_THRUST = 0.05;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the motor type.
|
* Return the motor type.
|
||||||
*
|
*
|
||||||
* @return the motorType
|
* @return the motorType
|
||||||
*/
|
*/
|
||||||
public Type getMotorType();
|
public Type getMotorType();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the designation of the motor.
|
* Return the designation of the motor.
|
||||||
*
|
*
|
||||||
@ -100,7 +86,7 @@ public interface Motor {
|
|||||||
*/
|
*/
|
||||||
public String getDesignation(double delay);
|
public String getDesignation(double delay);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return extra description for the motor. This may include for example
|
* Return extra description for the motor. This may include for example
|
||||||
* comments on the source of the thrust curve. The returned <code>String</code>
|
* comments on the source of the thrust curve. The returned <code>String</code>
|
||||||
@ -117,7 +103,7 @@ public interface Motor {
|
|||||||
* @return the diameter
|
* @return the diameter
|
||||||
*/
|
*/
|
||||||
public double getDiameter();
|
public double getDiameter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the length of the motor. This should be a "characteristic" length,
|
* 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
|
* and the exact definition may depend on the motor type. Typically this should
|
||||||
@ -129,21 +115,33 @@ public interface Motor {
|
|||||||
public double getLength();
|
public double getLength();
|
||||||
|
|
||||||
public String getDigest();
|
public String getDigest();
|
||||||
|
|
||||||
public MotorInstance getInstance();
|
public MotorInstance getInstance();
|
||||||
|
|
||||||
|
|
||||||
public Coordinate getLaunchCG();
|
public Coordinate getLaunchCG();
|
||||||
|
|
||||||
public Coordinate getEmptyCG();
|
public Coordinate getEmptyCG();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an estimate of the burn time of this motor, or NaN if an estimate is unavailable.
|
||||||
|
*/
|
||||||
public double getBurnTimeEstimate();
|
public double getBurnTimeEstimate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an estimate of the average thrust of this motor, or NaN if an estimate is unavailable.
|
||||||
|
*/
|
||||||
public double getAverageThrustEstimate();
|
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 getMaxThrustEstimate();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an estimate of the total impulse of this motor, or NaN if an estimate is unavailable.
|
||||||
|
*/
|
||||||
public double getTotalImpulseEstimate();
|
public double getTotalImpulseEstimate();
|
||||||
|
|
||||||
public double[] getTimePoints();
|
|
||||||
public double[] getThrustPoints();
|
|
||||||
public Coordinate[] getCGPoints();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,23 @@ public class MotorDigest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
// Check for correct order
|
||||||
if (lastOrder >= type.getOrder()) {
|
if (lastOrder >= type.getOrder()) {
|
||||||
@ -91,23 +107,6 @@ public class MotorDigest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) {
|
private static double next(double v) {
|
||||||
return v + Math.signum(v) * EPSILON;
|
return v + Math.signum(v) * EPSILON;
|
||||||
}
|
}
|
||||||
@ -123,7 +122,7 @@ public class MotorDigest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private byte[] bytes(int value) {
|
private byte[] bytes(int value) {
|
||||||
return new byte[] {
|
return new byte[] {
|
||||||
(byte) ((value >>> 24) & 0xFF), (byte) ((value >>> 16) & 0xFF),
|
(byte) ((value >>> 24) & 0xFF), (byte) ((value >>> 16) & 0xFF),
|
||||||
@ -138,7 +137,7 @@ public class MotorDigest {
|
|||||||
* @param m the motor to digest
|
* @param m the motor to digest
|
||||||
* @return the 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
|
// Create the motor digest from data available in RASP files
|
||||||
MotorDigest motorDigest = new MotorDigest();
|
MotorDigest motorDigest = new MotorDigest();
|
||||||
|
@ -0,0 +1,112 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user