Implement RASAero launch site exporting
This commit is contained in:
parent
7bef89c7da
commit
c60fc87538
@ -1,12 +1,121 @@
|
|||||||
package net.sf.openrocket.file.rasaero.export;
|
package net.sf.openrocket.file.rasaero.export;
|
||||||
|
|
||||||
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.document.Simulation;
|
||||||
|
import net.sf.openrocket.file.rasaero.CustomDoubleAdapter;
|
||||||
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
|
import net.sf.openrocket.file.rasaero.RASAeroCommonConstants;
|
||||||
|
import net.sf.openrocket.logging.ErrorSet;
|
||||||
|
import net.sf.openrocket.logging.WarningSet;
|
||||||
|
import net.sf.openrocket.simulation.SimulationOptions;
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
|
import net.sf.openrocket.startup.Preferences;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
|
||||||
@XmlRootElement(name = RASAeroCommonConstants.LAUNCH_SITE)
|
@XmlRootElement(name = RASAeroCommonConstants.LAUNCH_SITE)
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class LaunchSiteDTO {
|
public class LaunchSiteDTO {
|
||||||
|
|
||||||
|
@XmlElement(name = RASAeroCommonConstants.LAUNCH_ALTITUDE)
|
||||||
|
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
|
||||||
|
private Double altitude = 0d;
|
||||||
|
@XmlElement(name = RASAeroCommonConstants.LAUNCH_PRESSURE)
|
||||||
|
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
|
||||||
|
private Double pressure = 0d;
|
||||||
|
@XmlElement(name = RASAeroCommonConstants.LAUNCH_ROD_ANGLE)
|
||||||
|
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
|
||||||
|
private Double rodAngle = 0d;
|
||||||
|
@XmlElement(name = RASAeroCommonConstants.LAUNCH_ROD_LENGTH)
|
||||||
|
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
|
||||||
|
private Double rodLength = 0d;
|
||||||
|
@XmlElement(name = RASAeroCommonConstants.LAUNCH_TEMPERATURE)
|
||||||
|
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
|
||||||
|
private Double temperature = 0d;
|
||||||
|
@XmlElement(name = RASAeroCommonConstants.LAUNCH_WIND_SPEED)
|
||||||
|
@XmlJavaTypeAdapter(CustomDoubleAdapter.class)
|
||||||
|
private Double windSpeed = 0d;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We need a default, no-args constructor.
|
||||||
|
*/
|
||||||
|
public LaunchSiteDTO() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LaunchSiteDTO(OpenRocketDocument document, WarningSet warnings, ErrorSet errors) {
|
||||||
|
for (Simulation sim : document.getSimulations()) {
|
||||||
|
SimulationOptions options = sim.getSimulatedConditions();
|
||||||
|
if (options == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
setAltitude(options.getLaunchAltitude() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ALTITUDE);
|
||||||
|
setPressure(options.getLaunchPressure() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_PRESSURE);
|
||||||
|
setTemperature(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TEMPERATURE(options.getLaunchTemperature()));
|
||||||
|
setRodAngle(options.getLaunchRodAngle() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ANGLE);
|
||||||
|
setRodLength(options.getLaunchRodLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
|
||||||
|
setWindSpeed(options.getWindSpeedAverage() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_SPEED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we can't get settings from the sims, use the launch site settings from the preferences
|
||||||
|
Preferences prefs = Application.getPreferences();
|
||||||
|
setAltitude(prefs.getLaunchAltitude() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ALTITUDE);
|
||||||
|
setPressure(prefs.getLaunchPressure() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_PRESSURE);
|
||||||
|
setTemperature(RASAeroCommonConstants.OPENROCKET_TO_RASAERO_TEMPERATURE(prefs.getLaunchTemperature()));
|
||||||
|
setRodAngle(prefs.getLaunchRodAngle() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_ANGLE);
|
||||||
|
setRodLength(prefs.getLaunchRodLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
|
||||||
|
setWindSpeed(prefs.getWindSpeedAverage() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_SPEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getAltitude() {
|
||||||
|
return altitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAltitude(Double altitude) {
|
||||||
|
this.altitude = altitude;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getPressure() {
|
||||||
|
return pressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPressure(Double pressure) {
|
||||||
|
this.pressure = pressure;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getRodAngle() {
|
||||||
|
return rodAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRodAngle(Double rodAngle) {
|
||||||
|
this.rodAngle = rodAngle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getRodLength() {
|
||||||
|
return rodLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRodLength(Double rodLength) {
|
||||||
|
this.rodLength = rodLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getTemperature() {
|
||||||
|
return temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemperature(Double temperature) {
|
||||||
|
this.temperature = temperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getWindSpeed() {
|
||||||
|
return windSpeed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWindSpeed(Double windSpeed) {
|
||||||
|
this.windSpeed = windSpeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,9 @@ public class RASAeroSaver extends RocketSaver {
|
|||||||
private RASAeroDocumentDTO toRASAeroDocumentDTO(OpenRocketDocument doc, WarningSet warnings, ErrorSet errors) throws RASAeroExportException {
|
private RASAeroDocumentDTO toRASAeroDocumentDTO(OpenRocketDocument doc, WarningSet warnings, ErrorSet errors) throws RASAeroExportException {
|
||||||
RASAeroDocumentDTO rad = new RASAeroDocumentDTO();
|
RASAeroDocumentDTO rad = new RASAeroDocumentDTO();
|
||||||
rad.setDesign(toRocketDesignDTO(doc.getRocket(), warnings, errors));
|
rad.setDesign(toRocketDesignDTO(doc.getRocket(), warnings, errors));
|
||||||
|
rad.setLaunchSite(toLaunchSiteDTO(doc, warnings, errors));
|
||||||
rad.setSimulationList(toSimulationListDTO(doc, warnings, errors));
|
rad.setSimulationList(toSimulationListDTO(doc, warnings, errors));
|
||||||
|
|
||||||
return rad;
|
return rad;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +96,17 @@ public class RASAeroSaver extends RocketSaver {
|
|||||||
return new RocketDesignDTO(rocket, warnings, errors);
|
return new RocketDesignDTO(rocket, warnings, errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create RASAero launch site settings.
|
||||||
|
* @param document document that contains simulations to take the launch site settings from
|
||||||
|
* @param warnings list to add export warnings to
|
||||||
|
* @param errors list to add export errors to
|
||||||
|
* @return the RASAero launch site settings
|
||||||
|
*/
|
||||||
|
private LaunchSiteDTO toLaunchSiteDTO(OpenRocketDocument document, WarningSet warnings, ErrorSet errors) {
|
||||||
|
return new LaunchSiteDTO(document, warnings, errors);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a list of simulations.
|
* Create a list of simulations.
|
||||||
* @param document document that contains simulations
|
* @param document document that contains simulations
|
||||||
|
Loading…
x
Reference in New Issue
Block a user