From 88f84396d003160be73baa80b5f523eea0085ee5 Mon Sep 17 00:00:00 2001 From: Kevin Ruland Date: Mon, 14 Dec 2015 18:41:02 -0600 Subject: [PATCH 1/3] Initial refactoring of MotorInstance and ThrustCurveMotorInstance --- .../openrocket/importt/MotorMountHandler.java | 6 +- core/src/net/sf/openrocket/motor/Motor.java | 3 +- .../sf/openrocket/motor/MotorInstance.java | 255 ++++++++---------- .../src/net/sf/openrocket/motor/MotorSet.java | 4 +- .../sf/openrocket/motor/ThrustCurveMotor.java | 2 +- .../motor/ThrustCurveMotorInstance.java | 164 +++++------ .../motor/ThrustCurveMotorPlaceholder.java | 3 +- .../openrocket/rocketcomponent/BodyTube.java | 2 +- .../rocketcomponent/FlightConfiguration.java | 65 +---- .../IgnitionConfiguration.java | 72 +++++ .../rocketcomponent/IgnitionEvent.java | 34 +-- .../openrocket/rocketcomponent/InnerTube.java | 2 +- .../rocketcomponent/MotorConfiguration.java | 72 +++++ .../simulation/AbstractSimulationStepper.java | 4 +- .../BasicEventSimulationEngine.java | 10 +- .../sf/openrocket/simulation/MotorState.java | 31 +++ .../simulation/SimulationStatus.java | 36 ++- .../impl/ScriptingSimulationListener.java | 10 +- .../listeners/AbstractSimulationListener.java | 4 +- .../listeners/SimulationEventListener.java | 4 +- .../listeners/SimulationListenerHelper.java | 4 +- .../net/sf/openrocket/util/TestRockets.java | 15 +- .../sf/openrocket/utils/MotorCorrelation.java | 6 +- .../motor/ThrustCurveMotorTest.java | 5 +- .../rocketcomponent/ConfigurationTest.java | 8 +- .../MotorConfigurationPanel.java | 17 +- 26 files changed, 475 insertions(+), 363 deletions(-) create mode 100644 core/src/net/sf/openrocket/rocketcomponent/IgnitionConfiguration.java create mode 100644 core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java create mode 100644 core/src/net/sf/openrocket/simulation/MotorState.java diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java index 7b7c8807e..09484754d 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java @@ -73,15 +73,17 @@ class MotorMountHandler extends AbstractElementHandler { } Motor motor = motorHandler.getMotor(warnings); - MotorInstance motorInstance = motor.getNewInstance(); + MotorInstance motorInstance = new MotorInstance(); + motorInstance.setMotor(motor); RocketComponent mountComponent = (RocketComponent)mount; + motorInstance.setMount(mount); motorInstance.setID( new MotorInstanceId(mountComponent.getID(), 1)); motorInstance.setEjectionDelay(motorHandler.getDelay(warnings)); mount.setMotorInstance(fcid, motorInstance); Rocket rkt = ((RocketComponent)mount).getRocket(); rkt.createFlightConfiguration(fcid); - + rkt.getFlightConfiguration(fcid).addMotor(motorInstance); return; } diff --git a/core/src/net/sf/openrocket/motor/Motor.java b/core/src/net/sf/openrocket/motor/Motor.java index d334d8d62..1b735da6a 100644 --- a/core/src/net/sf/openrocket/motor/Motor.java +++ b/core/src/net/sf/openrocket/motor/Motor.java @@ -1,5 +1,6 @@ package net.sf.openrocket.motor; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.Coordinate; public interface Motor { @@ -117,7 +118,7 @@ public interface Motor { public String getDigest(); - public MotorInstance getNewInstance(); + public MotorState getNewInstance(); public Coordinate getLaunchCG(); diff --git a/core/src/net/sf/openrocket/motor/MotorInstance.java b/core/src/net/sf/openrocket/motor/MotorInstance.java index 59797f96d..831c0b1ad 100644 --- a/core/src/net/sf/openrocket/motor/MotorInstance.java +++ b/core/src/net/sf/openrocket/motor/MotorInstance.java @@ -3,91 +3,77 @@ package net.sf.openrocket.motor; import java.util.EventObject; import java.util.List; -import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.rocketcomponent.FlightConfigurableParameter; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; +import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.Inertia; import net.sf.openrocket.util.StateChangeListener; /** * A single motor configuration. This includes the selected motor * and the ejection charge delay. */ -public abstract class MotorInstance implements FlightConfigurableParameter { +public class MotorInstance implements FlightConfigurableParameter { - // deferred to subclasses - //protected MotorMount mount = null; - //protected Motor motor = null; - - protected MotorInstanceId id = null; + protected MotorMount mount = null; + protected Motor motor = null; + protected Coordinate position = Coordinate.ZERO; protected double ejectionDelay = 0.0; + + protected MotorInstanceId id = null; + + protected boolean ignitionOveride = false; protected double ignitionDelay = 0.0; protected IgnitionEvent ignitionEvent = IgnitionEvent.NEVER; - protected Coordinate position = Coordinate.ZERO; protected double ignitionTime = 0.0; - protected int modID = 0; private final List listeners = new ArrayList(); - /** Immutable configuration with no motor and zero delay. */ - public static final MotorInstance EMPTY_INSTANCE = new MotorInstance(){ - @Override - public boolean equals( Object other ){ - return (this==other); - } - - @Override - public Motor getMotor() { - throw new UnsupportedOperationException("Retrieve a motor from an immutable no-motors instance"); - } - - @Override - public MotorMount getMount() { - throw new UnsupportedOperationException("Retrieve a mount from an immutable no-motors instance"); - } - - @Override - public double getThrust() { - throw new UnsupportedOperationException("Trying to get thrust from an empty motor instance."); - } - - @Override - public Coordinate getCM() { - throw new UnsupportedOperationException("Trying to get Center-of-Mass from an empty motor instance."); - } - - @Override - public double getPropellantMass(){ - throw new UnsupportedOperationException("Trying to get mass from an empty motor instance."); - } - - @Override - public double getLongitudinalInertia() { - throw new UnsupportedOperationException("Trying to get inertia from an empty motor instance."); - } - - @Override - public double getRotationalInertia() { - throw new UnsupportedOperationException("Trying to get inertia from an empty motor instance."); - } - - @Override - public void step(double time, double acceleration, AtmosphericConditions cond) { - throw new UnsupportedOperationException("Cannot step an abstract base class"); - } - }; + public MotorInstance( Motor motor ) { + this(); + this.motor = motor; + } - protected MotorInstance() { + public MotorInstance() { this.id = MotorInstanceId.EMPTY_ID; ejectionDelay = 0.0; - ignitionEvent = IgnitionEvent.NEVER; + ignitionEvent = IgnitionEvent.LAUNCH; ignitionDelay = 0.0; modID++; } + public MotorState getSimulationState() { + MotorState state = motor.getNewInstance(); + if( ignitionOveride ) { + state.setIgnitionTime( this.ignitionTime ); + state.setIgnitionEvent( this.ignitionEvent ); + state.setIgnitionDelay( this.ignitionDelay ); + state.setEjectionDelay( this.ejectionDelay ); + } else { + MotorInstance defInstance = mount.getDefaultMotorInstance(); + state.setIgnitionTime( defInstance.ignitionTime ); + state.setIgnitionEvent( defInstance.ignitionEvent ); + state.setIgnitionDelay( defInstance.ignitionDelay ); + state.setEjectionDelay( defInstance.ejectionDelay ); + } + state.setMount( mount ); + state.setId( id ); + return state; + } + + public boolean hasIgnitionOverride() { + return ignitionOveride; + } + + public boolean isActive() { + return motor != null; + } + public MotorInstanceId getID() { return this.id; } @@ -96,22 +82,30 @@ public abstract class MotorInstance implements FlightConfigurableParameter { public static final int DEFAULT_MOTOR_EVENT_TYPE = ComponentChangeEvent.MOTOR_CHANGE | ComponentChangeEvent.EVENT_CHANGE; public MotorSet(RocketComponent component ) { - super(component, DEFAULT_MOTOR_EVENT_TYPE, MotorInstance.EMPTY_INSTANCE); + super(component, DEFAULT_MOTOR_EVENT_TYPE, new MotorInstance()); } /** @@ -45,7 +45,7 @@ public class MotorSet extends ParameterSet { MotorInstance curInstance = this.map.get(loopFCID); String designation; - if( MotorInstance.EMPTY_INSTANCE == curInstance){ + if( null == curInstance.getMotor() ){ designation = "EMPTY_INSTANCE"; }else{ designation = curInstance.getMotor().getDesignation(curInstance.getEjectionDelay()); diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index c92b4b98c..23bd0d17f 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -250,7 +250,7 @@ public class ThrustCurveMotor implements Motor, Comparable, Se @Override - public MotorInstance getNewInstance() { + public ThrustCurveMotorInstance getNewInstance() { return new ThrustCurveMotorInstance(this); } diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java index bcdc60efe..b59542894 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java @@ -1,19 +1,27 @@ package net.sf.openrocket.motor; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; +import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RocketComponent; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Inertia; import net.sf.openrocket.util.MathUtil; -import net.sf.openrocket.util.Utils; -public class ThrustCurveMotorInstance extends MotorInstance { +public class ThrustCurveMotorInstance implements MotorState { // private static final Logger log = LoggerFactory.getLogger(ThrustCurveMotorInstance.class); private int timeIndex = -1; protected MotorMount mount = null; + protected MotorInstanceId id = null; + private double ignitionTime; + private double ignitionDelay; + private IgnitionEvent ignitionEvent; + private double ejectionDelay; + + protected ThrustCurveMotor motor = null; // Previous time step value @@ -47,46 +55,88 @@ public class ThrustCurveMotorInstance extends MotorInstance { unitRotationalInertia = Inertia.filledCylinderRotational(source.getDiameter() / 2); unitLongitudinalInertia = Inertia.filledCylinderLongitudinal(source.getDiameter() / 2, source.getLength()); - this.id = MotorInstanceId.ERROR_ID; } @Override + public double getIgnitionTime() { + return ignitionTime; + } + + @Override + public void setIgnitionTime(double ignitionTime) { + this.ignitionTime = ignitionTime; + } + + @Override + public MotorMount getMount() { + return mount; + } + + @Override + public void setMount(MotorMount mount) { + this.mount = mount; + } + + @Override + public IgnitionEvent getIgnitionEvent() { + return ignitionEvent; + } + + @Override + public void setIgnitionEvent(IgnitionEvent event) { + this.ignitionEvent = event; + } + + @Override + public double getIgnitionDelay() { + return ignitionDelay; + } + + @Override + public void setIgnitionDelay(double delay) { + this.ignitionDelay = delay; + } + + @Override + public double getEjectionDelay() { + return ejectionDelay; + } + + @Override + public void setEjectionDelay(double delay) { + this.ejectionDelay = delay; + } + + @Override + public void setId(MotorInstanceId id) { + this.id = id; + } + + @Override + public MotorInstanceId getID() { + return id; + } + public double getTime() { return prevTime; } - @Override public Coordinate getCG() { return stepCG; } - @Override public Coordinate getCM() { return stepCG; } - @Override public double getPropellantMass(){ return (motor.getLaunchCG().weight - motor.getEmptyCG().weight); } - @Override - public Coordinate getOffset( ){ - if( null == mount ){ - return Coordinate.NaN; - }else{ - RocketComponent comp = (RocketComponent) mount; - double delta_x = comp.getLength() + mount.getMotorOverhang() - this.motor.getLength(); - return new Coordinate(delta_x, 0, 0); - } - } - - @Override public double getLongitudinalInertia() { return unitLongitudinalInertia * stepCG.weight; } - @Override public double getRotationalInertia() { return unitRotationalInertia * stepCG.weight; } @@ -100,60 +150,21 @@ public class ThrustCurveMotorInstance extends MotorInstance { public boolean isActive() { return prevTime < motor.getCutOffTime(); } - - @Override - public void setMotor(Motor motor) { - if( !( motor instanceof ThrustCurveMotor )){ - return; - } - if (Utils.equals(this.motor, motor)) { - return; - } - - this.motor = (ThrustCurveMotor)motor; - - fireChangeEvent(); - } - @Override public Motor getMotor(){ return this.motor; } - - @Override + public boolean isEmpty(){ return false; } - @Override - public MotorMount getMount() { - return this.mount; - } - - @Override - public void setMount(final MotorMount _mount) { - this.mount = _mount; - - } - - @Override - public void setEjectionDelay(double delay) { - if (MathUtil.equals(ejectionDelay, delay)) { - return; - } - this.ejectionDelay = delay; - fireChangeEvent(); - } - - @Override public void step(double nextTime, double acceleration, AtmosphericConditions cond) { if (MathUtil.equals(prevTime, nextTime)) { return; } - modID++; - double[] time = motor.getTimePoints(); double[] thrust = motor.getThrustPoints(); Coordinate[] cg = motor.getCGPoints(); @@ -220,23 +231,6 @@ public class ThrustCurveMotorInstance extends MotorInstance { prevTime = nextTime; } - @Override - public MotorInstance clone() { - ThrustCurveMotorInstance clone = new ThrustCurveMotorInstance( this.motor); - - clone.id = this.id; - clone.mount = this.mount; - clone.ignitionEvent = this.ignitionEvent; - clone.ignitionDelay = this.ignitionDelay; - clone.ejectionDelay = this.ejectionDelay; - clone.position = this.position; - clone.ignitionTime = Double.POSITIVE_INFINITY; - //clone.ignitionTime = this.ignitionTime; - - return clone; - } - - @Override public void reset(){ timeIndex = 0; prevTime = 0; @@ -246,25 +240,9 @@ public class ThrustCurveMotorInstance extends MotorInstance { stepCG = instCG; } - @Override - public String toDebug(){ - String prefix = " "; - StringBuilder sb = new StringBuilder(); - final RocketComponent mountComp = (RocketComponent)this.mount; - - sb.append(String.format("%sMotor= %s(%s)(in %s)\n", prefix, this.motor.getDesignation(), this.id.toShortKey(), mountComp.getName())); - sb.append(String.format("%s Ignite: %s at %+f\n",prefix, this.ignitionEvent.name, this.ignitionDelay)); - //sb.append(String.format("%s Eject at: %+f\n",prefix, this.ejectionDelay)); - sb.append(String.format("%s L:%f W:%f @:%f mm\n",prefix, motor.getLength(), motor.getDiameter(), this.position.multiply(1000).x )); - sb.append(String.format("%s currentTime: %f\n", prefix, this.prevTime)); - sb.append("\n"); - return sb.toString(); - } - @Override public String toString(){ - return this.motor.getDesignation() + this.id.toShortKey(); + return this.motor.getDesignation(); } } - \ No newline at end of file diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotorPlaceholder.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotorPlaceholder.java index 950cdba72..27d0346ff 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotorPlaceholder.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotorPlaceholder.java @@ -1,5 +1,6 @@ package net.sf.openrocket.motor; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; @@ -74,7 +75,7 @@ public class ThrustCurveMotorPlaceholder implements Motor { } @Override - public MotorInstance getNewInstance() { + public MotorState getNewInstance() { throw new BugException("Called getInstance on PlaceholderMotor"); } diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java index 418ea8d7f..5a0811dc1 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java @@ -375,7 +375,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial @Override public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance){ - if((null == newMotorInstance)||(newMotorInstance.equals( MotorInstance.EMPTY_INSTANCE ))){ + if((null == newMotorInstance)){ this.motors.set( fcid, null); }else{ if( null == newMotorInstance.getMount()){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index e0a694619..b61a7ed29 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -357,44 +357,6 @@ public class FlightConfiguration implements FlightConfigurableParameter \n", motorInstanceNumber+1, intanceCount, curMotor.getID().toShortKey())); - }else{ - buff.append( String.format( " ..[%2d/%2d](%6s) %-10s (in: %s)(id: %8s)\n", - motorInstanceNumber+1, intanceCount, - (curMotor.isActive()? "active": "inactv"),curMotor.getMotor().getDesignation(), - ((RocketComponent)curMotor.getMount()).getName(), curMotor.getID().toShortKey() )); - } - ++motorInstanceNumber; - } - return buff.toString(); - } - - public String getMotorsOneline(){ StringBuilder buff = new StringBuilder("["); boolean first = true; @@ -493,10 +455,6 @@ public class FlightConfiguration implements FlightConfigurableParameter motor.refpoint - Coordinate curMotorOffset = cloneInstance.getOffset(); - cloneInstance.setPosition( curMountLocation.add(curMotorOffset) ); - this.motors.put( cloneInstance.getID(), cloneInstance); - - motorInstanceNumber ++; - } - } } } diff --git a/core/src/net/sf/openrocket/rocketcomponent/IgnitionConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/IgnitionConfiguration.java new file mode 100644 index 000000000..567455aa9 --- /dev/null +++ b/core/src/net/sf/openrocket/rocketcomponent/IgnitionConfiguration.java @@ -0,0 +1,72 @@ +package net.sf.openrocket.rocketcomponent; + +import java.util.EventObject; +import java.util.List; + +import net.sf.openrocket.util.ArrayList; +import net.sf.openrocket.util.StateChangeListener; + +public class IgnitionConfiguration implements FlightConfigurableParameter { + + protected double ignitionDelay = 0.0; + protected IgnitionEvent ignitionEvent = IgnitionEvent.NEVER; + protected double ignitionTime = 0.0; + + private final List listeners = new ArrayList(); + + public double getIgnitionDelay() { + return ignitionDelay; + } + + public void setIgnitionDelay(double ignitionDelay) { + this.ignitionDelay = ignitionDelay; + fireChangeEvent(); + } + + public IgnitionEvent getIgnitionEvent() { + return ignitionEvent; + } + + public void setIgnitionEvent(IgnitionEvent ignitionEvent) { + this.ignitionEvent = ignitionEvent; + fireChangeEvent(); + } + + public double getIgnitionTime() { + return ignitionTime; + } + + public void setIgnitionTime(double ignitionTime) { + this.ignitionTime = ignitionTime; + fireChangeEvent(); + } + + @Override + public IgnitionConfiguration clone() { + IgnitionConfiguration clone = new IgnitionConfiguration(); + clone.ignitionDelay = this.ignitionDelay; + clone.ignitionEvent = this.ignitionEvent; + clone.ignitionTime = this.ignitionTime; + return clone; + } + + @Override + public void addChangeListener(StateChangeListener listener) { + listeners.add(listener); + } + + @Override + public void removeChangeListener(StateChangeListener listener) { + listeners.remove(listener); + } + + private void fireChangeEvent() { + EventObject event = new EventObject(this); + Object[] list = listeners.toArray(); + for (Object l : list) { + ((StateChangeListener) l).stateChanged(event); + } + } + + +} diff --git a/core/src/net/sf/openrocket/rocketcomponent/IgnitionEvent.java b/core/src/net/sf/openrocket/rocketcomponent/IgnitionEvent.java index 8a0eb7a08..9605a8cb6 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/IgnitionEvent.java +++ b/core/src/net/sf/openrocket/rocketcomponent/IgnitionEvent.java @@ -9,23 +9,23 @@ import net.sf.openrocket.startup.Application; public enum IgnitionEvent { // //// Automatic (launch or ejection charge) -// AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){ -// @Override -// public boolean isActivationEvent(FlightEvent e, RocketComponent source) { -// int count = source.getRocket().getStageCount(); -// AxialStage stage = (AxialStage)source; -// -// if ( stage instanceof ParallelStage ){ -// return LAUNCH.isActivationEvent(e, source); -// }else if (????){ -// // no good option here. The non-sequential nature of -// // parallel stages prevents us from using the simple test as previousyl -// return LAUNCH.isActivationEvent(e, source); -// } else { -// return EJECTION_CHARGE.isActivationEvent(e, source); -// } -// } -// }, + AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){ + @Override + public boolean isActivationEvent(FlightEvent e, RocketComponent source) { + int count = source.getRocket().getStageCount(); + AxialStage stage = (AxialStage)source.getStage(); + + if ( stage instanceof ParallelStage ){ + return LAUNCH.isActivationEvent(e, source); + }else if (stage.getStageNumber() == count -1){ + // no good option here. The non-sequential nature of + // parallel stages prevents us from using the simple test as previousyl + return LAUNCH.isActivationEvent(e, source); + } else { + return EJECTION_CHARGE.isActivationEvent(e, source); + } + } + }, LAUNCH ( "LAUNCH", "MotorMount.IgnitionEvent.LAUNCH"){ @Override public boolean isActivationEvent( FlightEvent fe, RocketComponent source){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index 5b7fb50b8..36af5d3e9 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -283,7 +283,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra @Override public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance){ - if((null == newMotorInstance)||(newMotorInstance== MotorInstance.EMPTY_INSTANCE )){ + if((null == newMotorInstance)){ this.motors.set( fcid, null); }else{ if( null == newMotorInstance.getMount()){ diff --git a/core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java new file mode 100644 index 000000000..f115c9af9 --- /dev/null +++ b/core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java @@ -0,0 +1,72 @@ +package net.sf.openrocket.rocketcomponent; + +import java.util.EventObject; +import java.util.List; + +import net.sf.openrocket.motor.Motor; +import net.sf.openrocket.util.ArrayList; +import net.sf.openrocket.util.Coordinate; +import net.sf.openrocket.util.StateChangeListener; + +public class MotorConfiguration implements FlightConfigurableParameter { + + protected Coordinate position = Coordinate.ZERO; + protected double ejectionDelay = 0.0; + protected Motor motor = null; + + private final List listeners = new ArrayList(); + + public Coordinate getPosition() { + return position; + } + + public void setPosition(Coordinate position) { + this.position = position; + fireChangeEvent(); + } + + public double getEjectionDelay() { + return ejectionDelay; + } + + public void setEjectionDelay(double ejectionDelay) { + this.ejectionDelay = ejectionDelay; + fireChangeEvent(); + } + + public Motor getMotor() { + return motor; + } + + public void setMotor(Motor motor) { + this.motor = motor; + fireChangeEvent(); + } + + @Override + public MotorConfiguration clone() { + MotorConfiguration clone = new MotorConfiguration(); + clone.position = this.position; + clone.ejectionDelay = this.ejectionDelay; + return clone; + } + + @Override + public void addChangeListener(StateChangeListener listener) { + listeners.add(listener); + } + + @Override + public void removeChangeListener(StateChangeListener listener) { + listeners.remove(listener); + } + + private void fireChangeEvent() { + EventObject event = new EventObject(this); + Object[] list = listeners.toArray(); + for (Object l : list) { + ((StateChangeListener) l).stateChanged(event); + } + } + +} diff --git a/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java b/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java index 8e751f4f1..890bb02c6 100644 --- a/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java +++ b/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java @@ -172,8 +172,8 @@ public abstract class AbstractSimulationStepper implements SimulationStepper { thrust = 0; final double currentTime = status.getSimulationTime() + timestep; - Collection activeMotorList = status.getConfiguration().getActiveMotors(); - for (MotorInstance currentMotorInstance : activeMotorList ) { + Collection activeMotorList = status.getActiveMotors(); + for (MotorState currentMotorInstance : activeMotorList ) { // old: transplanted from MotorInstanceConfiguration double instanceTime = currentTime - currentMotorInstance.getIgnitionTime(); if (instanceTime >= 0) { diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index 91d0f45c9..1f04c496c 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -195,7 +195,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { // Check for burnt out motors - for( MotorInstance motor : currentStatus.getConfiguration().getAllMotors()){ + for( MotorState motor : currentStatus.getAllMotors()){ MotorInstanceId motorId = motor.getID(); if (!motor.isActive() && currentStatus.addBurntOutMotor(motorId)) { addEvent(new FlightEvent(FlightEvent.Type.BURNOUT, currentStatus.getSimulationTime(), @@ -276,7 +276,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { if (event.getType() == FlightEvent.Type.IGNITION) { MotorMount mount = (MotorMount) event.getSource(); MotorInstanceId motorId = (MotorInstanceId) event.getData(); - MotorInstance instance = currentStatus.getMotor(motorId); + MotorState instance = currentStatus.getMotor(motorId); if (!SimulationListenerHelper.fireMotorIgnition(currentStatus, motorId, mount, instance)) { continue; } @@ -289,7 +289,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { } // Check for motor ignition events, add ignition events to queue - for (MotorInstance inst : currentStatus.getFlightConfiguration().getActiveMotors() ){ + for (MotorState inst : currentStatus.getActiveMotors() ){ IgnitionEvent ignitionEvent = inst.getIgnitionEvent(); MotorMount mount = inst.getMount(); RocketComponent component = (RocketComponent) mount; @@ -342,7 +342,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { case IGNITION: { // Ignite the motor MotorInstanceId motorId = (MotorInstanceId) event.getData(); - MotorInstance inst = currentStatus.getMotor( motorId); + MotorState inst = currentStatus.getMotor( motorId); inst.setIgnitionTime(event.getTime()); //System.err.println("Igniting motor: "+inst.getMotor().getDesignation()+" @"+currentStatus.getSimulationTime()); @@ -373,7 +373,7 @@ public class BasicEventSimulationEngine implements SimulationEngine { } // Add ejection charge event MotorInstanceId motorId = (MotorInstanceId) event.getData(); - MotorInstance motor = currentStatus.getMotor( motorId); + MotorState motor = currentStatus.getMotor( motorId); double delay = motor.getEjectionDelay(); if (delay != Motor.PLUGGED) { addEvent(new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, currentStatus.getSimulationTime() + delay, diff --git a/core/src/net/sf/openrocket/simulation/MotorState.java b/core/src/net/sf/openrocket/simulation/MotorState.java new file mode 100644 index 000000000..a1bde98d0 --- /dev/null +++ b/core/src/net/sf/openrocket/simulation/MotorState.java @@ -0,0 +1,31 @@ +package net.sf.openrocket.simulation; + +import net.sf.openrocket.models.atmosphere.AtmosphericConditions; +import net.sf.openrocket.motor.MotorInstanceId; +import net.sf.openrocket.rocketcomponent.IgnitionEvent; +import net.sf.openrocket.rocketcomponent.MotorMount; + +public interface MotorState { + + public void step(double nextTime, double acceleration, AtmosphericConditions cond); + public double getThrust(); + public boolean isActive(); + + public double getIgnitionTime(); + public void setIgnitionTime( double ignitionTime ); + + public void setMount(MotorMount mount); + public MotorMount getMount(); + + public void setId(MotorInstanceId id); + public MotorInstanceId getID(); + + public IgnitionEvent getIgnitionEvent(); + public void setIgnitionEvent( IgnitionEvent event ); + + public double getIgnitionDelay(); + public void setIgnitionDelay( double delay ); + + public double getEjectionDelay(); + public void setEjectionDelay( double delay); +} diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java index b8b87b701..dcbe2727d 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java @@ -1,7 +1,10 @@ package net.sf.openrocket.simulation; +import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Set; @@ -27,7 +30,7 @@ import net.sf.openrocket.util.WorldCoordinate; */ public class SimulationStatus implements Monitorable { - + private SimulationConditions simulationConditions; private FlightConfiguration configuration; private FlightDataBranch flightData; @@ -48,6 +51,7 @@ public class SimulationStatus implements Monitorable { // Set of burnt out motors Set motorBurntOut = new HashSet(); + List motorState = new ArrayList(); /** Nanosecond time when the simulation was started. */ private long simulationStartWallTime = Long.MIN_VALUE; @@ -144,6 +148,9 @@ public class SimulationStatus implements Monitorable { this.launchRodCleared = false; this.apogeeReached = false; + for( MotorInstance motorInstance : this.configuration.getActiveMotors() ) { + this.motorState.add( motorInstance.getSimulationState() ); + } this.warnings = new WarningSet(); } @@ -183,6 +190,10 @@ public class SimulationStatus implements Monitorable { this.deployedRecoveryDevices.clear(); this.deployedRecoveryDevices.addAll(orig.deployedRecoveryDevices); + // FIXME - is this right? + this.motorState.clear(); + this.motorState.addAll(orig.motorState); + this.eventQueue.clear(); this.eventQueue.addAll(orig.eventQueue); @@ -214,6 +225,20 @@ public class SimulationStatus implements Monitorable { this.configuration = configuration; } + public Collection getAllMotors() { + return motorState; + } + + public Collection getActiveMotors() { + List activeList = new ArrayList(); + for( MotorState inst : this.motorState ){ + if( inst.isActive() ){ + activeList.add( inst ); + } + } + + return activeList; + } public FlightConfiguration getConfiguration() { return configuration; @@ -235,8 +260,13 @@ public class SimulationStatus implements Monitorable { return flightData; } - public MotorInstance getMotor( final MotorInstanceId motorId ){ - return this.getFlightConfiguration().getMotorInstance(motorId); + public MotorState getMotor( final MotorInstanceId motorId ){ + for( MotorState state : motorState ) { + if ( motorId.equals(state.getID() )) { + return state; + } + } + return null; } public double getPreviousTimeStep() { diff --git a/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java b/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java index 21e7f96aa..0cc613708 100644 --- a/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java +++ b/core/src/net/sf/openrocket/simulation/extension/impl/ScriptingSimulationListener.java @@ -6,16 +6,19 @@ import java.util.Set; import javax.script.Invocable; import javax.script.ScriptException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import net.sf.openrocket.aerodynamics.AerodynamicForces; import net.sf.openrocket.aerodynamics.FlightConditions; import net.sf.openrocket.masscalc.MassData; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.motor.MotorInstanceId; -import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.simulation.AccelerationData; import net.sf.openrocket.simulation.FlightEvent; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.simulation.SimulationStatus; import net.sf.openrocket.simulation.exception.SimulationException; import net.sf.openrocket.simulation.exception.SimulationListenerException; @@ -25,9 +28,6 @@ import net.sf.openrocket.simulation.listeners.SimulationListener; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.Coordinate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ScriptingSimulationListener implements SimulationListener, SimulationComputationListener, SimulationEventListener, Cloneable { private final static Logger logger = LoggerFactory.getLogger(ScriptingSimulationListener.class); @@ -105,7 +105,7 @@ public class ScriptingSimulationListener implements SimulationListener, Simulati } @Override - public boolean motorIgnition(SimulationStatus status, MotorInstanceId motorId, MotorMount mount, MotorInstance instance) throws SimulationException { + public boolean motorIgnition(SimulationStatus status, MotorInstanceId motorId, MotorMount mount, MotorState instance) throws SimulationException { return invoke(Boolean.class, true, "motorIgnition", status, motorId, mount, instance); } diff --git a/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java b/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java index 03c55bf0a..bc875c0c6 100644 --- a/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java +++ b/core/src/net/sf/openrocket/simulation/listeners/AbstractSimulationListener.java @@ -5,11 +5,11 @@ import net.sf.openrocket.aerodynamics.FlightConditions; import net.sf.openrocket.masscalc.MassData; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.motor.MotorInstanceId; -import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.simulation.AccelerationData; import net.sf.openrocket.simulation.FlightEvent; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.simulation.SimulationStatus; import net.sf.openrocket.simulation.exception.SimulationException; import net.sf.openrocket.util.BugException; @@ -72,7 +72,7 @@ public class AbstractSimulationListener implements SimulationListener, Simulatio } @Override - public boolean motorIgnition(SimulationStatus status, MotorInstanceId motorId, MotorMount mount, MotorInstance instance) throws SimulationException { + public boolean motorIgnition(SimulationStatus status, MotorInstanceId motorId, MotorMount mount, MotorState instance) throws SimulationException { return true; } diff --git a/core/src/net/sf/openrocket/simulation/listeners/SimulationEventListener.java b/core/src/net/sf/openrocket/simulation/listeners/SimulationEventListener.java index 5c0e481f8..c725309ec 100644 --- a/core/src/net/sf/openrocket/simulation/listeners/SimulationEventListener.java +++ b/core/src/net/sf/openrocket/simulation/listeners/SimulationEventListener.java @@ -1,10 +1,10 @@ package net.sf.openrocket.simulation.listeners; import net.sf.openrocket.motor.MotorInstanceId; -import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.simulation.FlightEvent; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.simulation.SimulationStatus; import net.sf.openrocket.simulation.exception.SimulationException; @@ -44,7 +44,7 @@ public interface SimulationEventListener { * @return true to ignite the motor, false to abort ignition */ public boolean motorIgnition(SimulationStatus status, MotorInstanceId motorId, MotorMount mount, - MotorInstance instance) throws SimulationException; + MotorState instance) throws SimulationException; /** diff --git a/core/src/net/sf/openrocket/simulation/listeners/SimulationListenerHelper.java b/core/src/net/sf/openrocket/simulation/listeners/SimulationListenerHelper.java index d6417471f..bd004c743 100644 --- a/core/src/net/sf/openrocket/simulation/listeners/SimulationListenerHelper.java +++ b/core/src/net/sf/openrocket/simulation/listeners/SimulationListenerHelper.java @@ -10,11 +10,11 @@ import net.sf.openrocket.aerodynamics.Warning; import net.sf.openrocket.masscalc.MassData; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.motor.MotorInstanceId; -import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.simulation.AccelerationData; import net.sf.openrocket.simulation.FlightEvent; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.simulation.SimulationStatus; import net.sf.openrocket.simulation.exception.SimulationException; import net.sf.openrocket.util.Coordinate; @@ -168,7 +168,7 @@ public class SimulationListenerHelper { * @return true to handle the event normally, false to skip event. */ public static boolean fireMotorIgnition(SimulationStatus status, MotorInstanceId motorId, MotorMount mount, - MotorInstance instance) throws SimulationException { + MotorState instance) throws SimulationException { boolean b; int modID = status.getModID(); // Contains also motor instance diff --git a/core/src/net/sf/openrocket/util/TestRockets.java b/core/src/net/sf/openrocket/util/TestRockets.java index 5ba0a6a40..7ddbccce8 100644 --- a/core/src/net/sf/openrocket/util/TestRockets.java +++ b/core/src/net/sf/openrocket/util/TestRockets.java @@ -101,7 +101,7 @@ public class TestRockets { new Coordinate[] { new Coordinate(.311, 0, 0, 4.808),new Coordinate(.311, 0, 0, 3.389),new Coordinate(.311, 0, 0, 1.970)}, "digest M1350 test"); - return mtr.getNewInstance(); + return new MotorInstance(mtr); } // This function is used for unit, integration tests, DO NOT CHANGE (without updating tests). @@ -117,7 +117,7 @@ public class TestRockets { new Coordinate[] { new Coordinate(.062, 0, 0, 0.123),new Coordinate(.062, 0, 0, .0935),new Coordinate(.062, 0, 0, 0.064)}, "digest G77 test"); - return mtr.getNewInstance(); + return new MotorInstance(mtr); } // @@ -420,10 +420,11 @@ public class TestRockets { new Coordinate(0.0035,0,0,30.0), new Coordinate(0.0035,0,0,21.0)}, "digest_D12"); - MotorInstance inst = motor.getNewInstance(); + MotorInstance inst = new MotorInstance(motor); inst.setEjectionDelay(5); return inst; } + public static Rocket makeSmallFlyable() { double noseconeLength = 0.10, noseconeRadius = 0.01; double bodytubeLength = 0.20, bodytubeRadius = 0.01, bodytubeThickness = 0.001; @@ -465,7 +466,7 @@ public class TestRockets { FlightConfigurationID fcid = config.getFlightConfigurationID(); ThrustCurveMotor motor = getTestMotor(); - MotorInstance instance = motor.getNewInstance(); + MotorInstance instance = new MotorInstance(motor); instance.setEjectionDelay(5); bodytube.setMotorInstance(fcid, instance); @@ -979,7 +980,7 @@ public class TestRockets { // create motor config and add a motor to it ThrustCurveMotor motor = getTestMotor(); - MotorInstance motorInst = motor.getNewInstance(); + MotorInstance motorInst = new MotorInstance(motor); motorInst.setEjectionDelay(5); // add motor config to inner tube (motor mount) @@ -1014,7 +1015,7 @@ public class TestRockets { // create motor config and add a motor to it ThrustCurveMotor motor = getTestMotor(); - MotorInstance motorConfig = motor.getNewInstance(); + MotorInstance motorConfig = new MotorInstance(motor); motorConfig.setEjectionDelay(5); // add motor config to inner tube (motor mount) @@ -1171,7 +1172,7 @@ public class TestRockets { bodyTube.addChild(innerTube); // make inner tube with motor mount flag set - MotorInstance inst = getTestMotor().getNewInstance(); + MotorInstance inst = new MotorInstance(getTestMotor()); innerTube.setMotorInstance(fcid, inst); // set ignition parameters for motor mount diff --git a/core/src/net/sf/openrocket/utils/MotorCorrelation.java b/core/src/net/sf/openrocket/utils/MotorCorrelation.java index 93dc1d75a..e1c5eb846 100644 --- a/core/src/net/sf/openrocket/utils/MotorCorrelation.java +++ b/core/src/net/sf/openrocket/utils/MotorCorrelation.java @@ -10,8 +10,8 @@ import net.sf.openrocket.file.motor.GeneralMotorLoader; import net.sf.openrocket.file.motor.MotorLoader; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.motor.ThrustCurveMotor; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.MathUtil; @@ -61,8 +61,8 @@ public class MotorCorrelation { * @return the scaled cross-correlation of the two thrust curves. */ public static double crossCorrelation(Motor motor1, Motor motor2) { - MotorInstance m1 = motor1.getNewInstance(); - MotorInstance m2 = motor2.getNewInstance(); + MotorState m1 = motor1.getNewInstance(); + MotorState m2 = motor2.getNewInstance(); AtmosphericConditions cond = new AtmosphericConditions(); diff --git a/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java b/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java index 43115005d..60be43c6c 100644 --- a/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java +++ b/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java @@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; +import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Inertia; @@ -41,7 +42,7 @@ public class ThrustCurveMotorTest { @Test public void testInstance() { - MotorInstance instance = motor.getNewInstance(); + ThrustCurveMotorInstance instance = motor.getNewInstance(); verify(instance, 0, 0.05, 0.02); instance.step(0.0, 0, null); @@ -63,7 +64,7 @@ public class ThrustCurveMotorTest { verify(instance, 0, 0.03, 0.03); } - private void verify(MotorInstance instance, double thrust, double mass, double cgx) { + private void verify(ThrustCurveMotorInstance instance, double thrust, double mass, double cgx) { assertEquals("Testing thrust", thrust, instance.getThrust(), EPS); assertEquals("Testing mass", mass, instance.getCG().weight, EPS); assertEquals("Testing cg x", cgx, instance.getCG().x, EPS); diff --git a/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java b/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java index f063c18b4..7ba1cb279 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java @@ -195,8 +195,8 @@ public class ConfigurationTest extends BaseTestCase { // test explicitly setting all stages up to second stage active config.setOnlyStage(1); - assertThat(config.toStageListDetail() + "Setting single stage active: ", config.isStageActive(0), equalTo(false)); - assertThat(config.toStageListDetail() + "Setting single stage active: ", config.isStageActive(1), equalTo(true)); + assertThat("Setting single stage active: ", config.isStageActive(0), equalTo(false)); + assertThat("Setting single stage active: ", config.isStageActive(1), equalTo(true)); config.clearStage(0); assertThat(" deactivate stage #0: ", config.isStageActive(0), equalTo(false)); @@ -560,7 +560,7 @@ public class ConfigurationTest extends BaseTestCase { InnerTube sustainerMount = (InnerTube) rocket.getChild(0).getChild(1).getChild(3); sustainerMount.setMotorMount(true); - sustainerMount.setMotorInstance(fcid, sustainerMotor.getNewInstance()); + sustainerMount.setMotorInstance(fcid, new MotorInstance(sustainerMotor)); } { @@ -577,7 +577,7 @@ public class ConfigurationTest extends BaseTestCase { "digest D21 test"); InnerTube boosterMount = (InnerTube) rocket.getChild(1).getChild(0).getChild(2); boosterMount.setMotorMount(true); - boosterMount.setMotorInstance(fcid, boosterMotor.getNewInstance()); + boosterMount.setMotorInstance(fcid, new MotorInstance(boosterMotor)); boosterMount.setClusterConfiguration( ClusterConfiguration.CONFIGURATIONS[1]); // double-mount } return rocket; diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index bf727a413..70e35e014 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -215,7 +215,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel Motor mtr = motorChooserDialog.getSelectedMotor(); double d = motorChooserDialog.getSelectedDelay(); if (mtr != null) { - MotorInstance curInstance = mtr.getNewInstance(); + MotorInstance curInstance = new MotorInstance(mtr); curInstance.setEjectionDelay(d); curInstance.setIgnitionEvent( IgnitionEvent.NEVER); curMount.setMotorInstance( fcid, curInstance); @@ -262,9 +262,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel } MotorInstance curInstance = curMount.getMotorInstance(fcid); - MotorInstance defInstance = curInstance.getMount().getDefaultMotorInstance(); - curInstance.setIgnitionDelay( defInstance.getIgnitionDelay()); - curInstance.setIgnitionEvent( defInstance.getIgnitionEvent()); + curInstance.useDefaultIgnition(); fireTableDataChanged(); } @@ -315,14 +313,19 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel IgnitionEvent ignitionEvent = curInstance.getIgnitionEvent(); Double ignitionDelay = curInstance.getIgnitionDelay(); - boolean isDefault = (defInstance.getIgnitionEvent() == curInstance.getIgnitionEvent()); - + boolean useDefault = !curInstance.hasIgnitionOverride(); + + if ( useDefault ) { + ignitionEvent = defInstance.getIgnitionEvent(); + ignitionDelay = defInstance.getIgnitionDelay(); + } + JLabel label = new JLabel(); String str = trans.get("MotorMount.IgnitionEvent.short." + ignitionEvent.name()); if (ignitionEvent != IgnitionEvent.NEVER && ignitionDelay > 0.001) { str = str + " + " + UnitGroup.UNITS_SHORT_TIME.toStringUnit(ignitionDelay); } - if (isDefault) { + if (useDefault) { shaded(label); String def = trans.get("MotorConfigurationTableModel.table.ignition.default"); str = def.replace("{0}", str); From 391571708f3911cf092e474a2c27ab4c03dc37f4 Mon Sep 17 00:00:00 2001 From: Kevin Ruland Date: Mon, 14 Dec 2015 20:58:05 -0600 Subject: [PATCH 2/3] Test argument in FlightConfigurationID constructor. Initialize FlightConfigurationID in SimulationOptions to new random id. Make the TestRockets compile --- .../sf/openrocket/rocketcomponent/FlightConfigurationID.java | 2 +- core/src/net/sf/openrocket/simulation/SimulationOptions.java | 2 +- core/src/net/sf/openrocket/util/TestRockets.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java index 71d59b231..9b04ba0bb 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java @@ -23,7 +23,7 @@ public final class FlightConfigurationID implements Comparable Date: Mon, 14 Dec 2015 22:46:36 -0600 Subject: [PATCH 3/3] Rename some classes for clarity. --- .../sf/openrocket/document/Simulation.java | 2 +- .../importt/MotorConfigurationHandler.java | 4 +- .../openrocket/importt/MotorMountHandler.java | 6 +- .../savers/RecoveryDeviceSaver.java | 4 +- .../savers/RocketComponentSaver.java | 6 +- .../file/openrocket/savers/RocketSaver.java | 4 +- .../MotorDescriptionSubstitutor.java | 4 +- .../openrocket/masscalc/MassCalculator.java | 6 +- ...rInstance.java => MotorConfiguration.java} | 16 ++--- ...torSet.java => MotorConfigurationSet.java} | 16 ++--- .../sf/openrocket/motor/ThrustCurveMotor.java | 4 +- ...stance.java => ThrustCurveMotorState.java} | 5 +- .../rocketcomponent/AxialStage.java | 8 +-- .../openrocket/rocketcomponent/BodyTube.java | 18 ++--- ...va => FlightConfigurableParameterSet.java} | 9 +-- .../rocketcomponent/FlightConfiguration.java | 24 +++---- .../FlightConfigurationSet.java | 2 +- .../openrocket/rocketcomponent/InnerTube.java | 20 +++--- .../rocketcomponent/MotorConfiguration.java | 72 ------------------- .../rocketcomponent/MotorMount.java | 10 +-- .../rocketcomponent/RecoveryDevice.java | 8 +-- .../sf/openrocket/rocketcomponent/Rocket.java | 2 +- .../simulation/AbstractSimulationStepper.java | 2 +- .../BasicEventSimulationEngine.java | 6 +- .../simulation/SimulationStatus.java | 4 +- .../listeners/example/DampingMoment.java | 4 +- .../net/sf/openrocket/util/TestRockets.java | 26 +++---- .../aerodynamics/BarrowmanCalculatorTest.java | 4 +- .../masscalc/MassCalculatorTest.java | 2 +- .../motor/ThrustCurveMotorTest.java | 4 +- .../rocketcomponent/ConfigurationTest.java | 6 +- .../gui/adaptors/ParameterSetModel.java | 6 +- .../gui/configdialog/MotorConfig.java | 4 +- .../IgnitionSelectionDialog.java | 10 +-- .../SeparationSelectionDialog.java | 2 +- .../motor/thrustcurve/MotorRowFilter.java | 6 +- .../ThrustCurveMotorSelectionPanel.java | 4 +- .../gui/figure3d/RocketRenderer.java | 4 +- .../MotorConfigurationPanel.java | 14 ++-- .../gui/scalefigure/RocketFigure.java | 4 +- .../gui/simulation/SimulationRunDialog.java | 6 +- 41 files changed, 145 insertions(+), 223 deletions(-) rename core/src/net/sf/openrocket/motor/{MotorInstance.java => MotorConfiguration.java} (92%) rename core/src/net/sf/openrocket/motor/{MotorSet.java => MotorConfigurationSet.java} (76%) rename core/src/net/sf/openrocket/motor/{ThrustCurveMotorInstance.java => ThrustCurveMotorState.java} (96%) rename core/src/net/sf/openrocket/rocketcomponent/{ParameterSet.java => FlightConfigurableParameterSet.java} (94%) delete mode 100644 core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java diff --git a/core/src/net/sf/openrocket/document/Simulation.java b/core/src/net/sf/openrocket/document/Simulation.java index f2f0780d5..7437c67ba 100644 --- a/core/src/net/sf/openrocket/document/Simulation.java +++ b/core/src/net/sf/openrocket/document/Simulation.java @@ -13,7 +13,7 @@ import net.sf.openrocket.aerodynamics.BarrowmanCalculator; import net.sf.openrocket.aerodynamics.WarningSet; import net.sf.openrocket.formatting.RocketDescriptor; import net.sf.openrocket.masscalc.MassCalculator; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.Rocket; diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/MotorConfigurationHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/MotorConfigurationHandler.java index b4f0dbd82..34ef25d11 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/MotorConfigurationHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/MotorConfigurationHandler.java @@ -12,7 +12,7 @@ import net.sf.openrocket.file.simplesax.ElementHandler; import net.sf.openrocket.file.simplesax.PlainTextHandler; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; -import net.sf.openrocket.rocketcomponent.ParameterSet; +import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet; import net.sf.openrocket.rocketcomponent.Rocket; class MotorConfigurationHandler extends AbstractElementHandler { @@ -64,7 +64,7 @@ class MotorConfigurationHandler extends AbstractElementHandler { if ("true".equals(attributes.remove("default"))) { // associate this configuration with both this FCID and the default. - ParameterSet fcs = rocket.getConfigSet(); + FlightConfigurableParameterSet fcs = rocket.getConfigSet(); FlightConfiguration fc = fcs.get(fcid); fcs.setDefault(fc); } diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java index ef5153093..f5819373e 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java @@ -11,7 +11,7 @@ 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.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.IgnitionEvent; @@ -73,7 +73,7 @@ class MotorMountHandler extends AbstractElementHandler { } Motor motor = motorHandler.getMotor(warnings); - MotorInstance motorInstance = new MotorInstance(); + MotorConfiguration motorInstance = new MotorConfiguration(); motorInstance.setMotor(motor); RocketComponent mountComponent = (RocketComponent)mount; motorInstance.setMount(mount); @@ -95,7 +95,7 @@ class MotorMountHandler extends AbstractElementHandler { return; } - MotorInstance inst = mount.getMotorInstance(fcid); + MotorConfiguration inst = mount.getMotorInstance(fcid); inst.setIgnitionDelay(ignitionConfigHandler.ignitionDelay); inst.setIgnitionEvent(ignitionConfigHandler.ignitionEvent); return; diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java index d13db610f..6acbb9a0f 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RecoveryDeviceSaver.java @@ -7,7 +7,7 @@ import java.util.Locale; import net.sf.openrocket.rocketcomponent.DeploymentConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; -import net.sf.openrocket.rocketcomponent.ParameterSet; +import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet; import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.Rocket; @@ -37,7 +37,7 @@ public class RecoveryDeviceSaver extends MassObjectSaver { //dev.getDeploymentConfigurations().printDebug(); // DEBUG - ParameterSet configList = rocket.getConfigSet(); + FlightConfigurableParameterSet configList = rocket.getConfigSet(); for (FlightConfigurationID fcid : configList.getSortedConfigurationIDs()) { //System.err.println("checking FlightConfiguration:"+fcid.getShortKey()+ " save?"); diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java index 98797f1ee..5c38fe41f 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketComponentSaver.java @@ -11,7 +11,7 @@ import net.sf.openrocket.appearance.Decal.EdgeMode; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.material.Material; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.rocketcomponent.Clusterable; @@ -179,7 +179,7 @@ public class RocketComponentSaver { List elements = new ArrayList(); - MotorInstance defaultInstance = mount.getDefaultMotorInstance(); + MotorConfiguration defaultInstance = mount.getDefaultMotorInstance(); elements.add(""); @@ -192,7 +192,7 @@ public class RocketComponentSaver { for( FlightConfigurationID fcid : rkt.getSortedConfigurationIDs()){ - MotorInstance motorInstance = mount.getMotorInstance(fcid); + MotorConfiguration motorInstance = mount.getMotorInstance(fcid); // Nothing is stored if no motor loaded if( motorInstance.isEmpty()){ continue; diff --git a/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java b/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java index 6c3883b7e..b565a9083 100644 --- a/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java +++ b/core/src/net/sf/openrocket/file/openrocket/savers/RocketSaver.java @@ -6,7 +6,7 @@ import java.util.Locale; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; -import net.sf.openrocket.rocketcomponent.ParameterSet; +import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet; import net.sf.openrocket.rocketcomponent.ReferenceType; import net.sf.openrocket.rocketcomponent.Rocket; @@ -43,7 +43,7 @@ public class RocketSaver extends RocketComponentSaver { // Motor configurations - ParameterSet allConfigs = rocket.getConfigSet(); + FlightConfigurableParameterSet allConfigs = rocket.getConfigSet(); for (FlightConfigurationID fcid : allConfigs.getSortedConfigurationIDs()) { FlightConfiguration flightConfig = allConfigs.get(fcid); if (fcid == null) diff --git a/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java b/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java index 055759893..d986dbd09 100644 --- a/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java +++ b/core/src/net/sf/openrocket/formatting/MotorDescriptionSubstitutor.java @@ -10,7 +10,7 @@ import com.google.inject.Inject; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.plugin.Plugin; import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; @@ -69,7 +69,7 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor { } else if (c instanceof MotorMount) { MotorMount mount = (MotorMount) c; - MotorInstance inst = mount.getMotorInstance(fcid); + MotorConfiguration inst = mount.getMotorInstance(fcid); Motor motor = inst.getMotor(); if (mount.isMotorMount() && motor != null) { diff --git a/core/src/net/sf/openrocket/masscalc/MassCalculator.java b/core/src/net/sf/openrocket/masscalc/MassCalculator.java index 4d806f7dc..f1ed4b5d4 100644 --- a/core/src/net/sf/openrocket/masscalc/MassCalculator.java +++ b/core/src/net/sf/openrocket/masscalc/MassCalculator.java @@ -7,7 +7,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.Instanceable; @@ -143,7 +143,7 @@ public class MassCalculator implements Monitorable { // ^^^^ DEVEL ^^^^ // int motorCount = 0; - for (MotorInstance inst : config.getActiveMotors() ) { + for (MotorConfiguration inst : config.getActiveMotors() ) { //ThrustCurveMotor motor = (ThrustCurveMotor) inst.getMotor(); Coordinate position = inst.getPosition(); @@ -254,7 +254,7 @@ public class MassCalculator implements Monitorable { //throw new BugException("getPropellantMass is not yet implemented.... "); // add up the masses of all motors in the rocket if ( MassCalcType.NO_MOTORS != calcType ){ - for (MotorInstance curInstance : configuration.getActiveMotors()) { + for (MotorConfiguration curInstance : configuration.getActiveMotors()) { mass = mass + curInstance.getPropellantMass(); mass = curInstance.getMotor().getLaunchCG().weight - curInstance.getMotor().getEmptyCG().weight; } diff --git a/core/src/net/sf/openrocket/motor/MotorInstance.java b/core/src/net/sf/openrocket/motor/MotorConfiguration.java similarity index 92% rename from core/src/net/sf/openrocket/motor/MotorInstance.java rename to core/src/net/sf/openrocket/motor/MotorConfiguration.java index 831c0b1ad..14780d09e 100644 --- a/core/src/net/sf/openrocket/motor/MotorInstance.java +++ b/core/src/net/sf/openrocket/motor/MotorConfiguration.java @@ -17,7 +17,7 @@ import net.sf.openrocket.util.StateChangeListener; * A single motor configuration. This includes the selected motor * and the ejection charge delay. */ -public class MotorInstance implements FlightConfigurableParameter { +public class MotorConfiguration implements FlightConfigurableParameter { protected MotorMount mount = null; protected Motor motor = null; @@ -34,12 +34,12 @@ public class MotorInstance implements FlightConfigurableParameter protected int modID = 0; private final List listeners = new ArrayList(); - public MotorInstance( Motor motor ) { + public MotorConfiguration( Motor motor ) { this(); this.motor = motor; } - public MotorInstance() { + public MotorConfiguration() { this.id = MotorInstanceId.EMPTY_ID; ejectionDelay = 0.0; ignitionEvent = IgnitionEvent.LAUNCH; @@ -55,7 +55,7 @@ public class MotorInstance implements FlightConfigurableParameter state.setIgnitionDelay( this.ignitionDelay ); state.setEjectionDelay( this.ejectionDelay ); } else { - MotorInstance defInstance = mount.getDefaultMotorInstance(); + MotorConfiguration defInstance = mount.getDefaultMotorInstance(); state.setIgnitionTime( defInstance.ignitionTime ); state.setIgnitionEvent( defInstance.ignitionEvent ); state.setIgnitionDelay( defInstance.ignitionDelay ); @@ -198,8 +198,8 @@ public class MotorInstance implements FlightConfigurableParameter public boolean equals( Object other ){ if( null == other ){ return false; - }else if( other instanceof MotorInstance ){ - MotorInstance omi = (MotorInstance)other; + }else if( other instanceof MotorConfiguration ){ + MotorConfiguration omi = (MotorConfiguration)other; if( this.id.equals( omi.id)){ return true; } @@ -217,8 +217,8 @@ public class MotorInstance implements FlightConfigurableParameter * identical to this instance and can be used independently from this one. */ @Override - public MotorInstance clone( ) { - MotorInstance clone = new MotorInstance(); + public MotorConfiguration clone( ) { + MotorConfiguration clone = new MotorConfiguration(); clone.motor = this.motor; clone.mount = this.mount; clone.ejectionDelay = this.ejectionDelay; diff --git a/core/src/net/sf/openrocket/motor/MotorSet.java b/core/src/net/sf/openrocket/motor/MotorConfigurationSet.java similarity index 76% rename from core/src/net/sf/openrocket/motor/MotorSet.java rename to core/src/net/sf/openrocket/motor/MotorConfigurationSet.java index 666fd4c22..8d912bd2c 100644 --- a/core/src/net/sf/openrocket/motor/MotorSet.java +++ b/core/src/net/sf/openrocket/motor/MotorConfigurationSet.java @@ -2,18 +2,18 @@ package net.sf.openrocket.motor; import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; -import net.sf.openrocket.rocketcomponent.ParameterSet; +import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet; import net.sf.openrocket.rocketcomponent.RocketComponent; /** * FlightConfigurationSet for motors. * This is used for motors, where the default value is always no motor. */ -public class MotorSet extends ParameterSet { +public class MotorConfigurationSet extends FlightConfigurableParameterSet { public static final int DEFAULT_MOTOR_EVENT_TYPE = ComponentChangeEvent.MOTOR_CHANGE | ComponentChangeEvent.EVENT_CHANGE; - public MotorSet(RocketComponent component ) { - super(component, DEFAULT_MOTOR_EVENT_TYPE, new MotorInstance()); + public MotorConfigurationSet(RocketComponent component ) { + super(component, DEFAULT_MOTOR_EVENT_TYPE, new MotorConfiguration()); } /** @@ -23,12 +23,12 @@ public class MotorSet extends ParameterSet { * @param component the rocket component on which events are fired when the parameter values are changed * @param eventType the event type that will be fired on changes */ - public MotorSet(ParameterSet flightConfiguration, RocketComponent component) { + public MotorConfigurationSet(FlightConfigurableParameterSet flightConfiguration, RocketComponent component) { super(flightConfiguration, component, DEFAULT_MOTOR_EVENT_TYPE); } @Override - public void setDefault( MotorInstance value) { + public void setDefault( MotorConfiguration value) { throw new UnsupportedOperationException("Cannot change default value of motor configuration"); } @@ -37,13 +37,13 @@ public class MotorSet extends ParameterSet { StringBuilder buffer = new StringBuilder(); buffer.append("====== Dumping MotorConfigurationSet for mount '"+this.component.toDebugName()+" ======\n"); buffer.append(" >> motorSet ("+this.size()+ " motors)\n"); - MotorInstance emptyInstance = this.getDefault(); + MotorConfiguration emptyInstance = this.getDefault(); buffer.append(" >> (["+emptyInstance.toString()+"]= @ "+ emptyInstance.getIgnitionEvent().name +" +"+emptyInstance.getIgnitionDelay()+"sec )\n"); for( FlightConfigurationID loopFCID : this.map.keySet()){ String shortKey = loopFCID.toShortKey(); - MotorInstance curInstance = this.map.get(loopFCID); + MotorConfiguration curInstance = this.map.get(loopFCID); String designation; if( null == curInstance.getMotor() ){ designation = "EMPTY_INSTANCE"; diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java index 23bd0d17f..4ff00c7bf 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotor.java @@ -250,8 +250,8 @@ public class ThrustCurveMotor implements Motor, Comparable, Se @Override - public ThrustCurveMotorInstance getNewInstance() { - return new ThrustCurveMotorInstance(this); + public ThrustCurveMotorState getNewInstance() { + return new ThrustCurveMotorState(this); } diff --git a/core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java b/core/src/net/sf/openrocket/motor/ThrustCurveMotorState.java similarity index 96% rename from core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java rename to core/src/net/sf/openrocket/motor/ThrustCurveMotorState.java index b59542894..a4f31f6a5 100644 --- a/core/src/net/sf/openrocket/motor/ThrustCurveMotorInstance.java +++ b/core/src/net/sf/openrocket/motor/ThrustCurveMotorState.java @@ -3,13 +3,12 @@ package net.sf.openrocket.motor; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; -import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.simulation.MotorState; import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Inertia; import net.sf.openrocket.util.MathUtil; -public class ThrustCurveMotorInstance implements MotorState { +public class ThrustCurveMotorState implements MotorState { // private static final Logger log = LoggerFactory.getLogger(ThrustCurveMotorInstance.class); private int timeIndex = -1; @@ -47,7 +46,7 @@ public class ThrustCurveMotorInstance implements MotorState { // unitLongitudinalInertia = Double.NaN; // } - public ThrustCurveMotorInstance(final ThrustCurveMotor source) { + public ThrustCurveMotorState(final ThrustCurveMotor source) { //log.debug( Creating motor instance of " + ThrustCurveMotor.this); this.motor = source; this.reset(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java index 4c677eb70..f1cb29db7 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java @@ -12,12 +12,12 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC private static final Translator trans = Application.getTranslator(); //private static final Logger log = LoggerFactory.getLogger(AxialStage.class); - protected ParameterSet separations; + protected FlightConfigurableParameterSet separations; protected int stageNumber; public AxialStage(){ - this.separations = new ParameterSet( + this.separations = new FlightConfigurableParameterSet( this, ComponentChangeEvent.EVENT_CHANGE, new StageSeparationConfiguration()); this.relativePosition = Position.AFTER; this.stageNumber = 0; @@ -34,7 +34,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC return trans.get("Stage.Stage"); } - public ParameterSet getSeparationConfigurations() { + public FlightConfigurableParameterSet getSeparationConfigurations() { return separations; } @@ -80,7 +80,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC @Override protected RocketComponent copyWithOriginalID() { AxialStage copy = (AxialStage) super.copyWithOriginalID(); - copy.separations = new ParameterSet(separations, + copy.separations = new FlightConfigurableParameterSet(separations, copy, ComponentChangeEvent.EVENT_CHANGE); return copy; } diff --git a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java index 5a0811dc1..0553f6fba 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/BodyTube.java @@ -6,9 +6,9 @@ import java.util.Iterator; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; -import net.sf.openrocket.motor.MotorSet; +import net.sf.openrocket.motor.MotorConfigurationSet; import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.BugException; @@ -32,7 +32,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial private double overhang = 0; private boolean isActingMount = false; - private MotorSet motors; + private MotorConfigurationSet motors; public BodyTube() { this(8 * DEFAULT_RADIUS, DEFAULT_RADIUS); @@ -44,7 +44,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial super(); this.outerRadius = Math.max(radius, 0); this.length = Math.max(length, 0); - motors = new MotorSet(this); + motors = new MotorConfigurationSet(this); } public BodyTube(double length, double radius, boolean filled) { @@ -364,17 +364,17 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial //////////////// Motor mount ///////////////// @Override - public MotorInstance getDefaultMotorInstance(){ + public MotorConfiguration getDefaultMotorInstance(){ return this.motors.getDefault(); } @Override - public MotorInstance getMotorInstance( final FlightConfigurationID fcid){ + public MotorConfiguration getMotorInstance( final FlightConfigurationID fcid){ return this.motors.get(fcid); } @Override - public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance){ + public void setMotorInstance(final FlightConfigurationID fcid, final MotorConfiguration newMotorInstance){ if((null == newMotorInstance)){ this.motors.set( fcid, null); }else{ @@ -395,7 +395,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial @Override - public Iterator getMotorIterator(){ + public Iterator getMotorIterator(){ return this.motors.iterator(); } @@ -468,7 +468,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial protected RocketComponent copyWithOriginalID() { BodyTube copy = (BodyTube) super.copyWithOriginalID(); - copy.motors = new MotorSet( this.motors, copy ); + copy.motors = new MotorConfigurationSet( this.motors, copy ); return copy; } } diff --git a/core/src/net/sf/openrocket/rocketcomponent/ParameterSet.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java similarity index 94% rename from core/src/net/sf/openrocket/rocketcomponent/ParameterSet.java rename to core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java index 12c84dbdc..4b0217c58 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/ParameterSet.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurableParameterSet.java @@ -7,9 +7,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map.Entry; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.StateChangeListener; import net.sf.openrocket.util.Utils; @@ -20,7 +17,7 @@ import net.sf.openrocket.util.Utils; * * @param the parameter type */ -public class ParameterSet> implements FlightConfigurable { +public class FlightConfigurableParameterSet> implements FlightConfigurable { //private static final Logger log = LoggerFactory.getLogger(ParameterSet.class); protected final HashMap map = new HashMap(); @@ -38,7 +35,7 @@ public class ParameterSet> implements F * @param component the rocket component on which events are fired when the parameter values are changed * @param eventType the event type that will be fired on changes */ - public ParameterSet(RocketComponent component, int eventType, E _defaultValue) { + public FlightConfigurableParameterSet(RocketComponent component, int eventType, E _defaultValue) { this.component = component; this.eventType = eventType; @@ -54,7 +51,7 @@ public class ParameterSet> implements F * @param component the rocket component on which events are fired when the parameter values are changed * @param eventType the event type that will be fired on changes */ - public ParameterSet(ParameterSet configSet, RocketComponent component, int eventType) { + public FlightConfigurableParameterSet(FlightConfigurableParameterSet configSet, RocketComponent component, int eventType) { this.component = component; this.eventType = eventType; diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java index b61a7ed29..79d40b4d8 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfiguration.java @@ -6,15 +6,13 @@ import java.util.EventListener; import java.util.EventObject; import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Queue; import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.ChangeSource; @@ -70,7 +68,7 @@ public class FlightConfiguration implements FlightConfigurableParameter stages = new HashMap(); - protected final HashMap motors = new HashMap(); + protected final HashMap motors = new HashMap(); private int boundsModID = -1; private ArrayList cachedBounds = new ArrayList(); @@ -364,7 +362,7 @@ public class FlightConfiguration implements FlightConfigurableParameter getAllMotors() { + public Collection getAllMotors() { return motors.values(); } @@ -463,7 +461,7 @@ public class FlightConfiguration implements FlightConfigurableParameter getActiveMotors() { - List activeList = new ArrayList(); - for( MotorInstance inst : this.motors.values() ){ + public Collection getActiveMotors() { + List activeList = new ArrayList(); + for( MotorConfiguration inst : this.motors.values() ){ if( inst.isActive() ){ activeList.add( inst ); } @@ -488,7 +486,7 @@ public class FlightConfiguration implements FlightConfigurableParameter the parameter type */ -public class FlightConfigurationSet extends ParameterSet { +public class FlightConfigurationSet extends FlightConfigurableParameterSet { /** * Construct a FlightConfiguration that has no overrides. diff --git a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java index 36af5d3e9..4766473ae 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java +++ b/core/src/net/sf/openrocket/rocketcomponent/InnerTube.java @@ -9,9 +9,9 @@ import org.slf4j.LoggerFactory; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; -import net.sf.openrocket.motor.MotorSet; +import net.sf.openrocket.motor.MotorConfigurationSet; import net.sf.openrocket.preset.ComponentPreset; import net.sf.openrocket.startup.Application; import net.sf.openrocket.util.BugException; @@ -35,7 +35,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra private double overhang = 0; private boolean isActingMount; - private MotorSet motors; + private MotorConfigurationSet motors; /** * Main constructor. @@ -46,7 +46,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra this.setInnerRadius(0.018 / 2); this.setLength(0.070); - motors = new MotorSet(this); + motors = new MotorConfigurationSet(this); } @@ -272,17 +272,17 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra //////////////// Motor mount ///////////////// @Override - public MotorInstance getDefaultMotorInstance(){ + public MotorConfiguration getDefaultMotorInstance(){ return this.motors.getDefault(); } @Override - public MotorInstance getMotorInstance( final FlightConfigurationID fcid){ + public MotorConfiguration getMotorInstance( final FlightConfigurationID fcid){ return this.motors.get(fcid); } @Override - public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance){ + public void setMotorInstance(final FlightConfigurationID fcid, final MotorConfiguration newMotorInstance){ if((null == newMotorInstance)){ this.motors.set( fcid, null); }else{ @@ -302,7 +302,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra } @Override - public Iterator getMotorIterator(){ + public Iterator getMotorIterator(){ return this.motors.iterator(); } @@ -374,7 +374,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra new IllegalArgumentException(" copyWithOriginalID should produce different motorSet instances! "); } - copy.motors = new MotorSet( this.motors, copy ); + copy.motors = new MotorConfigurationSet( this.motors, copy ); return copy; } @@ -414,7 +414,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra Coordinate[] absCoords = this.getLocations(); FlightConfigurationID curId = this.getRocket().getDefaultConfiguration().getFlightConfigurationID(); final int intanceCount = this.getInstanceCount(); - MotorInstance curInstance = this.motors.get(curId); + MotorConfiguration curInstance = this.motors.get(curId); if( curInstance.isEmpty() ){ // print just the tube locations buffer.append(prefix+" [X] This Instance doesn't have any motors... showing mount tubes only\n"); diff --git a/core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java b/core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java deleted file mode 100644 index f115c9af9..000000000 --- a/core/src/net/sf/openrocket/rocketcomponent/MotorConfiguration.java +++ /dev/null @@ -1,72 +0,0 @@ -package net.sf.openrocket.rocketcomponent; - -import java.util.EventObject; -import java.util.List; - -import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.util.ArrayList; -import net.sf.openrocket.util.Coordinate; -import net.sf.openrocket.util.StateChangeListener; - -public class MotorConfiguration implements FlightConfigurableParameter { - - protected Coordinate position = Coordinate.ZERO; - protected double ejectionDelay = 0.0; - protected Motor motor = null; - - private final List listeners = new ArrayList(); - - public Coordinate getPosition() { - return position; - } - - public void setPosition(Coordinate position) { - this.position = position; - fireChangeEvent(); - } - - public double getEjectionDelay() { - return ejectionDelay; - } - - public void setEjectionDelay(double ejectionDelay) { - this.ejectionDelay = ejectionDelay; - fireChangeEvent(); - } - - public Motor getMotor() { - return motor; - } - - public void setMotor(Motor motor) { - this.motor = motor; - fireChangeEvent(); - } - - @Override - public MotorConfiguration clone() { - MotorConfiguration clone = new MotorConfiguration(); - clone.position = this.position; - clone.ejectionDelay = this.ejectionDelay; - return clone; - } - - @Override - public void addChangeListener(StateChangeListener listener) { - listeners.add(listener); - } - - @Override - public void removeChangeListener(StateChangeListener listener) { - listeners.remove(listener); - } - - private void fireChangeEvent() { - EventObject event = new EventObject(this); - Object[] list = listeners.toArray(); - for (Object l : list) { - ((StateChangeListener) l).stateChanged(event); - } - } - -} diff --git a/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java b/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java index 47f247612..9fe322552 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java +++ b/core/src/net/sf/openrocket/rocketcomponent/MotorMount.java @@ -2,7 +2,7 @@ package net.sf.openrocket.rocketcomponent; import java.util.Iterator; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.util.ChangeSource; import net.sf.openrocket.util.Coordinate; @@ -38,14 +38,14 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent { * * @return an iterator to all motors configured for this component */ - public Iterator getMotorIterator(); + public Iterator getMotorIterator(); /** * Returns the Default Motor Instance for this mount. * * @return The default MotorInstance */ - public MotorInstance getDefaultMotorInstance(); + public MotorConfiguration getDefaultMotorInstance(); /** * Default implementatino supplied by RocketComponent (returns 1); @@ -59,14 +59,14 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent { * @param fcid id for which to return the motor (null retrieves the default) * @return requested motorInstance (which may also be the default motor instance) */ - public MotorInstance getMotorInstance( final FlightConfigurationID fcid); + public MotorConfiguration getMotorInstance( final FlightConfigurationID fcid); /** * * @param fcid index the supplied motor against this flight configuration * @param newMotorInstance motor instance to store */ - public void setMotorInstance(final FlightConfigurationID fcid, final MotorInstance newMotorInstance); + public void setMotorInstance(final FlightConfigurationID fcid, final MotorConfiguration newMotorInstance); /** * Get the number of motors available for all flight configurations diff --git a/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java b/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java index 441e27a4f..3c67d4908 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java +++ b/core/src/net/sf/openrocket/rocketcomponent/RecoveryDevice.java @@ -25,10 +25,10 @@ public abstract class RecoveryDevice extends MassObject implements FlightConfigu private Material.Surface material; - private ParameterSet deploymentConfigurations; + private FlightConfigurableParameterSet deploymentConfigurations; public RecoveryDevice() { - this.deploymentConfigurations = new ParameterSet(this, ComponentChangeEvent.EVENT_CHANGE, new DeploymentConfiguration()); + this.deploymentConfigurations = new FlightConfigurableParameterSet(this, ComponentChangeEvent.EVENT_CHANGE, new DeploymentConfiguration()); setMaterial(Application.getPreferences().getDefaultComponentMaterial(RecoveryDevice.class, Material.Type.SURFACE)); } @@ -85,7 +85,7 @@ public abstract class RecoveryDevice extends MassObject implements FlightConfigu fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); } - public ParameterSet getDeploymentConfigurations() { + public FlightConfigurableParameterSet getDeploymentConfigurations() { return deploymentConfigurations; } @@ -113,7 +113,7 @@ public abstract class RecoveryDevice extends MassObject implements FlightConfigu @Override protected RocketComponent copyWithOriginalID() { RecoveryDevice copy = (RecoveryDevice) super.copyWithOriginalID(); - copy.deploymentConfigurations = new ParameterSet(deploymentConfigurations, + copy.deploymentConfigurations = new FlightConfigurableParameterSet(deploymentConfigurations, copy, ComponentChangeEvent.EVENT_CHANGE); return copy; } diff --git a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java index fb31d9e17..d9b47b2aa 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java @@ -553,7 +553,7 @@ public class Rocket extends RocketComponent { return this.configSet.size(); } - public ParameterSet getConfigSet(){ + public FlightConfigurableParameterSet getConfigSet(){ checkState(); return this.configSet; } diff --git a/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java b/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java index 890bb02c6..f0b1ed4b6 100644 --- a/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java +++ b/core/src/net/sf/openrocket/simulation/AbstractSimulationStepper.java @@ -6,7 +6,7 @@ import net.sf.openrocket.masscalc.MassCalculator; import net.sf.openrocket.masscalc.MassCalculator.MassCalcType; import net.sf.openrocket.masscalc.MassData; import net.sf.openrocket.models.atmosphere.AtmosphericConditions; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.simulation.exception.SimulationException; import net.sf.openrocket.simulation.listeners.SimulationListenerHelper; diff --git a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java index 1f04c496c..c3434ad02 100644 --- a/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java +++ b/core/src/net/sf/openrocket/simulation/BasicEventSimulationEngine.java @@ -10,7 +10,7 @@ import org.slf4j.LoggerFactory; import net.sf.openrocket.aerodynamics.Warning; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.DeploymentConfiguration; @@ -427,8 +427,8 @@ public class BasicEventSimulationEngine implements SimulationEngine { // TODO: HIGH: Check stage activeness for other events as well? // Check whether any motor in the active stages is active anymore - Collection activeMotors = currentStatus.getConfiguration().getActiveMotors(); - for (MotorInstance curMotor : activeMotors) { + Collection activeMotors = currentStatus.getConfiguration().getActiveMotors(); + for (MotorConfiguration curMotor : activeMotors) { RocketComponent comp = ((RocketComponent) curMotor.getMount()); int stageNumber = comp.getStageNumber(); if (!currentStatus.getConfiguration().isStageActive(stageNumber)) diff --git a/core/src/net/sf/openrocket/simulation/SimulationStatus.java b/core/src/net/sf/openrocket/simulation/SimulationStatus.java index dcbe2727d..5160a99cb 100644 --- a/core/src/net/sf/openrocket/simulation/SimulationStatus.java +++ b/core/src/net/sf/openrocket/simulation/SimulationStatus.java @@ -10,7 +10,7 @@ import java.util.Set; import net.sf.openrocket.aerodynamics.FlightConditions; import net.sf.openrocket.aerodynamics.WarningSet; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.LaunchLug; @@ -148,7 +148,7 @@ public class SimulationStatus implements Monitorable { this.launchRodCleared = false; this.apogeeReached = false; - for( MotorInstance motorInstance : this.configuration.getActiveMotors() ) { + for( MotorConfiguration motorInstance : this.configuration.getActiveMotors() ) { this.motorState.add( motorInstance.getSimulationState() ); } this.warnings = new WarningSet(); diff --git a/core/src/net/sf/openrocket/simulation/listeners/example/DampingMoment.java b/core/src/net/sf/openrocket/simulation/listeners/example/DampingMoment.java index 8cae29049..65cdb053d 100644 --- a/core/src/net/sf/openrocket/simulation/listeners/example/DampingMoment.java +++ b/core/src/net/sf/openrocket/simulation/listeners/example/DampingMoment.java @@ -6,7 +6,7 @@ import java.util.Map; import net.sf.openrocket.aerodynamics.AerodynamicCalculator; import net.sf.openrocket.aerodynamics.AerodynamicForces; import net.sf.openrocket.aerodynamics.FlightConditions; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.simulation.FlightDataBranch; @@ -69,7 +69,7 @@ public class DampingMoment extends AbstractSimulationListener { // find the maximum distance from nose to nozzle. double nozzleDistance = 0; FlightConfiguration config = status.getConfiguration(); - for (MotorInstance inst : config.getActiveMotors()) { + for (MotorConfiguration inst : config.getActiveMotors()) { Coordinate position = inst.getPosition(); double x = position.x + inst.getMotor().getLength(); diff --git a/core/src/net/sf/openrocket/util/TestRockets.java b/core/src/net/sf/openrocket/util/TestRockets.java index 9810bd550..7fd7ce0f3 100644 --- a/core/src/net/sf/openrocket/util/TestRockets.java +++ b/core/src/net/sf/openrocket/util/TestRockets.java @@ -11,7 +11,7 @@ import net.sf.openrocket.material.Material; import net.sf.openrocket.material.Material.Type; import net.sf.openrocket.motor.Manufacturer; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.MotorInstanceId; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.preset.ComponentPreset; @@ -89,7 +89,7 @@ public class TestRockets { } // This function is used for unit, integration tests, DO NOT CHANGE (without updating tests). - private static MotorInstance generateMotorInstance_M1350_75mm(){ + private static MotorConfiguration generateMotorInstance_M1350_75mm(){ // public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description, // Motor.Type type, double[] delays, double diameter, double length, // double[] time, double[] thrust, @@ -101,11 +101,11 @@ public class TestRockets { new Coordinate[] { new Coordinate(.311, 0, 0, 4.808),new Coordinate(.311, 0, 0, 3.389),new Coordinate(.311, 0, 0, 1.970)}, "digest M1350 test"); - return new MotorInstance(mtr); + return new MotorConfiguration(mtr); } // This function is used for unit, integration tests, DO NOT CHANGE (without updating tests). - private static MotorInstance generateMotorInstance_G77_29mm(){ + private static MotorConfiguration generateMotorInstance_G77_29mm(){ // public ThrustCurveMotor(Manufacturer manufacturer, String designation, String description, // Motor.Type type, double[] delays, double diameter, double length, // double[] time, double[] thrust, @@ -117,7 +117,7 @@ public class TestRockets { new Coordinate[] { new Coordinate(.062, 0, 0, 0.123),new Coordinate(.062, 0, 0, .0935),new Coordinate(.062, 0, 0, 0.064)}, "digest G77 test"); - return new MotorInstance(mtr); + return new MotorConfiguration(mtr); } // @@ -409,7 +409,7 @@ public class TestRockets { } // This function is used for unit, integration tests, DO NOT CHANGE (without updating tests). - public static final MotorInstance getTestD12Motor() { + public static final MotorConfiguration getTestD12Motor() { // Estes D12: // http://nar.org/SandT/pdf/Estes/D12.pdf ThrustCurveMotor motor = new ThrustCurveMotor( @@ -420,7 +420,7 @@ public class TestRockets { new Coordinate(0.0035,0,0,30.0), new Coordinate(0.0035,0,0,21.0)}, "digest_D12"); - MotorInstance inst = new MotorInstance(motor); + MotorConfiguration inst = new MotorConfiguration(motor); inst.setEjectionDelay(5); return inst; } @@ -466,7 +466,7 @@ public class TestRockets { FlightConfigurationID fcid = config.getFlightConfigurationID(); ThrustCurveMotor motor = getTestMotor(); - MotorInstance instance = new MotorInstance(motor); + MotorConfiguration instance = new MotorConfiguration(motor); instance.setEjectionDelay(5); bodytube.setMotorInstance(fcid, instance); @@ -805,7 +805,7 @@ public class TestRockets { coreBody.setMotorMount(true); coreStage.addChild( coreBody); { - MotorInstance motorInstance = TestRockets.generateMotorInstance_M1350_75mm(); + MotorConfiguration motorInstance = TestRockets.generateMotorInstance_M1350_75mm(); motorInstance.setID( new MotorInstanceId( coreBody.getName(), 1) ); coreBody.setMotorMount( true); FlightConfigurationID motorConfigId = config.getFlightConfigurationID(); @@ -867,7 +867,7 @@ public class TestRockets { boosterBody.addChild( boosterMotorTubes); FlightConfigurationID motorConfigId = config.getFlightConfigurationID(); - MotorInstance motorInstance = TestRockets.generateMotorInstance_G77_29mm(); + MotorConfiguration motorInstance = TestRockets.generateMotorInstance_G77_29mm(); motorInstance.setID( new MotorInstanceId( boosterMotorTubes.getName(), 1) ); boosterMotorTubes.setMotorInstance( motorConfigId, motorInstance); boosterMotorTubes.setMotorOverhang(0.01234); @@ -980,7 +980,7 @@ public class TestRockets { // create motor config and add a motor to it ThrustCurveMotor motor = getTestMotor(); - MotorInstance motorInst = new MotorInstance(motor); + MotorConfiguration motorInst = new MotorConfiguration(motor); motorInst.setEjectionDelay(5); // add motor config to inner tube (motor mount) @@ -1015,7 +1015,7 @@ public class TestRockets { // create motor config and add a motor to it ThrustCurveMotor motor = getTestMotor(); - MotorInstance motorConfig = new MotorInstance(motor); + MotorConfiguration motorConfig = new MotorConfiguration(motor); motorConfig.setEjectionDelay(5); // add motor config to inner tube (motor mount) @@ -1172,7 +1172,7 @@ public class TestRockets { bodyTube.addChild(innerTube); // make inner tube with motor mount flag set - MotorInstance inst = new MotorInstance(getTestMotor()); + MotorConfiguration inst = new MotorConfiguration(getTestMotor()); innerTube.setMotorInstance(fcid, inst); // set ignition parameters for motor mount diff --git a/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java b/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java index 3676fea23..449972566 100644 --- a/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java +++ b/core/test/net/sf/openrocket/aerodynamics/BarrowmanCalculatorTest.java @@ -11,7 +11,7 @@ import com.google.inject.Injector; import com.google.inject.Module; import net.sf.openrocket.ServicesForTesting; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.plugin.PluginModule; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; @@ -69,7 +69,7 @@ public class BarrowmanCalculatorTest { FlightConditions conditions = new FlightConditions(config); WarningSet warnings = new WarningSet(); - MotorInstance inst = TestRockets.getTestD12Motor(); + MotorConfiguration inst = TestRockets.getTestD12Motor(); InnerTube motorTube = (InnerTube)rkt.getChild(0).getChild(1).getChild(1); motorTube.setMotorInstance(fcid, inst); motorTube.setMotorMount(true); diff --git a/core/test/net/sf/openrocket/masscalc/MassCalculatorTest.java b/core/test/net/sf/openrocket/masscalc/MassCalculatorTest.java index 74382d111..d0b6a7bbd 100644 --- a/core/test/net/sf/openrocket/masscalc/MassCalculatorTest.java +++ b/core/test/net/sf/openrocket/masscalc/MassCalculatorTest.java @@ -7,7 +7,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import net.sf.openrocket.masscalc.MassCalculator.MassCalcType; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.ParallelStage; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; diff --git a/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java b/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java index 60be43c6c..c90673a68 100644 --- a/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java +++ b/core/test/net/sf/openrocket/motor/ThrustCurveMotorTest.java @@ -42,7 +42,7 @@ public class ThrustCurveMotorTest { @Test public void testInstance() { - ThrustCurveMotorInstance instance = motor.getNewInstance(); + ThrustCurveMotorState instance = motor.getNewInstance(); verify(instance, 0, 0.05, 0.02); instance.step(0.0, 0, null); @@ -64,7 +64,7 @@ public class ThrustCurveMotorTest { verify(instance, 0, 0.03, 0.03); } - private void verify(ThrustCurveMotorInstance instance, double thrust, double mass, double cgx) { + private void verify(ThrustCurveMotorState instance, double thrust, double mass, double cgx) { assertEquals("Testing thrust", thrust, instance.getThrust(), EPS); assertEquals("Testing mass", mass, instance.getCG().weight, EPS); assertEquals("Testing cg x", cgx, instance.getCG().x, EPS); diff --git a/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java b/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java index 7ba1cb279..beee676af 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/ConfigurationTest.java @@ -11,7 +11,7 @@ import org.junit.Test; import net.sf.openrocket.motor.Manufacturer; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.rocketcomponent.RocketComponent.Position; import net.sf.openrocket.util.Coordinate; @@ -560,7 +560,7 @@ public class ConfigurationTest extends BaseTestCase { InnerTube sustainerMount = (InnerTube) rocket.getChild(0).getChild(1).getChild(3); sustainerMount.setMotorMount(true); - sustainerMount.setMotorInstance(fcid, new MotorInstance(sustainerMotor)); + sustainerMount.setMotorInstance(fcid, new MotorConfiguration(sustainerMotor)); } { @@ -577,7 +577,7 @@ public class ConfigurationTest extends BaseTestCase { "digest D21 test"); InnerTube boosterMount = (InnerTube) rocket.getChild(1).getChild(0).getChild(2); boosterMount.setMotorMount(true); - boosterMount.setMotorInstance(fcid, new MotorInstance(boosterMotor)); + boosterMount.setMotorInstance(fcid, new MotorConfiguration(boosterMotor)); boosterMount.setClusterConfiguration( ClusterConfiguration.CONFIGURATIONS[1]); // double-mount } return rocket; diff --git a/swing/src/net/sf/openrocket/gui/adaptors/ParameterSetModel.java b/swing/src/net/sf/openrocket/gui/adaptors/ParameterSetModel.java index f899bf3e8..942e022f2 100644 --- a/swing/src/net/sf/openrocket/gui/adaptors/ParameterSetModel.java +++ b/swing/src/net/sf/openrocket/gui/adaptors/ParameterSetModel.java @@ -13,7 +13,7 @@ import javax.swing.event.ListDataListener; import net.sf.openrocket.rocketcomponent.ComponentChangeEvent; import net.sf.openrocket.rocketcomponent.FlightConfigurableParameter; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; -import net.sf.openrocket.rocketcomponent.ParameterSet; +import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet; import net.sf.openrocket.util.StateChangeListener; /** @@ -28,10 +28,10 @@ public class ParameterSetModel> impleme private EventListenerList listenerList = new EventListenerList(); private Object selected; - private final ParameterSet sourceSet; + private final FlightConfigurableParameterSet sourceSet; List idList= new Vector(); - public ParameterSetModel(ParameterSet set ) { + public ParameterSetModel(FlightConfigurableParameterSet set ) { this.sourceSet = set; this.selected = this.sourceSet.getDefault(); } diff --git a/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java b/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java index e29a3ebef..095a1e3bc 100644 --- a/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java +++ b/swing/src/net/sf/openrocket/gui/configdialog/MotorConfig.java @@ -21,7 +21,7 @@ import net.sf.openrocket.gui.components.BasicSlider; import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.components.UnitSelector; import net.sf.openrocket.l10n.Translator; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.rocketcomponent.RocketComponent; @@ -69,7 +69,7 @@ public class MotorConfig extends JPanel { //// Ignition at: panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), ""); - MotorInstance motorInstance = mount.getDefaultMotorInstance(); + MotorConfiguration motorInstance = mount.getDefaultMotorInstance(); final EnumModel igEvModel = new EnumModel(motorInstance, "IgnitionEvent", IgnitionEvent.values()); final JComboBox eventBox = new JComboBox( igEvModel); diff --git a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/IgnitionSelectionDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/IgnitionSelectionDialog.java index d11bcd73e..1566dfa5e 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/IgnitionSelectionDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/IgnitionSelectionDialog.java @@ -22,7 +22,7 @@ import net.sf.openrocket.gui.adaptors.DoubleModel; import net.sf.openrocket.gui.adaptors.EnumModel; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; @@ -39,7 +39,7 @@ public class IgnitionSelectionDialog extends JDialog { private RocketDescriptor descriptor = Application.getInjector().getInstance(RocketDescriptor.class); private MotorMount curMount; - private MotorInstance curMotorInstance; + private MotorConfiguration curMotorInstance; private IgnitionEvent startIgnitionEvent; private double startIgnitionDelay; @@ -106,15 +106,15 @@ public class IgnitionSelectionDialog extends JDialog { IgnitionEvent cie = curMotorInstance.getIgnitionEvent(); // update the default instance - final MotorInstance defaultMotorInstance = curMount.getDefaultMotorInstance(); + final MotorConfiguration defaultMotorInstance = curMount.getDefaultMotorInstance(); defaultMotorInstance.setIgnitionDelay( cid); defaultMotorInstance.setIgnitionEvent( cie); // and change all remaining configs // this seems like odd behavior to me, but it matches the text on the UI dialog popup. -teyrana (equipoise@gmail.com) - Iterator iter = curMount.getMotorIterator(); + Iterator iter = curMount.getMotorIterator(); while( iter.hasNext() ){ - MotorInstance next = iter.next(); + MotorConfiguration next = iter.next(); next.setIgnitionDelay( cid); next.setIgnitionEvent( cie); } diff --git a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java index b2885c431..d416eb22e 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/flightconfiguration/SeparationSelectionDialog.java @@ -23,7 +23,7 @@ import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; -import net.sf.openrocket.rocketcomponent.ParameterSet; +import net.sf.openrocket.rocketcomponent.FlightConfigurableParameterSet; import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration; import net.sf.openrocket.rocketcomponent.StageSeparationConfiguration.SeparationEvent; diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java index c8cdbef43..f8bce4943 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/MotorRowFilter.java @@ -12,7 +12,7 @@ import javax.swing.table.TableModel; import net.sf.openrocket.database.motor.ThrustCurveMotorSet; import net.sf.openrocket.motor.Manufacturer; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.rocketcomponent.MotorMount; import net.sf.openrocket.util.AbstractChangeSource; @@ -64,9 +64,9 @@ public class MotorRowFilter extends RowFilter implements Ch public void setMotorMount( MotorMount mount ) { if (mount != null) { - Iterator iter = mount.getMotorIterator(); + Iterator iter = mount.getMotorIterator(); while( iter.hasNext()){ - MotorInstance mi = iter.next(); + MotorConfiguration mi = iter.next(); if( !mi.isEmpty()){ this.usedMotors.add((ThrustCurveMotor) mi.getMotor()); } diff --git a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java index f6245a227..331d9d407 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/motor/thrustcurve/ThrustCurveMotorSelectionPanel.java @@ -54,7 +54,7 @@ import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.logging.Markers; import net.sf.openrocket.motor.Manufacturer; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.motor.ThrustCurveMotor; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.MotorMount; @@ -319,7 +319,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec } motorFilterPanel.setMotorMount(mountToEdit); - MotorInstance curMotorInstance = mountToEdit.getMotorInstance(_fcid); + MotorConfiguration curMotorInstance = mountToEdit.getMotorInstance(_fcid); selectedMotor = null; selectedMotorSet = null; selectedDelay = 0; diff --git a/swing/src/net/sf/openrocket/gui/figure3d/RocketRenderer.java b/swing/src/net/sf/openrocket/gui/figure3d/RocketRenderer.java index d58c7ad76..4abf748cd 100644 --- a/swing/src/net/sf/openrocket/gui/figure3d/RocketRenderer.java +++ b/swing/src/net/sf/openrocket/gui/figure3d/RocketRenderer.java @@ -18,7 +18,7 @@ import net.sf.openrocket.gui.figure3d.geometry.ComponentRenderer; import net.sf.openrocket.gui.figure3d.geometry.DisplayListComponentRenderer; import net.sf.openrocket.gui.figure3d.geometry.Geometry.Surface; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.MotorMount; @@ -188,7 +188,7 @@ public abstract class RocketRenderer { // } // } - for( MotorInstance curMotor : configuration.getActiveMotors()){ + for( MotorConfiguration curMotor : configuration.getActiveMotors()){ MotorMount mount = curMotor.getMount(); Motor motor = curMotor.getMotor(); diff --git a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java index 70e35e014..bd16b07ce 100644 --- a/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java +++ b/swing/src/net/sf/openrocket/gui/main/flightconfigpanel/MotorConfigurationPanel.java @@ -26,7 +26,7 @@ import net.sf.openrocket.gui.dialogs.flightconfiguration.IgnitionSelectionDialog import net.sf.openrocket.gui.dialogs.flightconfiguration.MotorMountConfigurationPanel; import net.sf.openrocket.gui.dialogs.motor.MotorChooserDialog; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfigurationID; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.rocketcomponent.MotorMount; @@ -215,7 +215,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel Motor mtr = motorChooserDialog.getSelectedMotor(); double d = motorChooserDialog.getSelectedDelay(); if (mtr != null) { - MotorInstance curInstance = new MotorInstance(mtr); + MotorConfiguration curInstance = new MotorConfiguration(mtr); curInstance.setEjectionDelay(d); curInstance.setIgnitionEvent( IgnitionEvent.NEVER); curMount.setMotorInstance( fcid, curInstance); @@ -260,7 +260,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel if ( (null == fcid )||( null == curMount )){ return; } - MotorInstance curInstance = curMount.getMotorInstance(fcid); + MotorConfiguration curInstance = curMount.getMotorInstance(fcid); curInstance.useDefaultIgnition(); @@ -276,7 +276,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel JLabel label = new JLabel(); label.setLayout(new BoxLayout(label, BoxLayout.X_AXIS)); - MotorInstance curMotor = mount.getMotorInstance( configId); + MotorConfiguration curMotor = mount.getMotorInstance( configId); String motorString = getMotorSpecification( curMotor ); JLabel motorDescriptionLabel = new JLabel(motorString); @@ -288,7 +288,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel return label; } - private String getMotorSpecification(MotorInstance curMotorInstance ) { + private String getMotorSpecification(MotorConfiguration curMotorInstance ) { if( curMotorInstance.isEmpty()){ return NONE; } @@ -308,8 +308,8 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel } private JLabel getIgnitionEventString(FlightConfigurationID id, MotorMount mount) { - MotorInstance defInstance = mount.getDefaultMotorInstance(); - MotorInstance curInstance = mount.getMotorInstance(id); + MotorConfiguration defInstance = mount.getDefaultMotorInstance(); + MotorConfiguration curInstance = mount.getMotorInstance(id); IgnitionEvent ignitionEvent = curInstance.getIgnitionEvent(); Double ignitionDelay = curInstance.getIgnitionDelay(); diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java index 2696fb973..48f19b9ef 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketFigure.java @@ -26,7 +26,7 @@ import net.sf.openrocket.gui.rocketfigure.RocketComponentShape; import net.sf.openrocket.gui.util.ColorConversion; import net.sf.openrocket.gui.util.SwingPreferences; import net.sf.openrocket.motor.Motor; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.AxialStage; import net.sf.openrocket.rocketcomponent.ComponentAssembly; import net.sf.openrocket.rocketcomponent.FlightConfiguration; @@ -338,7 +338,7 @@ public class RocketFigure extends AbstractScaleFigure { Color borderColor = ((SwingPreferences)Application.getPreferences()).getMotorBorderColor(); FlightConfiguration config = rocket.getDefaultConfiguration(); - for( MotorInstance curInstance : config.getActiveMotors()){ + for( MotorConfiguration curInstance : config.getActiveMotors()){ MotorMount mount = curInstance.getMount(); Motor motor = curInstance.getMotor(); double motorLength = motor.getLength(); diff --git a/swing/src/net/sf/openrocket/gui/simulation/SimulationRunDialog.java b/swing/src/net/sf/openrocket/gui/simulation/SimulationRunDialog.java index 6a6a633eb..48b88e69c 100644 --- a/swing/src/net/sf/openrocket/gui/simulation/SimulationRunDialog.java +++ b/swing/src/net/sf/openrocket/gui/simulation/SimulationRunDialog.java @@ -33,7 +33,7 @@ import net.sf.openrocket.gui.dialogs.DetailDialog; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.gui.util.SwingPreferences; import net.sf.openrocket.l10n.Translator; -import net.sf.openrocket.motor.MotorInstance; +import net.sf.openrocket.motor.MotorConfiguration; import net.sf.openrocket.rocketcomponent.FlightConfiguration; import net.sf.openrocket.rocketcomponent.IgnitionEvent; import net.sf.openrocket.simulation.FlightEvent; @@ -293,9 +293,9 @@ public class SimulationRunDialog extends JDialog { FlightConfiguration config = simulation.getRocket().getDefaultConfiguration(); - Collection activeMotors = config.getActiveMotors(); + Collection activeMotors = config.getActiveMotors(); - for (MotorInstance curInstance : activeMotors) { + for (MotorConfiguration curInstance : activeMotors) { if (curInstance.getIgnitionEvent() == IgnitionEvent.LAUNCH) launchBurn = MathUtil.max(launchBurn, curInstance.getMotor().getBurnTimeEstimate()); else