Store which wind model type to use
This commit is contained in:
parent
f645f580ec
commit
93bf3df742
@ -361,6 +361,8 @@ public class OpenRocketSaver extends RocketSaver {
|
||||
writeln("</wind>");
|
||||
}
|
||||
|
||||
writeElement("windmodeltype", cond.getWindModelType().toStringValue());
|
||||
|
||||
writeElement("launchaltitude", cond.getLaunchAltitude());
|
||||
writeElement("launchlatitude", cond.getLaunchLatitude());
|
||||
writeElement("launchlongitude", cond.getLaunchLongitude());
|
||||
|
@ -7,6 +7,7 @@ import info.openrocket.core.file.DocumentLoadingContext;
|
||||
import info.openrocket.core.file.simplesax.AbstractElementHandler;
|
||||
import info.openrocket.core.file.simplesax.ElementHandler;
|
||||
import info.openrocket.core.file.simplesax.PlainTextHandler;
|
||||
import info.openrocket.core.models.wind.WindModelType;
|
||||
import info.openrocket.core.rocketcomponent.FlightConfigurationId;
|
||||
import info.openrocket.core.rocketcomponent.Rocket;
|
||||
import info.openrocket.core.simulation.SimulationOptions;
|
||||
@ -53,85 +54,95 @@ class SimulationConditionsHandler extends AbstractElementHandler {
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
|
||||
if (element.equals("configid")) {
|
||||
this.idToSet = new FlightConfigurationId(content);
|
||||
} else if (element.equals("launchrodlength")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod length defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchRodLength(d);
|
||||
switch (element) {
|
||||
case "configid" -> this.idToSet = new FlightConfigurationId(content);
|
||||
case "launchrodlength" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod length defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchRodLength(d);
|
||||
}
|
||||
}
|
||||
} else if (element.equals("launchrodangle")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod angle defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchRodAngle(d * Math.PI / 180);
|
||||
case "launchrodangle" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod angle defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchRodAngle(d * Math.PI / 180);
|
||||
}
|
||||
}
|
||||
} else if (element.equals("launchroddirection")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod direction defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
||||
case "launchroddirection" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod direction defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: remove once support for OR 23.09 and prior is dropped
|
||||
else if (element.equals("windaverage")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal average windspeed defined, ignoring.");
|
||||
} else {
|
||||
options.getPinkNoiseWindModel().setAverage(d);
|
||||
}
|
||||
} else if (element.equals("windturbulence")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal wind turbulence intensity defined, ignoring.");
|
||||
} else {
|
||||
options.getPinkNoiseWindModel().setTurbulenceIntensity(d);
|
||||
}
|
||||
} else if (element.equals("winddirection")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal wind direction defined, ignoring.");
|
||||
} else {
|
||||
options.getPinkNoiseWindModel().setDirection(d);
|
||||
}
|
||||
}
|
||||
|
||||
else if (element.equals("wind")) {
|
||||
windHandler.storeSettings(options, warnings);
|
||||
}
|
||||
// TODO: remove once support for OR 23.09 and prior is dropped
|
||||
case "windaverage" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal average windspeed defined, ignoring.");
|
||||
} else {
|
||||
options.getPinkNoiseWindModel().setAverage(d);
|
||||
}
|
||||
}
|
||||
case "windturbulence" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal wind turbulence intensity defined, ignoring.");
|
||||
} else {
|
||||
options.getPinkNoiseWindModel().setTurbulenceIntensity(d);
|
||||
}
|
||||
}
|
||||
case "winddirection" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal wind direction defined, ignoring.");
|
||||
} else {
|
||||
options.getPinkNoiseWindModel().setDirection(d);
|
||||
}
|
||||
}
|
||||
|
||||
else if (element.equals("launchaltitude")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch altitude defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchAltitude(d);
|
||||
case "wind" -> windHandler.storeSettings(options, warnings);
|
||||
case "windmodeltype" -> {
|
||||
options.setWindModelType(WindModelType.fromString(content));
|
||||
}
|
||||
} else if (element.equals("launchlatitude")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch latitude defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchLatitude(d);
|
||||
|
||||
case "launchaltitude" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch altitude defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchAltitude(d);
|
||||
}
|
||||
}
|
||||
} else if (element.equals("launchlongitude")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch longitude.");
|
||||
} else {
|
||||
options.setLaunchLongitude(d);
|
||||
case "launchlatitude" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch latitude defined, ignoring.");
|
||||
} else {
|
||||
options.setLaunchLatitude(d);
|
||||
}
|
||||
}
|
||||
} else if (element.equals("geodeticmethod")) {
|
||||
GeodeticComputationStrategy gcs = (GeodeticComputationStrategy) DocumentConfig.findEnum(content,
|
||||
GeodeticComputationStrategy.class);
|
||||
if (gcs != null) {
|
||||
options.setGeodeticComputation(gcs);
|
||||
} else {
|
||||
warnings.add("Unknown geodetic computation method '" + content + "'");
|
||||
case "launchlongitude" -> {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch longitude.");
|
||||
} else {
|
||||
options.setLaunchLongitude(d);
|
||||
}
|
||||
}
|
||||
} else if (element.equals("atmosphere")) {
|
||||
atmosphereHandler.storeSettings(options, warnings);
|
||||
} else if (element.equals("timestep")) {
|
||||
if (Double.isNaN(d) || d <= 0) {
|
||||
warnings.add("Illegal time step defined, ignoring.");
|
||||
} else {
|
||||
options.setTimeStep(d);
|
||||
case "geodeticmethod" -> {
|
||||
GeodeticComputationStrategy gcs = (GeodeticComputationStrategy) DocumentConfig.findEnum(content,
|
||||
GeodeticComputationStrategy.class);
|
||||
if (gcs != null) {
|
||||
options.setGeodeticComputation(gcs);
|
||||
} else {
|
||||
warnings.add("Unknown geodetic computation method '" + content + "'");
|
||||
}
|
||||
}
|
||||
case "atmosphere" -> atmosphereHandler.storeSettings(options, warnings);
|
||||
case "timestep" -> {
|
||||
if (Double.isNaN(d) || d <= 0) {
|
||||
warnings.add("Illegal time step defined, ignoring.");
|
||||
} else {
|
||||
options.setTimeStep(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,25 @@
|
||||
package info.openrocket.core.models.wind;
|
||||
|
||||
public enum WindModelType {
|
||||
PINK_NOISE,
|
||||
MULTI_LEVEL
|
||||
PINK_NOISE("PinkNoise"),
|
||||
MULTI_LEVEL("MultiLevel");
|
||||
|
||||
private final String stringValue;
|
||||
|
||||
WindModelType(String stringValue) {
|
||||
this.stringValue = stringValue;
|
||||
}
|
||||
|
||||
public String toStringValue() {
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
public static WindModelType fromString(String stringValue) {
|
||||
for (WindModelType type : WindModelType.values()) {
|
||||
if (type.stringValue.equalsIgnoreCase(stringValue)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No enum constant " + WindModelType.class.getCanonicalName() + " for string value: " + stringValue);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user