Merge pull request #253 from teyrana/parallel_staging

Restored Automatic Ignition Event, plus a few other small fixes.
This commit is contained in:
kruland2607 2015-12-14 20:55:40 -06:00
commit 426ee80688
8 changed files with 42 additions and 32 deletions

View File

@ -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)) {

View File

@ -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();

View File

@ -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;

View File

@ -23,11 +23,17 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
}
public FlightConfigurationID(final String _str) {
UUID candidate;
if("".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) {

View File

@ -8,24 +8,19 @@ 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 (launch or ejection charge)
AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){
@Override
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
AxialStage stage = (AxialStage)source;
if ( stage.isLaunchStage() ){
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){

View File

@ -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 ){

View File

@ -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()) {

View File

@ -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);