Merge pull request #1436 from ptsongalis/unstable

Feature Request 1373 - Adds a warning when there is no recovery device for a simulation
This commit is contained in:
SiboVG 2022-06-13 01:34:11 +02:00 committed by GitHub
commit 1c129e64a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 1 deletions

View File

@ -1787,6 +1787,7 @@ Warning.PARALLEL_FINS = Too many parallel fins
Warning.SUPERSONIC = Body calculations may not be entirely accurate at supersonic speeds.
Warning.RECOVERY_LAUNCH_ROD = Recovery device device deployed while on the launch guide.
Warning.RECOVERY_HIGH_SPEED = Recovery device deployment at high speed
Warning.NO_RECOVERY_DEVICE = No recovery device defined in the simulation.
Warning.TUMBLE_UNDER_THRUST = Stage began to tumble under thrust.
Warning.EVENT_AFTER_LANDING = Flight Event occurred after landing:
Warning.ZERO_LENGTH_BODY = Zero length bodies may not result in accurate simulations.

View File

@ -375,6 +375,8 @@ public abstract class Warning {
////Recovery device opened while motor still burning.
public static final Warning RECOVERY_DEPLOYMENT_WHILE_BURNING = new Other(trans.get("Warning.RECOVERY_DEPLOYMENT_WHILE_BURNING"));
////No recovery device for simulation
public static final Warning NO_RECOVERY_DEVICE = new Other(trans.get("Warning.NO_RECOVERY_DEVICE"));
//// Invalid parameter encountered, ignoring.
public static final Warning FILE_INVALID_PARAMETER = new Other(trans.get("Warning.FILE_INVALID_PARAMETER"));

View File

@ -547,7 +547,18 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
updateMotors();
updateActiveInstances();
}
/**
* Return true if rocket has a RecoveryDevice
*/
public boolean hasRecoveryDevice() {
if (fcid.hasError()) {
return false;
}
return this.getRocket().hasRecoveryDevice();
}
/////////////// Helper methods ///////////////
/**

View File

@ -427,6 +427,19 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
}
}
/**
* Return true if any of this component's children are a RecoveryDevice
*/
public boolean hasRecoveryDevice() {
Iterator<RocketComponent> iterator = this.iterator();
while (iterator.hasNext()) {
RocketComponent child = iterator.next();
if (child instanceof RecoveryDevice) {
return true;
}
}
return false;
}
////////////// Methods that may not be overridden ////////////

View File

@ -344,6 +344,11 @@ public class BasicEventSimulationEngine implements SimulationEngine {
}
}
// Add a warning if there is no recovery device defined.
if (!currentStatus.getConfiguration().hasRecoveryDevice()) {
currentStatus.getWarnings().add(Warning.NO_RECOVERY_DEVICE);
}
// Handle event
log.trace("Handling event " + event);
switch (event.getType()) {