Merge pull request #1854 from SiboVG/issue-1848
[#1848] Allow only booster stage to be active
This commit is contained in:
commit
6d1b32cff4
@ -209,16 +209,16 @@ public class Rocket extends ComponentAssembly {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the topmost stage, only taking into account active stages from the flight configuration.
|
* Get the topmost stage (including boosters), only taking into account active stages from the flight configuration.
|
||||||
* @param config flight configuration dictating which stages are active
|
* @param config flight configuration dictating which stages are active
|
||||||
* @return the topmost active stage, or null if there are no active stages.
|
* @return the topmost active stage, or null if there are no active stages.
|
||||||
*/
|
*/
|
||||||
public AxialStage getTopmostStage(FlightConfiguration config) {
|
public AxialStage getTopmostStage(FlightConfiguration config) {
|
||||||
if (config == null) return null;
|
if (config == null) return null;
|
||||||
|
|
||||||
for (int i = 0; i < getChildCount(); i++) {
|
for (AxialStage stage : getStageList()) {
|
||||||
if (getChild(i) instanceof AxialStage && config.isStageActive(getChild(i).getStageNumber())) {
|
if (config.isStageActive(stage.getStageNumber())) {
|
||||||
return (AxialStage) getChild(i);
|
return stage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -235,6 +235,34 @@ public class DisableStageTest extends BaseTestCase {
|
|||||||
compareSims(simOriginal, simDisabled, delta);
|
compareSims(simOriginal, simDisabled, delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test whether the simulations run when only the booster stage is active.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testBooster3() {
|
||||||
|
Rocket rocketDisabled = TestRockets.makeFalcon9Heavy();
|
||||||
|
|
||||||
|
FlightConfigurationId fid = new FlightConfigurationId(TestRockets.FALCON_9H_FCID_1);
|
||||||
|
Simulation simDisabled = new Simulation(rocketDisabled);
|
||||||
|
simDisabled.setFlightConfigurationId(fid);
|
||||||
|
simDisabled.getOptions().setISAAtmosphere(true);
|
||||||
|
simDisabled.getOptions().setTimeStep(0.05);
|
||||||
|
|
||||||
|
//// Test only enabling the booster stage (test for GitHub issue #1848)
|
||||||
|
simDisabled.getActiveConfiguration().setOnlyStage(2);
|
||||||
|
|
||||||
|
//// Test that the top stage is the booster stage
|
||||||
|
Assert.assertEquals(rocketDisabled.getTopmostStage(simDisabled.getActiveConfiguration()), rocketDisabled.getStage(2));
|
||||||
|
|
||||||
|
try { // Just check that the simulation runs without exceptions
|
||||||
|
simDisabled.simulate();
|
||||||
|
} catch (SimulationException e) {
|
||||||
|
if (!(e instanceof MotorIgnitionException)) {
|
||||||
|
Assert.fail("Simulation failed: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare simActual to simExpected and fail the unit test if there was an error during simulation or
|
* Compare simActual to simExpected and fail the unit test if there was an error during simulation or
|
||||||
* the two don't match.
|
* the two don't match.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user