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>");
|
writeln("</wind>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
writeElement("windmodeltype", cond.getWindModelType().toStringValue());
|
||||||
|
|
||||||
writeElement("launchaltitude", cond.getLaunchAltitude());
|
writeElement("launchaltitude", cond.getLaunchAltitude());
|
||||||
writeElement("launchlatitude", cond.getLaunchLatitude());
|
writeElement("launchlatitude", cond.getLaunchLatitude());
|
||||||
writeElement("launchlongitude", cond.getLaunchLongitude());
|
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.AbstractElementHandler;
|
||||||
import info.openrocket.core.file.simplesax.ElementHandler;
|
import info.openrocket.core.file.simplesax.ElementHandler;
|
||||||
import info.openrocket.core.file.simplesax.PlainTextHandler;
|
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.FlightConfigurationId;
|
||||||
import info.openrocket.core.rocketcomponent.Rocket;
|
import info.openrocket.core.rocketcomponent.Rocket;
|
||||||
import info.openrocket.core.simulation.SimulationOptions;
|
import info.openrocket.core.simulation.SimulationOptions;
|
||||||
@ -53,85 +54,95 @@ class SimulationConditionsHandler extends AbstractElementHandler {
|
|||||||
} catch (NumberFormatException ignore) {
|
} catch (NumberFormatException ignore) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.equals("configid")) {
|
switch (element) {
|
||||||
this.idToSet = new FlightConfigurationId(content);
|
case "configid" -> this.idToSet = new FlightConfigurationId(content);
|
||||||
} else if (element.equals("launchrodlength")) {
|
case "launchrodlength" -> {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch rod length defined, ignoring.");
|
warnings.add("Illegal launch rod length defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
options.setLaunchRodLength(d);
|
options.setLaunchRodLength(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchrodangle")) {
|
case "launchrodangle" -> {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch rod angle defined, ignoring.");
|
warnings.add("Illegal launch rod angle defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
options.setLaunchRodAngle(d * Math.PI / 180);
|
options.setLaunchRodAngle(d * Math.PI / 180);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchroddirection")) {
|
case "launchroddirection" -> {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch rod direction defined, ignoring.");
|
warnings.add("Illegal launch rod direction defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
options.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
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")) {
|
// TODO: remove once support for OR 23.09 and prior is dropped
|
||||||
windHandler.storeSettings(options, warnings);
|
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")) {
|
case "wind" -> windHandler.storeSettings(options, warnings);
|
||||||
if (Double.isNaN(d)) {
|
case "windmodeltype" -> {
|
||||||
warnings.add("Illegal launch altitude defined, ignoring.");
|
options.setWindModelType(WindModelType.fromString(content));
|
||||||
} else {
|
|
||||||
options.setLaunchAltitude(d);
|
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchlatitude")) {
|
|
||||||
if (Double.isNaN(d)) {
|
case "launchaltitude" -> {
|
||||||
warnings.add("Illegal launch latitude defined, ignoring.");
|
if (Double.isNaN(d)) {
|
||||||
} else {
|
warnings.add("Illegal launch altitude defined, ignoring.");
|
||||||
options.setLaunchLatitude(d);
|
} else {
|
||||||
|
options.setLaunchAltitude(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchlongitude")) {
|
case "launchlatitude" -> {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch longitude.");
|
warnings.add("Illegal launch latitude defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
options.setLaunchLongitude(d);
|
options.setLaunchLatitude(d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (element.equals("geodeticmethod")) {
|
case "launchlongitude" -> {
|
||||||
GeodeticComputationStrategy gcs = (GeodeticComputationStrategy) DocumentConfig.findEnum(content,
|
if (Double.isNaN(d)) {
|
||||||
GeodeticComputationStrategy.class);
|
warnings.add("Illegal launch longitude.");
|
||||||
if (gcs != null) {
|
} else {
|
||||||
options.setGeodeticComputation(gcs);
|
options.setLaunchLongitude(d);
|
||||||
} else {
|
}
|
||||||
warnings.add("Unknown geodetic computation method '" + content + "'");
|
|
||||||
}
|
}
|
||||||
} else if (element.equals("atmosphere")) {
|
case "geodeticmethod" -> {
|
||||||
atmosphereHandler.storeSettings(options, warnings);
|
GeodeticComputationStrategy gcs = (GeodeticComputationStrategy) DocumentConfig.findEnum(content,
|
||||||
} else if (element.equals("timestep")) {
|
GeodeticComputationStrategy.class);
|
||||||
if (Double.isNaN(d) || d <= 0) {
|
if (gcs != null) {
|
||||||
warnings.add("Illegal time step defined, ignoring.");
|
options.setGeodeticComputation(gcs);
|
||||||
} else {
|
} else {
|
||||||
options.setTimeStep(d);
|
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;
|
package info.openrocket.core.models.wind;
|
||||||
|
|
||||||
public enum WindModelType {
|
public enum WindModelType {
|
||||||
PINK_NOISE,
|
PINK_NOISE("PinkNoise"),
|
||||||
MULTI_LEVEL
|
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