From 756ae90f9d2b7609a398f383827b9973cbe22eff Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Mon, 3 Oct 2022 12:39:15 -0600 Subject: [PATCH] Add a warning to the WarningSet when stage separation order is unreasonable --- core/resources/l10n/messages.properties | 1 + core/src/net/sf/openrocket/aerodynamics/Warning.java | 2 ++ .../simulation/BasicEventSimulationEngine.java | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 4b1c2b4b8..46a969ff4 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -1827,6 +1827,7 @@ Warning.ZERO_LENGTH_BODY = Zero length bodies may not result in accurate simulat Warning.ZERO_RADIUS_BODY = Zero length bodies may not result in accurate simulations. Warning.TUBE_SEPARATION = Space between tube fins may not result in accurate simulations. Warning.TUBE_OVERLAP = Overlapping tube fins may not result in accurate simulations. +Warning.SEPARATION_ORDER = Stages separated in an unreasonable order ! 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 b48a35a5e..803073948 100644 --- a/core/src/net/sf/openrocket/aerodynamics/Warning.java +++ b/core/src/net/sf/openrocket/aerodynamics/Warning.java @@ -396,4 +396,6 @@ public abstract class Warning { public static final Warning TUBE_SEPARATION = new Other(trans.get("Warning.TUBE_SEPARATION")); public static final Warning TUBE_OVERLAP = new Other(trans.get("Warning.TUBE_OVERLAP")); + + public static final Warning SEPARATION_ORDER = new Other(trans.get("Warning.SEPARATION_ORDER")); } diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index 5212790b8..ecb4ae5cb 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -444,6 +444,18 @@ public class BasicEventSimulationEngine implements SimulationEngine { // Record the event. currentStatus.getFlightData().addEvent(event); + // If I've got something other than one active stage below the separation point, + // flag a warning + int numActiveBelow = 0; + for (int i = stageNumber; i < currentStatus.getConfiguration().getStageCount(); i++) { + if (currentStatus.getConfiguration().isStageActive(i)) { + numActiveBelow++; + } + } + if (numActiveBelow != 1) { + currentStatus.getWarnings().add(Warning.SEPARATION_ORDER); + } + // Create a new simulation branch for the booster SimulationStatus boosterStatus = new SimulationStatus(currentStatus);