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 //
|
// Version 1.6 //
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
||||||
// Search the rocket for any Appearances or non-motor flight configurations (version 1.6)
|
// OpenRocket only writes back to 1.6 now.
|
||||||
for (RocketComponent c : document.getRocket()) {
|
return FILE_VERSION_DIVISOR + 6;
|
||||||
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
|
@Override
|
||||||
public ElementHandler openElement(String element, HashMap<String, String> attributes,
|
public ElementHandler openElement(String element, HashMap<String, String> attributes,
|
||||||
WarningSet warnings) {
|
WarningSet warnings) {
|
||||||
@ -37,10 +36,6 @@ class IgnitionConfigurationHandler extends AbstractElementHandler {
|
|||||||
content = content.trim();
|
content = content.trim();
|
||||||
|
|
||||||
if (element.equals("ignitionevent")) {
|
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()) {
|
for (IgnitionEvent ie : IgnitionEvent.values()) {
|
||||||
if (ie.equals(content)) {
|
if (ie.equals(content)) {
|
||||||
|
@ -79,6 +79,7 @@ class MotorMountHandler extends AbstractElementHandler {
|
|||||||
motorInstance.setMount(mount);
|
motorInstance.setMount(mount);
|
||||||
motorInstance.setID( new MotorInstanceId(mountComponent.getID(), 1));
|
motorInstance.setID( new MotorInstanceId(mountComponent.getID(), 1));
|
||||||
motorInstance.setEjectionDelay(motorHandler.getDelay(warnings));
|
motorInstance.setEjectionDelay(motorHandler.getDelay(warnings));
|
||||||
|
|
||||||
mount.setMotorInstance(fcid, motorInstance);
|
mount.setMotorInstance(fcid, motorInstance);
|
||||||
|
|
||||||
Rocket rkt = ((RocketComponent)mount).getRocket();
|
Rocket rkt = ((RocketComponent)mount).getRocket();
|
||||||
|
@ -118,6 +118,10 @@ public class AxialStage extends ComponentAssembly implements FlightConfigurableC
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isLaunchStage(){
|
||||||
|
return ( getRocket().getBottomCoreStage().equals(this));
|
||||||
|
}
|
||||||
|
|
||||||
public void setStageNumber(final int newStageNumber) {
|
public void setStageNumber(final int newStageNumber) {
|
||||||
this.stageNumber = newStageNumber;
|
this.stageNumber = newStageNumber;
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,17 @@ public final class FlightConfigurationID implements Comparable<FlightConfigurati
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FlightConfigurationID(final String _str) {
|
public FlightConfigurationID(final String _str) {
|
||||||
|
UUID candidate;
|
||||||
if(_str == null || "".equals(_str)){
|
if(_str == null || "".equals(_str)){
|
||||||
this.key = UUID.randomUUID();
|
candidate = UUID.randomUUID();
|
||||||
}else{
|
}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) {
|
public FlightConfigurationID(final UUID _val) {
|
||||||
|
@ -8,7 +8,7 @@ import net.sf.openrocket.startup.Application;
|
|||||||
|
|
||||||
public enum IgnitionEvent {
|
public enum IgnitionEvent {
|
||||||
|
|
||||||
// //// Automatic (launch or ejection charge)
|
//// Automatic (launch or ejection charge)
|
||||||
AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){
|
AUTOMATIC( "AUTOMATIC", "MotorMount.IgnitionEvent.AUTOMATIC"){
|
||||||
@Override
|
@Override
|
||||||
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
|
public boolean isActivationEvent(FlightEvent e, RocketComponent source) {
|
||||||
|
@ -106,6 +106,11 @@ public class ParallelStage extends AxialStage implements FlightConfigurableCompo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLaunchStage(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInstanceCount( final int newCount ){
|
public void setInstanceCount( final int newCount ){
|
||||||
mutex.verify();
|
mutex.verify();
|
||||||
|
@ -204,7 +204,8 @@ public class Rocket extends RocketComponent {
|
|||||||
* @Return a reference to the topmost stage
|
* @Return a reference to the topmost stage
|
||||||
*/
|
*/
|
||||||
public AxialStage getBottomCoreStage(){
|
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() {
|
private int getNewStageNumber() {
|
||||||
@ -432,9 +433,6 @@ public class Rocket extends RocketComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( -1 == cce.getType()){
|
|
||||||
log.debug(">>fireComponentChangeEvent()>> . . .");
|
|
||||||
}
|
|
||||||
// Notify all components first
|
// Notify all components first
|
||||||
Iterator<RocketComponent> iterator = this.iterator(true);
|
Iterator<RocketComponent> iterator = this.iterator(true);
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
@ -25,12 +25,14 @@ import net.sf.openrocket.file.RocketLoadException;
|
|||||||
import net.sf.openrocket.file.motor.GeneralMotorLoader;
|
import net.sf.openrocket.file.motor.GeneralMotorLoader;
|
||||||
import net.sf.openrocket.l10n.DebugTranslator;
|
import net.sf.openrocket.l10n.DebugTranslator;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
|
import net.sf.openrocket.motor.Manufacturer;
|
||||||
import net.sf.openrocket.motor.Motor;
|
import net.sf.openrocket.motor.Motor;
|
||||||
import net.sf.openrocket.motor.ThrustCurveMotor;
|
import net.sf.openrocket.motor.ThrustCurveMotor;
|
||||||
import net.sf.openrocket.plugin.PluginModule;
|
import net.sf.openrocket.plugin.PluginModule;
|
||||||
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
import net.sf.openrocket.simulation.extension.impl.ScriptingExtension;
|
||||||
import net.sf.openrocket.simulation.extension.impl.ScriptingUtil;
|
import net.sf.openrocket.simulation.extension.impl.ScriptingUtil;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.TestRockets;
|
import net.sf.openrocket.util.TestRockets;
|
||||||
|
|
||||||
import org.junit.After;
|
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 //
|
// Tests for File Version 1.6 //
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@ -384,8 +310,13 @@ public class OpenRocketSaverTest {
|
|||||||
|
|
||||||
public MotorDbProvider() {
|
public MotorDbProvider() {
|
||||||
db.addMotor(readMotor());
|
db.addMotor(readMotor());
|
||||||
|
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(1, db.getMotorSets().size());
|
assertEquals(2, db.getMotorSets().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -257,12 +257,13 @@ public class FinSetTest extends BaseTestCase {
|
|||||||
rocket.addChild(stage);
|
rocket.addChild(stage);
|
||||||
stage.addChild(body);
|
stage.addChild(body);
|
||||||
body.addChild(fin);
|
body.addChild(fin);
|
||||||
|
rocket.enableEvents();
|
||||||
|
|
||||||
Listener l1 = new Listener("l1");
|
Listener l1 = new Listener("l1");
|
||||||
rocket.addComponentChangeListener(l1);
|
rocket.addComponentChangeListener(l1);
|
||||||
|
|
||||||
fin.setName("Custom name");
|
fin.setName("Custom name");
|
||||||
assertTrue(l1.changed);
|
assertEquals("FinSet listener has not been notified: ", l1.changed, true);
|
||||||
assertEquals(ComponentChangeEvent.NONFUNCTIONAL_CHANGE, l1.changetype);
|
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);
|
FinSet fincopy = (FinSet) rocketcopy.getChild(0).getChild(0).getChild(0);
|
||||||
FreeformFinSet.convertFinSet(fincopy);
|
FreeformFinSet.convertFinSet(fincopy);
|
||||||
|
|
||||||
assertTrue(l2.changed);
|
assertTrue("FinSet listener is changed", l2.changed);
|
||||||
assertEquals(ComponentChangeEvent.TREE_CHANGE,
|
assertEquals(ComponentChangeEvent.TREE_CHANGE,
|
||||||
l2.changetype & 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.hamcrest.CoreMatchers.equalTo;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
import net.sf.openrocket.material.Material;
|
import org.junit.Test;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent.Position;
|
|
||||||
import net.sf.openrocket.startup.Application;
|
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.MathUtil;
|
import net.sf.openrocket.util.MathUtil;
|
||||||
import net.sf.openrocket.util.TestRockets;
|
import net.sf.openrocket.util.TestRockets;
|
||||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class RocketTest extends BaseTestCase {
|
public class RocketTest extends BaseTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCopyFrom() {
|
public void testCopyFrom() {
|
||||||
// Rocket r1 = net.sf.openrocket.util.TestRockets.makeIsoHaisu();
|
Rocket r1 = net.sf.openrocket.util.TestRockets.makeIsoHaisu();
|
||||||
// Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue();
|
Rocket r2 = net.sf.openrocket.util.TestRockets.makeBigBlue();
|
||||||
//
|
|
||||||
// Rocket copy = (Rocket) r2.copy();
|
Rocket copy = (Rocket) r2.copy();
|
||||||
//
|
|
||||||
// ComponentCompare.assertDeepEquality(r2, copy);
|
ComponentCompare.assertDeepEquality(r2, copy);
|
||||||
//
|
|
||||||
// r1.copyFrom(copy);
|
r1.copyFrom(copy);
|
||||||
//
|
|
||||||
// ComponentCompare.assertDeepEquality(r1, r2);
|
ComponentCompare.assertDeepEquality(r1, r2);
|
||||||
fail("NYI");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user