Replace designation with common name in ThrustCurveMotorColumns
Get rid of simplified designation in ThrustCurveMotorSet, using common name instead
This commit is contained in:
parent
08f76683e9
commit
88f5d19185
@ -1588,7 +1588,7 @@ FlightEvent.Type.EXCEPTION = Exception
|
|||||||
|
|
||||||
! ThrustCurveMotorColumns
|
! ThrustCurveMotorColumns
|
||||||
TCurveMotorCol.MANUFACTURER = Manufacturer
|
TCurveMotorCol.MANUFACTURER = Manufacturer
|
||||||
TCurveMotorCol.DESIGNATION = Designation
|
TCurveMotorCol.COMMON_NAME = Name
|
||||||
TCurveMotorCol.CASEINFO = Case
|
TCurveMotorCol.CASEINFO = Case
|
||||||
TCurveMotorCol.DIAMETER = Diameter
|
TCurveMotorCol.DIAMETER = Diameter
|
||||||
TCurveMotorCol.LENGTH = Length
|
TCurveMotorCol.LENGTH = Length
|
||||||
|
@ -38,8 +38,8 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
private final List<Double> delays = new ArrayList<Double>();
|
private final List<Double> delays = new ArrayList<Double>();
|
||||||
|
|
||||||
private Manufacturer manufacturer = null;
|
private Manufacturer manufacturer = null;
|
||||||
|
private String commonName = null;
|
||||||
private String designation = null;
|
private String designation = null;
|
||||||
private String simplifiedDesignation = null;
|
|
||||||
private double diameter = -1;
|
private double diameter = -1;
|
||||||
private double length = -1;
|
private double length = -1;
|
||||||
private long totalImpulse = 0;
|
private long totalImpulse = 0;
|
||||||
@ -57,7 +57,6 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
checkFirstInsertion(motor);
|
checkFirstInsertion(motor);
|
||||||
verifyMotor(motor);
|
verifyMotor(motor);
|
||||||
updateType(motor);
|
updateType(motor);
|
||||||
checkChangeSimplifiedDesignation(motor);
|
|
||||||
addStandardDelays(motor);
|
addStandardDelays(motor);
|
||||||
if(!checkMotorOverwrite(motor)){
|
if(!checkMotorOverwrite(motor)){
|
||||||
motors.add(motor);
|
motors.add(motor);
|
||||||
@ -144,23 +143,6 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
Collections.sort(delays);
|
Collections.sort(delays);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* checks if simplified designation should be changed with the given motor
|
|
||||||
* @param motor the motor to be checked with
|
|
||||||
*/
|
|
||||||
private void checkChangeSimplifiedDesignation(ThrustCurveMotor motor) {
|
|
||||||
// Change the simplified designation if necessary
|
|
||||||
if (!designation.equalsIgnoreCase(motor.getDesignation().trim())) {
|
|
||||||
designation = simplifiedDesignation;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (caseInfo == null) {
|
|
||||||
caseInfo = motor.getCaseInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if the cached type should be changed with the given motor
|
* checks if the cached type should be changed with the given motor
|
||||||
* if it's hybrid, delays will be added
|
* if it's hybrid, delays will be added
|
||||||
@ -206,7 +188,7 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
if (motors.isEmpty()) {
|
if (motors.isEmpty()) {
|
||||||
manufacturer = motor.getManufacturer();
|
manufacturer = motor.getManufacturer();
|
||||||
designation = motor.getDesignation();
|
designation = motor.getDesignation();
|
||||||
simplifiedDesignation = simplifyDesignation(designation);
|
commonName = motor.getCommonName();
|
||||||
diameter = motor.getDiameter();
|
diameter = motor.getDiameter();
|
||||||
length = motor.getLength();
|
length = motor.getLength();
|
||||||
totalImpulse = Math.round((motor.getTotalImpulseEstimate()));
|
totalImpulse = Math.round((motor.getTotalImpulseEstimate()));
|
||||||
@ -239,14 +221,14 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!simplifiedDesignation.equalsIgnoreCase(simplifyDesignation(m.getDesignation())))
|
if (!designation.equalsIgnoreCase(m.getDesignation()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (caseInfo != null && !caseInfo.equalsIgnoreCase(m.getCaseInfo()))
|
if (caseInfo != null && !caseInfo.equalsIgnoreCase(m.getCaseInfo()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns a new list with the stored motors
|
* returns a new list with the stored motors
|
||||||
@ -283,11 +265,17 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
public Manufacturer getManufacturer() {
|
public Manufacturer getManufacturer() {
|
||||||
return manufacturer;
|
return manufacturer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the designation of this motor type. This is either the exact or simplified
|
* Return the common name of this motor type.
|
||||||
* designation, depending on what motors have been added.
|
* @return the common name
|
||||||
|
*/
|
||||||
|
public String getCommonName() {
|
||||||
|
return commonName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the designation of this motor type.
|
||||||
* @return the designation
|
* @return the designation
|
||||||
*/
|
*/
|
||||||
public String getDesignation() {
|
public String getDesignation() {
|
||||||
@ -352,25 +340,6 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
|||||||
return "ThrustCurveMotorSet[" + manufacturer + " " + designation +
|
return "ThrustCurveMotorSet[" + manufacturer + " " + designation +
|
||||||
", type=" + type + ", count=" + motors.size() + "]";
|
", type=" + type + ", count=" + motors.size() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Pattern SIMPLIFY_PATTERN = Pattern.compile("^[0-9]*[ -]*([A-Z][0-9]+).*");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Simplify a motor designation, if possible. This attempts to reduce the designation
|
|
||||||
* into a simple letter + number notation for the impulse class and average thrust.
|
|
||||||
*
|
|
||||||
* @param str the designation to simplify
|
|
||||||
* @return the simplified designation, or the string itself if the format was not detected
|
|
||||||
*/
|
|
||||||
public static String simplifyDesignation(String str) {
|
|
||||||
str = str.trim();
|
|
||||||
Matcher m = SIMPLIFY_PATTERN.matcher(str);
|
|
||||||
if (m.matches()) {
|
|
||||||
return m.group(1);
|
|
||||||
} else {
|
|
||||||
return str.replaceAll("\\s", "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comparator for deciding in which order to display matching motors.
|
* Comparator for deciding in which order to display matching motors.
|
||||||
|
@ -30,11 +30,11 @@ enum ThrustCurveMotorColumns {
|
|||||||
return Collator.getInstance();
|
return Collator.getInstance();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
//// Designation
|
//// Common name
|
||||||
DESIGNATION("TCurveMotorCol.DESIGNATION") {
|
COMMON_NAME("TCurveMotorCol.COMMON_NAME") {
|
||||||
@Override
|
@Override
|
||||||
public String getValue(ThrustCurveMotorSet m) {
|
public String getValue(ThrustCurveMotorSet m) {
|
||||||
return m.getDesignation();
|
return m.getCommonName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user