Throw error when wrong component in booster stage

This commit is contained in:
SiboVG 2023-04-08 23:43:56 +02:00
parent 99250aa621
commit 8cccf49a8f
5 changed files with 19 additions and 22 deletions

View File

@ -1378,12 +1378,10 @@ RASAeroExport.warning6 = Already added a launch lug, ignoring rail button '%s'.
RASAeroExport.warning7 = Already added a launch shoe, ignoring rail button '%s'.
RASAeroExport.warning8 = Instance count of '%s' equals %d, defaulting to 2.
RASAeroExport.warning9 = Unsupported component '%s', ignoring.
RASAeroExport.warning10 = Stage '%s' can only contain a body tube, ignoring other %d component(s).
RASAeroExport.warning11 = Stage '%s' can only contain a body tube and transition shoulder, ignoring other %d component(s).
RASAeroExport.warning12 = Rocket should have no more then 3 stages (excl. boosters) in total.\nIgnoring other stage(s).
RASAeroExport.warning13 = Empty simulation '%s', ignoring.
RASAeroExport.warning14 = No motors found in simulation '%s', ignoring.
RASAeroExport.warning15 = <html>Stage %s has no motor.<br>&nbsp --> When adding a motor in RASAero, don't forget to update the stage mass and CG.</html>
RASAeroExport.warning10 = Rocket should have no more then 3 stages (excl. boosters) in total.\nIgnoring other stage(s).
RASAeroExport.warning11 = Empty simulation '%s', ignoring.
RASAeroExport.warning12 = No motors found in simulation '%s', ignoring.
RASAeroExport.warning13 = <html>Stage %s has no motor.<br>&nbsp --> When adding a motor in RASAero, don't forget to update the stage mass and CG.</html>
RASAeroExport.error1 = Unsupported component: %s.
RASAeroExport.error2 = Length of '%s' must be greater than 0.
RASAeroExport.error3 = Diameter of '%s' must be greater than 0.
@ -1414,6 +1412,8 @@ RASAeroExport.error27 = Transition '%s' has no previous component.
RASAeroExport.error28 = Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not %f.
RASAeroExport.error29 = Boattail length may not be zero.
RASAeroExport.error30 = Boattail rear diameter may not be zero.
RASAeroExport.error31 = Stage '%s' can only contain a body tube (incl. shoulder transition), ignoring other %d component(s).
RASAeroExport.error32 = Boattails can only be added to the last stage.
! SaveAsFileChooser
SaveAsFileChooser.illegalFilename.title = Illegal filename

View File

@ -169,24 +169,21 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
}
} else {
// If this booster is the last stage, and the last component is a transition, it could be a boattail
if (stageNr == rocket.getChildCount() - 1 && (comp instanceof Transition && !(comp instanceof NoseCone)) &&
i == stage.getChildCount() - 1) {
boolean isBoattail = (comp instanceof Transition && !(comp instanceof NoseCone)) && i == stage.getChildCount() - 1;
if (stageNr == rocket.getChildCount() - 1 && isBoattail) {
Transition transition = (Transition) comp;
setBoattailLength(transition.getLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
setBoattailRearDiameter(transition.getAftRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
}
// Case: normal body tube
if (stage.getChildPosition(firstTube) == 0) {
warnings.add(String.format(trans.get("RASAeroExport.warning10"),
stage.getName(), stage.getChildCount() - i));
}
// Case: body tube with transition shoulder
else {
warnings.add(String.format(trans.get("RASAeroExport.warning11"),
stage.getName(), stage.getChildCount() - i));
String msg = String.format(trans.get("RASAeroExport.error31"), stage.getName(), stage.getChildCount() - i);
if (isBoattail) {
msg = "<html>" + msg + "<br>&nbsp;" + trans.get("RASAeroExport.error32") + "</html>";
}
errors.add(msg);
break;
}
}

View File

@ -76,7 +76,7 @@ public class RocketDesignDTO {
public RocketDesignDTO(Rocket rocket, WarningSet warnings, ErrorSet errors) {
setComments(rocket.getComment());
if (rocket.getChildCount() > 3) {
warnings.add(trans.get("RASAeroExport.warning12"));
warnings.add(trans.get("RASAeroExport.warning10"));
}
setUseBooster1(rocket.getChildCount() >= 2);
setUseBooster2(rocket.getChildCount() == 3);

View File

@ -130,12 +130,12 @@ public class SimulationDTO {
FlightConfigurationId fcid = simulation != null ? simulation.getFlightConfigurationId() : null;
if (simulation != null && fcid == null) {
warnings.add(String.format(trans.get("RASAeroExport.warning13"), simulationName));
warnings.add(String.format(trans.get("RASAeroExport.warning11"), simulationName));
return;
}
if (mounts.isEmpty()) {
warnings.add(String.format(trans.get("RASAeroExport.warning14"), simulationName));
warnings.add(String.format(trans.get("RASAeroExport.warning12"), simulationName));
return;
}
@ -170,7 +170,7 @@ public class SimulationDTO {
// Add friendly reminder to user
if (motor == null) {
warnings.add(String.format(trans.get("RASAeroExport.warning15"), stage.getName()));
warnings.add(String.format(trans.get("RASAeroExport.warning13"), stage.getName()));
}
// Add the simulation info for each stage

View File

@ -160,7 +160,7 @@ public class SimulationHandler extends AbstractElementHandler {
}
MotorMount mount = getMotorMountForStage(stageNr);
if (mount == null) {
warnings.add("No motor mount found for stage " + stageNr + ". Ignoring motor.");
warnings.add("No motor mount found for stage " + stageNr + ". Ignoring motor.");
return null;
}
MotorConfiguration motorConfig = new MotorConfiguration(mount, id);