Fix number of motors and stageMass for DesignReport
Fix the number of motors that are reported. A previous change made the MotorMount.getMotorCount() return the number of motors which have been configured. However, according to the javadocs of the MotorMount interface, the getMotorCount() method is supposed to return the number of motors that a MotorMount can take for configuring it. This restores the InnerTube and BodyTube getMotorCount behavior and adds a new getMotorConfigurationCount() method to provide the new behavior. Additionally, the stageMass calculations in the DesignReport were using a deprecated method which does not return proper component weights. Change this to use the MassCalculator.calculateLaunch(...) method, which is consistent with the RocketPanel behavior. Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
parent
d5598d7380
commit
94534ee8f8
@ -371,6 +371,11 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
||||
return this.motors.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotorConfigurationSet getMotorConfigurationSet() {
|
||||
return this.motors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotorConfiguration getMotorConfig( final FlightConfigurationId fcid){
|
||||
return this.motors.get(fcid);
|
||||
@ -432,7 +437,7 @@ public class BodyTube extends SymmetricComponent implements MotorMount, Coaxial
|
||||
|
||||
@Override
|
||||
public int getMotorCount() {
|
||||
return this.motors.size();
|
||||
return this.getClusterConfiguration().getClusterCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,6 +257,11 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab
|
||||
public MotorConfiguration getDefaultMotorConfig(){
|
||||
return this.motors.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotorConfigurationSet getMotorConfigurationSet() {
|
||||
return this.motors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MotorConfiguration getMotorConfig( final FlightConfigurationId fcid){
|
||||
@ -321,7 +326,7 @@ public class InnerTube extends ThicknessRingComponent implements AxialPositionab
|
||||
|
||||
@Override
|
||||
public int getMotorCount() {
|
||||
return this.motors.size();
|
||||
return this.getClusterConfiguration().getClusterCount();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@ package net.sf.openrocket.rocketcomponent;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.motor.MotorConfigurationSet;
|
||||
import net.sf.openrocket.util.ChangeSource;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
|
||||
@ -80,6 +81,13 @@ public interface MotorMount extends ChangeSource, FlightConfigurableComponent {
|
||||
// duplicate of RocketComponent
|
||||
public Coordinate[] getLocations();
|
||||
|
||||
/**
|
||||
* Returns the set of motors configured for flight/simulation in this motor mount.
|
||||
* @return the MotorConfigurationSet containing the set of motors configured in
|
||||
* this motor mount.
|
||||
*/
|
||||
public MotorConfigurationSet getMotorConfigurationSet();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fcid id for which to return the motor (null retrieves the default)
|
||||
|
@ -201,7 +201,7 @@ public class FlightConfigurationTest extends BaseTestCase {
|
||||
InnerTube smmt = (InnerTube)rkt.getChild(0).getChild(1).getChild(2);
|
||||
|
||||
int expectedMotorCount = 5;
|
||||
int actualMotorCount = smmt.getMotorCount();
|
||||
int actualMotorCount = smmt.getMotorConfigurationSet().size();
|
||||
assertThat("number of motor configurations doesn't match.", actualMotorCount, equalTo(expectedMotorCount));
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import net.sf.openrocket.gui.figureelements.FigureElement;
|
||||
import net.sf.openrocket.gui.figureelements.RocketInfo;
|
||||
import net.sf.openrocket.gui.scalefigure.RocketPanel;
|
||||
import net.sf.openrocket.masscalc.MassCalculator;
|
||||
import net.sf.openrocket.masscalc.RigidBody;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.MotorConfiguration;
|
||||
import net.sf.openrocket.rocketcomponent.AxialStage;
|
||||
@ -329,13 +330,11 @@ public class DesignReport {
|
||||
|
||||
DecimalFormat ttwFormat = new DecimalFormat("0.00");
|
||||
|
||||
MassCalculator massCalc = new MassCalculator();
|
||||
|
||||
if( motorId.hasError() ){
|
||||
throw new IllegalStateException("Attempted to add motor data with an invalid fcid");
|
||||
}
|
||||
rocket.createFlightConfiguration(motorId);
|
||||
FlightConfiguration config = rocket.getFlightConfiguration( motorId);
|
||||
FlightConfiguration config = rocket.getFlightConfiguration(motorId);
|
||||
|
||||
int totalMotorCount = 0;
|
||||
double totalPropMass = 0;
|
||||
@ -352,7 +351,8 @@ public class DesignReport {
|
||||
config.clearAllStages();
|
||||
config.setOnlyStage(stage);
|
||||
stage++;
|
||||
stageMass = massCalc.getCGAnalysis(config).get(c).weight;
|
||||
RigidBody launchInfo = MassCalculator.calculateLaunch(config);
|
||||
stageMass = launchInfo.getMass();
|
||||
// Calculate total thrust-to-weight from only lowest stage motors
|
||||
totalTTW = 0;
|
||||
topBorder = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user