From 724cd3f5dcc3006f86572962a4540da70d3f6f4c Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Sun, 30 Aug 2020 11:18:57 -0600 Subject: [PATCH 1/2] Don't set a warning if recovery device is deployed (for instance, due to apogee detect) while motor is coasting. Background: a motor that has burned out can be in one of two states: DELAYING (the delay charge has not yet fired) or SPENT (either the delay charge, if any, has fired or there was no delay charge). The existing SimulationStatus:getActiveMotors() method returned a list of motors that were active for the stage, and which were not SPENT. The test for the warning redudantly tested for a SPENT motor, still didn't test for a DELAYING motr, and consequently set the warning. This PR (1) adds a boolean MotorClusterStatus:isDelaying() method, analogous to the existing state test methods (2) modifies SimulationStatus.java:getActiveMotors() to return all the motors, not just the ones that aren't SPENT. This is to improve consistency with FlightConfiguration:getActiveMotors(), and to make for a more consistent usage between the two calls to the method. (3) adds !isDelaying() to the test for the warning. --- .../openrocket/simulation/BasicEventSimulationEngine.java | 2 +- .../src/net/sf/openrocket/simulation/MotorClusterState.java | 6 +++++- core/src/net/sf/openrocket/simulation/SimulationStatus.java | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index f952404ae..82cccd9ed 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -466,7 +466,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { // Check whether any motor in the active stages is active anymore for (MotorClusterState state : currentStatus.getActiveMotors() ) { - if ( state.isSpent() ) { + if (state.isDelaying() || state.isSpent()) { continue; } currentStatus.getWarnings().add(Warning.RECOVERY_DEPLOYMENT_WHILE_BURNING); diff --git a/core/src/net/sf/openrocket/simulation/MotorClusterState.java b/core/src/net/sf/openrocket/simulation/MotorClusterState.java index 39a97d746..ecf48f94d 100644 --- a/core/src/net/sf/openrocket/simulation/MotorClusterState.java +++ b/core/src/net/sf/openrocket/simulation/MotorClusterState.java @@ -162,6 +162,10 @@ public class MotorClusterState { return ! isPlugged(); } + public boolean isDelaying() { + return currentState == ThrustState.DELAYING; + } + public boolean isSpent(){ return currentState == ThrustState.SPENT; } @@ -196,4 +200,4 @@ public class MotorClusterState { -} \ No newline at end of file +} diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java index a3aeaf510..f702a980f 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java @@ -229,7 +229,7 @@ public class SimulationStatus implements Monitorable { public Collection getActiveMotors() { List activeList = new ArrayList(); for( MotorClusterState state: this.motorStateList ){ - if(( ! state.isSpent()) && (this.configuration.isComponentActive( state.getMount()))){ + if (this.configuration.isComponentActive( state.getMount() { activeList.add( state ); } } From 94a5e1c2d9453b1c6339e93b279919d88b1c44dd Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Sun, 30 Aug 2020 11:44:19 -0600 Subject: [PATCH 2/2] fix typo -- two missing right parentheses --- core/src/net/sf/openrocket/simulation/SimulationStatus.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java index f702a980f..3b1b4c32f 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java @@ -229,7 +229,7 @@ public class SimulationStatus implements Monitorable { public Collection getActiveMotors() { List activeList = new ArrayList(); for( MotorClusterState state: this.motorStateList ){ - if (this.configuration.isComponentActive( state.getMount() { + if (this.configuration.isComponentActive( state.getMount())) { activeList.add( state ); } }