Get rid of a bit of duplicate code

Handle case with no data in specified format for motor
This commit is contained in:
JoePfeiffer 2020-11-05 10:41:15 -07:00
parent 67fed96137
commit d231cb320f
2 changed files with 10 additions and 10 deletions

View File

@ -161,20 +161,20 @@ public class SerializeThrustcurveMotors {
}
}
}
private static List<MotorBurnFile> getThrustCurvesForMotorId(int motorId) {
String formats[] = new String[] {"RASP", "RockSim"};
List<MotorBurnFile> b = new ArrayList<>();
try {
b.addAll(ThrustCurveAPI.downloadData(motorId, "RockSim"));
} catch (Exception ex) {
System.out.println("\tError downloading RockSim for motorID=" + motorId);
}
try {
b.addAll(ThrustCurveAPI.downloadData(motorId, "RASP"));
} catch (Exception ex) {
System.out.println("\tError downloading RASP for motorID=" + motorId);
for (String format : formats) {
try {
List<MotorBurnFile> motorData = ThrustCurveAPI.downloadData(motorId, format);
if (motorData != null) {
b.addAll(motorData);
}
} catch (Exception ex) {
System.out.println("\tError downloading " + format + " for motorID=" + motorId + ": " + ex.getLocalizedMessage());
}
}
return b;
}