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.warning7 = Already added a launch shoe, ignoring rail button '%s'.
RASAeroExport.warning8 = Instance count of '%s' equals %d, defaulting to 2. RASAeroExport.warning8 = Instance count of '%s' equals %d, defaulting to 2.
RASAeroExport.warning9 = Unsupported component '%s', ignoring. RASAeroExport.warning9 = Unsupported component '%s', ignoring.
RASAeroExport.warning10 = Stage '%s' can only contain a body tube, ignoring other %d component(s). RASAeroExport.warning10 = Rocket should have no more then 3 stages (excl. boosters) in total.\nIgnoring other stage(s).
RASAeroExport.warning11 = Stage '%s' can only contain a body tube and transition shoulder, ignoring other %d component(s). RASAeroExport.warning11 = Empty simulation '%s', ignoring.
RASAeroExport.warning12 = Rocket should have no more then 3 stages (excl. boosters) in total.\nIgnoring other stage(s). RASAeroExport.warning12 = No motors found in simulation '%s', ignoring.
RASAeroExport.warning13 = Empty 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.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.error1 = Unsupported component: %s. RASAeroExport.error1 = Unsupported component: %s.
RASAeroExport.error2 = Length of '%s' must be greater than 0. RASAeroExport.error2 = Length of '%s' must be greater than 0.
RASAeroExport.error3 = Diameter 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.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.error29 = Boattail length may not be zero.
RASAeroExport.error30 = Boattail rear diameter 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
SaveAsFileChooser.illegalFilename.title = Illegal filename SaveAsFileChooser.illegalFilename.title = Illegal filename

View File

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

View File

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

View File

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