[Bugfix] Cleaned up simulation and configuration Ids loading
- Simulations now load the configuration ids corresponding to it's file entry. - involved removing redundand flightconfig id fields - FROM simulation conditions and simulation options - TO "Simulation" - Distilled some unit tests to use all rockets from the TestRocket class. - Fixed a few warnings
This commit is contained in:
parent
1226666a41
commit
39420ddfc0
@ -281,7 +281,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
||||
}
|
||||
for (Simulation s : getSimulations()) {
|
||||
// Assumes modifiable collection - which it is
|
||||
if (configId.equals(s.getOptions().getId())) {
|
||||
if (configId.equals(s.getId())) {
|
||||
removeSimulation(s);
|
||||
}
|
||||
}
|
||||
@ -637,7 +637,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
||||
str.append(">> Dumping simulation list:\n");
|
||||
int simNum = 0;
|
||||
for( Simulation s : this.simulations ){
|
||||
str.append(String.format(" [%d] %s (%s) \n", simNum, s.getName(), s.getOptions().getId().toShortKey() ));
|
||||
str.append(String.format(" [%d] %s (%s) \n", simNum, s.getName(), s.getId().toShortKey() ));
|
||||
simNum++;
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
private SafetyMutex mutex = SafetyMutex.newInstance();
|
||||
|
||||
private final Rocket rocket;
|
||||
FlightConfigurationId configId = FlightConfigurationId.ERROR_FCID;
|
||||
|
||||
private String name = "";
|
||||
|
||||
@ -77,7 +78,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
|
||||
/** The conditions to use */
|
||||
// TODO: HIGH: Change to use actual conditions class??
|
||||
private SimulationOptions options;
|
||||
private SimulationOptions options = new SimulationOptions();
|
||||
|
||||
private ArrayList<SimulationExtension> simulationExtensions = new ArrayList<SimulationExtension>();
|
||||
|
||||
@ -109,13 +110,12 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
this.rocket = rocket;
|
||||
this.status = Status.NOT_SIMULATED;
|
||||
|
||||
options = new SimulationOptions(rocket);
|
||||
|
||||
DefaultSimulationOptionFactory f = Application.getInjector().getInstance(DefaultSimulationOptionFactory.class);
|
||||
options.copyConditionsFrom(f.getDefault());
|
||||
|
||||
FlightConfigurationId fcid = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||
options.setFlightConfigurationId(fcid);
|
||||
setFlightConfigurationId(fcid);
|
||||
|
||||
options.addChangeListener(new ConditionListener());
|
||||
}
|
||||
|
||||
@ -146,9 +146,8 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
|
||||
this.options = options;
|
||||
|
||||
FlightConfigurationId fcid = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||
options.setFlightConfigurationId(fcid);
|
||||
|
||||
this.setFlightConfigurationId( rocket.getSelectedConfiguration().getFlightConfigurationID());
|
||||
|
||||
options.addChangeListener(new ConditionListener());
|
||||
|
||||
if (extensions != null) {
|
||||
@ -176,9 +175,35 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
return rocket;
|
||||
}
|
||||
|
||||
public FlightConfigurationId getId(){
|
||||
return this.options.getFlightConfigurationId();
|
||||
public FlightConfigurationId getFlightConfigurationId(){
|
||||
return this.configId;
|
||||
}
|
||||
public FlightConfigurationId getId(){
|
||||
return this.getFlightConfigurationId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the motor configuration ID. If this id does not yet exist, it will be created.
|
||||
*
|
||||
* @param id the configuration to set.
|
||||
*/
|
||||
public void setFlightConfigurationId(FlightConfigurationId fcid) {
|
||||
if ( null == fcid ){
|
||||
throw new NullPointerException("Attempted to set a null Config id in simulation options. Not allowed!");
|
||||
}else if ( fcid.hasError() ){
|
||||
throw new IllegalArgumentException("Attempted to set the configuration to an error id. Not Allowed!");
|
||||
}else if (!rocket.containsFlightConfigurationID(fcid)){
|
||||
rocket.createFlightConfiguration(fcid);
|
||||
}
|
||||
|
||||
if( fcid.equals(this.configId)){
|
||||
return;
|
||||
}
|
||||
|
||||
this.configId = fcid;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * Return a newly created Configuration for this simulation. The configuration
|
||||
@ -284,13 +309,13 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
}
|
||||
|
||||
// if the id hasn't been set yet, skip.
|
||||
if ( options.getId().hasError() ){
|
||||
if ( getId().hasError() ){
|
||||
log.warn(" simulationOptions lacks a valid id. Skipping.");
|
||||
status = Status.CANT_RUN;
|
||||
return status;
|
||||
}
|
||||
|
||||
FlightConfiguration config = rocket.getFlightConfiguration(options.getId());
|
||||
FlightConfiguration config = rocket.getFlightConfiguration( this.getId()).clone();
|
||||
|
||||
//Make sure this simulation has motors.
|
||||
if ( ! config.hasMotors() ){
|
||||
@ -346,7 +371,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
||||
|
||||
// Set simulated info after simulation, will not be set in case of exception
|
||||
simulatedConditions = options.clone();
|
||||
simulatedConfigurationDescription = descriptor.format( this.rocket, options.getId());
|
||||
simulatedConfigurationDescription = descriptor.format( this.rocket, getId());
|
||||
simulatedRocketID = rocket.getFunctionalModID();
|
||||
|
||||
status = Status.UPTODATE;
|
||||
|
@ -380,7 +380,7 @@ public class OpenRocketSaver extends RocketSaver {
|
||||
writeln("<conditions>");
|
||||
indent++;
|
||||
|
||||
writeElement("configid", cond.getId().key);
|
||||
writeElement("configid", simulation.getId().key);
|
||||
writeElement("launchrodlength", cond.getLaunchRodLength());
|
||||
writeElement("launchrodangle", cond.getLaunchRodAngle() * 180.0 / Math.PI);
|
||||
writeElement("launchroddirection", cond.getLaunchRodDirection() * 360.0 / (2.0 * Math.PI));
|
||||
|
@ -14,18 +14,19 @@ import net.sf.openrocket.util.GeodeticComputationStrategy;
|
||||
|
||||
class SimulationConditionsHandler extends AbstractElementHandler {
|
||||
private final DocumentLoadingContext context;
|
||||
private SimulationOptions conditions;
|
||||
public FlightConfigurationId idToSet = FlightConfigurationId.ERROR_FCID;
|
||||
private SimulationOptions options;
|
||||
private AtmosphereHandler atmosphereHandler;
|
||||
|
||||
public SimulationConditionsHandler(Rocket rocket, DocumentLoadingContext context) {
|
||||
this.context = context;
|
||||
conditions = new SimulationOptions(rocket);
|
||||
options = new SimulationOptions();
|
||||
// Set up default loading settings (which may differ from the new defaults)
|
||||
conditions.setGeodeticComputation(GeodeticComputationStrategy.FLAT);
|
||||
options.setGeodeticComputation(GeodeticComputationStrategy.FLAT);
|
||||
}
|
||||
|
||||
public SimulationOptions getConditions() {
|
||||
return conditions;
|
||||
return options;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,72 +51,70 @@ class SimulationConditionsHandler extends AbstractElementHandler {
|
||||
|
||||
|
||||
if (element.equals("configid")) {
|
||||
// the ID constructor is designed to always return a valid value
|
||||
FlightConfigurationId idToSet= new FlightConfigurationId(content);
|
||||
conditions.setFlightConfigurationId(idToSet);
|
||||
this.idToSet= new FlightConfigurationId(content);
|
||||
} else if (element.equals("launchrodlength")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod length defined, ignoring.");
|
||||
} else {
|
||||
conditions.setLaunchRodLength(d);
|
||||
options.setLaunchRodLength(d);
|
||||
}
|
||||
} else if (element.equals("launchrodangle")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod angle defined, ignoring.");
|
||||
} else {
|
||||
conditions.setLaunchRodAngle(d * Math.PI / 180);
|
||||
options.setLaunchRodAngle(d * Math.PI / 180);
|
||||
}
|
||||
} else if (element.equals("launchroddirection")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch rod direction defined, ignoring.");
|
||||
} else {
|
||||
conditions.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
||||
options.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
||||
}
|
||||
} else if (element.equals("windaverage")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal average windspeed defined, ignoring.");
|
||||
} else {
|
||||
conditions.setWindSpeedAverage(d);
|
||||
options.setWindSpeedAverage(d);
|
||||
}
|
||||
} else if (element.equals("windturbulence")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal wind turbulence intensity defined, ignoring.");
|
||||
} else {
|
||||
conditions.setWindTurbulenceIntensity(d);
|
||||
options.setWindTurbulenceIntensity(d);
|
||||
}
|
||||
} else if (element.equals("launchaltitude")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch altitude defined, ignoring.");
|
||||
} else {
|
||||
conditions.setLaunchAltitude(d);
|
||||
options.setLaunchAltitude(d);
|
||||
}
|
||||
} else if (element.equals("launchlatitude")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch latitude defined, ignoring.");
|
||||
} else {
|
||||
conditions.setLaunchLatitude(d);
|
||||
options.setLaunchLatitude(d);
|
||||
}
|
||||
} else if (element.equals("launchlongitude")) {
|
||||
if (Double.isNaN(d)) {
|
||||
warnings.add("Illegal launch longitude.");
|
||||
} else {
|
||||
conditions.setLaunchLongitude(d);
|
||||
options.setLaunchLongitude(d);
|
||||
}
|
||||
} else if (element.equals("geodeticmethod")) {
|
||||
GeodeticComputationStrategy gcs =
|
||||
(GeodeticComputationStrategy) DocumentConfig.findEnum(content, GeodeticComputationStrategy.class);
|
||||
if (gcs != null) {
|
||||
conditions.setGeodeticComputation(gcs);
|
||||
options.setGeodeticComputation(gcs);
|
||||
} else {
|
||||
warnings.add("Unknown geodetic computation method '" + content + "'");
|
||||
}
|
||||
} else if (element.equals("atmosphere")) {
|
||||
atmosphereHandler.storeSettings(conditions, warnings);
|
||||
atmosphereHandler.storeSettings(options, warnings);
|
||||
} else if (element.equals("timestep")) {
|
||||
if (Double.isNaN(d) || d <= 0) {
|
||||
warnings.add("Illegal time step defined, ignoring.");
|
||||
} else {
|
||||
conditions.setTimeStep(d);
|
||||
options.setTimeStep(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import net.sf.openrocket.file.DocumentLoadingContext;
|
||||
import net.sf.openrocket.file.simplesax.AbstractElementHandler;
|
||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.simulation.FlightData;
|
||||
import net.sf.openrocket.simulation.SimulationOptions;
|
||||
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
||||
@ -115,12 +116,14 @@ class SingleSimulationHandler extends AbstractElementHandler {
|
||||
status = Simulation.Status.OUTDATED;
|
||||
}
|
||||
|
||||
SimulationOptions conditions;
|
||||
SimulationOptions options;
|
||||
FlightConfigurationId idToSet= FlightConfigurationId.ERROR_FCID;
|
||||
if (conditionHandler != null) {
|
||||
conditions = conditionHandler.getConditions();
|
||||
options = conditionHandler.getConditions();
|
||||
idToSet = conditionHandler.idToSet;
|
||||
} else {
|
||||
warnings.add("Simulation conditions not defined, using defaults.");
|
||||
conditions = new SimulationOptions(doc.getRocket());
|
||||
options = new SimulationOptions();
|
||||
}
|
||||
|
||||
if (name == null)
|
||||
@ -133,7 +136,8 @@ class SingleSimulationHandler extends AbstractElementHandler {
|
||||
data = dataHandler.getFlightData();
|
||||
|
||||
Simulation simulation = new Simulation(doc.getRocket(), status, name,
|
||||
conditions, extensions, data);
|
||||
options, extensions, data);
|
||||
simulation.setFlightConfigurationId( idToSet );
|
||||
|
||||
doc.addSimulation(simulation);
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
||||
public String toDebug(){
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("====== Dumping MotorConfigurationSet for mount ("+this.size()+ " motors)\n");
|
||||
MotorConfiguration emptyInstance = this.getDefault();
|
||||
buffer.append(" >> (["+emptyInstance.toString()+"]= @ "+ emptyInstance.getIgnitionEvent().name +" +"+emptyInstance.getIgnitionDelay()+"sec )\n");
|
||||
MotorConfiguration defaultConfig = this.getDefault();
|
||||
buffer.append(" (Ignition@ "+ defaultConfig.getIgnitionEvent().name +" +"+defaultConfig.getIgnitionDelay()+"sec )\n");
|
||||
|
||||
for( FlightConfigurationId loopFCID : this.map.keySet()){
|
||||
String shortKey = loopFCID.toShortKey();
|
||||
@ -45,7 +45,7 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
||||
MotorConfiguration curInstance = this.map.get(loopFCID);
|
||||
String designation;
|
||||
if( null == curInstance.getMotor() ){
|
||||
designation = "EMPTY_INSTANCE";
|
||||
designation = "<EMPTY>";
|
||||
}else{
|
||||
designation = curInstance.getMotor().getDesignation(curInstance.getEjectionDelay());
|
||||
}
|
||||
@ -54,7 +54,8 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
||||
if( 0 != delay ){
|
||||
ignition += " +"+delay;
|
||||
}
|
||||
buffer.append(" >> ["+shortKey+"]= "+designation+" @ "+ignition+"\n");
|
||||
buffer.append(String.format(" >> [%10s]= %6s @ %4s\n",
|
||||
shortKey, designation, ignition ));
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
@ -420,10 +420,11 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
||||
for (RocketComponent component : this.getActiveComponents()) {
|
||||
for (Coordinate coord : component.getComponentBounds()) {
|
||||
cachedBounds.add(coord);
|
||||
if (coord.x < minX)
|
||||
if (coord.x < minX){
|
||||
minX = coord.x;
|
||||
if (coord.x > maxX)
|
||||
}else if (coord.x > maxX){
|
||||
maxX = coord.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -818,11 +818,10 @@ public class Rocket extends RocketComponent {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(String.format("====== Dumping %d Configurations from rocket: \n", this.getConfigurationCount(), this.getName()));
|
||||
final String fmt = " [%-12s]: %s\n";
|
||||
buf.append(String.format(fmt, " *SELECTED* ", selectedConfiguration.getName() ));
|
||||
for( FlightConfiguration config : this.configSet.values() ){
|
||||
String shortKey = config.getId().toShortKey();
|
||||
if( this.selectedConfiguration.equals( config)){
|
||||
shortKey = "*"+shortKey+"*";
|
||||
shortKey = shortKey+"<=";
|
||||
}
|
||||
buf.append(String.format(fmt, shortKey, config.getName() ));
|
||||
}
|
||||
|
@ -2114,7 +2114,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
public String toDebugTree() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("\n ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== ======\n");
|
||||
buffer.append(" [Name] [Length] [Rel Pos] [Abs Pos] \n");
|
||||
buffer.append(" [Name] [Length] [Rel Pos] [Abs Pos] \n");
|
||||
this.dumpTreeHelper(buffer, "");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ public class DefaultSimulationOptionFactory {
|
||||
}
|
||||
|
||||
public SimulationOptions getDefault() {
|
||||
SimulationOptions defaults = new SimulationOptions(null);
|
||||
SimulationOptions defaults = new SimulationOptions();
|
||||
if (prefs != null) {
|
||||
|
||||
defaults.setWindSpeedAverage(prefs.getDouble(SIMCONDITION_WIND_SPEED, defaults.getWindSpeedAverage()));
|
||||
|
@ -27,9 +27,6 @@ import net.sf.openrocket.util.WorldCoordinate;
|
||||
*/
|
||||
public class SimulationConditions implements Monitorable, Cloneable {
|
||||
|
||||
private Rocket rocket;
|
||||
private FlightConfigurationId configId= null;
|
||||
|
||||
private Simulation simulation; // The parent simulation
|
||||
|
||||
private double launchRodLength = 1;
|
||||
@ -103,29 +100,16 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
||||
|
||||
|
||||
public Rocket getRocket() {
|
||||
return rocket;
|
||||
return simulation.getRocket();
|
||||
}
|
||||
|
||||
|
||||
public void setRocket(Rocket rocket) {
|
||||
if (this.rocket != null)
|
||||
this.modIDadd += this.rocket.getModID();
|
||||
this.modID++;
|
||||
this.rocket = rocket;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FlightConfigurationId getMotorConfigurationID() {
|
||||
return configId;
|
||||
return simulation.getId();
|
||||
}
|
||||
|
||||
public FlightConfigurationId getFlightConfigurationID() {
|
||||
return configId;
|
||||
}
|
||||
|
||||
public void setFlightConfigurationID(FlightConfigurationId _fcid) {
|
||||
this.configId = _fcid;
|
||||
this.modID++;
|
||||
return simulation.getId();
|
||||
}
|
||||
|
||||
|
||||
@ -313,7 +297,7 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
||||
public int getModID() {
|
||||
//return (modID + modIDadd + rocket.getModID() + windModel.getModID() + atmosphericModel.getModID() +
|
||||
// gravityModel.getModID() + aerodynamicCalculator.getModID() + massCalculator.getModID());
|
||||
return (modID + modIDadd + rocket.getModID() + windModel.getModID() + atmosphericModel.getModID() +
|
||||
return (modID + modIDadd + simulation.getRocket().getModID() + windModel.getModID() + atmosphericModel.getModID() +
|
||||
aerodynamicCalculator.getModID() + massCalculator.getModID());
|
||||
}
|
||||
|
||||
@ -327,8 +311,6 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
||||
for (SimulationListener listener : this.simulationListeners) {
|
||||
clone.simulationListeners.add(listener.clone());
|
||||
}
|
||||
clone.rocket = this.rocket; // the rocket should be read-only from this point
|
||||
clone.configId = this.configId; // configIds are read-only
|
||||
|
||||
return clone;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
|
@ -10,15 +10,12 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
|
||||
import net.sf.openrocket.formatting.MotorDescriptionSubstitutor;
|
||||
import net.sf.openrocket.masscalc.MassCalculator;
|
||||
import net.sf.openrocket.models.atmosphere.AtmosphericModel;
|
||||
import net.sf.openrocket.models.atmosphere.ExtendedISAModel;
|
||||
import net.sf.openrocket.models.gravity.GravityModel;
|
||||
import net.sf.openrocket.models.gravity.WGSGravityModel;
|
||||
import net.sf.openrocket.models.wind.PinkNoiseWindModel;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.rocketcomponent.Rocket;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.startup.Preferences;
|
||||
import net.sf.openrocket.util.BugException;
|
||||
@ -26,7 +23,6 @@ import net.sf.openrocket.util.ChangeSource;
|
||||
import net.sf.openrocket.util.GeodeticComputationStrategy;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
import net.sf.openrocket.util.StateChangeListener;
|
||||
import net.sf.openrocket.util.Utils;
|
||||
import net.sf.openrocket.util.WorldCoordinate;
|
||||
|
||||
/**
|
||||
@ -50,9 +46,6 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
||||
|
||||
protected final Preferences preferences = Application.getPreferences();
|
||||
|
||||
private final Rocket rocket;
|
||||
private FlightConfigurationId configId = FlightConfigurationId.ERROR_FCID;
|
||||
|
||||
/*
|
||||
* NOTE: When adding/modifying parameters, they must also be added to the
|
||||
* equals and copyFrom methods!!
|
||||
@ -92,45 +85,9 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
||||
|
||||
private List<EventListener> listeners = new ArrayList<EventListener>();
|
||||
|
||||
public SimulationOptions(Rocket rocket) {
|
||||
this.rocket = rocket;
|
||||
public SimulationOptions() {
|
||||
}
|
||||
|
||||
public Rocket getRocket() {
|
||||
return rocket;
|
||||
}
|
||||
|
||||
public FlightConfigurationId getFlightConfigurationId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
public FlightConfigurationId getId() {
|
||||
return this.configId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the motor configuration ID. If this id does not yet exist, it will be created.
|
||||
*
|
||||
* @param id the configuration to set.
|
||||
*/
|
||||
public void setFlightConfigurationId(FlightConfigurationId fcid) {
|
||||
if ( null == fcid ){
|
||||
throw new NullPointerException("Attempted to set a null Config id in simulation options. Not allowed!");
|
||||
}else if ( fcid.hasError() ){
|
||||
throw new IllegalArgumentException("Attempted to set the configuration to an error id. Not Allowed!");
|
||||
}else if (!rocket.containsFlightConfigurationID(fcid)){
|
||||
rocket.createFlightConfiguration(fcid);
|
||||
}
|
||||
|
||||
if( fcid.equals(this.configId)){
|
||||
return;
|
||||
}
|
||||
|
||||
this.configId = fcid;
|
||||
fireChangeEvent();
|
||||
}
|
||||
|
||||
|
||||
public double getLaunchRodLength() {
|
||||
return launchRodLength;
|
||||
}
|
||||
@ -436,35 +393,6 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
||||
|
||||
public void copyFrom(SimulationOptions src) {
|
||||
|
||||
if (this.rocket == src.rocket) {
|
||||
this.configId = src.configId;
|
||||
} else {
|
||||
if (src.rocket.hasMotors(src.configId)) {
|
||||
// First check for exact match:
|
||||
if (this.rocket.containsFlightConfigurationID(src.configId)) {
|
||||
this.configId = src.configId;
|
||||
} else {
|
||||
// Try to find a closely matching motor ID
|
||||
MotorDescriptionSubstitutor formatter = Application.getInjector().getInstance(MotorDescriptionSubstitutor.class);
|
||||
|
||||
String motorDesc = formatter.getMotorConfigurationDescription(src.rocket, src.configId);
|
||||
FlightConfigurationId matchID = null;
|
||||
|
||||
for (FlightConfigurationId fcid : rocket.getIds()){
|
||||
String motorDesc2 = formatter.getMotorConfigurationDescription(this.rocket, fcid);
|
||||
if (motorDesc.equals(motorDesc2)) {
|
||||
matchID = fcid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.configId = matchID;
|
||||
}
|
||||
} else {
|
||||
this.configId = FlightConfigurationId.ERROR_FCID;
|
||||
}
|
||||
}
|
||||
|
||||
this.launchAltitude = src.launchAltitude;
|
||||
this.launchLatitude = src.launchLatitude;
|
||||
this.launchLongitude = src.launchLongitude;
|
||||
@ -564,9 +492,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
||||
if (!(other instanceof SimulationOptions))
|
||||
return false;
|
||||
SimulationOptions o = (SimulationOptions) other;
|
||||
return ((this.rocket == o.rocket) &&
|
||||
Utils.equals(this.configId, o.configId) &&
|
||||
MathUtil.equals(this.launchAltitude, o.launchAltitude) &&
|
||||
return (MathUtil.equals(this.launchAltitude, o.launchAltitude) &&
|
||||
MathUtil.equals(this.launchLatitude, o.launchLatitude) &&
|
||||
MathUtil.equals(this.launchLongitude, o.launchLongitude) &&
|
||||
MathUtil.equals(this.launchPressure, o.launchPressure) &&
|
||||
@ -587,9 +513,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (configId.hasError())
|
||||
return rocket.hashCode();
|
||||
return rocket.hashCode() + configId.hashCode();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -619,9 +543,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
||||
// TODO: HIGH: Clean up
|
||||
public SimulationConditions toSimulationConditions() {
|
||||
SimulationConditions conditions = new SimulationConditions();
|
||||
|
||||
conditions.setRocket((Rocket) getRocket().copy());
|
||||
conditions.setFlightConfigurationID(this.getId());
|
||||
|
||||
conditions.setLaunchRodLength(getLaunchRodLength());
|
||||
conditions.setLaunchRodAngle(getLaunchRodAngle());
|
||||
conditions.setLaunchRodDirection(getLaunchRodDirection());
|
||||
|
@ -51,7 +51,6 @@ import net.sf.openrocket.rocketcomponent.Transition;
|
||||
import net.sf.openrocket.rocketcomponent.Transition.Shape;
|
||||
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
|
||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||
import net.sf.openrocket.simulation.SimulationOptions;
|
||||
import net.sf.openrocket.simulation.customexpression.CustomExpression;
|
||||
import net.sf.openrocket.simulation.exception.SimulationException;
|
||||
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
||||
@ -87,7 +86,48 @@ public class TestRockets {
|
||||
this.rnd = new Random(key.hashCode());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Minimal motor without any useful numbers data
|
||||
private static ThrustCurveMotor getTestMotor() {
|
||||
return new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("A"),
|
||||
"F12X", "Desc", Motor.Type.UNKNOWN, new double[] {},
|
||||
0.024, 0.07, new double[] { 0, 1, 2 }, new double[] { 0, 1, 0 },
|
||||
new Coordinate[] { Coordinate.NUL, Coordinate.NUL, Coordinate.NUL }, "digestA");
|
||||
}
|
||||
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
private static MotorConfiguration generateMotorInstance_A8_18mm(){
|
||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
||||
// Motor.Type type, double[] delays, double diameter, double length,
|
||||
// double[] time, double[] thrust,
|
||||
// Coordinate[] cg, String digest);
|
||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("Estes"),"A8", " SU Black Powder",
|
||||
Motor.Type.SINGLE, new double[] {0,3,5}, 0.018, 0.070,
|
||||
new double[] { 0, 1, 2 }, new double[] { 0, 9, 0 },
|
||||
new Coordinate[] {
|
||||
new Coordinate(0.035, 0, 0, 0.0164),new Coordinate(.035, 0, 0, 0.0145),new Coordinate(.035, 0, 0, 0.0131)},
|
||||
"digest A8 test");
|
||||
return new MotorConfiguration(mtr);
|
||||
}
|
||||
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
private static MotorConfiguration generateMotorInstance_B4_18mm(){
|
||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
||||
// Motor.Type type, double[] delays, double diameter, double length,
|
||||
// double[] time, double[] thrust,
|
||||
// Coordinate[] cg, String digest);
|
||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("Estes"),"B4", " SU Black Powder",
|
||||
Motor.Type.SINGLE, new double[] {0,3,5}, 0.018, 0.070,
|
||||
new double[] { 0, 1, 2 }, new double[] { 0, 11.4, 0 },
|
||||
new Coordinate[] {
|
||||
new Coordinate(0.035, 0, 0, 0.0195),new Coordinate(.035, 0, 0, 0.0155),new Coordinate(.035, 0, 0, 0.013)},
|
||||
"digest B4 test");
|
||||
return new MotorConfiguration(mtr);
|
||||
}
|
||||
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
private static MotorConfiguration generateMotorInstance_C6_18mm(){
|
||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
||||
@ -99,11 +139,23 @@ public class TestRockets {
|
||||
Motor.Type.SINGLE, new double[] {0,3,5,7}, 0.018, 0.070,
|
||||
new double[] { 0, 1, 2 }, new double[] { 0, 6, 0 },
|
||||
new Coordinate[] {
|
||||
new Coordinate(0.035, 0, 0, 0.0227),new Coordinate(.035, 0, 0, 0.0165),new Coordinate(.035, 0, 0, 0.0102)},
|
||||
new Coordinate(0.035, 0, 0, 0.0227),new Coordinate(.035, 0, 0, 0.0165),new Coordinate(.035, 0, 0, 0.012)},
|
||||
"digest C6 test");
|
||||
return new MotorConfiguration(mtr);
|
||||
}
|
||||
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
private static MotorConfiguration generateMotorInstance_D21_18mm(){
|
||||
ThrustCurveMotor mtr = new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("AeroTech"),"D21", "Desc",
|
||||
Motor.Type.SINGLE, new double[] {}, 0.018, 0.07,
|
||||
new double[] { 0, 1, 2 }, new double[] { 0, 32, 0 },
|
||||
new Coordinate[] {
|
||||
new Coordinate(.035, 0, 0, 0.025),new Coordinate(.035, 0, 0, .020),new Coordinate(.035, 0, 0, 0.0154)},
|
||||
"digest D21 test");
|
||||
return new MotorConfiguration(mtr);
|
||||
}
|
||||
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
private static MotorConfiguration generateMotorInstance_M1350_75mm(){
|
||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
||||
@ -332,6 +384,18 @@ public class TestRockets {
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
public static final Rocket makeEstesAlphaIII(){
|
||||
Rocket rocket = new Rocket();
|
||||
FlightConfigurationId fcid[] = new FlightConfigurationId[5];
|
||||
fcid[0] = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||
rocket.createFlightConfiguration(fcid[0]);
|
||||
fcid[1] = new FlightConfigurationId();
|
||||
rocket.createFlightConfiguration(fcid[1]);
|
||||
fcid[2] = new FlightConfigurationId();
|
||||
rocket.createFlightConfiguration(fcid[2]);
|
||||
fcid[3] = new FlightConfigurationId();
|
||||
rocket.createFlightConfiguration(fcid[3]);
|
||||
fcid[4] = new FlightConfigurationId();
|
||||
rocket.createFlightConfiguration(fcid[4]);
|
||||
|
||||
rocket.setName("Estes Alpha III / Code Verification Rocket");
|
||||
AxialStage stage = new AxialStage();
|
||||
stage.setName("Stage");
|
||||
@ -394,12 +458,38 @@ public class TestRockets {
|
||||
thrustBlock.setThickness(0.0008);
|
||||
thrustBlock.setName("Engine Block");
|
||||
inner.addChild(thrustBlock);
|
||||
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
inner.setMotorMount( true);
|
||||
FlightConfigurationId motorConfigId = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||
inner.setMotorInstance( motorConfigId, motorConfig);
|
||||
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_A8_18mm();
|
||||
motorConfig.setEjectionDelay(0.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
inner.setMotorInstance( fcid[0], motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_B4_18mm();
|
||||
motorConfig.setEjectionDelay(3.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
inner.setMotorInstance( fcid[1], motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setEjectionDelay(3.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
inner.setMotorInstance( fcid[2], motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setEjectionDelay(5.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
inner.setMotorInstance( fcid[3], motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setEjectionDelay(7.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
inner.setMotorInstance( fcid[4], motorConfig);
|
||||
}
|
||||
}
|
||||
|
||||
// parachute
|
||||
@ -432,6 +522,192 @@ public class TestRockets {
|
||||
return rocket;
|
||||
}
|
||||
|
||||
// This is an extra stage tacked onto the end of an Estes Alpha III
|
||||
// http://www.rocketreviews.com/alpha-iii---estes-221256.html
|
||||
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||
public static final Rocket makeBeta(){
|
||||
Rocket rocket = new Rocket();
|
||||
rocket.setName("Kit-bash Beta");
|
||||
AxialStage sustainerStage = new AxialStage();
|
||||
sustainerStage.setName("Sustainer Stage");
|
||||
rocket.addChild(sustainerStage);
|
||||
|
||||
double noseconeLength = 0.07;
|
||||
double noseconeRadius = 0.012;
|
||||
NoseCone nosecone = new NoseCone(Transition.Shape.OGIVE, noseconeLength, noseconeRadius);
|
||||
nosecone.setAftShoulderLength(0.025);
|
||||
nosecone.setAftShoulderRadius(0.012);
|
||||
nosecone.setName("Nose Cone");
|
||||
sustainerStage.addChild(nosecone);
|
||||
|
||||
double bodytubeLength = 0.20;
|
||||
double bodytubeRadius = 0.012;
|
||||
double bodyTubeThickness = 0.0003;
|
||||
BodyTube bodytube = new BodyTube(bodytubeLength, bodytubeRadius, bodyTubeThickness);
|
||||
bodytube.setName("Body Tube");
|
||||
sustainerStage.addChild(bodytube);
|
||||
|
||||
TrapezoidFinSet finset;
|
||||
{
|
||||
int finCount = 3;
|
||||
double finRootChord = .05;
|
||||
double finTipChord = .03;
|
||||
double finSweep = 0.02;
|
||||
double finHeight = 0.05;
|
||||
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
|
||||
finset.setThickness( 0.0032);
|
||||
finset.setRelativePosition(Position.BOTTOM);
|
||||
finset.setName("3 Fin Set");
|
||||
bodytube.addChild(finset);
|
||||
|
||||
LaunchLug lug = new LaunchLug();
|
||||
lug.setName("Launch Lugs");
|
||||
lug.setRelativePosition(Position.TOP);
|
||||
lug.setAxialOffset(0.111);
|
||||
lug.setLength(0.050);
|
||||
lug.setOuterRadius(0.0022);
|
||||
lug.setInnerRadius(0.0020);
|
||||
bodytube.addChild(lug);
|
||||
|
||||
InnerTube inner = new InnerTube();
|
||||
inner.setRelativePosition(Position.TOP);
|
||||
inner.setAxialOffset(0.133);
|
||||
inner.setLength(0.07);
|
||||
inner.setOuterRadius(0.009);
|
||||
inner.setThickness(0.0003);
|
||||
inner.setMotorMount(true);
|
||||
inner.setName("Motor Mount Tube");
|
||||
bodytube.addChild(inner);
|
||||
|
||||
{
|
||||
// MotorBlock
|
||||
EngineBlock thrustBlock= new EngineBlock();
|
||||
thrustBlock.setRelativePosition(Position.TOP);
|
||||
thrustBlock.setAxialOffset(0.0);
|
||||
thrustBlock.setLength(0.005);
|
||||
thrustBlock.setOuterRadius(0.009);
|
||||
thrustBlock.setThickness(0.0008);
|
||||
thrustBlock.setName("Engine Block");
|
||||
inner.addChild(thrustBlock);
|
||||
inner.setMotorMount( true);
|
||||
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_A8_18mm();
|
||||
motorConfig.setEjectionDelay(0.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
FlightConfigurationId motorConfigId = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||
inner.setMotorInstance( motorConfigId, motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_B4_18mm();
|
||||
motorConfig.setEjectionDelay(3.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
FlightConfigurationId motorConfigId = new FlightConfigurationId();
|
||||
inner.setMotorInstance( motorConfigId, motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setEjectionDelay(3.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
FlightConfigurationId motorConfigId = new FlightConfigurationId();
|
||||
inner.setMotorInstance( motorConfigId, motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setEjectionDelay(5.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
FlightConfigurationId motorConfigId = new FlightConfigurationId();
|
||||
inner.setMotorInstance( motorConfigId, motorConfig);
|
||||
}
|
||||
{
|
||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
||||
motorConfig.setEjectionDelay(7.0);
|
||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
||||
FlightConfigurationId motorConfigId = new FlightConfigurationId();
|
||||
inner.setMotorInstance( motorConfigId, motorConfig);
|
||||
}
|
||||
}
|
||||
|
||||
// parachute
|
||||
Parachute chute = new Parachute();
|
||||
chute.setRelativePosition(Position.TOP);
|
||||
chute.setName("Parachute");
|
||||
chute.setAxialOffset(0.028);
|
||||
chute.setOverrideMass(0.002);
|
||||
chute.setMassOverridden(true);
|
||||
bodytube.addChild(chute);
|
||||
|
||||
// bulkhead x2
|
||||
CenteringRing centerings = new CenteringRing();
|
||||
centerings.setName("Centering Rings");
|
||||
centerings.setRelativePosition(Position.TOP);
|
||||
centerings.setAxialOffset(0.14);
|
||||
centerings.setLength(0.006);
|
||||
centerings.setInstanceCount(2);
|
||||
centerings.setInstanceSeparation(0.035);
|
||||
bodytube.addChild(centerings);
|
||||
}
|
||||
|
||||
Material material = Application.getPreferences().getDefaultComponentMaterial(null, Material.Type.BULK);
|
||||
nosecone.setMaterial(material);
|
||||
bodytube.setMaterial(material);
|
||||
finset.setMaterial(material);
|
||||
|
||||
{
|
||||
AxialStage boosterStage = new AxialStage();
|
||||
boosterStage.setName("Booster");
|
||||
|
||||
BodyTube boosterTube = new BodyTube(0.06, bodytubeRadius, bodyTubeThickness);
|
||||
boosterStage.addChild(boosterTube);
|
||||
|
||||
TubeCoupler coupler = new TubeCoupler();
|
||||
coupler.setName("Interstage");
|
||||
coupler.setOuterRadiusAutomatic(true);
|
||||
coupler.setThickness( bodyTubeThickness);
|
||||
coupler.setLength(0.03);
|
||||
coupler.setRelativePosition(Position.TOP);
|
||||
coupler.setPositionValue(-1.5);
|
||||
boosterTube.addChild(coupler);
|
||||
|
||||
int finCount = 3;
|
||||
double finRootChord = .05;
|
||||
double finTipChord = .03;
|
||||
double finSweep = 0.02;
|
||||
double finHeight = 0.05;
|
||||
finset = new TrapezoidFinSet(finCount, finRootChord, finTipChord, finSweep, finHeight);
|
||||
finset.setThickness( 0.0032);
|
||||
finset.setRelativePosition(Position.BOTTOM);
|
||||
finset.setPositionValue(1);
|
||||
finset.setName("Booster Fins");
|
||||
boosterTube.addChild(finset);
|
||||
|
||||
// Motor mount
|
||||
InnerTube boosterMMT = new InnerTube();
|
||||
boosterMMT.setName("Booster MMT");
|
||||
boosterMMT.setPositionValue(0.005);
|
||||
boosterMMT.setRelativePosition(Position.BOTTOM);
|
||||
boosterMMT.setOuterRadius(0.019 / 2);
|
||||
boosterMMT.setInnerRadius(0.018 / 2);
|
||||
boosterMMT.setLength(0.075);
|
||||
boosterTube.addChild(boosterMMT);
|
||||
|
||||
rocket.addChild(boosterStage);
|
||||
|
||||
boosterMMT.setMotorMount(true);
|
||||
{
|
||||
FlightConfigurationId mcid = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||
MotorConfiguration motorConfig= generateMotorInstance_D21_18mm();
|
||||
motorConfig.setID( new MotorInstanceId( boosterMMT.getName(), 1) );
|
||||
boosterMMT.setMotorInstance( mcid, motorConfig);
|
||||
}
|
||||
|
||||
}
|
||||
rocket.getSelectedConfiguration().setAllStages();
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
}
|
||||
|
||||
|
||||
public static Rocket makeSmallFlyable() {
|
||||
double noseconeLength = 0.10, noseconeRadius = 0.01;
|
||||
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
|
||||
@ -553,6 +829,8 @@ public class TestRockets {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static Rocket makeIsoHaisu() {
|
||||
Rocket rocket;
|
||||
AxialStage stage;
|
||||
@ -1036,9 +1314,8 @@ public class TestRockets {
|
||||
OpenRocketDocument rocketDoc = OpenRocketDocumentFactory.createDocumentFromRocket(rocket);
|
||||
|
||||
// create simulation data
|
||||
SimulationOptions options = new SimulationOptions(rocket);
|
||||
options.setFlightConfigurationId(fcid);
|
||||
Simulation simulation1 = new Simulation(rocket);
|
||||
simulation1.setFlightConfigurationId(fcid);
|
||||
|
||||
rocketDoc.addSimulation(simulation1);
|
||||
Simulation simulation2 = new Simulation(rocket);
|
||||
@ -1358,16 +1635,6 @@ public class TestRockets {
|
||||
return rocketDoc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private static ThrustCurveMotor getTestMotor() {
|
||||
return new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("A"),
|
||||
"F12X", "Desc", Motor.Type.UNKNOWN, new double[] {},
|
||||
0.024, 0.07, new double[] { 0, 1, 2 }, new double[] { 0, 1, 0 },
|
||||
new Coordinate[] { Coordinate.NUL, Coordinate.NUL, Coordinate.NUL }, "digestA");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -11,9 +11,11 @@ import net.sf.openrocket.motor.Manufacturer;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||
import net.sf.openrocket.optimization.rocketoptimization.TestRocketOptimizationFunction;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
import net.sf.openrocket.util.TestRockets;
|
||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||
|
||||
public class FlightConfigurationTest extends BaseTestCase {
|
||||
@ -25,7 +27,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
*/
|
||||
@Test
|
||||
public void testEmptyRocket() {
|
||||
Rocket r1 = makeEmptyRocket();
|
||||
Rocket r1 = TestRockets.makeSmallFlyable();
|
||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
||||
|
||||
FlightConfiguration configClone = config.clone();
|
||||
@ -38,9 +40,12 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
*/
|
||||
@Test
|
||||
public void testCloneBasic() {
|
||||
Rocket rkt1 = makeTwoStageMotorRocket();
|
||||
Rocket rkt1 = TestRockets.makeBeta();
|
||||
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
||||
|
||||
// final String treedump = rkt1.toDebugTree();
|
||||
// System.err.println("treedump: \n" + treedump);
|
||||
|
||||
// preconditions
|
||||
config1.setAllStages();
|
||||
int expectedStageCount = 2;
|
||||
@ -49,13 +54,13 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
int expectedMotorCount = 2;
|
||||
int actualMotorCount = config1.getActiveMotors().size();
|
||||
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||
double expectedLength = 176.8698848;
|
||||
double expectedLength = 0.33;
|
||||
double actualLength = config1.getLength();
|
||||
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
||||
double expectedReferenceLength = 2.5;
|
||||
double expectedReferenceLength = 0.024;
|
||||
double actualReferenceLength = config1.getReferenceLength();
|
||||
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, actualReferenceLength, EPSILON);
|
||||
double expectedReferenceArea = 4.9087385212;
|
||||
double expectedReferenceArea = Math.pow(expectedReferenceLength/2,2)*Math.PI;
|
||||
double actualReferenceArea = config1.getReferenceArea();
|
||||
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
||||
|
||||
@ -84,7 +89,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
*/
|
||||
@Test
|
||||
public void testCloneIndependence() {
|
||||
Rocket rkt1 = makeTwoStageMotorRocket();
|
||||
Rocket rkt1 = TestRockets.makeBeta();
|
||||
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
||||
int expectedStageCount;
|
||||
int actualStageCount;
|
||||
@ -121,18 +126,13 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
*/
|
||||
@Test
|
||||
public void testSingleStageRocket() {
|
||||
|
||||
/* Setup */
|
||||
Rocket r1 = makeSingleStageTestRocket();
|
||||
Rocket r1 = TestRockets.makeEstesAlphaIII();
|
||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
||||
|
||||
// test explicitly setting only first stage active
|
||||
config.clearAllStages();
|
||||
config.setOnlyStage(0);
|
||||
|
||||
//config.dumpConfig();
|
||||
//System.err.println("treedump: \n" + treedump);
|
||||
|
||||
// test that getStageCount() returns correct value
|
||||
int expectedStageCount = 1;
|
||||
int stageCount = config.getStageCount();
|
||||
@ -150,6 +150,35 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Single stage rocket specific configuration tests
|
||||
*/
|
||||
@Test
|
||||
public void testConfigurationSwitching() {
|
||||
/* Setup */
|
||||
Rocket rkt = TestRockets.makeEstesAlphaIII();
|
||||
//FlightConfiguration config = rkt.getSelectedConfiguration();
|
||||
|
||||
InnerTube smmt = (InnerTube)rkt.getChild(0).getChild(1).getChild(2);
|
||||
System.err.println( smmt.toMotorDebug());
|
||||
|
||||
final String configDump= rkt.toDebugConfigs();
|
||||
System.err.println("configs:\n" +configDump);
|
||||
// final String treedump = rkt.toDebugTree();
|
||||
// System.err.println("treedump: \n" + treedump);
|
||||
|
||||
|
||||
//int actualMotorCount = smmt.getM
|
||||
//assertThat("number of motor configurations doesn't actually match.", actualMotorCount, equalTo(expectedMotorCount));
|
||||
|
||||
// test that all configurations correctly loaded:
|
||||
int expectedConfigCount = 5;
|
||||
int actualConfigCount = rkt.getConfigurationCount();
|
||||
assertThat("number of loaded configuration counts doesn't actually match.", actualConfigCount, equalTo(expectedConfigCount));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Multi stage rocket specific configuration tests
|
||||
*/
|
||||
@ -157,8 +186,8 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
public void testMultiStageRocket() {
|
||||
|
||||
/* Setup */
|
||||
Rocket r1 = makeTwoStageTestRocket();
|
||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
||||
Rocket rkt = TestRockets.makeBeta();
|
||||
FlightConfiguration config = rkt.getSelectedConfiguration();
|
||||
|
||||
int expectedStageCount;
|
||||
int stageCount;
|
||||
@ -214,7 +243,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
public void testMotorClusters() {
|
||||
|
||||
/* Setup */
|
||||
Rocket rkt = makeTwoStageMotorRocket();
|
||||
Rocket rkt = TestRockets.makeBeta();
|
||||
FlightConfiguration config = rkt.getSelectedConfiguration();
|
||||
|
||||
|
||||
@ -239,256 +268,5 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
||||
}
|
||||
|
||||
//////////////////// Test Rocket Creation Methods /////////////////////////
|
||||
|
||||
public static Rocket makeEmptyRocket() {
|
||||
Rocket rocket = new Rocket();
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
}
|
||||
|
||||
public static Rocket makeSingleStageTestRocket() {
|
||||
|
||||
// TODO: get units correct, these units are prob wrong, are lengths are CM, mass are grams
|
||||
|
||||
Rocket rocket;
|
||||
AxialStage stage;
|
||||
NoseCone nosecone;
|
||||
BodyTube tube1;
|
||||
TrapezoidFinSet finset;
|
||||
|
||||
// body tube constants
|
||||
final double R = 2.5 / 2; // cm
|
||||
final double BT_T = 0.1;
|
||||
|
||||
// nose cone constants
|
||||
final double NC_T = 0.2;
|
||||
final double R2 = 2.3 / 2;
|
||||
|
||||
rocket = new Rocket();
|
||||
stage = new AxialStage();
|
||||
stage.setName("Stage1");
|
||||
|
||||
nosecone = new NoseCone(Transition.Shape.OGIVE, 10.0, R);
|
||||
nosecone.setThickness(NC_T);
|
||||
nosecone.setAftShoulderLength(2.0);
|
||||
nosecone.setAftShoulderRadius(R2);
|
||||
nosecone.setAftShoulderThickness(NC_T);
|
||||
nosecone.setAftShoulderCapped(true);
|
||||
nosecone.setFilled(false);
|
||||
stage.addChild(nosecone);
|
||||
|
||||
tube1 = new BodyTube(30, R, BT_T);
|
||||
stage.addChild(tube1);
|
||||
|
||||
LaunchLug lug = new LaunchLug();
|
||||
lug.setLength(3.5);
|
||||
tube1.addChild(lug);
|
||||
|
||||
/*
|
||||
TubeCoupler coupler = new TubeCoupler();
|
||||
coupler.setOuterRadiusAutomatic(true);
|
||||
coupler.setThickness(0.005);
|
||||
coupler.setLength(0.28);
|
||||
coupler.setMassOverridden(true);
|
||||
coupler.setOverrideMass(0.360);
|
||||
coupler.setRelativePosition(Position.BOTTOM);
|
||||
coupler.setPositionValue(-0.14);
|
||||
tube1.addChild(coupler);
|
||||
*/
|
||||
|
||||
// Parachute
|
||||
MassComponent mass = new MassComponent(4.5, R2, 8.0);
|
||||
mass.setRelativePosition(Position.TOP);
|
||||
mass.setPositionValue(3.0);
|
||||
tube1.addChild(mass);
|
||||
|
||||
// Cord
|
||||
mass = new MassComponent(40.0, R2, 72);
|
||||
mass.setRelativePosition(Position.TOP);
|
||||
mass.setPositionValue(2.0);
|
||||
tube1.addChild(mass);
|
||||
|
||||
// Motor mount
|
||||
InnerTube inner = new InnerTube();
|
||||
inner.setName("Sustainer MMT");
|
||||
inner.setPositionValue(0.5);
|
||||
inner.setRelativePosition(Position.BOTTOM);
|
||||
inner.setOuterRadius(1.9 / 2);
|
||||
inner.setInnerRadius(1.8 / 2);
|
||||
inner.setLength(7.5);
|
||||
tube1.addChild(inner);
|
||||
|
||||
// Motor
|
||||
|
||||
// Centering rings for motor mount
|
||||
CenteringRing center = new CenteringRing();
|
||||
center.setInnerRadiusAutomatic(true);
|
||||
center.setOuterRadiusAutomatic(true);
|
||||
center.setLength(0.005);
|
||||
center.setMassOverridden(true);
|
||||
center.setOverrideMass(0.038);
|
||||
center.setRelativePosition(Position.BOTTOM);
|
||||
center.setPositionValue(0.25);
|
||||
tube1.addChild(center);
|
||||
|
||||
center = new CenteringRing();
|
||||
center.setInnerRadiusAutomatic(true);
|
||||
center.setOuterRadiusAutomatic(true);
|
||||
center.setLength(0.005);
|
||||
center.setMassOverridden(true);
|
||||
center.setOverrideMass(0.038);
|
||||
center.setRelativePosition(Position.BOTTOM);
|
||||
center.setPositionValue(-6.0);
|
||||
tube1.addChild(center);
|
||||
|
||||
|
||||
center = new CenteringRing();
|
||||
center.setInnerRadiusAutomatic(true);
|
||||
center.setOuterRadiusAutomatic(true);
|
||||
center.setLength(0.005);
|
||||
center.setMassOverridden(true);
|
||||
center.setOverrideMass(0.038);
|
||||
center.setRelativePosition(Position.TOP);
|
||||
center.setPositionValue(0.83);
|
||||
tube1.addChild(center);
|
||||
|
||||
// Fins
|
||||
finset = new TrapezoidFinSet();
|
||||
finset.setFinCount(3);
|
||||
finset.setRootChord(5.0);
|
||||
finset.setTipChord(5.0);
|
||||
finset.setHeight(3.0);
|
||||
finset.setThickness(0.005);
|
||||
finset.setSweepAngle(40.0);
|
||||
finset.setRelativePosition(Position.BOTTOM);
|
||||
finset.setPositionValue(-0.5);
|
||||
finset.setBaseRotation(Math.PI / 2);
|
||||
tube1.addChild(finset);
|
||||
|
||||
// Stage construction
|
||||
rocket.addChild(stage);
|
||||
rocket.setPerfectFinish(false);
|
||||
rocket.enableEvents();
|
||||
|
||||
final int expectedStageCount = 1;
|
||||
assertThat(" rocket has incorrect stage count: ", rocket.getStageCount(), equalTo(expectedStageCount));
|
||||
|
||||
int expectedConfigurationCount = 0;
|
||||
assertThat(" configuration list contains : ", rocket.getFlightConfigurationCount(), equalTo(expectedConfigurationCount));
|
||||
|
||||
FlightConfiguration newConfig = new FlightConfiguration(rocket,null);
|
||||
rocket.setFlightConfiguration( newConfig.getId(), newConfig);
|
||||
rocket.setDefaultConfiguration( newConfig.getId());
|
||||
assertThat(" configuration updates stage Count correctly: ", newConfig.getActiveStageCount(), equalTo(expectedStageCount));
|
||||
expectedConfigurationCount = 1;
|
||||
assertThat(" configuration list contains : ", rocket.getFlightConfigurationCount(), equalTo(expectedConfigurationCount));
|
||||
|
||||
rocket.update();
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
}
|
||||
|
||||
|
||||
public static Rocket makeTwoStageTestRocket() {
|
||||
|
||||
// TODO: get units correct, these units are prob wrong, are lengths are CM, mass are grams
|
||||
|
||||
final double R = 2.5 / 2; // cm
|
||||
final double BT_T = 0.1;
|
||||
|
||||
Rocket rocket = makeSingleStageTestRocket();
|
||||
|
||||
AxialStage stage = new AxialStage();
|
||||
stage.setName("Booster");
|
||||
|
||||
BodyTube boosterTube = new BodyTube(9.0, R, BT_T);
|
||||
stage.addChild(boosterTube);
|
||||
|
||||
TubeCoupler coupler = new TubeCoupler();
|
||||
coupler.setOuterRadiusAutomatic(true);
|
||||
coupler.setThickness(BT_T);
|
||||
coupler.setLength(3.0);
|
||||
coupler.setRelativePosition(Position.TOP);
|
||||
coupler.setPositionValue(-1.5);
|
||||
boosterTube.addChild(coupler);
|
||||
|
||||
TrapezoidFinSet finset = new TrapezoidFinSet();
|
||||
finset.setFinCount(3);
|
||||
finset.setRootChord(5.0);
|
||||
finset.setTipChord(5.0);
|
||||
finset.setHeight(3.0);
|
||||
finset.setThickness(0.005);
|
||||
finset.setSweepAngle(40.0);
|
||||
finset.setRelativePosition(Position.BOTTOM);
|
||||
finset.setPositionValue(-0.25);
|
||||
finset.setBaseRotation(Math.PI / 2);
|
||||
boosterTube.addChild(finset);
|
||||
|
||||
// Motor mount
|
||||
InnerTube inner = new InnerTube();
|
||||
inner.setName("Booster MMT");
|
||||
inner.setPositionValue(0.5);
|
||||
inner.setRelativePosition(Position.BOTTOM);
|
||||
inner.setOuterRadius(1.9 / 2);
|
||||
inner.setInnerRadius(1.8 / 2);
|
||||
inner.setLength(7.5);
|
||||
boosterTube.addChild(inner);
|
||||
|
||||
rocket.addChild(stage);
|
||||
|
||||
// already set in "makeSingleStageTestRocket()" above...
|
||||
// rocket.enableEvents();
|
||||
// FlightConfiguration newConfig = new FlightConfiguration(rocket,null);
|
||||
// rocket.setFlightConfiguration( newConfig.getId(), newConfig);
|
||||
|
||||
rocket.update();
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
}
|
||||
|
||||
public static Rocket makeTwoStageMotorRocket() {
|
||||
Rocket rocket = makeTwoStageTestRocket();
|
||||
FlightConfigurationId fcid = rocket.getSelectedConfiguration().getId();
|
||||
|
||||
{
|
||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
||||
// Motor.Type type, double[] delays, double diameter, double length,
|
||||
// double[] time, double[] thrust,
|
||||
// Coordinate[] cg, String digest);
|
||||
ThrustCurveMotor sustainerMotor = new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("AeroTech"),"D10", "Desc",
|
||||
Motor.Type.SINGLE, new double[] {3,5,7},0.018, 0.07,
|
||||
new double[] { 0, 1, 2 }, new double[] { 0, 25, 0 },
|
||||
new Coordinate[] {
|
||||
new Coordinate(.035, 0, 0, 0.026),new Coordinate(.035, 0, 0, .021),new Coordinate(.035, 0, 0, 0.016)},
|
||||
"digest D10 test");
|
||||
|
||||
InnerTube sustainerMount = (InnerTube) rocket.getChild(0).getChild(1).getChild(3);
|
||||
sustainerMount.setMotorMount(true);
|
||||
sustainerMount.setMotorInstance(fcid, new MotorConfiguration(sustainerMotor));
|
||||
}
|
||||
|
||||
{
|
||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
||||
// Motor.Type type, double[] delays, double diameter, double length,
|
||||
// double[] time, double[] thrust,
|
||||
// Coordinate[] cg, String digest);
|
||||
ThrustCurveMotor boosterMotor = new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("AeroTech"),"D21", "Desc",
|
||||
Motor.Type.SINGLE, new double[] {}, 0.018, 0.07,
|
||||
new double[] { 0, 1, 2 }, new double[] { 0, 32, 0 },
|
||||
new Coordinate[] {
|
||||
new Coordinate(.035, 0, 0, 0.025),new Coordinate(.035, 0, 0, .020),new Coordinate(.035, 0, 0, 0.0154)},
|
||||
"digest D21 test");
|
||||
InnerTube boosterMount = (InnerTube) rocket.getChild(1).getChild(0).getChild(2);
|
||||
boosterMount.setMotorMount(true);
|
||||
boosterMount.setMotorInstance(fcid, new MotorConfiguration(boosterMotor));
|
||||
boosterMount.setClusterConfiguration( ClusterConfiguration.CONFIGURATIONS[1]); // double-mount
|
||||
}
|
||||
rocket.update();
|
||||
rocket.enableEvents();
|
||||
return rocket;
|
||||
}
|
||||
|
||||
}
|
||||
|
Binary file not shown.
BIN
swing/resources/datafiles/examples/Parallel_Staging_Example.ork
Normal file
BIN
swing/resources/datafiles/examples/Parallel_Staging_Example.ork
Normal file
Binary file not shown.
@ -1167,7 +1167,7 @@ public class GeneralOptimizationDialog extends JDialog {
|
||||
}
|
||||
|
||||
// Update the active configuration
|
||||
FlightConfigurationId fcid = getSelectedSimulation().getOptions().getId();
|
||||
FlightConfigurationId fcid = getSelectedSimulation().getId();
|
||||
getSelectedSimulation().getRocket().setDefaultConfiguration(fcid);
|
||||
|
||||
updating = false;
|
||||
|
@ -612,7 +612,7 @@ public class SimulationPanel extends JPanel {
|
||||
if((s==Simulation.Status.NOT_SIMULATED) ||
|
||||
(s==Simulation.Status.OUTDATED)){
|
||||
outdated++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(outdated>0){
|
||||
Simulation[] sims = new Simulation[outdated];
|
||||
@ -668,7 +668,6 @@ public class SimulationPanel extends JPanel {
|
||||
}
|
||||
|
||||
private class JLabelRenderer extends DefaultTableCellRenderer {
|
||||
private static final long serialVersionUID = 5487619660216145843L;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
|
@ -3,7 +3,6 @@ package net.sf.openrocket.gui.main.flightconfigpanel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
|
||||
@ -25,7 +24,6 @@ public class FlightConfigurableTableModel<T extends FlightConfigurableComponent>
|
||||
protected final Rocket rocket;
|
||||
protected final Class<T> clazz;
|
||||
private final List<T> components = new ArrayList<T>();
|
||||
private List<FlightConfigurationId> ids = new Vector<FlightConfigurationId>();
|
||||
|
||||
public FlightConfigurableTableModel(Class<T> clazz, Rocket rocket) {
|
||||
super();
|
||||
@ -52,6 +50,7 @@ public class FlightConfigurableTableModel<T extends FlightConfigurableComponent>
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void initialize() {
|
||||
components.clear();
|
||||
Iterator<RocketComponent> it = rocket.iterator();
|
||||
|
@ -513,7 +513,7 @@ public class DesignReport {
|
||||
try {
|
||||
for (int i = 0; i < simulations.size(); i++) {
|
||||
Simulation simulation = simulations.get(i);
|
||||
if (Utils.equals(simulation.getOptions().getId(), motorId)) {
|
||||
if (Utils.equals(simulation.getId(), motorId)) {
|
||||
simulation = simulation.copy();
|
||||
simulation.simulate();
|
||||
flight = simulation.getSimulatedData();
|
||||
|
@ -687,8 +687,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
|
||||
Rocket duplicate = (Rocket) document.getRocket().copy();
|
||||
Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate);
|
||||
simulation.getOptions().setFlightConfigurationId(
|
||||
document.getDefaultConfiguration().getFlightConfigurationID());
|
||||
simulation.setFlightConfigurationId( document.getDefaultConfiguration().getFlightConfigurationID());
|
||||
|
||||
backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation);
|
||||
backgroundSimulationExecutor.execute(backgroundSimulationWorker);
|
||||
|
@ -25,7 +25,6 @@ import net.sf.openrocket.gui.util.GUIUtil;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||
import net.sf.openrocket.simulation.SimulationOptions;
|
||||
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
|
||||
@ -33,9 +32,8 @@ import net.sf.openrocket.startup.Application;
|
||||
public class SimulationEditDialog extends JDialog {
|
||||
private static final long serialVersionUID = -4468157685542912715L;
|
||||
private final Window parentWindow;
|
||||
private final Simulation[] simulation;
|
||||
private final Simulation[] simulationList;
|
||||
private final OpenRocketDocument document;
|
||||
private final SimulationOptions conditions;
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
JPanel cards;
|
||||
@ -47,8 +45,7 @@ public class SimulationEditDialog extends JDialog {
|
||||
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
||||
this.document = document;
|
||||
this.parentWindow = parent;
|
||||
this.simulation = sims;
|
||||
this.conditions = simulation[0].getOptions();
|
||||
this.simulationList = sims;
|
||||
|
||||
this.cards = new JPanel(new CardLayout());
|
||||
this.add(cards);
|
||||
@ -64,11 +61,11 @@ public class SimulationEditDialog extends JDialog {
|
||||
}
|
||||
|
||||
private boolean isSingleEdit() {
|
||||
return simulation.length == 1;
|
||||
return simulationList.length == 1;
|
||||
}
|
||||
|
||||
private boolean allowsPlotMode() {
|
||||
return simulation.length == 1 && simulation[0].hasSimulationData();
|
||||
return simulationList.length == 1 && simulationList[0].hasSimulationData();
|
||||
}
|
||||
|
||||
public void setEditMode() {
|
||||
@ -87,12 +84,12 @@ public class SimulationEditDialog extends JDialog {
|
||||
}
|
||||
|
||||
private void copyChangesToAllSims() {
|
||||
if (simulation.length > 1) {
|
||||
for (int i = 1; i < simulation.length; i++) {
|
||||
simulation[i].getOptions().copyConditionsFrom(simulation[0].getOptions());
|
||||
simulation[i].getSimulationExtensions().clear();
|
||||
for (SimulationExtension c : simulation[0].getSimulationExtensions()) {
|
||||
simulation[i].getSimulationExtensions().add(c.clone());
|
||||
if (simulationList.length > 1) {
|
||||
for (int i = 1; i < simulationList.length; i++) {
|
||||
simulationList[i].getOptions().copyConditionsFrom(simulationList[0].getOptions());
|
||||
simulationList[i].getSimulationExtensions().clear();
|
||||
for (SimulationExtension c : simulationList[0].getSimulationExtensions()) {
|
||||
simulationList[i].getSimulationExtensions().add(c.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,7 +110,7 @@ public class SimulationEditDialog extends JDialog {
|
||||
|
||||
//// Simulation name:
|
||||
panel.add(new JLabel(trans.get("simedtdlg.lbl.Simname") + " "), "growx 0, gapright para");
|
||||
final JTextField field = new JTextField(simulation[0].getName());
|
||||
final JTextField field = new JTextField(simulationList[0].getName());
|
||||
field.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
@ -135,7 +132,7 @@ public class SimulationEditDialog extends JDialog {
|
||||
if (name == null || name.equals(""))
|
||||
return;
|
||||
//System.out.println("Setting name:" + name);
|
||||
simulation[0].setName(name);
|
||||
simulationList[0].setName(name);
|
||||
|
||||
}
|
||||
});
|
||||
@ -158,7 +155,8 @@ public class SimulationEditDialog extends JDialog {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
FlightConfiguration config = (FlightConfiguration)configComboBox.getSelectedItem();
|
||||
FlightConfigurationId id = config.getId();
|
||||
conditions.setFlightConfigurationId( id );
|
||||
|
||||
simulationList[0].setFlightConfigurationId( id );
|
||||
}
|
||||
});
|
||||
panel.add(configComboBox, "span");
|
||||
@ -170,9 +168,9 @@ public class SimulationEditDialog extends JDialog {
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
|
||||
//// Launch conditions
|
||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Launchcond"), new SimulationConditionsPanel(simulation[0]));
|
||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Launchcond"), new SimulationConditionsPanel(simulationList[0]));
|
||||
//// Simulation options
|
||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Simopt"), new SimulationOptionsPanel(document, simulation[0]));
|
||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Simopt"), new SimulationOptionsPanel(document, simulationList[0]));
|
||||
|
||||
tabbedPane.setSelectedIndex(0);
|
||||
|
||||
@ -205,7 +203,7 @@ public class SimulationEditDialog extends JDialog {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
copyChangesToAllSims();
|
||||
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulation);
|
||||
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulationList);
|
||||
refreshView();
|
||||
if (allowsPlotMode()) {
|
||||
setPlotMode();
|
||||
@ -236,17 +234,17 @@ public class SimulationEditDialog extends JDialog {
|
||||
|
||||
//// Simulation name:
|
||||
plotExportPanel.add(new JLabel(trans.get("simedtdlg.lbl.Simname") + " "), "span, split 2, shrink");
|
||||
final JTextField field = new JTextField(simulation[0].getName());
|
||||
final JTextField field = new JTextField(simulationList[0].getName());
|
||||
field.setEditable(false);
|
||||
plotExportPanel.add(field, "shrinky, growx, wrap");
|
||||
|
||||
final JTabbedPane tabbedPane = new JTabbedPane();
|
||||
|
||||
//// Plot data
|
||||
final SimulationPlotPanel plotTab = new SimulationPlotPanel(simulation[0]);
|
||||
final SimulationPlotPanel plotTab = new SimulationPlotPanel(simulationList[0]);
|
||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Plotdata"), plotTab);
|
||||
//// Export data
|
||||
final SimulationExportPanel exportTab = new SimulationExportPanel(simulation[0]);
|
||||
final SimulationExportPanel exportTab = new SimulationExportPanel(simulationList[0]);
|
||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Exportdata"), exportTab);
|
||||
|
||||
plotExportPanel.add(tabbedPane, "grow, wrap");
|
||||
@ -286,8 +284,8 @@ public class SimulationEditDialog extends JDialog {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
// If the simulation is out of date, run the simulation.
|
||||
if (simulation[0].getStatus() != Simulation.Status.UPTODATE) {
|
||||
new SimulationRunDialog(SimulationEditDialog.this.parentWindow, document, simulation[0]).setVisible(true);
|
||||
if (simulationList[0].getStatus() != Simulation.Status.UPTODATE) {
|
||||
new SimulationRunDialog(SimulationEditDialog.this.parentWindow, document, simulationList[0]).setVisible(true);
|
||||
}
|
||||
|
||||
if (tabbedPane.getSelectedIndex() == 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user