[Minor] Harmonized interface for instanceable components

Implemented 'Instanceable' Interface
    - MotorMount implements instanceable
        - BodyTube
        - Innertube
    -RingInstance interface
        - BoosterSet
        - PodSet
    -LineInstanceable interface [This feature is not exposed in UI)
        - LaunchLug
        - LaunchButton (Stub only, ATT)
        - RingComponent (abstract ancestor class)
-Reverted MotorMount Function names to "[is|set]MotorMount"
This commit is contained in:
Daniel_M_Williams 2015-10-06 12:00:37 -04:00
parent 1401d99528
commit 0a55f59548
39 changed files with 648 additions and 160 deletions

View File

@ -1376,7 +1376,9 @@ RocketComponent.Position.ABSOLUTE = Tip of the nose cone
! LaunchLug ! LaunchLug
LaunchLug.Launchlug = Launch lug LaunchLug.Launchlug = Launch Lug
! LaunchButton
LaunchButton.LaunchButton = Launch Button
! NoseCone ! NoseCone
NoseCone.NoseCone = Nose cone NoseCone.NoseCone = Nose cone
! Transition ! Transition

View File

@ -21,7 +21,9 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent.Finish;
import net.sf.openrocket.rocketcomponent.FinSet; import net.sf.openrocket.rocketcomponent.FinSet;
import net.sf.openrocket.rocketcomponent.FreeformFinSet; import net.sf.openrocket.rocketcomponent.FreeformFinSet;
import net.sf.openrocket.rocketcomponent.InnerTube; import net.sf.openrocket.rocketcomponent.InnerTube;
import net.sf.openrocket.rocketcomponent.Instanceable;
import net.sf.openrocket.rocketcomponent.LaunchLug; import net.sf.openrocket.rocketcomponent.LaunchLug;
import net.sf.openrocket.rocketcomponent.LineInstanceable;
import net.sf.openrocket.rocketcomponent.MassComponent; import net.sf.openrocket.rocketcomponent.MassComponent;
import net.sf.openrocket.rocketcomponent.MassObject; import net.sf.openrocket.rocketcomponent.MassObject;
import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.NoseCone;
@ -31,6 +33,7 @@ import net.sf.openrocket.rocketcomponent.RadiusRingComponent;
import net.sf.openrocket.rocketcomponent.RecoveryDevice; import net.sf.openrocket.rocketcomponent.RecoveryDevice;
import net.sf.openrocket.rocketcomponent.ReferenceType; import net.sf.openrocket.rocketcomponent.ReferenceType;
import net.sf.openrocket.rocketcomponent.RingComponent; import net.sf.openrocket.rocketcomponent.RingComponent;
import net.sf.openrocket.rocketcomponent.RingInstanceable;
import net.sf.openrocket.rocketcomponent.Rocket; import net.sf.openrocket.rocketcomponent.Rocket;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
import net.sf.openrocket.rocketcomponent.ShockCord; import net.sf.openrocket.rocketcomponent.ShockCord;
@ -411,9 +414,27 @@ class DocumentConfig {
Reflection.findMethod(AxialStage.class, "getSeparationConfigurations"), Reflection.findMethod(AxialStage.class, "getSeparationConfigurations"),
Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class))); Reflection.findMethod(StageSeparationConfiguration.class, "setSeparationDelay", double.class)));
setters.put("ComponentAssembly:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class))); /*
setters.put("ComponentAssembly:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class))); * The keys are of the form Class:param, where Class is the class name and param
setters.put("ComponentAssembly:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class))); * the element name. Setters are searched for in descending class order.
* A setter of null means setting the parameter is not allowed.
*/
// setters.put("ComponentAssembly:instancecount", new IntSetter(Reflection.findMethod(AxialStage.class, "setInstanceCount", int.class)));
// setters.put("ComponentAssembly:radialoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setRadialOffset", double.class)));
// setters.put("ComponentAssembly:angleoffset", new DoubleSetter(Reflection.findMethod(AxialStage.class, "setAngularOffset", double.class)));
setters.put("Instanceable:instancecount", new IntSetter(
Reflection.findMethod(Instanceable.class, "setInstanceCount",int.class)));
setters.put("RingInstanceable:radialoffset", new DoubleSetter(
Reflection.findMethod(RingInstanceable.class, "setRadialOffset", double.class)));
setters.put("RingInstance:angleoffset", new DoubleSetter(
Reflection.findMethod(RingInstanceable.class, "setAngularOffset", double.class)));
setters.put("LineInstanceable:instanceseparation", new DoubleSetter(
Reflection.findMethod( LineInstanceable.class, "setInstanceSeparation", double.class)));
} }

View File

@ -25,7 +25,7 @@ class MotorMountHandler extends AbstractElementHandler {
public MotorMountHandler(MotorMount mount, DocumentLoadingContext context) { public MotorMountHandler(MotorMount mount, DocumentLoadingContext context) {
this.mount = mount; this.mount = mount;
this.context = context; this.context = context;
mount.setActive(true); mount.setMotorMount(true);
} }
@Override @Override

View File

@ -27,7 +27,7 @@ public class BodyTubeSaver extends SymmetricComponentSaver {
else else
elements.add("<radius>" + tube.getOuterRadius() + "</radius>"); elements.add("<radius>" + tube.getOuterRadius() + "</radius>");
if (tube.isActive()) { if (tube.isMotorMount()) {
elements.addAll(motorMountParams(tube)); elements.addAll(motorMountParams(tube));
} }
} }

View File

@ -6,7 +6,9 @@ import java.util.List;
import net.sf.openrocket.rocketcomponent.BoosterSet; import net.sf.openrocket.rocketcomponent.BoosterSet;
import net.sf.openrocket.rocketcomponent.ComponentAssembly; import net.sf.openrocket.rocketcomponent.ComponentAssembly;
import net.sf.openrocket.rocketcomponent.Instanceable;
import net.sf.openrocket.rocketcomponent.PodSet; import net.sf.openrocket.rocketcomponent.PodSet;
import net.sf.openrocket.rocketcomponent.RingInstanceable;
import net.sf.openrocket.rocketcomponent.RocketComponent; import net.sf.openrocket.rocketcomponent.RocketComponent;
public class ComponentAssemblySaver extends RocketComponentSaver { public class ComponentAssemblySaver extends RocketComponentSaver {
@ -50,14 +52,17 @@ public class ComponentAssemblySaver extends RocketComponentSaver {
final String startangle_tag = "angleoffset"; final String startangle_tag = "angleoffset";
if (null != currentStage) { if ( currentStage instanceof Instanceable) {
int instanceCount = currentStage.getInstanceCount(); int instanceCount = currentStage.getInstanceCount();
elementsToReturn.add("<" + instCt_tag + ">" + instanceCount + "</" + instCt_tag + ">"); elementsToReturn.add("<" + instCt_tag + ">" + instanceCount + "</" + instCt_tag + ">");
double radialOffset = currentStage.getRadialOffset(); if( currentStage instanceof RingInstanceable ){
RingInstanceable ring = (RingInstanceable) currentStage;
double radialOffset = ring.getRadialOffset();
elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "</" + radoffs_tag + ">"); elementsToReturn.add("<" + radoffs_tag + ">" + radialOffset + "</" + radoffs_tag + ">");
double angularOffset = currentStage.getAngularOffset(); double angularOffset = ring.getAngularOffset();
elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "</" + startangle_tag + ">"); elementsToReturn.add("<" + startangle_tag + ">" + angularOffset + "</" + startangle_tag + ">");
} }
}
return elementsToReturn; return elementsToReturn;
} }

View File

@ -32,7 +32,7 @@ public class InnerTubeSaver extends ThicknessRingComponentSaver {
elements.add("<clusterrotation>" + (tube.getClusterRotation() * 180.0 / Math.PI) elements.add("<clusterrotation>" + (tube.getClusterRotation() * 180.0 / Math.PI)
+ "</clusterrotation>"); + "</clusterrotation>");
if (tube.isActive()) { if (tube.isMotorMount()) {
elements.addAll(motorMountParams(tube)); elements.addAll(motorMountParams(tube));
} }

View File

@ -144,7 +144,7 @@ public class RocketComponentSaver {
protected final List<String> motorMountParams(MotorMount mount) { protected final List<String> motorMountParams(MotorMount mount) {
if (!mount.isActive()) if (!mount.isMotorMount())
return Collections.emptyList(); return Collections.emptyList();
//FlightConfigurationID[] motorConfigIDs = ((RocketComponent) mount).getRocket().getFlightConfigurationIDs(); //FlightConfigurationID[] motorConfigIDs = ((RocketComponent) mount).getRocket().getFlightConfigurationIDs();

View File

@ -87,7 +87,7 @@ public class BodyTubeDTO extends BasePartDTO implements AttachableParts {
setID(theORBodyTube.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS); setID(theORBodyTube.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setOD(theORBodyTube.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS); setOD(theORBodyTube.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorDia((theORBodyTube.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS); setMotorDia((theORBodyTube.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorMount(theORBodyTube.isActive()); setMotorMount(theORBodyTube.isMotorMount());
List<RocketComponent> children = theORBodyTube.getChildren(); List<RocketComponent> children = theORBodyTube.getChildren();
for (int i = 0; i < children.size(); i++) { for (int i = 0; i < children.size(); i++) {

View File

@ -49,7 +49,7 @@ public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachableParts {
setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS); setID(bt.getInnerRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS); setOD(bt.getOuterRadius() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS); setMotorDia((bt.getMotorMountDiameter() / 2) * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_RADIUS);
setMotorMount(bt.isActive()); setMotorMount(bt.isMotorMount());
setInsideTube(true); setInsideTube(true);
setRadialAngle(bt.getRadialDirection()); setRadialAngle(bt.getRadialDirection());
setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH); setRadialLoc(bt.getRadialPosition() * RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);

View File

@ -72,7 +72,7 @@ public class MotorDescriptionSubstitutor implements RocketSubstitutor {
MotorInstance inst = mount.getMotorInstance(fcid); MotorInstance inst = mount.getMotorInstance(fcid);
Motor motor = inst.getMotor(); Motor motor = inst.getMotor();
if (mount.isActive() && motor != null) { if (mount.isMotorMount() && motor != null) {
String designation = motor.getDesignation(inst.getEjectionDelay()); String designation = motor.getDesignation(inst.getEjectionDelay());
for (int i = 0; i < mount.getMotorCount(); i++) { for (int i = 0; i < mount.getMotorCount(); i++) {

View File

@ -179,7 +179,7 @@ public class DefaultSimulationModifierService implements SimulationModifierServi
// Conditional motor mount parameters // Conditional motor mount parameters
if (c instanceof MotorMount) { if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c; MotorMount mount = (MotorMount) c;
if (mount.isActive()) { if (mount.isMotorMount()) {
SimulationModifier mod = new GenericComponentModifier( SimulationModifier mod = new GenericComponentModifier(
trans.get("optimization.modifier.motormount.overhang"), trans.get("optimization.modifier.motormount.overhang"),

View File

@ -12,7 +12,7 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
//private static final Logger log = LoggerFactory.getLogger(AxialStage.class); //private static final Logger log = LoggerFactory.getLogger(AxialStage.class);
private FlightConfigurationSet<StageSeparationConfiguration> separationConfigurations; protected FlightConfigurationSet<StageSeparationConfiguration> separationConfigurations;
protected int stageNumber; protected int stageNumber;

View File

@ -28,7 +28,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
// When changing the inner radius, thickness is modified // When changing the inner radius, thickness is modified
private double overhang = 0; private double overhang = 0;
private boolean isActiveMount = false; private boolean isActing = false;
private MotorConfigurationSet motors; private MotorConfigurationSet motors;
@ -382,7 +382,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
if( null != newMotorInstance ){ if( null != newMotorInstance ){
newMotorInstance.setMount( this); newMotorInstance.setMount( this);
if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){ if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){
this.setActive(true); this.setMotorMount(true);
} }
} }
} }
@ -398,21 +398,23 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
} }
@Override @Override
public void setActive(boolean _active){ public void setMotorMount(boolean _active){
if (this.isActiveMount == _active) if (this.isActing == _active)
return; return;
this.isActiveMount = _active; this.isActing = _active;
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
} }
@Override @Override
public boolean isActive(){ public boolean isMotorMount(){
return this.isActiveMount; return this.isActing;
} }
//@Override @Override
public boolean hasMotor() { public boolean hasMotor() {
return ( 0 < this.motors.size()); // the default MotorInstance is the EMPTY_INSTANCE.
// If the class contains more instances, at least one will have motors.
return ( 1 < this.motors.size());
} }
@Override @Override

View File

@ -11,16 +11,28 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
public class BoosterSet extends AxialStage implements FlightConfigurableComponent, OutsideComponent { public class BoosterSet extends AxialStage implements FlightConfigurableComponent, RingInstanceable, OutsideComponent {
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(BoosterSet.class); private static final Logger log = LoggerFactory.getLogger(BoosterSet.class);
private FlightConfigurationSet<StageSeparationConfiguration> separationConfigurations; protected int count = 1;
protected double angularSeparation = Math.PI;
protected double angularPosition_rad = 0;
protected double radialPosition_m = 0;
public BoosterSet() { public BoosterSet() {
this.count = 2; this.count = 2;
this.relativePosition = Position.BOTTOM; this.relativePosition = Position.BOTTOM;
this.angularSeparation = Math.PI * 2 / this.count;
}
public BoosterSet( final int _count ){
this();
this.count = _count;
this.angularSeparation = Math.PI * 2 / this.count;
} }
@Override @Override
@ -71,7 +83,7 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
@Override @Override
public void cloneFlightConfiguration(FlightConfigurationID oldConfigId, FlightConfigurationID newConfigId) { public void cloneFlightConfiguration(FlightConfigurationID oldConfigId, FlightConfigurationID newConfigId) {
separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId); this.separationConfigurations.cloneFlightConfiguration(oldConfigId, newConfigId);
} }
@Override @Override
@ -80,6 +92,21 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return copy; return copy;
} }
@Override
public double getAngularOffset() {
return this.angularPosition_rad;
}
@Override
public int getInstanceCount() {
return this.count;
}
@Override
public double getRadialOffset() {
return this.radialPosition_m;
}
@Override @Override
public Coordinate[] getLocation() { public Coordinate[] getLocation() {
if (null == this.parent) { if (null == this.parent) {
@ -102,6 +129,11 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return !isCenterline(); return !isCenterline();
} }
@Override
public String getPatternName(){
return (this.getInstanceCount() + "-ring");
}
/** /**
* Boosters are, by definition, not centerline. * Boosters are, by definition, not centerline.
* *
@ -130,6 +162,18 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return this.getAxialOffset(); return this.getAxialOffset();
} }
@Override
public void setRadialOffset(final double radius) {
this.radialPosition_m = radius;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public void setAngularOffset(final double angle_rad) {
this.angularPosition_rad = angle_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override @Override
public Coordinate[] shiftCoordinates(Coordinate[] c) { public Coordinate[] shiftCoordinates(Coordinate[] c) {
checkState(); checkState();
@ -159,4 +203,31 @@ public class BoosterSet extends AxialStage implements FlightConfigurableComponen
return toReturn; return toReturn;
} }
@Override
public void toDebugTreeNode(final StringBuilder buffer, final String prefix) {
String thisLabel = this.getName() + " (" + this.getStageNumber() + ")";
buffer.append(String.format("%s %-24s %5.3f", prefix, thisLabel, this.getLength()));
if (this.isCenterline()) {
buffer.append(String.format(" %24s %24s\n", this.getOffset(), this.getLocation()[0]));
} else {
buffer.append(String.format(" (offset: %4.1f via: %s )\n", this.getAxialOffset(), this.relativePosition.name()));
Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
Coordinate[] absCoords = this.getLocation();
for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
Coordinate instanceRelativePosition = relCoords[instanceNumber];
Coordinate instanceAbsolutePosition = absCoords[instanceNumber];
buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
instanceRelativePosition, instanceAbsolutePosition));
}
}
}
} }

View File

@ -9,6 +9,7 @@ import net.sf.openrocket.startup.Application;
public class Bulkhead extends RadiusRingComponent { public class Bulkhead extends RadiusRingComponent {
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
public Bulkhead() { public Bulkhead() {
setOuterRadiusAutomatic(true); setOuterRadiusAutomatic(true);
setLength(0.002); setLength(0.002);

View File

@ -7,7 +7,7 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
public class CenteringRing extends RadiusRingComponent { public class CenteringRing extends RadiusRingComponent implements LineInstanceable {
public CenteringRing() { public CenteringRing() {
setOuterRadiusAutomatic(true); setOuterRadiusAutomatic(true);

View File

@ -2,10 +2,13 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.util.ChangeSource; import net.sf.openrocket.util.ChangeSource;
public interface Clusterable extends ChangeSource { public interface Clusterable extends ChangeSource, Instanceable {
public ClusterConfiguration getClusterConfiguration(); public ClusterConfiguration getClusterConfiguration();
public void setClusterConfiguration(ClusterConfiguration cluster); public void setClusterConfiguration(ClusterConfiguration cluster);
public double getClusterSeparation(); public double getClusterSeparation();
} }

View File

@ -4,11 +4,11 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import net.sf.openrocket.util.Coordinate;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import net.sf.openrocket.util.Coordinate;
/** /**
@ -22,12 +22,6 @@ import org.slf4j.LoggerFactory;
public abstract class ComponentAssembly extends RocketComponent { public abstract class ComponentAssembly extends RocketComponent {
private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class); private static final Logger log = LoggerFactory.getLogger(ComponentAssembly.class);
protected double angularPosition_rad = 0;
protected double radialPosition_m = 0;
protected int count = 1;
protected double angularSeparation = Math.PI;
/** /**
* Sets the position of the components to POSITION_RELATIVE_AFTER. * Sets the position of the components to POSITION_RELATIVE_AFTER.
* (Should have no effect.) * (Should have no effect.)
@ -36,23 +30,11 @@ public abstract class ComponentAssembly extends RocketComponent {
super(RocketComponent.Position.AFTER); super(RocketComponent.Position.AFTER);
} }
@Override
public int getInstanceCount() {
return this.count;
}
public double getAngularOffset() {
return this.angularPosition_rad;
}
@Override @Override
public double getAxialOffset() { public double getAxialOffset() {
return super.asPositionValue(this.relativePosition); return super.asPositionValue(this.relativePosition);
} }
/** /**
* Null method (ComponentAssembly has no bounds of itself). * Null method (ComponentAssembly has no bounds of itself).
*/ */
@ -77,11 +59,6 @@ public abstract class ComponentAssembly extends RocketComponent {
return 0; return 0;
} }
public double getRadialOffset() {
return this.radialPosition_m;
}
/** /**
* Null method (ComponentAssembly has no mass of itself). * Null method (ComponentAssembly has no mass of itself).
*/ */
@ -121,15 +98,6 @@ public abstract class ComponentAssembly extends RocketComponent {
} }
public void setAngularOffset(final double angle_rad) {
if (this.isCenterline()) {
return;
}
this.angularPosition_rad = angle_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override @Override
public void setAxialOffset(final double _pos) { public void setAxialOffset(final double _pos) {
this.updateBounds(); this.updateBounds();
@ -151,18 +119,9 @@ public abstract class ComponentAssembly extends RocketComponent {
return; return;
} }
this.count = _count;
this.angularSeparation = Math.PI * 2 / this.count;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
} }
public void setRadialOffset(final double radius) {
if (false == this.isCenterline()) {
this.radialPosition_m = radius;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
}
public void setRelativePositionMethod(final Position _newPosition) { public void setRelativePositionMethod(final Position _newPosition) {
if (null == this.parent) { if (null == this.parent) {
throw new NullPointerException(" a Stage requires a parent before any positioning! "); throw new NullPointerException(" a Stage requires a parent before any positioning! ");
@ -192,31 +151,6 @@ public abstract class ComponentAssembly extends RocketComponent {
return false; return false;
} }
@Override
public void toDebugTreeNode(final StringBuilder buffer, final String prefix) {
String thisLabel = this.getName() + " (" + this.getStageNumber() + ")";
buffer.append(String.format("%s %-24s %5.3f", prefix, thisLabel, this.getLength()));
if (this.isCenterline()) {
buffer.append(String.format(" %24s %24s\n", this.getOffset(), this.getLocation()[0]));
} else {
buffer.append(String.format(" (offset: %4.1f via: %s )\n", this.getAxialOffset(), this.relativePosition.name()));
Coordinate[] relCoords = this.shiftCoordinates(new Coordinate[] { Coordinate.ZERO });
Coordinate[] absCoords = this.getLocation();
for (int instanceNumber = 0; instanceNumber < this.count; instanceNumber++) {
Coordinate instanceRelativePosition = relCoords[instanceNumber];
Coordinate instanceAbsolutePosition = absCoords[instanceNumber];
buffer.append(String.format("%s [instance %2d of %2d] %32s %32s\n", prefix, instanceNumber, count,
instanceRelativePosition, instanceAbsolutePosition));
}
}
}
@Override @Override
protected void update() { protected void update() {
if (null == this.parent) { if (null == this.parent) {

View File

@ -188,11 +188,12 @@ public class FlightConfiguration implements FlightConfigurableParameter<FlightCo
} }
// DEVEL // DEVEL
// see planning notes... // see planning notes...
if (comp instanceof MotorMount) { // is instance, AND is activeMount if ( comp instanceof MotorMount ){
MotorMount mount = (MotorMount)comp; MotorMount mount = (MotorMount)comp;
//if( mount.isActive() ){ //if( mount.isActive() ){
// if( mount instanceof Clusterable ){ // if( mount instanceof Clusterable ){
// if( 1 < comp.getInstanceCount() ){
// if comp is clustered, it will be clustered from the innerTube, no? // if comp is clustered, it will be clustered from the innerTube, no?
//List<MotorInstance> instanceList = mount.getMotorInstance(this.fcid); //List<MotorInstance> instanceList = mount.getMotorInstance(this.fcid);

View File

@ -4,6 +4,9 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.motor.Motor; import net.sf.openrocket.motor.Motor;
import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.motor.MotorInstance;
@ -23,13 +26,14 @@ import net.sf.openrocket.util.MathUtil;
*/ */
public class InnerTube extends ThicknessRingComponent implements Clusterable, RadialParent, MotorMount { public class InnerTube extends ThicknessRingComponent implements Clusterable, RadialParent, MotorMount {
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(InnerTube.class);
private ClusterConfiguration cluster = ClusterConfiguration.SINGLE; private ClusterConfiguration cluster = ClusterConfiguration.SINGLE;
private double clusterScale = 1.0; private double clusterScale = 1.0;
private double clusterRotation = 0.0; private double clusterRotation = 0.0;
private double overhang = 0; private double overhang = 0;
private boolean isActiveMount; private boolean isActing;
private FlightConfigurationSet<MotorInstance> motors; private FlightConfigurationSet<MotorInstance> motors;
/** /**
@ -63,6 +67,12 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return trans.get("InnerTube.InnerTube"); return trans.get("InnerTube.InnerTube");
} }
@Override
public String getPatternName() {
return this.cluster.getXMLName();
}
@Override @Override
public boolean allowsChildren() { public boolean allowsChildren() {
return true; return true;
@ -133,6 +143,11 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return cluster.getClusterCount(); return cluster.getClusterCount();
} }
@Override
public void setInstanceCount( final int newCount ){
log.error("Programmer Error: cannot set the instance count of an "+this.getClass().getSimpleName()+" directly. Please set setClusterConfiguration(ClusterConfiguration) instead.");
}
/** /**
* Get the cluster scaling. A value of 1.0 indicates that the tubes are packed * Get the cluster scaling. A value of 1.0 indicates that the tubes are packed
* touching each other, larger values separate the tubes and smaller values * touching each other, larger values separate the tubes and smaller values
@ -142,6 +157,11 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return clusterScale; return clusterScale;
} }
@Override
public boolean isCenterline() {
return (1 == this.getClusterCount());
}
/** /**
* Set the cluster scaling. * Set the cluster scaling.
* @see #getClusterScale() * @see #getClusterScale()
@ -243,7 +263,7 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
if( null != newMotorInstance ){ if( null != newMotorInstance ){
newMotorInstance.setMount( this); newMotorInstance.setMount( this);
if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){ if( MotorInstanceId.EMPTY_ID != newMotorInstance.getID()){
this.setActive(true); this.setMotorMount(true);
} }
} }
} }
@ -260,21 +280,22 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
@Override @Override
public void setActive(boolean _active){ public void setMotorMount(boolean _active){
if (this.isActiveMount == _active) if (this.isActing == _active)
return; return;
this.isActiveMount = _active; this.isActing = _active;
fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
} }
@Override @Override
public boolean isActive(){ public boolean isMotorMount(){
return this.isActiveMount; return this.isActing;
} }
//@Override @Override
public boolean hasMotor() { public boolean hasMotor() {
return ( 0 < this.motors.size()); // the default MotorInstance is the EMPTY_INSTANCE. If we have more than that, then the other instance will have a motor.
return ( 1 < this.motors.size());
} }
@Override @Override
@ -339,4 +360,6 @@ public class InnerTube extends ThicknessRingComponent implements Clusterable, Ra
return copy; return copy;
} }
} }

View File

@ -0,0 +1,26 @@
package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.util.Coordinate;
public interface Instanceable {
/** duplicate override... especially vs shiftCoordinates...
// one of the two should be private
*
* @return coordinates each instance of this component
*/
public Coordinate[] getLocation();
// overrides a method in RocketComponent
// not modifiable
public boolean isCenterline();
public void setInstanceCount( final int newCount );
public int getInstanceCount();
public Coordinate[] shiftCoordinates(Coordinate[] c);
public String getPatternName();
}

View File

@ -0,0 +1,275 @@
package net.sf.openrocket.rocketcomponent;
import java.util.ArrayList;
import java.util.Collection;
import net.sf.openrocket.l10n.Translator;
import net.sf.openrocket.preset.ComponentPreset;
import net.sf.openrocket.preset.ComponentPreset.Type;
import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.Coordinate;
import net.sf.openrocket.util.MathUtil;
/**
* WARNING! This class is stubbed out, partially implemented, but DEFINITELY not ready for use.
* @author widget (Daniel Williams)
*
*/
public abstract class LaunchButton extends ExternalComponent implements LineInstanceable {
private static final Translator trans = Application.getTranslator();
private double radius;
private double thickness;
private double radialDirection = 0;
private int instanceCount = 1;
private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
/* These are calculated when the component is first attached to any Rocket */
private double shiftY, shiftZ;
public LaunchButton() {
super(Position.MIDDLE);
radius = 0.01 / 2;
thickness = 0.001;
length = 0.03;
}
// @Override
// public double getOuterRadius() {
// return radius;
// }
//
// @Override
// public void setOuterRadius(double radius) {
// if (MathUtil.equals(this.radius, radius))
// return;
// this.radius = radius;
// this.thickness = Math.min(this.thickness, this.radius);
// clearPreset();
// fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
// }
// @Override
// public double getInnerRadius() {
// return radius - thickness;
// }
//
// @Override
// public void setInnerRadius(double innerRadius) {
// setOuterRadius(innerRadius + thickness);
// }
//
// @Override
// public double getThickness() {
// return thickness;
// }
public void setThickness(double thickness) {
if (MathUtil.equals(this.thickness, thickness))
return;
this.thickness = MathUtil.clamp(thickness, 0, radius);
clearPreset();
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
public double getRadialDirection() {
return radialDirection;
}
public void setRadialDirection(double direction) {
direction = MathUtil.reduce180(direction);
if (MathUtil.equals(this.radialDirection, direction))
return;
this.radialDirection = direction;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
public void setLength(double length) {
if (MathUtil.equals(this.length, length))
return;
this.length = length;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public boolean isCenterline() {
return false;
}
@Override
public void setRelativePosition(RocketComponent.Position position) {
super.setRelativePosition(position);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public void setPositionValue(double value) {
super.setPositionValue(value);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
protected void loadFromPreset(ComponentPreset preset) {
if (preset.has(ComponentPreset.OUTER_DIAMETER)) {
double outerDiameter = preset.get(ComponentPreset.OUTER_DIAMETER);
this.radius = outerDiameter / 2.0;
if (preset.has(ComponentPreset.INNER_DIAMETER)) {
double innerDiameter = preset.get(ComponentPreset.INNER_DIAMETER);
this.thickness = (outerDiameter - innerDiameter) / 2.0;
}
}
super.loadFromPreset(preset);
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public Type getPresetType() {
return ComponentPreset.Type.LAUNCH_LUG;
}
@Override
public Coordinate[] shiftCoordinates(Coordinate[] array) {
array = super.shiftCoordinates(array);
for (int i = 0; i < array.length; i++) {
array[i] = array[i].add(0, shiftY, shiftZ);
}
return array;
}
@Override
public void componentChanged(ComponentChangeEvent e) {
super.componentChanged(e);
/*
* shiftY and shiftZ must be computed here since calculating them
* in shiftCoordinates() would cause an infinite loop due to .toRelative
*/
RocketComponent body;
double parentRadius;
for (body = this.getParent(); body != null; body = body.getParent()) {
if (body instanceof SymmetricComponent)
break;
}
if (body == null) {
parentRadius = 0;
} else {
SymmetricComponent s = (SymmetricComponent) body;
double x1, x2;
x1 = this.toRelative(Coordinate.NUL, body)[0].x;
x2 = this.toRelative(new Coordinate(length, 0, 0), body)[0].x;
x1 = MathUtil.clamp(x1, 0, body.getLength());
x2 = MathUtil.clamp(x2, 0, body.getLength());
parentRadius = Math.max(s.getRadius(x1), s.getRadius(x2));
}
shiftY = Math.cos(radialDirection) * (parentRadius + radius);
shiftZ = Math.sin(radialDirection) * (parentRadius + radius);
// System.out.println("Computed shift: y="+shiftY+" z="+shiftZ);
}
@Override
public double getComponentVolume() {
return length * Math.PI * (MathUtil.pow2(radius) - MathUtil.pow2(radius - thickness));
}
@Override
public Collection<Coordinate> getComponentBounds() {
ArrayList<Coordinate> set = new ArrayList<Coordinate>();
addBound(set, 0, radius);
addBound(set, length, radius);
return set;
}
@Override
public Coordinate getComponentCG() {
return new Coordinate(length / 2, 0, 0, getComponentMass());
}
@Override
public String getComponentName() {
// Launch Button
return trans.get("LaunchButton.LaunchButton");
}
@Override
public double getLongitudinalUnitInertia() {
// 1/12 * (3 * (r2^2 + r1^2) + h^2)
// return (3 * (MathUtil.pow2(getOuterRadius()) + MathUtil.pow2(getInnerRadius())) + MathUtil.pow2(getLength())) / 12;
return 0.0;
}
@Override
public double getRotationalUnitInertia() {
// 1/2 * (r1^2 + r2^2)
// return (MathUtil.pow2(getInnerRadius()) + MathUtil.pow2(getOuterRadius())) / 2;
return 0.0;
}
@Override
public boolean allowsChildren() {
return false;
}
@Override
public boolean isCompatible(Class<? extends RocketComponent> type) {
// Allow nothing to be attached to a LaunchButton
return false;
}
@Override
public double getInstanceSeparation(){
return this.instanceSeparation;
}
@Override
public void setInstanceSeparation(final double _separation){
this.instanceSeparation = _separation;
}
@Override
public void setInstanceCount( final int newCount ){
if( 0 < newCount ){
this.instanceCount = newCount;
}
}
@Override
public int getInstanceCount(){
return this.instanceCount;
}
@Override
public String getPatternName(){
return (this.getInstanceCount() + "-Line");
}
}

View File

@ -12,7 +12,7 @@ import net.sf.openrocket.util.MathUtil;
public class LaunchLug extends ExternalComponent implements Coaxial { public class LaunchLug extends ExternalComponent implements Coaxial, LineInstanceable {
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
@ -21,6 +21,9 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
private double radialDirection = 0; private double radialDirection = 0;
private int instanceCount = 1;
private double instanceSeparation = 0; // front-front along the positive rocket axis. i.e. [1,0,0];
/* These are calculated when the component is first attached to any Rocket */ /* These are calculated when the component is first attached to any Rocket */
private double shiftY, shiftZ; private double shiftY, shiftZ;
@ -95,7 +98,10 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
} }
@Override
public boolean isCenterline() {
return false;
}
@Override @Override
@ -232,4 +238,33 @@ public class LaunchLug extends ExternalComponent implements Coaxial {
return false; return false;
} }
@Override
public double getInstanceSeparation(){
return this.instanceSeparation;
}
@Override
public void setInstanceSeparation(final double _separation){
this.instanceSeparation = _separation;
}
@Override
public void setInstanceCount( final int newCount ){
if( 0 < newCount ){
this.instanceCount = newCount;
}
}
@Override
public int getInstanceCount(){
return this.instanceCount;
}
@Override
public String getPatternName(){
return (this.getInstanceCount() + "-Line");
}
} }

View File

@ -0,0 +1,9 @@
package net.sf.openrocket.rocketcomponent;
public interface LineInstanceable extends Instanceable {
public double getInstanceSeparation();
public void setInstanceSeparation(final double radius);
}

View File

@ -3,7 +3,7 @@ package net.sf.openrocket.rocketcomponent;
import net.sf.openrocket.motor.MotorInstance; import net.sf.openrocket.motor.MotorInstance;
/** /**
* FlightConfiguration implementation that prevents changing the default value. * FlightConfigurationSet for motors.
* This is used for motors, where the default value is always no motor. * This is used for motors, where the default value is always no motor.
*/ */
public class MotorConfigurationSet extends FlightConfigurationSet<MotorInstance> { public class MotorConfigurationSet extends FlightConfigurationSet<MotorInstance> {
@ -15,7 +15,7 @@ public class MotorConfigurationSet extends FlightConfigurationSet<MotorInstance>
} }
/** /**
* Construct a copy of an existing FlightConfigurationImpl. * Construct a copy of an existing FlightConfigurationSet.
* *
* @param flightConfiguration another flightConfiguration to copy data from. * @param flightConfiguration another flightConfiguration to copy data from.
* @param component the rocket component on which events are fired when the parameter values are changed * @param component the rocket component on which events are fired when the parameter values are changed

View File

@ -10,23 +10,28 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
/** /**
* is this mount currently configured to carry a motor? * Does this mount contain at least one motor?
* *
* @return whether the component holds a motor * @return whether the component holds a motor
*/ */
public boolean hasMotor(); public boolean hasMotor();
/** /**
* Set whether the component is acting as a motor mount. * Programmatically : implementing classes will always be <code>(x instanceof MotorMount)</code>
* The component may potentially act as a mount, or just a structural component.
* This flag indicates how the component behaves.
*
* @param acting if the component should behave like a motor mount. False if it's structural only.
*/ */
public void setActive(boolean mount); public void setMotorMount(boolean acting);
/** /**
* Is the component currently acting as a motor mount. * Programmatically : implementing classes will always be <code>(x instanceof MotorMount)</code>
* This flag indicates whether the component is acting as a motor mount, or just a structural component
* *
* @return if the motor mount is turned on * @return true if the component is acting as a motor mount
*/ */
public boolean isActive(); public boolean isMotorMount();
/** /**
* Get all motors configured for this mount. * Get all motors configured for this mount.

View File

@ -8,13 +8,16 @@ import net.sf.openrocket.startup.Application;
import net.sf.openrocket.util.BugException; import net.sf.openrocket.util.BugException;
import net.sf.openrocket.util.Coordinate; import net.sf.openrocket.util.Coordinate;
import org.slf4j.Logger; public class PodSet extends ComponentAssembly implements RingInstanceable, OutsideComponent {
import org.slf4j.LoggerFactory;
public class PodSet extends ComponentAssembly implements OutsideComponent {
private static final Translator trans = Application.getTranslator(); private static final Translator trans = Application.getTranslator();
private static final Logger log = LoggerFactory.getLogger(PodSet.class); //private static final Logger log = LoggerFactory.getLogger(PodSet.class);
protected int count = 1;
protected double angularSeparation = Math.PI;
protected double angularPosition_rad = 0;
protected double radialPosition_m = 0;
public PodSet() { public PodSet() {
this.count = 2; this.count = 2;
@ -152,6 +155,22 @@ public class PodSet extends ComponentAssembly implements OutsideComponent {
return returnValue; return returnValue;
} }
@Override
public double getAngularOffset() {
return this.angularPosition_rad;
}
@Override
public String getPatternName(){
return (this.getInstanceCount() + "-ring");
}
@Override
public double getRadialOffset() {
return this.radialPosition_m;
}
@Override @Override
public Coordinate[] shiftCoordinates(Coordinate[] c) { public Coordinate[] shiftCoordinates(Coordinate[] c) {
checkState(); checkState();
@ -191,4 +210,16 @@ public class PodSet extends ComponentAssembly implements OutsideComponent {
return buf; return buf;
} }
@Override
public void setAngularOffset(double angle_rad) {
this.angularPosition_rad = angle_rad;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
@Override
public void setRadialOffset(double radius_m) {
this.radialPosition_m = radius_m;
fireComponentChangeEvent(ComponentChangeEvent.BOTH_CHANGE);
}
} }

View File

@ -16,18 +16,21 @@ import net.sf.openrocket.util.MathUtil;
* *
* @author Sampo Niskanen <sampo.niskanen@iki.fi> * @author Sampo Niskanen <sampo.niskanen@iki.fi>
*/ */
public abstract class RingComponent extends StructuralComponent implements Coaxial { public abstract class RingComponent extends StructuralComponent implements Coaxial, LineInstanceable {
protected boolean outerRadiusAutomatic = false; protected boolean outerRadiusAutomatic = false;
protected boolean innerRadiusAutomatic = false; protected boolean innerRadiusAutomatic = false;
private double radialDirection = 0; protected double radialDirection = 0;
private double radialPosition = 0; protected double radialPosition = 0;
private double shiftY = 0; private double shiftY = 0;
private double shiftZ = 0; private double shiftZ = 0;
protected int instanceCount = 1;
// front-front along the positive rocket axis. i.e. [1,0,0];
protected double instanceSeparation = 0;
@Override @Override
@ -218,4 +221,33 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
return ringRotationalUnitInertia(getOuterRadius(), getInnerRadius()); return ringRotationalUnitInertia(getOuterRadius(), getInnerRadius());
} }
@Override
public double getInstanceSeparation(){
return this.instanceSeparation;
}
@Override
public void setInstanceSeparation(final double _separation){
this.instanceSeparation = _separation;
}
@Override
public void setInstanceCount( final int newCount ){
if( 0 < newCount ){
this.instanceCount = newCount;
}
}
@Override
public int getInstanceCount(){
return this.instanceCount;
}
@Override
public String getPatternName(){
return (this.getInstanceCount() + "-Line");
}
} }

View File

@ -0,0 +1,13 @@
package net.sf.openrocket.rocketcomponent;
public interface RingInstanceable extends Instanceable {
public double getAngularOffset();
public double getRadialOffset();
public void setAngularOffset(final double radius);
public void setRadialOffset(final double radius);
}

View File

@ -582,7 +582,7 @@ public class Rocket extends RocketComponent {
if (c instanceof MotorMount) { if (c instanceof MotorMount) {
MotorMount mount = (MotorMount) c; MotorMount mount = (MotorMount) c;
if (!mount.isActive()) if (!mount.isMotorMount())
continue; continue;
if (mount.getMotorInstance(fcid).getMotor() != null) { if (mount.getMotorInstance(fcid).getMotor() != null) {
return true; return true;

View File

@ -270,6 +270,14 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
//////////// Methods that may be overridden //////////// //////////// Methods that may be overridden ////////////
/**
* This enables one-line testing if a component is on the rocket center-line or not.
*
* @return indicates if this component is centered around the rocket's centerline
*/
public boolean isCenterline() {
return true;
}
/** /**
@ -959,14 +967,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
return this.asPositionValue(this.relativePosition); return this.asPositionValue(this.relativePosition);
} }
/**
*
* @return always returns false for base components. This enables one-line testing if a component is on the rocket center-line or not.
*/
public boolean isCenterline() {
return true;
}
public boolean isAncestor(final RocketComponent testComp) { public boolean isAncestor(final RocketComponent testComp) {
RocketComponent curComp = testComp.parent; RocketComponent curComp = testComp.parent;
while (curComp != null) { while (curComp != null) {

View File

@ -11,7 +11,7 @@ public class ListMotorMounts extends ListComponents<RocketComponent> {
@Override @Override
protected void doAction(RocketComponent visitable) { protected void doAction(RocketComponent visitable) {
if (visitable instanceof MotorMount && ((MotorMount) visitable).isActive()) { if (visitable instanceof MotorMount && ((MotorMount) visitable).isMotorMount()) {
components.add(visitable); components.add(visitable);
} }
} }

View File

@ -99,11 +99,11 @@ public class BodyTubeHandlerTest extends RocksimTestBase {
warnings.clear(); warnings.clear();
handler.closeElement("IsMotorMount", attributes, "1", warnings); handler.closeElement("IsMotorMount", attributes, "1", warnings);
Assert.assertTrue(component.isActive()); Assert.assertTrue(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "0", warnings); handler.closeElement("IsMotorMount", attributes, "0", warnings);
Assert.assertFalse(component.isActive()); Assert.assertFalse(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "foo", warnings); handler.closeElement("IsMotorMount", attributes, "foo", warnings);
Assert.assertFalse(component.isActive()); Assert.assertFalse(component.isMotorMount());
handler.closeElement("EngineOverhang", attributes, "-1", warnings); handler.closeElement("EngineOverhang", attributes, "-1", warnings);
Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);

View File

@ -98,11 +98,11 @@ public class InnerBodyTubeHandlerTest extends RocksimTestBase {
warnings.clear(); warnings.clear();
handler.closeElement("IsMotorMount", attributes, "1", warnings); handler.closeElement("IsMotorMount", attributes, "1", warnings);
Assert.assertTrue(component.isActive()); Assert.assertTrue(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "0", warnings); handler.closeElement("IsMotorMount", attributes, "0", warnings);
Assert.assertFalse(component.isActive()); Assert.assertFalse(component.isMotorMount());
handler.closeElement("IsMotorMount", attributes, "foo", warnings); handler.closeElement("IsMotorMount", attributes, "foo", warnings);
Assert.assertFalse(component.isActive()); Assert.assertFalse(component.isMotorMount());
handler.closeElement("EngineOverhang", attributes, "-1", warnings); handler.closeElement("EngineOverhang", attributes, "-1", warnings);
Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001); Assert.assertEquals(-1d/ RocksimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH, component.getMotorOverhang(), 0.001);

View File

@ -240,7 +240,7 @@ public abstract class FinSetConfig extends RocketComponentConfig {
RocketComponent rocketComponent = iter.next(); RocketComponent rocketComponent = iter.next();
if (rocketComponent instanceof InnerTube) { if (rocketComponent instanceof InnerTube) {
InnerTube it = (InnerTube) rocketComponent; InnerTube it = (InnerTube) rocketComponent;
if (it.isActive()) { if (it.isMotorMount()) {
double depth = ((Coaxial) parent).getOuterRadius() - it.getOuterRadius(); double depth = ((Coaxial) parent).getOuterRadius() - it.getOuterRadius();
//Set fin tab depth //Set fin tab depth
if (depth >= 0.0d) { if (depth >= 0.0d) {

View File

@ -40,7 +40,7 @@ public class MotorConfig extends JPanel {
BooleanModel model; BooleanModel model;
model = new BooleanModel(motorMount, "Active"); model = new BooleanModel(motorMount, "MotorMount");
JCheckBox check = new JCheckBox(model); JCheckBox check = new JCheckBox(model);
////This component is a motor mount ////This component is a motor mount
check.setText(trans.get("MotorCfg.checkbox.compmotormount")); check.setText(trans.get("MotorCfg.checkbox.compmotormount"));
@ -64,7 +64,6 @@ public class MotorConfig extends JPanel {
panel.add(new BasicSlider(dm.getSliderModel(-0.02, 0.06)), "w 100lp, wrap unrel"); panel.add(new BasicSlider(dm.getSliderModel(-0.02, 0.06)), "w 100lp, wrap unrel");
// Select ignition event // Select ignition event
//// Ignition at: //// Ignition at:
panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), ""); panel.add(new JLabel(trans.get("MotorCfg.lbl.Ignitionat") + " " + CommonStrings.dagger), "");
@ -113,11 +112,11 @@ public class MotorConfig extends JPanel {
// Set enabled status // Set enabled status
setDeepEnabled(panel, motorMount.isActive()); setDeepEnabled(panel, motorMount.isMotorMount());
check.addChangeListener(new ChangeListener() { check.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
setDeepEnabled(panel, mount.isActive()); setDeepEnabled(panel, mount.isMotorMount());
} }
}); });

View File

@ -80,7 +80,7 @@ class MotorMountTableModel extends AbstractTableModel implements ComponentChange
public Object getValueAt(int row, int column) { public Object getValueAt(int row, int column) {
switch (column) { switch (column) {
case 0: case 0:
return new Boolean(potentialMounts.get(row).isActive()); return new Boolean(potentialMounts.get(row).isMotorMount());
case 1: case 1:
return potentialMounts.get(row).toString(); return potentialMounts.get(row).toString();

View File

@ -141,7 +141,7 @@ public class MotorConfigurationPanel extends FlightConfigurablePanel<MotorMount>
@Override @Override
protected boolean includeComponent(MotorMount component) { protected boolean includeComponent(MotorMount component) {
return component.isActive(); return component.isMotorMount();
} }
}; };

View File

@ -356,11 +356,11 @@ public class DesignReport {
topBorder = true; topBorder = true;
} }
if (c instanceof MotorMount && ((MotorMount) c).isActive()) { if (c instanceof MotorMount && ((MotorMount) c).isMotorMount()) {
MotorMount mount = (MotorMount) c; MotorMount mount = (MotorMount) c;
// TODO: refactor this... it's redundant with containing if, and could probably be simplified // TODO: refactor this... it's redundant with containing if, and could probably be simplified
if (mount.isActive() && (mount.getMotorInstance(motorId) != null) &&(null != mount.getMotorInstance(motorId).getMotor())) { if (mount.isMotorMount() && (mount.getMotorInstance(motorId) != null) &&(null != mount.getMotorInstance(motorId).getMotor())) {
Motor motor = mount.getMotorInstance(motorId).getMotor(); Motor motor = mount.getMotorInstance(motorId).getMotor();
int motorCount = mount.getMotorCount(); int motorCount = mount.getMotorCount();