Refactor RASAero motor conversion
This commit is contained in:
parent
b6af7220c6
commit
a7c63260c5
@ -2,6 +2,8 @@ package net.sf.openrocket.file.rasaero;
|
|||||||
|
|
||||||
import net.sf.openrocket.logging.WarningSet;
|
import net.sf.openrocket.logging.WarningSet;
|
||||||
import net.sf.openrocket.motor.Manufacturer;
|
import net.sf.openrocket.motor.Manufacturer;
|
||||||
|
import net.sf.openrocket.motor.Motor;
|
||||||
|
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||||
import net.sf.openrocket.rocketcomponent.DeploymentConfiguration;
|
import net.sf.openrocket.rocketcomponent.DeploymentConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
import net.sf.openrocket.rocketcomponent.ExternalComponent;
|
||||||
import net.sf.openrocket.rocketcomponent.FinSet;
|
import net.sf.openrocket.rocketcomponent.FinSet;
|
||||||
@ -10,6 +12,7 @@ import net.sf.openrocket.util.Color;
|
|||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
|
import net.sf.openrocket.file.rasaero.export.RASAeroSaver.RASAeroExportException;
|
||||||
@ -371,6 +374,29 @@ public class RASAeroCommonConstants {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format an OpenRocket motor as a RASAero motor.
|
||||||
|
* @param motors list of available RASAero motors
|
||||||
|
* @param ORMotor OpenRocket motor
|
||||||
|
* @return a RASAero String representation of a motor
|
||||||
|
*/
|
||||||
|
public static String OPENROCKET_TO_RASAERO_MOTOR(List<ThrustCurveMotor> motors, Motor ORMotor, WarningSet warnings) {
|
||||||
|
if (!(ORMotor instanceof ThrustCurveMotor)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ThrustCurveMotor motor : motors) {
|
||||||
|
if (ORMotor.getDesignation().equals(motor.getDesignation()) &&
|
||||||
|
((ThrustCurveMotor) ORMotor).getManufacturer().matches(motor.getManufacturer().getDisplayName())) {
|
||||||
|
return motor.getDesignation() +
|
||||||
|
" (" + OPENROCKET_TO_RASAERO_MANUFACTURER(motor.getManufacturer()) + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
warnings.add(String.format("Could not find RASAero motor for '%s'", ORMotor.getDesignation()));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static String OPENROCKET_TO_RASAERO_MANUFACTURER(Manufacturer manufacturer) {
|
public static String OPENROCKET_TO_RASAERO_MANUFACTURER(Manufacturer manufacturer) {
|
||||||
if (manufacturer.matches("AeroTech")) {
|
if (manufacturer.matches("AeroTech")) {
|
||||||
return "AT";
|
return "AT";
|
||||||
|
@ -139,7 +139,7 @@ public class SimulationDTO {
|
|||||||
switch (stageNr) {
|
switch (stageNr) {
|
||||||
// Sustainer
|
// Sustainer
|
||||||
case 0:
|
case 0:
|
||||||
setSustainerEngine(getRASAeroMotor(motors, motorConfig.getMotor(), warnings));
|
setSustainerEngine(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_MOTOR(motors, motorConfig.getMotor(), warnings));
|
||||||
setSustainerLaunchWt(stage.getSectionMass() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_WEIGHT);
|
setSustainerLaunchWt(stage.getSectionMass() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_WEIGHT);
|
||||||
|
|
||||||
// Calculate CG of sustainer
|
// Calculate CG of sustainer
|
||||||
@ -151,7 +151,7 @@ public class SimulationDTO {
|
|||||||
break;
|
break;
|
||||||
// Booster 1
|
// Booster 1
|
||||||
case 1:
|
case 1:
|
||||||
setBooster1Engine(getRASAeroMotor(motors, motorConfig.getMotor(), warnings));
|
setBooster1Engine(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_MOTOR(motors, motorConfig.getMotor(), warnings));
|
||||||
|
|
||||||
// Aggregate mass of sustainer and booster 1
|
// Aggregate mass of sustainer and booster 1
|
||||||
setBooster1LaunchWt(rocket.getChild(0).getSectionMass() + stage.getSectionMass()
|
setBooster1LaunchWt(rocket.getChild(0).getSectionMass() + stage.getSectionMass()
|
||||||
@ -171,7 +171,7 @@ public class SimulationDTO {
|
|||||||
break;
|
break;
|
||||||
// Booster 2
|
// Booster 2
|
||||||
case 2:
|
case 2:
|
||||||
setBooster2Engine(getRASAeroMotor(motors, motorConfig.getMotor(), warnings));
|
setBooster2Engine(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_MOTOR(motors, motorConfig.getMotor(), warnings));
|
||||||
|
|
||||||
// Aggregate mass of sustainer, booster 1 and booster 2
|
// Aggregate mass of sustainer, booster 1 and booster 2
|
||||||
setBooster2LaunchWt(rocket.getChild(0).getSectionMass() + rocket.getChild(1).getSectionMass() +
|
setBooster2LaunchWt(rocket.getChild(0).getSectionMass() + rocket.getChild(1).getSectionMass() +
|
||||||
@ -196,29 +196,6 @@ public class SimulationDTO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Format an OpenRocket motor as a RASAero motor.
|
|
||||||
* @param motors list of available RASAero motors
|
|
||||||
* @param ORMotor OpenRocket motor
|
|
||||||
* @return a RASAero String representation of a motor
|
|
||||||
*/
|
|
||||||
private String getRASAeroMotor(List<ThrustCurveMotor> motors, Motor ORMotor, WarningSet warnings) {
|
|
||||||
if (!(ORMotor instanceof ThrustCurveMotor)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ThrustCurveMotor motor : motors) {
|
|
||||||
if (ORMotor.getDesignation().equals(motor.getDesignation()) &&
|
|
||||||
((ThrustCurveMotor) ORMotor).getManufacturer().matches(motor.getManufacturer().getDisplayName())) {
|
|
||||||
return motor.getDesignation() +
|
|
||||||
" (" + RASAeroCommonConstants.OPENROCKET_TO_RASAERO_MANUFACTURER(motor.getManufacturer()) + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
warnings.add(String.format("Could not find RASAero motor for '%s'", ORMotor.getDesignation()));
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getSustainerEngine() {
|
public String getSustainerEngine() {
|
||||||
return sustainerEngine;
|
return sustainerEngine;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user