From e7fbec3d8912bd0c17f7ee585c490e2d9db40ee4 Mon Sep 17 00:00:00 2001 From: Daniel_M_Williams Date: Mon, 14 Dec 2015 19:44:43 -0500 Subject: [PATCH 1/2] [Bugfix] Restored AUTOMATIC Ignition Event, et al. Restored Automatic ignition Option - "bottom" core stage is the lowest centerline ('AFTER') - Parallel Stages are always considered as 'launch' stages... and thus ignite on launch. Motors now copy Ignition parameters when loaded into a rocket. Added additional error checking in FlightConfigurationID - class is now tolerant of random string initializations --- .../importt/IgnitionConfigurationHandler.java | 5 --- .../openrocket/importt/MotorMountHandler.java | 6 ++++ .../rocketcomponent/AxialStage.java | 4 +++ .../FlightConfigurationID.java | 10 ++++-- .../rocketcomponent/IgnitionEvent.java | 31 ++++++++----------- .../rocketcomponent/ParallelStage.java | 5 +++ .../sf/openrocket/rocketcomponent/Rocket.java | 3 +- 7 files changed, 38 insertions(+), 26 deletions(-) diff --git a/core/src/net/sf/openrocket/file/openrocket/importt/IgnitionConfigurationHandler.java b/core/src/net/sf/openrocket/file/openrocket/importt/IgnitionConfigurationHandler.java index ebf413267..e05248d7d 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/IgnitionConfigurationHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/IgnitionConfigurationHandler.java @@ -23,7 +23,6 @@ class IgnitionConfigurationHandler extends AbstractElementHandler { } - @Override public ElementHandler openElement(String element, HashMap 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)) { 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..eb24e256a 100644 --- a/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java +++ b/core/src/net/sf/openrocket/file/openrocket/importt/MotorMountHandler.java @@ -77,6 +77,12 @@ class MotorMountHandler extends AbstractElementHandler { RocketComponent mountComponent = (RocketComponent)mount; motorInstance.setID( new MotorInstanceId(mountComponent.getID(), 1)); motorInstance.setEjectionDelay(motorHandler.getDelay(warnings)); + + // pull event data from defaults + MotorInstance defInstance = mount.getDefaultMotorInstance(); + motorInstance.setIgnitionEvent( defInstance.getIgnitionEvent()); + motorInstance.setIgnitionDelay( defInstance.getIgnitionDelay()); + mount.setMotorInstance(fcid, motorInstance); Rocket rkt = ((RocketComponent)mount).getRocket(); diff --git a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java index 0b1a34cd5..4c677eb70 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java +++ b/core/src/net/sf/openrocket/rocketcomponent/AxialStage.java @@ -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; diff --git a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java index 71d59b231..eeee7d033 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java +++ b/core/src/net/sf/openrocket/rocketcomponent/FlightConfigurationID.java @@ -23,11 +23,17 @@ public final class FlightConfigurationID implements Comparable Date: Mon, 14 Dec 2015 20:13:51 -0500 Subject: [PATCH 2/2] fixed FinSetTest --- core/src/net/sf/openrocket/rocketcomponent/Rocket.java | 5 +---- core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java | 5 +++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java index 407d4032a..fb31d9e17 100644 --- a/core/src/net/sf/openrocket/rocketcomponent/Rocket.java +++ b/core/src/net/sf/openrocket/rocketcomponent/Rocket.java @@ -432,10 +432,7 @@ public class Rocket extends RocketComponent { freezeList.add(cce); return; } - - if( -1 == cce.getType()){ - log.debug(">>fireComponentChangeEvent()>> . . ."); - } + // Notify all components first Iterator iterator = this.iterator(true); while (iterator.hasNext()) { diff --git a/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java b/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java index b568dc32e..7c083bbd3 100644 --- a/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java +++ b/core/test/net/sf/openrocket/rocketcomponent/FinSetTest.java @@ -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);