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");
- if (str != null && str.equalsIgnoreCase("single-use")) {
+ if ("single-use".equalsIgnoreCase(str)) {
type = Motor.Type.SINGLE;
- } else if (str != null && str.equalsIgnoreCase("hybrid")) {
+ } else if ("hybrid".equalsIgnoreCase(str)) {
type = Motor.Type.HYBRID;
- } else if (str != null && str.equalsIgnoreCase("reloadable")) {
+ } else if ("reloadable".equalsIgnoreCase(str)) {
type = Motor.Type.RELOAD;
} else {
type = Motor.Type.UNKNOWN;
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);
motorDigest.update(DataType.CG_PER_TIME, toArray(cg));
}
motorDigest.update(DataType.FORCE_PER_TIME, thrustArray);
- // TODO: HIGH: Motor digest?
- // final String digest = motorDigest.getDigest();
+ final String digest = motorDigest.getDigest();
+
-
try {
Manufacturer m = Manufacturer.getManufacturer(manufacturer);
Motor.Type t = type;
}
return new ThrustCurveMotor(m, designation, description, t,
- delays, diameter, length, timeArray, thrustArray, cgArray);
+ delays, diameter, length, timeArray, thrustArray, cgArray, digest);
} catch (IllegalArgumentException e) {
throw new SAXException("Illegal motor data", e);
}
}
-
+
private static boolean hasIllegalValue(List<Double> list) {
for (Double d : list) {
if (d == null || d.isNaN() || d.isInfinite()) {