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
|
||||
TCurveMotorCol.MANUFACTURER = Manufacturer
|
||||
TCurveMotorCol.DESIGNATION = Designation
|
||||
TCurveMotorCol.COMMON_NAME = Name
|
||||
TCurveMotorCol.CASEINFO = Case
|
||||
TCurveMotorCol.DIAMETER = Diameter
|
||||
TCurveMotorCol.LENGTH = Length
|
||||
|
@ -38,8 +38,8 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
private final List<Double> delays = new ArrayList<Double>();
|
||||
|
||||
private Manufacturer manufacturer = null;
|
||||
private String commonName = null;
|
||||
private String designation = null;
|
||||
private String simplifiedDesignation = null;
|
||||
private double diameter = -1;
|
||||
private double length = -1;
|
||||
private long totalImpulse = 0;
|
||||
@ -57,7 +57,6 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
checkFirstInsertion(motor);
|
||||
verifyMotor(motor);
|
||||
updateType(motor);
|
||||
checkChangeSimplifiedDesignation(motor);
|
||||
addStandardDelays(motor);
|
||||
if(!checkMotorOverwrite(motor)){
|
||||
motors.add(motor);
|
||||
@ -144,23 +143,6 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
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
|
||||
* if it's hybrid, delays will be added
|
||||
@ -206,7 +188,7 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
if (motors.isEmpty()) {
|
||||
manufacturer = motor.getManufacturer();
|
||||
designation = motor.getDesignation();
|
||||
simplifiedDesignation = simplifyDesignation(designation);
|
||||
commonName = motor.getCommonName();
|
||||
diameter = motor.getDiameter();
|
||||
length = motor.getLength();
|
||||
totalImpulse = Math.round((motor.getTotalImpulseEstimate()));
|
||||
@ -239,7 +221,7 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!simplifiedDesignation.equalsIgnoreCase(simplifyDesignation(m.getDesignation())))
|
||||
if (!designation.equalsIgnoreCase(m.getDesignation()))
|
||||
return false;
|
||||
|
||||
if (caseInfo != null && !caseInfo.equalsIgnoreCase(m.getCaseInfo()))
|
||||
@ -284,10 +266,16 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the common name of this motor type.
|
||||
* @return the common name
|
||||
*/
|
||||
public String getCommonName() {
|
||||
return commonName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the designation of this motor type. This is either the exact or simplified
|
||||
* designation, depending on what motors have been added.
|
||||
* Return the designation of this motor type.
|
||||
* @return the designation
|
||||
*/
|
||||
public String getDesignation() {
|
||||
@ -353,25 +341,6 @@ public class ThrustCurveMotorSet implements Comparable<ThrustCurveMotorSet> {
|
||||
", 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.
|
||||
*/
|
||||
|
@ -30,11 +30,11 @@ enum ThrustCurveMotorColumns {
|
||||
return Collator.getInstance();
|
||||
}
|
||||
},
|
||||
//// Designation
|
||||
DESIGNATION("TCurveMotorCol.DESIGNATION") {
|
||||
//// Common name
|
||||
COMMON_NAME("TCurveMotorCol.COMMON_NAME") {
|
||||
@Override
|
||||
public String getValue(ThrustCurveMotorSet m) {
|
||||
return m.getDesignation();
|
||||
return m.getCommonName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user