diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index fc0dcd6cd..08e7c57de 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -92,6 +92,37 @@ public abstract class Warning { } } + /** + * A Warning indicating recovery device deployment at high speed was encountered. + * + * @author Craig Earls + */ + public static class HighSpeedDeployment extends Warning { + private double recoverySpeed; + + /** + * Sole constructor. The argument is the speed that caused this warning. + * + * @param speed the speed that caused this warning + */ + public HighSpeedDeployment(double speed) { + this.recoverySpeed = speed; + } + + @Override + public String toString() { + if (Double.isNaN(recoverySpeed)) { + return trans.get("Warning.RECOVERY_HIGH_SPEED"); + } + return trans.get("Warning.RECOVERY_HIGH_SPEED") + " (" + UnitGroup.UNITS_VELOCITY.toStringUnit(recoverySpeed) + ")"; + } + + @Override + public boolean replaceBy(Warning other) { + return false; + } + } + public static class MissingMotor extends Warning { private Motor.Type type = null; diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index b7d8889a0..afadf26c2 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -23,7 +23,6 @@ import net.sf.openrocket.simulation.exception.SimulationLaunchException; import net.sf.openrocket.simulation.listeners.SimulationListenerHelper; import net.sf.openrocket.simulation.listeners.system.OptimumCoastListener; import net.sf.openrocket.startup.Application; -import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.MathUtil; import net.sf.openrocket.util.Pair; @@ -494,11 +493,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { // Check current velocity if (status.getRocketVelocity().length() > 20) { - // TODO: LOW: Custom warning. - status.getWarnings().add(Warning.fromString(trans.get("Warning.RECOVERY_HIGH_SPEED") + - " (" - + UnitGroup.UNITS_VELOCITY.toStringUnit(status.getRocketVelocity().length()) - + ").")); + status.getWarnings().add(new Warning.HighSpeedDeployment(status.getRocketVelocity().length())); } status.setLiftoff(true);