Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
f429255801
@ -282,127 +282,13 @@ public class OpenRocketSaver extends RocketSaver {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/////////////////
|
||||
// Version 1.6 //
|
||||
/////////////////
|
||||
|
||||
// OpenRocket only writes back to 1.6 now.
|
||||
return FILE_VERSION_DIVISOR + 6;
|
||||
|
||||
// Search the rocket for any Appearances or non-motor flight configurations (version 1.6)
|
||||
for (RocketComponent c : document.getRocket()) {
|
||||
if (c.getAppearance() != null) {
|
||||
return FILE_VERSION_DIVISOR + 6;
|
||||
}
|
||||
if (c instanceof FlightConfigurableComponent) {
|
||||
if (c instanceof MotorMount) {
|
||||
MotorMount mmt = (MotorMount) c;
|
||||
if (mmt.getMotorCount() > 0) {
|
||||
return FILE_VERSION_DIVISOR + 6;
|
||||
}
|
||||
}
|
||||
if (c instanceof RecoveryDevice) {
|
||||
RecoveryDevice recovery = (RecoveryDevice) c;
|
||||
if (recovery.getDeploymentConfigurations().size() > 0) {
|
||||
return FILE_VERSION_DIVISOR + 6;
|
||||
}
|
||||
}
|
||||
if (c instanceof AxialStage) {
|
||||
AxialStage stage = (AxialStage) c;
|
||||
if (stage.getSeparationConfigurations().size() > 0) {
|
||||
return FILE_VERSION_DIVISOR + 6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// Version 1.5 //
|
||||
/////////////////
|
||||
|
||||
// Search the rocket for any ComponentPresets (version 1.5)
|
||||
for (RocketComponent c : document.getRocket()) {
|
||||
if (c.getPresetComponent() != null) {
|
||||
return FILE_VERSION_DIVISOR + 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Search for recovery device deployment type LOWER_STAGE_SEPARATION (version 1.5)
|
||||
for (RocketComponent c : document.getRocket()) {
|
||||
if (c instanceof RecoveryDevice) {
|
||||
if (((RecoveryDevice) c).getDeploymentConfigurations().getDefault().getDeployEvent() == DeployEvent.LOWER_STAGE_SEPARATION) {
|
||||
return FILE_VERSION_DIVISOR + 5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for custom expressions (version 1.5)
|
||||
if (!document.getCustomExpressions().isEmpty()) {
|
||||
return FILE_VERSION_DIVISOR + 5;
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// Version 1.4 //
|
||||
/////////////////
|
||||
|
||||
// Check if design has simulations defined (version 1.4)
|
||||
if (document.getSimulationCount() > 0) {
|
||||
return FILE_VERSION_DIVISOR + 4;
|
||||
}
|
||||
|
||||
// Check for motor definitions (version 1.4)
|
||||
for (RocketComponent c : document.getRocket()) {
|
||||
if (!(c instanceof MotorMount))
|
||||
continue;
|
||||
|
||||
MotorMount mount = (MotorMount) c;
|
||||
for( FlightConfiguration config : document.getRocket().getConfigSet()) {
|
||||
FlightConfigurationID fcid = config.getFlightConfigurationID();
|
||||
if (mount.getMotorInstance(fcid) != null) {
|
||||
return FILE_VERSION_DIVISOR + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// Version 1.3 //
|
||||
/////////////////
|
||||
|
||||
// no version 1.3 file type exists
|
||||
|
||||
/////////////////
|
||||
// Version 1.2 //
|
||||
/////////////////
|
||||
|
||||
// no version 1.2 file type exists
|
||||
|
||||
/////////////////
|
||||
// Version 1.1 //
|
||||
/////////////////
|
||||
|
||||
// Check for fin tabs or tube coupler children (version 1.1)
|
||||
for (RocketComponent c : document.getRocket()) {
|
||||
// Check for fin tabs
|
||||
if (c instanceof FinSet) {
|
||||
FinSet fin = (FinSet) c;
|
||||
if (!MathUtil.equals(fin.getTabHeight(), 0) &&
|
||||
!MathUtil.equals(fin.getTabLength(), 0)) {
|
||||
return FILE_VERSION_DIVISOR + 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for components attached to tube coupler
|
||||
if (c instanceof TubeCoupler) {
|
||||
if (c.getChildCount() > 0) {
|
||||
return FILE_VERSION_DIVISOR + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////
|
||||
// Version 1.0 //
|
||||
/////////////////
|
||||
|
||||
// Default (version 1.0)
|
||||
return FILE_VERSION_DIVISOR + 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,7 +23,6 @@ class IgnitionConfigurationHandler extends AbstractElementHandler {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ElementHandler openElement(String element, HashMap<String, String> attributes,
|
||||
WarningSet warnings) {
|
||||
@ -37,10 +36,6 @@ class IgnitionConfigurationHandler extends AbstractElementHandler {
|
||||
content = content.trim();
|
||||
|
||||
if (element.equals("ignitionevent")) {
|
||||
if ( content.equals( "automatic")){
|
||||
content = "launch";
|
||||
warnings.add( Warning.fromString("'automatic' separation is deprecated and has been converted to the 'launch' setting."));
|
||||
}
|
||||
|
||||
for (IgnitionEvent ie : IgnitionEvent.values()) {
|
||||
if (ie.equals(content)) {
|
||||
|
@ -79,6 +79,7 @@ class MotorMountHandler extends AbstractElementHandler {
|
||||
motorInstance.setMount(mount);
|
||||
motorInstance.setID( new MotorInstanceId(mountComponent.getID(), 1));
|
||||
motorInstance.setEjectionDelay(motorHandler.getDelay(warnings));
|
||||
|
||||
mount.setMotorInstance(fcid, motorInstance);
|
||||
|
||||
Rocket rkt = ((RocketComponent)mount).getRocket();
|
||||
|
@ -117,6 +117,10 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
|
||||
public boolean isAfter(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isLaunchStage(){
|
||||
return ( getRocket().getBottomCoreStage().equals(this));
|
||||
}
|
||||
|
||||
public void setStageNumber(final int newStageNumber) {
|
||||
this.stageNumber = newStageNumber;
|
||||
|
@ -23,11 +23,17 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
||||
}
|
||||
|
||||
public FlightConfigurationID(final String _str) {
|
||||
UUID candidate;
|
||||
if(_str == null || "".equals(_str)){
|
||||
this.key = UUID.randomUUID();
|
||||
candidate = UUID.randomUUID();
|
||||
}else{
|
||||
this.key = UUID.fromString( _str);
|
||||
try{
|
||||
candidate = UUID.fromString( _str);
|
||||
}catch( IllegalArgumentException iae ){
|
||||
candidate = new UUID( 0, _str.hashCode() );
|
||||
}
|
||||
}
|
||||
this.key = candidate;
|
||||
}
|
||||
|
||||
public FlightConfigurationID(final UUID _val) {
|
||||
@ -55,7 +61,7 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
||||
return ERROR_KEY_NAME;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getFullKeyText(){
|
||||
return this.key.toString();
|
||||
}
|
||||
@ -80,7 +86,7 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
||||
public String toString() {
|
||||
return this.key.toString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(FlightConfigurationID other) {
|
||||
return (this.key.compareTo( other.key));
|
||||
|
@ -8,7 +8,7 @@ import net.sf.openrocket.startup.Application;
|
||||
|
||||
public enum IgnitionEvent {
|
||||
|
||||
// //// Automatic (launch or ejection charge)
|
||||
//// Automatic (launch or ejection charge)
|
||||
AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){
|
||||
@Override
|
||||
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
|
||||
|
@ -105,6 +105,11 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
||||
public boolean isAfter(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLaunchStage(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstanceCount( final int newCount ){
|
||||
|
@ -204,7 +204,8 @@ public class Rocket extends RocketComponent {
|
||||
* @Return a reference to the topmost stage
|
||||
*/
|
||||
public AxialStage getBottomCoreStage(){
|
||||
return (AxialStage) getChild(0);
|
||||
// get last stage that's a direct child of the rocket.
|
||||
return (AxialStage) children.get( children.size()-1 );
|
||||
}
|
||||
|
||||
private int getNewStageNumber() {
|
||||
@ -431,10 +432,7 @@ public class Rocket extends RocketComponent {
|
||||
freezeList.add(cce);
|
||||
return;
|
||||
}
|
||||
|
||||
if( -1 == cce.getType()){
|
||||
log.debug(">>fireComponentChangeEvent()>> . . .");
|
||||
}
|
||||
|
||||
// Notify all components first
|
||||
Iterator<RocketComponent> iterator = this.iterator(true);
|
||||
while (iterator.hasNext()) {
|
||||
|
@ -25,12 +25,14 @@ import net.sf.openrocket.file.RocketLoadException;
|
||||
import net.sf.openrocket.file.motor.GeneralMotorLoader;
|
||||
import net.sf.openrocket.l10n.DebugTranslator;
|
||||
import net.sf.openrocket.l10n.Translator;
|
||||
import net.sf.openrocket.motor.Manufacturer;
|
||||
import net.sf.openrocket.motor.Motor;
|
||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||
import net.sf.openrocket.plugin.PluginModule;
|
||||
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
||||
import net.sf.openrocket.simulation.extension.impl.ScriptingUtil;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.TestRockets;
|
||||
|
||||
import org.junit.After;
|
||||
@ -190,82 +192,6 @@ public class OpenRocketSaverTest {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.0 //
|
||||
////////////////////////////////
|
||||
|
||||
@Test
|
||||
public void testFileVersion100() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v100();
|
||||
assertEquals(100, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.1 //
|
||||
////////////////////////////////
|
||||
|
||||
@Test
|
||||
public void testFileVersion101_withFinTabs() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v101_withFinTabs();
|
||||
assertEquals(101, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileVersion101_withTubeCouplerChild() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v101_withTubeCouplerChild();
|
||||
assertEquals(101, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.2 //
|
||||
////////////////////////////////
|
||||
|
||||
// no version 1.2 file type exists
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.3 //
|
||||
////////////////////////////////
|
||||
|
||||
// no version 1.3 file type exists
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.4 //
|
||||
////////////////////////////////
|
||||
|
||||
@Test
|
||||
public void testFileVersion104_withSimulationData() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v104_withSimulationData();
|
||||
assertEquals(104, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileVersion104_withMotor() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v104_withMotor();
|
||||
assertEquals(104, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.5 //
|
||||
////////////////////////////////
|
||||
|
||||
@Test
|
||||
public void testFileVersion105_withComponentPresets() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v105_withComponentPreset();
|
||||
assertEquals(105, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileVersion105_withCustomExpressions() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v105_withCustomExpression();
|
||||
assertEquals(105, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFileVersion105_withLowerStageRecoveryDevice() {
|
||||
OpenRocketDocument rocketDoc = TestRockets.makeTestRocket_v105_withLowerStageRecoveryDevice();
|
||||
assertEquals(105, getCalculatedFileVersion(rocketDoc));
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
// Tests for File Version 1.6 //
|
||||
////////////////////////////////
|
||||
@ -384,8 +310,13 @@ public class OpenRocketSaverTest {
|
||||
|
||||
public MotorDbProvider() {
|
||||
db.addMotor(readMotor());
|
||||
|
||||
assertEquals(1, db.getMotorSets().size());
|
||||
db.addMotor( new ThrustCurveMotor(
|
||||
Manufacturer.getManufacturer("A"),
|
||||
"F12X", "Desc", Motor.Type.UNKNOWN, new double[] {},
|
||||
0.024, 0.07, new double[] { 0, 1, 2 }, new double[] { 0, 1, 0 },
|
||||
new Coordinate[] { Coordinate.NUL, Coordinate.NUL, Coordinate.NUL }, "digestA"));
|
||||
|
||||
assertEquals(2, db.getMotorSets().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -257,12 +257,13 @@ public class FinSetTest extends BaseTestCase {
|
||||
rocket.addChild(stage);
|
||||
stage.addChild(body);
|
||||
body.addChild(fin);
|
||||
rocket.enableEvents();
|
||||
|
||||
Listener l1 = new Listener("l1");
|
||||
rocket.addComponentChangeListener(l1);
|
||||
|
||||
fin.setName("Custom name");
|
||||
assertTrue(l1.changed);
|
||||
assertEquals("FinSet listener has not been notified: ", l1.changed, true);
|
||||
assertEquals(ComponentChangeEvent.NONFUNCTIONAL_CHANGE, l1.changetype);
|
||||
|
||||
|
||||
@ -275,7 +276,7 @@ public class FinSetTest extends BaseTestCase {
|
||||
FinSet fincopy = (FinSet) rocketcopy.getChild(0).getChild(0).getChild(0);
|
||||
FreeformFinSet.convertFinSet(fincopy);
|
||||
|
||||
assertTrue(l2.changed);
|
||||
assertTrue("FinSet listener is changed", l2.changed);
|
||||
assertEquals(ComponentChangeEvent.TREE_CHANGE,
|
||||
l2.changetype & ComponentChangeEvent.TREE_CHANGE);
|
||||
|
||||
|
@ -3,32 +3,28 @@ package net.sf.openrocket.rocketcomponent;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.fail;
|
||||
import net.sf.openrocket.material.Material;
|
||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
||||
import net.sf.openrocket.startup.Application;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import net.sf.openrocket.util.Coordinate;
|
||||
import net.sf.openrocket.util.MathUtil;
|
||||
import net.sf.openrocket.util.TestRockets;
|
||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class RocketTest extends BaseTestCase {
|
||||
|
||||
@Test
|
||||
public void testCopyFrom() {
|
||||
// Rocket r1 = net.sf.openrocket.util.TestRockets.makeIsoHaisu();
|
||||
// Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue();
|
||||
//
|
||||
// Rocket copy = (Rocket) r2.copy();
|
||||
//
|
||||
// ComponentCompare.assertDeepEquality(r2, copy);
|
||||
//
|
||||
// r1.copyFrom(copy);
|
||||
//
|
||||
// ComponentCompare.assertDeepEquality(r1, r2);
|
||||
fail("NYI");
|
||||
Rocket r1 = net.sf.openrocket.util.TestRockets.makeIsoHaisu();
|
||||
Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue();
|
||||
|
||||
Rocket copy = (Rocket) r2.copy();
|
||||
|
||||
ComponentCompare.assertDeepEquality(r2, copy);
|
||||
|
||||
r1.copyFrom(copy);
|
||||
|
||||
ComponentCompare.assertDeepEquality(r1, r2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user