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 "$@"
|
||||||
|
|
||||||
|
@ -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");
|
||||||
@ -352,6 +360,7 @@ 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();
|
||||||
|
|
||||||
|
@ -23,20 +23,6 @@ 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.
|
||||||
@ -134,16 +120,28 @@ public interface Motor {
|
|||||||
|
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@ -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