[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()) {
|
for (Simulation s : getSimulations()) {
|
||||||
// Assumes modifiable collection - which it is
|
// Assumes modifiable collection - which it is
|
||||||
if (configId.equals(s.getOptions().getId())) {
|
if (configId.equals(s.getId())) {
|
||||||
removeSimulation(s);
|
removeSimulation(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -637,7 +637,7 @@ public class OpenRocketDocument implements ComponentChangeListener {
|
|||||||
str.append(">> Dumping simulation list:\n");
|
str.append(">> Dumping simulation list:\n");
|
||||||
int simNum = 0;
|
int simNum = 0;
|
||||||
for( Simulation s : this.simulations ){
|
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++;
|
simNum++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
private SafetyMutex mutex = SafetyMutex.newInstance();
|
private SafetyMutex mutex = SafetyMutex.newInstance();
|
||||||
|
|
||||||
private final Rocket rocket;
|
private final Rocket rocket;
|
||||||
|
FlightConfigurationId configId = FlightConfigurationId.ERROR_FCID;
|
||||||
|
|
||||||
private String name = "";
|
private String name = "";
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
|
|
||||||
/** The conditions to use */
|
/** The conditions to use */
|
||||||
// TODO: HIGH: Change to use actual conditions class??
|
// TODO: HIGH: Change to use actual conditions class??
|
||||||
private SimulationOptions options;
|
private SimulationOptions options = new SimulationOptions();
|
||||||
|
|
||||||
private ArrayList<SimulationExtension> simulationExtensions = new ArrayList<SimulationExtension>();
|
private ArrayList<SimulationExtension> simulationExtensions = new ArrayList<SimulationExtension>();
|
||||||
|
|
||||||
@ -109,13 +110,12 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
this.rocket = rocket;
|
this.rocket = rocket;
|
||||||
this.status = Status.NOT_SIMULATED;
|
this.status = Status.NOT_SIMULATED;
|
||||||
|
|
||||||
options = new SimulationOptions(rocket);
|
|
||||||
|
|
||||||
DefaultSimulationOptionFactory f = Application.getInjector().getInstance(DefaultSimulationOptionFactory.class);
|
DefaultSimulationOptionFactory f = Application.getInjector().getInstance(DefaultSimulationOptionFactory.class);
|
||||||
options.copyConditionsFrom(f.getDefault());
|
options.copyConditionsFrom(f.getDefault());
|
||||||
|
|
||||||
FlightConfigurationId fcid = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
FlightConfigurationId fcid = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
||||||
options.setFlightConfigurationId(fcid);
|
setFlightConfigurationId(fcid);
|
||||||
|
|
||||||
options.addChangeListener(new ConditionListener());
|
options.addChangeListener(new ConditionListener());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,9 +146,8 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
|
||||||
FlightConfigurationId fcid = rocket.getSelectedConfiguration().getFlightConfigurationID();
|
this.setFlightConfigurationId( rocket.getSelectedConfiguration().getFlightConfigurationID());
|
||||||
options.setFlightConfigurationId(fcid);
|
|
||||||
|
|
||||||
options.addChangeListener(new ConditionListener());
|
options.addChangeListener(new ConditionListener());
|
||||||
|
|
||||||
if (extensions != null) {
|
if (extensions != null) {
|
||||||
@ -176,9 +175,35 @@ public class Simulation implements ChangeSource, Cloneable {
|
|||||||
return rocket;
|
return rocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationId getId(){
|
public FlightConfigurationId getFlightConfigurationId(){
|
||||||
return this.options.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
|
// * 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 the id hasn't been set yet, skip.
|
||||||
if ( options.getId().hasError() ){
|
if ( getId().hasError() ){
|
||||||
log.warn(" simulationOptions lacks a valid id. Skipping.");
|
log.warn(" simulationOptions lacks a valid id. Skipping.");
|
||||||
status = Status.CANT_RUN;
|
status = Status.CANT_RUN;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlightConfiguration config = rocket.getFlightConfiguration(options.getId());
|
FlightConfiguration config = rocket.getFlightConfiguration( this.getId()).clone();
|
||||||
|
|
||||||
//Make sure this simulation has motors.
|
//Make sure this simulation has motors.
|
||||||
if ( ! config.hasMotors() ){
|
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
|
// Set simulated info after simulation, will not be set in case of exception
|
||||||
simulatedConditions = options.clone();
|
simulatedConditions = options.clone();
|
||||||
simulatedConfigurationDescription = descriptor.format( this.rocket, options.getId());
|
simulatedConfigurationDescription = descriptor.format( this.rocket, getId());
|
||||||
simulatedRocketID = rocket.getFunctionalModID();
|
simulatedRocketID = rocket.getFunctionalModID();
|
||||||
|
|
||||||
status = Status.UPTODATE;
|
status = Status.UPTODATE;
|
||||||
|
@ -380,7 +380,7 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
writeln("<conditions>");
|
writeln("<conditions>");
|
||||||
indent++;
|
indent++;
|
||||||
|
|
||||||
writeElement("configid", cond.getId().key);
|
writeElement("configid", simulation.getId().key);
|
||||||
writeElement("launchrodlength", cond.getLaunchRodLength());
|
writeElement("launchrodlength", cond.getLaunchRodLength());
|
||||||
writeElement("launchrodangle", cond.getLaunchRodAngle() * 180.0 / Math.PI);
|
writeElement("launchrodangle", cond.getLaunchRodAngle() * 180.0 / Math.PI);
|
||||||
writeElement("launchroddirection", cond.getLaunchRodDirection() * 360.0 / (2.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 {
|
class SimulationConditionsHandler extends AbstractElementHandler {
|
||||||
private final DocumentLoadingContext context;
|
private final DocumentLoadingContext context;
|
||||||
private SimulationOptions conditions;
|
public FlightConfigurationId idToSet = FlightConfigurationId.ERROR_FCID;
|
||||||
|
private SimulationOptions options;
|
||||||
private AtmosphereHandler atmosphereHandler;
|
private AtmosphereHandler atmosphereHandler;
|
||||||
|
|
||||||
public SimulationConditionsHandler(Rocket rocket, DocumentLoadingContext context) {
|
public SimulationConditionsHandler(Rocket rocket, DocumentLoadingContext context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
conditions = new SimulationOptions(rocket);
|
options = new SimulationOptions();
|
||||||
// Set up default loading settings (which may differ from the new defaults)
|
// Set up default loading settings (which may differ from the new defaults)
|
||||||
conditions.setGeodeticComputation(GeodeticComputationStrategy.FLAT);
|
options.setGeodeticComputation(GeodeticComputationStrategy.FLAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimulationOptions getConditions() {
|
public SimulationOptions getConditions() {
|
||||||
return conditions;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,72 +51,70 @@ class SimulationConditionsHandler extends AbstractElementHandler {
|
|||||||
|
|
||||||
|
|
||||||
if (element.equals("configid")) {
|
if (element.equals("configid")) {
|
||||||
// the ID constructor is designed to always return a valid value
|
this.idToSet= new FlightConfigurationId(content);
|
||||||
FlightConfigurationId idToSet= new FlightConfigurationId(content);
|
|
||||||
conditions.setFlightConfigurationId(idToSet);
|
|
||||||
} else if (element.equals("launchrodlength")) {
|
} else if (element.equals("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 {
|
||||||
conditions.setLaunchRodLength(d);
|
options.setLaunchRodLength(d);
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchrodangle")) {
|
} else if (element.equals("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 {
|
||||||
conditions.setLaunchRodAngle(d * Math.PI / 180);
|
options.setLaunchRodAngle(d * Math.PI / 180);
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchroddirection")) {
|
} else if (element.equals("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 {
|
||||||
conditions.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
options.setLaunchRodDirection(d * 2.0 * Math.PI / 360);
|
||||||
}
|
}
|
||||||
} else if (element.equals("windaverage")) {
|
} else if (element.equals("windaverage")) {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal average windspeed defined, ignoring.");
|
warnings.add("Illegal average windspeed defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
conditions.setWindSpeedAverage(d);
|
options.setWindSpeedAverage(d);
|
||||||
}
|
}
|
||||||
} else if (element.equals("windturbulence")) {
|
} else if (element.equals("windturbulence")) {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal wind turbulence intensity defined, ignoring.");
|
warnings.add("Illegal wind turbulence intensity defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
conditions.setWindTurbulenceIntensity(d);
|
options.setWindTurbulenceIntensity(d);
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchaltitude")) {
|
} else if (element.equals("launchaltitude")) {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch altitude defined, ignoring.");
|
warnings.add("Illegal launch altitude defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
conditions.setLaunchAltitude(d);
|
options.setLaunchAltitude(d);
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchlatitude")) {
|
} else if (element.equals("launchlatitude")) {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch latitude defined, ignoring.");
|
warnings.add("Illegal launch latitude defined, ignoring.");
|
||||||
} else {
|
} else {
|
||||||
conditions.setLaunchLatitude(d);
|
options.setLaunchLatitude(d);
|
||||||
}
|
}
|
||||||
} else if (element.equals("launchlongitude")) {
|
} else if (element.equals("launchlongitude")) {
|
||||||
if (Double.isNaN(d)) {
|
if (Double.isNaN(d)) {
|
||||||
warnings.add("Illegal launch longitude.");
|
warnings.add("Illegal launch longitude.");
|
||||||
} else {
|
} else {
|
||||||
conditions.setLaunchLongitude(d);
|
options.setLaunchLongitude(d);
|
||||||
}
|
}
|
||||||
} else if (element.equals("geodeticmethod")) {
|
} else if (element.equals("geodeticmethod")) {
|
||||||
GeodeticComputationStrategy gcs =
|
GeodeticComputationStrategy gcs =
|
||||||
(GeodeticComputationStrategy) DocumentConfig.findEnum(content, GeodeticComputationStrategy.class);
|
(GeodeticComputationStrategy) DocumentConfig.findEnum(content, GeodeticComputationStrategy.class);
|
||||||
if (gcs != null) {
|
if (gcs != null) {
|
||||||
conditions.setGeodeticComputation(gcs);
|
options.setGeodeticComputation(gcs);
|
||||||
} else {
|
} else {
|
||||||
warnings.add("Unknown geodetic computation method '" + content + "'");
|
warnings.add("Unknown geodetic computation method '" + content + "'");
|
||||||
}
|
}
|
||||||
} else if (element.equals("atmosphere")) {
|
} else if (element.equals("atmosphere")) {
|
||||||
atmosphereHandler.storeSettings(conditions, warnings);
|
atmosphereHandler.storeSettings(options, warnings);
|
||||||
} else if (element.equals("timestep")) {
|
} else if (element.equals("timestep")) {
|
||||||
if (Double.isNaN(d) || d <= 0) {
|
if (Double.isNaN(d) || d <= 0) {
|
||||||
warnings.add("Illegal time step defined, ignoring.");
|
warnings.add("Illegal time step defined, ignoring.");
|
||||||
} else {
|
} 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.AbstractElementHandler;
|
||||||
import net.sf.openrocket.file.simplesax.ElementHandler;
|
import net.sf.openrocket.file.simplesax.ElementHandler;
|
||||||
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
import net.sf.openrocket.file.simplesax.PlainTextHandler;
|
||||||
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.simulation.FlightData;
|
import net.sf.openrocket.simulation.FlightData;
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
import net.sf.openrocket.simulation.SimulationOptions;
|
||||||
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
||||||
@ -115,12 +116,14 @@ class SingleSimulationHandler extends AbstractElementHandler {
|
|||||||
status = Simulation.Status.OUTDATED;
|
status = Simulation.Status.OUTDATED;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimulationOptions conditions;
|
SimulationOptions options;
|
||||||
|
FlightConfigurationId idToSet= FlightConfigurationId.ERROR_FCID;
|
||||||
if (conditionHandler != null) {
|
if (conditionHandler != null) {
|
||||||
conditions = conditionHandler.getConditions();
|
options = conditionHandler.getConditions();
|
||||||
|
idToSet = conditionHandler.idToSet;
|
||||||
} else {
|
} else {
|
||||||
warnings.add("Simulation conditions not defined, using defaults.");
|
warnings.add("Simulation conditions not defined, using defaults.");
|
||||||
conditions = new SimulationOptions(doc.getRocket());
|
options = new SimulationOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name == null)
|
if (name == null)
|
||||||
@ -133,7 +136,8 @@ class SingleSimulationHandler extends AbstractElementHandler {
|
|||||||
data = dataHandler.getFlightData();
|
data = dataHandler.getFlightData();
|
||||||
|
|
||||||
Simulation simulation = new Simulation(doc.getRocket(), status, name,
|
Simulation simulation = new Simulation(doc.getRocket(), status, name,
|
||||||
conditions, extensions, data);
|
options, extensions, data);
|
||||||
|
simulation.setFlightConfigurationId( idToSet );
|
||||||
|
|
||||||
doc.addSimulation(simulation);
|
doc.addSimulation(simulation);
|
||||||
}
|
}
|
||||||
|
@ -36,8 +36,8 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
|||||||
public String toDebug(){
|
public String toDebug(){
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("====== Dumping MotorConfigurationSet for mount ("+this.size()+ " motors)\n");
|
buffer.append("====== Dumping MotorConfigurationSet for mount ("+this.size()+ " motors)\n");
|
||||||
MotorConfiguration emptyInstance = this.getDefault();
|
MotorConfiguration defaultConfig = this.getDefault();
|
||||||
buffer.append(" >> (["+emptyInstance.toString()+"]= @ "+ emptyInstance.getIgnitionEvent().name +" +"+emptyInstance.getIgnitionDelay()+"sec )\n");
|
buffer.append(" (Ignition@ "+ defaultConfig.getIgnitionEvent().name +" +"+defaultConfig.getIgnitionDelay()+"sec )\n");
|
||||||
|
|
||||||
for( FlightConfigurationId loopFCID : this.map.keySet()){
|
for( FlightConfigurationId loopFCID : this.map.keySet()){
|
||||||
String shortKey = loopFCID.toShortKey();
|
String shortKey = loopFCID.toShortKey();
|
||||||
@ -45,7 +45,7 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
|||||||
MotorConfiguration curInstance = this.map.get(loopFCID);
|
MotorConfiguration curInstance = this.map.get(loopFCID);
|
||||||
String designation;
|
String designation;
|
||||||
if( null == curInstance.getMotor() ){
|
if( null == curInstance.getMotor() ){
|
||||||
designation = "EMPTY_INSTANCE";
|
designation = "<EMPTY>";
|
||||||
}else{
|
}else{
|
||||||
designation = curInstance.getMotor().getDesignation(curInstance.getEjectionDelay());
|
designation = curInstance.getMotor().getDesignation(curInstance.getEjectionDelay());
|
||||||
}
|
}
|
||||||
@ -54,7 +54,8 @@ public class MotorConfigurationSet extends FlightConfigurableParameterSet<MotorC
|
|||||||
if( 0 != delay ){
|
if( 0 != delay ){
|
||||||
ignition += " +"+delay;
|
ignition += " +"+delay;
|
||||||
}
|
}
|
||||||
buffer.append(" >> ["+shortKey+"]= "+designation+" @ "+ignition+"\n");
|
buffer.append(String.format(" >> [%10s]= %6s @ %4s\n",
|
||||||
|
shortKey, designation, ignition ));
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -420,10 +420,11 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
|
|||||||
for (RocketComponent component : this.getActiveComponents()) {
|
for (RocketComponent component : this.getActiveComponents()) {
|
||||||
for (Coordinate coord : component.getComponentBounds()) {
|
for (Coordinate coord : component.getComponentBounds()) {
|
||||||
cachedBounds.add(coord);
|
cachedBounds.add(coord);
|
||||||
if (coord.x < minX)
|
if (coord.x < minX){
|
||||||
minX = coord.x;
|
minX = coord.x;
|
||||||
if (coord.x > maxX)
|
}else if (coord.x > maxX){
|
||||||
maxX = coord.x;
|
maxX = coord.x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,11 +818,10 @@ public class Rocket extends RocketComponent {
|
|||||||
StringBuilder buf = new StringBuilder();
|
StringBuilder buf = new StringBuilder();
|
||||||
buf.append(String.format("====== Dumping %d Configurations from rocket: \n", this.getConfigurationCount(), this.getName()));
|
buf.append(String.format("====== Dumping %d Configurations from rocket: \n", this.getConfigurationCount(), this.getName()));
|
||||||
final String fmt = " [%-12s]: %s\n";
|
final String fmt = " [%-12s]: %s\n";
|
||||||
buf.append(String.format(fmt, " *SELECTED* ", selectedConfiguration.getName() ));
|
|
||||||
for( FlightConfiguration config : this.configSet.values() ){
|
for( FlightConfiguration config : this.configSet.values() ){
|
||||||
String shortKey = config.getId().toShortKey();
|
String shortKey = config.getId().toShortKey();
|
||||||
if( this.selectedConfiguration.equals( config)){
|
if( this.selectedConfiguration.equals( config)){
|
||||||
shortKey = "*"+shortKey+"*";
|
shortKey = shortKey+"<=";
|
||||||
}
|
}
|
||||||
buf.append(String.format(fmt, shortKey, config.getName() ));
|
buf.append(String.format(fmt, shortKey, config.getName() ));
|
||||||
}
|
}
|
||||||
|
@ -2114,7 +2114,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
public String toDebugTree() {
|
public String toDebugTree() {
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append("\n ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== ====== ======\n");
|
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, "");
|
this.dumpTreeHelper(buffer, "");
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public class DefaultSimulationOptionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SimulationOptions getDefault() {
|
public SimulationOptions getDefault() {
|
||||||
SimulationOptions defaults = new SimulationOptions(null);
|
SimulationOptions defaults = new SimulationOptions();
|
||||||
if (prefs != null) {
|
if (prefs != null) {
|
||||||
|
|
||||||
defaults.setWindSpeedAverage(prefs.getDouble(SIMCONDITION_WIND_SPEED, defaults.getWindSpeedAverage()));
|
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 {
|
public class SimulationConditions implements Monitorable, Cloneable {
|
||||||
|
|
||||||
private Rocket rocket;
|
|
||||||
private FlightConfigurationId configId= null;
|
|
||||||
|
|
||||||
private Simulation simulation; // The parent simulation
|
private Simulation simulation; // The parent simulation
|
||||||
|
|
||||||
private double launchRodLength = 1;
|
private double launchRodLength = 1;
|
||||||
@ -103,29 +100,16 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
|||||||
|
|
||||||
|
|
||||||
public Rocket getRocket() {
|
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() {
|
public FlightConfigurationId getMotorConfigurationID() {
|
||||||
return configId;
|
return simulation.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationId getFlightConfigurationID() {
|
public FlightConfigurationId getFlightConfigurationID() {
|
||||||
return configId;
|
return simulation.getId();
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlightConfigurationID(FlightConfigurationId _fcid) {
|
|
||||||
this.configId = _fcid;
|
|
||||||
this.modID++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -313,7 +297,7 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
|||||||
public int getModID() {
|
public int getModID() {
|
||||||
//return (modID + modIDadd + rocket.getModID() + windModel.getModID() + atmosphericModel.getModID() +
|
//return (modID + modIDadd + rocket.getModID() + windModel.getModID() + atmosphericModel.getModID() +
|
||||||
// gravityModel.getModID() + aerodynamicCalculator.getModID() + massCalculator.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());
|
aerodynamicCalculator.getModID() + massCalculator.getModID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,8 +311,6 @@ public class SimulationConditions implements Monitorable, Cloneable {
|
|||||||
for (SimulationListener listener : this.simulationListeners) {
|
for (SimulationListener listener : this.simulationListeners) {
|
||||||
clone.simulationListeners.add(listener.clone());
|
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;
|
return clone;
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
|
@ -10,15 +10,12 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
|
import net.sf.openrocket.aerodynamics.BarrowmanCalculator;
|
||||||
import net.sf.openrocket.formatting.MotorDescriptionSubstitutor;
|
|
||||||
import net.sf.openrocket.masscalc.MassCalculator;
|
import net.sf.openrocket.masscalc.MassCalculator;
|
||||||
import net.sf.openrocket.models.atmosphere.AtmosphericModel;
|
import net.sf.openrocket.models.atmosphere.AtmosphericModel;
|
||||||
import net.sf.openrocket.models.atmosphere.ExtendedISAModel;
|
import net.sf.openrocket.models.atmosphere.ExtendedISAModel;
|
||||||
import net.sf.openrocket.models.gravity.GravityModel;
|
import net.sf.openrocket.models.gravity.GravityModel;
|
||||||
import net.sf.openrocket.models.gravity.WGSGravityModel;
|
import net.sf.openrocket.models.gravity.WGSGravityModel;
|
||||||
import net.sf.openrocket.models.wind.PinkNoiseWindModel;
|
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.Application;
|
||||||
import net.sf.openrocket.startup.Preferences;
|
import net.sf.openrocket.startup.Preferences;
|
||||||
import net.sf.openrocket.util.BugException;
|
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.GeodeticComputationStrategy;
|
||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
import net.sf.openrocket.util.Utils;
|
|
||||||
import net.sf.openrocket.util.WorldCoordinate;
|
import net.sf.openrocket.util.WorldCoordinate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,9 +46,6 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
|
|
||||||
protected final Preferences preferences = Application.getPreferences();
|
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
|
* NOTE: When adding/modifying parameters, they must also be added to the
|
||||||
* equals and copyFrom methods!!
|
* equals and copyFrom methods!!
|
||||||
@ -92,45 +85,9 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
|
|
||||||
private List<EventListener> listeners = new ArrayList<EventListener>();
|
private List<EventListener> listeners = new ArrayList<EventListener>();
|
||||||
|
|
||||||
public SimulationOptions(Rocket rocket) {
|
public SimulationOptions() {
|
||||||
this.rocket = rocket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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() {
|
public double getLaunchRodLength() {
|
||||||
return launchRodLength;
|
return launchRodLength;
|
||||||
}
|
}
|
||||||
@ -436,35 +393,6 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
|
|
||||||
public void copyFrom(SimulationOptions src) {
|
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.launchAltitude = src.launchAltitude;
|
||||||
this.launchLatitude = src.launchLatitude;
|
this.launchLatitude = src.launchLatitude;
|
||||||
this.launchLongitude = src.launchLongitude;
|
this.launchLongitude = src.launchLongitude;
|
||||||
@ -564,9 +492,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
if (!(other instanceof SimulationOptions))
|
if (!(other instanceof SimulationOptions))
|
||||||
return false;
|
return false;
|
||||||
SimulationOptions o = (SimulationOptions) other;
|
SimulationOptions o = (SimulationOptions) other;
|
||||||
return ((this.rocket == o.rocket) &&
|
return (MathUtil.equals(this.launchAltitude, o.launchAltitude) &&
|
||||||
Utils.equals(this.configId, o.configId) &&
|
|
||||||
MathUtil.equals(this.launchAltitude, o.launchAltitude) &&
|
|
||||||
MathUtil.equals(this.launchLatitude, o.launchLatitude) &&
|
MathUtil.equals(this.launchLatitude, o.launchLatitude) &&
|
||||||
MathUtil.equals(this.launchLongitude, o.launchLongitude) &&
|
MathUtil.equals(this.launchLongitude, o.launchLongitude) &&
|
||||||
MathUtil.equals(this.launchPressure, o.launchPressure) &&
|
MathUtil.equals(this.launchPressure, o.launchPressure) &&
|
||||||
@ -587,9 +513,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (configId.hasError())
|
return 0;
|
||||||
return rocket.hashCode();
|
|
||||||
return rocket.hashCode() + configId.hashCode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -619,9 +543,7 @@ public class SimulationOptions implements ChangeSource, Cloneable {
|
|||||||
// TODO: HIGH: Clean up
|
// TODO: HIGH: Clean up
|
||||||
public SimulationConditions toSimulationConditions() {
|
public SimulationConditions toSimulationConditions() {
|
||||||
SimulationConditions conditions = new SimulationConditions();
|
SimulationConditions conditions = new SimulationConditions();
|
||||||
|
|
||||||
conditions.setRocket((Rocket) getRocket().copy());
|
|
||||||
conditions.setFlightConfigurationID(this.getId());
|
|
||||||
conditions.setLaunchRodLength(getLaunchRodLength());
|
conditions.setLaunchRodLength(getLaunchRodLength());
|
||||||
conditions.setLaunchRodAngle(getLaunchRodAngle());
|
conditions.setLaunchRodAngle(getLaunchRodAngle());
|
||||||
conditions.setLaunchRodDirection(getLaunchRodDirection());
|
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.Transition.Shape;
|
||||||
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
|
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
|
||||||
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
import net.sf.openrocket.rocketcomponent.TubeCoupler;
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
|
||||||
import net.sf.openrocket.simulation.customexpression.CustomExpression;
|
import net.sf.openrocket.simulation.customexpression.CustomExpression;
|
||||||
import net.sf.openrocket.simulation.exception.SimulationException;
|
import net.sf.openrocket.simulation.exception.SimulationException;
|
||||||
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
||||||
@ -87,7 +86,48 @@ public class TestRockets {
|
|||||||
this.rnd = new Random(key.hashCode());
|
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).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
private static MotorConfiguration generateMotorInstance_C6_18mm(){
|
private static MotorConfiguration generateMotorInstance_C6_18mm(){
|
||||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
// 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,
|
Motor.Type.SINGLE, new double[] {0,3,5,7}, 0.018, 0.070,
|
||||||
new double[] { 0, 1, 2 }, new double[] { 0, 6, 0 },
|
new double[] { 0, 1, 2 }, new double[] { 0, 6, 0 },
|
||||||
new Coordinate[] {
|
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");
|
"digest C6 test");
|
||||||
return new MotorConfiguration(mtr);
|
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).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
private static MotorConfiguration generateMotorInstance_M1350_75mm(){
|
private static MotorConfiguration generateMotorInstance_M1350_75mm(){
|
||||||
// public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description,
|
// 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).
|
// This function is used for unit, integration tests, DO NOT CHANGE (without updating tests).
|
||||||
public static final Rocket makeEstesAlphaIII(){
|
public static final Rocket makeEstesAlphaIII(){
|
||||||
Rocket rocket = new Rocket();
|
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");
|
rocket.setName("Estes Alpha III / Code Verification Rocket");
|
||||||
AxialStage stage = new AxialStage();
|
AxialStage stage = new AxialStage();
|
||||||
stage.setName("Stage");
|
stage.setName("Stage");
|
||||||
@ -394,12 +458,38 @@ public class TestRockets {
|
|||||||
thrustBlock.setThickness(0.0008);
|
thrustBlock.setThickness(0.0008);
|
||||||
thrustBlock.setName("Engine Block");
|
thrustBlock.setName("Engine Block");
|
||||||
inner.addChild(thrustBlock);
|
inner.addChild(thrustBlock);
|
||||||
|
|
||||||
MotorConfiguration motorConfig = TestRockets.generateMotorInstance_C6_18mm();
|
|
||||||
motorConfig.setID( new MotorInstanceId( inner.getName(), 1) );
|
|
||||||
inner.setMotorMount( true);
|
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
|
// parachute
|
||||||
@ -432,6 +522,192 @@ public class TestRockets {
|
|||||||
return rocket;
|
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() {
|
public static Rocket makeSmallFlyable() {
|
||||||
double noseconeLength = 0.10, noseconeRadius = 0.01;
|
double noseconeLength = 0.10, noseconeRadius = 0.01;
|
||||||
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
|
double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001;
|
||||||
@ -553,6 +829,8 @@ public class TestRockets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Rocket makeIsoHaisu() {
|
public static Rocket makeIsoHaisu() {
|
||||||
Rocket rocket;
|
Rocket rocket;
|
||||||
AxialStage stage;
|
AxialStage stage;
|
||||||
@ -1036,9 +1314,8 @@ public class TestRockets {
|
|||||||
OpenRocketDocument rocketDoc = OpenRocketDocumentFactory.createDocumentFromRocket(rocket);
|
OpenRocketDocument rocketDoc = OpenRocketDocumentFactory.createDocumentFromRocket(rocket);
|
||||||
|
|
||||||
// create simulation data
|
// create simulation data
|
||||||
SimulationOptions options = new SimulationOptions(rocket);
|
|
||||||
options.setFlightConfigurationId(fcid);
|
|
||||||
Simulation simulation1 = new Simulation(rocket);
|
Simulation simulation1 = new Simulation(rocket);
|
||||||
|
simulation1.setFlightConfigurationId(fcid);
|
||||||
|
|
||||||
rocketDoc.addSimulation(simulation1);
|
rocketDoc.addSimulation(simulation1);
|
||||||
Simulation simulation2 = new Simulation(rocket);
|
Simulation simulation2 = new Simulation(rocket);
|
||||||
@ -1358,16 +1635,6 @@ public class TestRockets {
|
|||||||
return rocketDoc;
|
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.Motor;
|
||||||
import net.sf.openrocket.motor.MotorConfiguration;
|
import net.sf.openrocket.motor.MotorConfiguration;
|
||||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||||
|
import net.sf.openrocket.optimization.rocketoptimization.TestRocketOptimizationFunction;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
|
import net.sf.openrocket.util.TestRockets;
|
||||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||||
|
|
||||||
public class FlightConfigurationTest extends BaseTestCase {
|
public class FlightConfigurationTest extends BaseTestCase {
|
||||||
@ -25,7 +27,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEmptyRocket() {
|
public void testEmptyRocket() {
|
||||||
Rocket r1 = makeEmptyRocket();
|
Rocket r1 = TestRockets.makeSmallFlyable();
|
||||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
FlightConfiguration config = r1.getSelectedConfiguration();
|
||||||
|
|
||||||
FlightConfiguration configClone = config.clone();
|
FlightConfiguration configClone = config.clone();
|
||||||
@ -38,9 +40,12 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCloneBasic() {
|
public void testCloneBasic() {
|
||||||
Rocket rkt1 = makeTwoStageMotorRocket();
|
Rocket rkt1 = TestRockets.makeBeta();
|
||||||
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
||||||
|
|
||||||
|
// final String treedump = rkt1.toDebugTree();
|
||||||
|
// System.err.println("treedump: \n" + treedump);
|
||||||
|
|
||||||
// preconditions
|
// preconditions
|
||||||
config1.setAllStages();
|
config1.setAllStages();
|
||||||
int expectedStageCount = 2;
|
int expectedStageCount = 2;
|
||||||
@ -49,13 +54,13 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
int expectedMotorCount = 2;
|
int expectedMotorCount = 2;
|
||||||
int actualMotorCount = config1.getActiveMotors().size();
|
int actualMotorCount = config1.getActiveMotors().size();
|
||||||
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
assertThat("active motor count doesn't match", actualMotorCount, equalTo(expectedMotorCount));
|
||||||
double expectedLength = 176.8698848;
|
double expectedLength = 0.33;
|
||||||
double actualLength = config1.getLength();
|
double actualLength = config1.getLength();
|
||||||
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
assertEquals("source config length doesn't match: ", expectedLength, actualLength, EPSILON);
|
||||||
double expectedReferenceLength = 2.5;
|
double expectedReferenceLength = 0.024;
|
||||||
double actualReferenceLength = config1.getReferenceLength();
|
double actualReferenceLength = config1.getReferenceLength();
|
||||||
assertEquals("source config reference length doesn't match: ", expectedReferenceLength, actualReferenceLength, EPSILON);
|
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();
|
double actualReferenceArea = config1.getReferenceArea();
|
||||||
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
assertEquals("source config reference area doesn't match: ", expectedReferenceArea, actualReferenceArea, EPSILON);
|
||||||
|
|
||||||
@ -84,7 +89,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCloneIndependence() {
|
public void testCloneIndependence() {
|
||||||
Rocket rkt1 = makeTwoStageMotorRocket();
|
Rocket rkt1 = TestRockets.makeBeta();
|
||||||
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
FlightConfiguration config1 = rkt1.getSelectedConfiguration();
|
||||||
int expectedStageCount;
|
int expectedStageCount;
|
||||||
int actualStageCount;
|
int actualStageCount;
|
||||||
@ -121,18 +126,13 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSingleStageRocket() {
|
public void testSingleStageRocket() {
|
||||||
|
Rocket r1 = TestRockets.makeEstesAlphaIII();
|
||||||
/* Setup */
|
|
||||||
Rocket r1 = makeSingleStageTestRocket();
|
|
||||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
FlightConfiguration config = r1.getSelectedConfiguration();
|
||||||
|
|
||||||
// test explicitly setting only first stage active
|
// test explicitly setting only first stage active
|
||||||
config.clearAllStages();
|
config.clearAllStages();
|
||||||
config.setOnlyStage(0);
|
config.setOnlyStage(0);
|
||||||
|
|
||||||
//config.dumpConfig();
|
|
||||||
//System.err.println("treedump: \n" + treedump);
|
|
||||||
|
|
||||||
// test that getStageCount() returns correct value
|
// test that getStageCount() returns correct value
|
||||||
int expectedStageCount = 1;
|
int expectedStageCount = 1;
|
||||||
int stageCount = config.getStageCount();
|
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
|
* Multi stage rocket specific configuration tests
|
||||||
*/
|
*/
|
||||||
@ -157,8 +186,8 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
public void testMultiStageRocket() {
|
public void testMultiStageRocket() {
|
||||||
|
|
||||||
/* Setup */
|
/* Setup */
|
||||||
Rocket r1 = makeTwoStageTestRocket();
|
Rocket rkt = TestRockets.makeBeta();
|
||||||
FlightConfiguration config = r1.getSelectedConfiguration();
|
FlightConfiguration config = rkt.getSelectedConfiguration();
|
||||||
|
|
||||||
int expectedStageCount;
|
int expectedStageCount;
|
||||||
int stageCount;
|
int stageCount;
|
||||||
@ -214,7 +243,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
public void testMotorClusters() {
|
public void testMotorClusters() {
|
||||||
|
|
||||||
/* Setup */
|
/* Setup */
|
||||||
Rocket rkt = makeTwoStageMotorRocket();
|
Rocket rkt = TestRockets.makeBeta();
|
||||||
FlightConfiguration config = rkt.getSelectedConfiguration();
|
FlightConfiguration config = rkt.getSelectedConfiguration();
|
||||||
|
|
||||||
|
|
||||||
@ -239,256 +268,5 @@ public class FlightConfigurationTest extends BaseTestCase {
|
|||||||
assertThat("active motor count doesn't match: ", actualMotorCount, equalTo(expectedMotorCount));
|
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
|
// Update the active configuration
|
||||||
FlightConfigurationId fcid = getSelectedSimulation().getOptions().getId();
|
FlightConfigurationId fcid = getSelectedSimulation().getId();
|
||||||
getSelectedSimulation().getRocket().setDefaultConfiguration(fcid);
|
getSelectedSimulation().getRocket().setDefaultConfiguration(fcid);
|
||||||
|
|
||||||
updating = false;
|
updating = false;
|
||||||
|
@ -612,7 +612,7 @@ public class SimulationPanel extends JPanel {
|
|||||||
if((s==Simulation.Status.NOT_SIMULATED) ||
|
if((s==Simulation.Status.NOT_SIMULATED) ||
|
||||||
(s==Simulation.Status.OUTDATED)){
|
(s==Simulation.Status.OUTDATED)){
|
||||||
outdated++;
|
outdated++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(outdated>0){
|
if(outdated>0){
|
||||||
Simulation[] sims = new Simulation[outdated];
|
Simulation[] sims = new Simulation[outdated];
|
||||||
@ -668,7 +668,6 @@ public class SimulationPanel extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class JLabelRenderer extends DefaultTableCellRenderer {
|
private class JLabelRenderer extends DefaultTableCellRenderer {
|
||||||
private static final long serialVersionUID = 5487619660216145843L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getTableCellRendererComponent(JTable table,
|
public Component getTableCellRendererComponent(JTable table,
|
||||||
|
@ -3,7 +3,6 @@ package net.sf.openrocket.gui.main.flightconfigpanel;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
|
|
||||||
@ -25,7 +24,6 @@ public class FlightConfigurableTableModel<T extends FlightConfigurableComponent>
|
|||||||
protected final Rocket rocket;
|
protected final Rocket rocket;
|
||||||
protected final Class<T> clazz;
|
protected final Class<T> clazz;
|
||||||
private final List<T> components = new ArrayList<T>();
|
private final List<T> components = new ArrayList<T>();
|
||||||
private List<FlightConfigurationId> ids = new Vector<FlightConfigurationId>();
|
|
||||||
|
|
||||||
public FlightConfigurableTableModel(Class<T> clazz, Rocket rocket) {
|
public FlightConfigurableTableModel(Class<T> clazz, Rocket rocket) {
|
||||||
super();
|
super();
|
||||||
@ -52,6 +50,7 @@ public class FlightConfigurableTableModel<T extends FlightConfigurableComponent>
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
protected void initialize() {
|
protected void initialize() {
|
||||||
components.clear();
|
components.clear();
|
||||||
Iterator<RocketComponent> it = rocket.iterator();
|
Iterator<RocketComponent> it = rocket.iterator();
|
||||||
|
@ -513,7 +513,7 @@ public class DesignReport {
|
|||||||
try {
|
try {
|
||||||
for (int i = 0; i < simulations.size(); i++) {
|
for (int i = 0; i < simulations.size(); i++) {
|
||||||
Simulation simulation = simulations.get(i);
|
Simulation simulation = simulations.get(i);
|
||||||
if (Utils.equals(simulation.getOptions().getId(), motorId)) {
|
if (Utils.equals(simulation.getId(), motorId)) {
|
||||||
simulation = simulation.copy();
|
simulation = simulation.copy();
|
||||||
simulation.simulate();
|
simulation.simulate();
|
||||||
flight = simulation.getSimulatedData();
|
flight = simulation.getSimulatedData();
|
||||||
|
@ -687,8 +687,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
|||||||
|
|
||||||
Rocket duplicate = (Rocket) document.getRocket().copy();
|
Rocket duplicate = (Rocket) document.getRocket().copy();
|
||||||
Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate);
|
Simulation simulation = ((SwingPreferences) Application.getPreferences()).getBackgroundSimulation(duplicate);
|
||||||
simulation.getOptions().setFlightConfigurationId(
|
simulation.setFlightConfigurationId( document.getDefaultConfiguration().getFlightConfigurationID());
|
||||||
document.getDefaultConfiguration().getFlightConfigurationID());
|
|
||||||
|
|
||||||
backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation);
|
backgroundSimulationWorker = new BackgroundSimulationWorker(document, simulation);
|
||||||
backgroundSimulationExecutor.execute(backgroundSimulationWorker);
|
backgroundSimulationExecutor.execute(backgroundSimulationWorker);
|
||||||
|
@ -25,7 +25,6 @@ import net.sf.openrocket.gui.util.GUIUtil;
|
|||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
import net.sf.openrocket.rocketcomponent.FlightConfiguration;
|
||||||
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
import net.sf.openrocket.rocketcomponent.FlightConfigurationId;
|
||||||
import net.sf.openrocket.simulation.SimulationOptions;
|
|
||||||
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
import net.sf.openrocket.simulation.extension.SimulationExtension;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
@ -33,9 +32,8 @@ import net.sf.openrocket.startup.Application;
|
|||||||
public class SimulationEditDialog extends JDialog {
|
public class SimulationEditDialog extends JDialog {
|
||||||
private static final long serialVersionUID = -4468157685542912715L;
|
private static final long serialVersionUID = -4468157685542912715L;
|
||||||
private final Window parentWindow;
|
private final Window parentWindow;
|
||||||
private final Simulation[] simulation;
|
private final Simulation[] simulationList;
|
||||||
private final OpenRocketDocument document;
|
private final OpenRocketDocument document;
|
||||||
private final SimulationOptions conditions;
|
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
JPanel cards;
|
JPanel cards;
|
||||||
@ -47,8 +45,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
super(parent, trans.get("simedtdlg.title.Editsim"), JDialog.ModalityType.DOCUMENT_MODAL);
|
||||||
this.document = document;
|
this.document = document;
|
||||||
this.parentWindow = parent;
|
this.parentWindow = parent;
|
||||||
this.simulation = sims;
|
this.simulationList = sims;
|
||||||
this.conditions = simulation[0].getOptions();
|
|
||||||
|
|
||||||
this.cards = new JPanel(new CardLayout());
|
this.cards = new JPanel(new CardLayout());
|
||||||
this.add(cards);
|
this.add(cards);
|
||||||
@ -64,11 +61,11 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isSingleEdit() {
|
private boolean isSingleEdit() {
|
||||||
return simulation.length == 1;
|
return simulationList.length == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean allowsPlotMode() {
|
private boolean allowsPlotMode() {
|
||||||
return simulation.length == 1 && simulation[0].hasSimulationData();
|
return simulationList.length == 1 && simulationList[0].hasSimulationData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setEditMode() {
|
public void setEditMode() {
|
||||||
@ -87,12 +84,12 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void copyChangesToAllSims() {
|
private void copyChangesToAllSims() {
|
||||||
if (simulation.length > 1) {
|
if (simulationList.length > 1) {
|
||||||
for (int i = 1; i < simulation.length; i++) {
|
for (int i = 1; i < simulationList.length; i++) {
|
||||||
simulation[i].getOptions().copyConditionsFrom(simulation[0].getOptions());
|
simulationList[i].getOptions().copyConditionsFrom(simulationList[0].getOptions());
|
||||||
simulation[i].getSimulationExtensions().clear();
|
simulationList[i].getSimulationExtensions().clear();
|
||||||
for (SimulationExtension c : simulation[0].getSimulationExtensions()) {
|
for (SimulationExtension c : simulationList[0].getSimulationExtensions()) {
|
||||||
simulation[i].getSimulationExtensions().add(c.clone());
|
simulationList[i].getSimulationExtensions().add(c.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,7 +110,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
|
|
||||||
//// Simulation name:
|
//// Simulation name:
|
||||||
panel.add(new JLabel(trans.get("simedtdlg.lbl.Simname") + " "), "growx 0, gapright para");
|
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() {
|
field.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
@ -135,7 +132,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
if (name == null || name.equals(""))
|
if (name == null || name.equals(""))
|
||||||
return;
|
return;
|
||||||
//System.out.println("Setting name:" + name);
|
//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) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
FlightConfiguration config = (FlightConfiguration)configComboBox.getSelectedItem();
|
FlightConfiguration config = (FlightConfiguration)configComboBox.getSelectedItem();
|
||||||
FlightConfigurationId id = config.getId();
|
FlightConfigurationId id = config.getId();
|
||||||
conditions.setFlightConfigurationId( id );
|
|
||||||
|
simulationList[0].setFlightConfigurationId( id );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(configComboBox, "span");
|
panel.add(configComboBox, "span");
|
||||||
@ -170,9 +168,9 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
JTabbedPane tabbedPane = new JTabbedPane();
|
JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
|
|
||||||
//// Launch conditions
|
//// 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
|
//// 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);
|
tabbedPane.setSelectedIndex(0);
|
||||||
|
|
||||||
@ -205,7 +203,7 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
copyChangesToAllSims();
|
copyChangesToAllSims();
|
||||||
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulation);
|
SimulationRunDialog.runSimulations(parentWindow, SimulationEditDialog.this.document, simulationList);
|
||||||
refreshView();
|
refreshView();
|
||||||
if (allowsPlotMode()) {
|
if (allowsPlotMode()) {
|
||||||
setPlotMode();
|
setPlotMode();
|
||||||
@ -236,17 +234,17 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
|
|
||||||
//// Simulation name:
|
//// Simulation name:
|
||||||
plotExportPanel.add(new JLabel(trans.get("simedtdlg.lbl.Simname") + " "), "span, split 2, shrink");
|
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);
|
field.setEditable(false);
|
||||||
plotExportPanel.add(field, "shrinky, growx, wrap");
|
plotExportPanel.add(field, "shrinky, growx, wrap");
|
||||||
|
|
||||||
final JTabbedPane tabbedPane = new JTabbedPane();
|
final JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
|
|
||||||
//// Plot data
|
//// Plot data
|
||||||
final SimulationPlotPanel plotTab = new SimulationPlotPanel(simulation[0]);
|
final SimulationPlotPanel plotTab = new SimulationPlotPanel(simulationList[0]);
|
||||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Plotdata"), plotTab);
|
tabbedPane.addTab(trans.get("simedtdlg.tab.Plotdata"), plotTab);
|
||||||
//// Export data
|
//// Export data
|
||||||
final SimulationExportPanel exportTab = new SimulationExportPanel(simulation[0]);
|
final SimulationExportPanel exportTab = new SimulationExportPanel(simulationList[0]);
|
||||||
tabbedPane.addTab(trans.get("simedtdlg.tab.Exportdata"), exportTab);
|
tabbedPane.addTab(trans.get("simedtdlg.tab.Exportdata"), exportTab);
|
||||||
|
|
||||||
plotExportPanel.add(tabbedPane, "grow, wrap");
|
plotExportPanel.add(tabbedPane, "grow, wrap");
|
||||||
@ -286,8 +284,8 @@ public class SimulationEditDialog extends JDialog {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
// If the simulation is out of date, run the simulation.
|
// If the simulation is out of date, run the simulation.
|
||||||
if (simulation[0].getStatus() != Simulation.Status.UPTODATE) {
|
if (simulationList[0].getStatus() != Simulation.Status.UPTODATE) {
|
||||||
new SimulationRunDialog(SimulationEditDialog.this.parentWindow, document, simulation[0]).setVisible(true);
|
new SimulationRunDialog(SimulationEditDialog.this.parentWindow, document, simulationList[0]).setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tabbedPane.getSelectedIndex() == 0) {
|
if (tabbedPane.getSelectedIndex() == 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user