From eeb82c4573627d311f4399958fe192f29eb4b532 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Tue, 19 Feb 2019 13:21:58 -0700 Subject: [PATCH] Add warning when flight events remain in queue at ground hit time (addresses issue #361) --- core/resources/l10n/messages.properties | 2 +- .../sf/openrocket/aerodynamics/Warning.java | 30 +++++++++++++++++++ .../BasicEventSimulationEngine.java | 7 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 23ec515b3..071c09fa0 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1693,7 +1693,7 @@ Warning.SUPERSONIC = Body calculations may not be entirely accurate at supersoni Warning.RECOVERY_LAUNCH_ROD = Recovery device device deployed while on the launch guide. Warning.RECOVERY_HIGH_SPEED = Recovery device deployment at high speed Warning.TUMBLE_UNDER_THRUST = Stage began to tumble under thrust. - +Warning.EVENT_REMAINING = Event still in queue at ground hit: ! Scale dialog ScaleDialog.lbl.scaleRocket = Entire rocket diff --git a/core/src/net/sf/openrocket/aerodynamics/Warning.java b/core/src/net/sf/openrocket/aerodynamics/Warning.java index 7f93654fa..9807af874 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -3,6 +3,7 @@ package net.sf.openrocket.aerodynamics; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; import net.sf.openrocket.startup.Application; +import net.sf.openrocket.simulation.FlightEvent; import net.sf.openrocket.unit.UnitGroup; public abstract class Warning { @@ -123,6 +124,33 @@ public abstract class Warning { return false; } } + + /** + * A Warning indicating flight events remain in the event queue on ground hit. + * + */ + public static class EventRemaining extends Warning { + private FlightEvent event; + + /** + * Sole constructor. The argument is an event remaining in the queue + * + * @param event the event that caused this warning + */ + public EventRemaining(FlightEvent _event) { + this.event = _event; + } + + @Override + public String toString() { + return trans.get("Warning.EVENT_REMAINING") + event.getType(); + } + + @Override + public boolean replaceBy(Warning other) { + return false; + } + } public static class MissingMotor extends Warning { @@ -350,5 +378,7 @@ public abstract class Warning { public static final Warning RECOVERY_LAUNCH_ROD = new Other(trans.get("Warning.RECOVERY_LAUNCH_ROD")); public static final Warning TUMBLE_UNDER_THRUST = new Other(trans.get("Warning.TUMBLE_UNDER_THRUST")); + + public static final Warning EVENT_REMAINING = new Other(trans.get("Warning.EVENT_REMAINING")); } diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index f64a164c3..692029bc7 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -487,6 +487,13 @@ public class BasicEventSimulationEngine implements SimulationEngine { break; case GROUND_HIT: + // have I hit the ground while I still have events in the queue? + for (FlightEvent e : currentStatus.getEventQueue()) { + if ((e.getType() != FlightEvent.Type.ALTITUDE) && + (e.getType() != FlightEvent.Type.SIMULATION_END)) + currentStatus.getWarnings().add(new Warning.EventRemaining(e)); + } + currentStatus.getFlightData().addEvent(event); break;