+
+ public static File replace_extension(File input, String extension) {
+ return new File(replace_extension(input.getPath(), extension));
+ }
+
+ public static String product_name(int product_id) {
+ switch (product_id) {
+ case product_altusmetrum: return "AltusMetrum";
+ case product_telemetrum: return "TeleMetrum";
+ case product_teledongle: return "TeleDongle";
+ case product_easytimer: return "EasyTimer";
+ case product_telebt: return "TeleBT";
+ case product_telelaunch: return "TeleLaunch";
+ case product_telelco: return "TeleLco";
+ case product_telescience: return "Telescience";
+ case product_telepyro: return "TelePyro";
+ case product_telemega: return "TeleMega";
+ case product_megadongle: return "MegaDongle";
+ case product_telegps: return "TeleGPS";
+ case product_easymini: return "EasyMini";
+ case product_telemini: return "TeleMini";
+ case product_easymega: return "EasyMega";
+ case product_easymotor: return "EasyMotor";
+ default: return "unknown";
+ }
+ }
+
+ public static int product_id_from_log_format(int log_format) {
+ switch (log_format){
+ case AO_LOG_FORMAT_UNKNOWN:
+ return product_altusmetrum;
+ case AO_LOG_FORMAT_FULL:
+ return product_telemetrum;
+ case AO_LOG_FORMAT_TINY:
+ return product_telemini;
+ case AO_LOG_FORMAT_TELEMETRY:
+ return product_altusmetrum;
+ case AO_LOG_FORMAT_TELESCIENCE:
+ return product_telescience;
+ case AO_LOG_FORMAT_TELEMEGA_OLD:
+ return product_telemega;
+ case AO_LOG_FORMAT_EASYMINI1:
+ return product_easymini;
+ case AO_LOG_FORMAT_TELEMETRUM:
+ return product_telemetrum;
+ case AO_LOG_FORMAT_TELEMINI2:
+ return product_telemini;
+ case AO_LOG_FORMAT_TELEGPS:
+ return product_telegps;
+ case AO_LOG_FORMAT_TELEMEGA:
+ return product_telemega;
+ case AO_LOG_FORMAT_DETHERM:
+ return product_altusmetrum;
+ case AO_LOG_FORMAT_TELEMINI3:
+ return product_telemini;
+ case AO_LOG_FORMAT_TELEFIRETWO:
+ return product_altusmetrum;
+ case AO_LOG_FORMAT_EASYMINI2:
+ return product_easymini;
+ case AO_LOG_FORMAT_TELEMEGA_3:
+ return product_telemega;
+ case AO_LOG_FORMAT_EASYMEGA_2:
+ case AO_LOG_FORMAT_EASYMEGA_3:
+ return product_easymega;
+ case AO_LOG_FORMAT_TELESTATIC:
+ return product_altusmetrum;
+ case AO_LOG_FORMAT_MICROPEAK2:
+ return product_altusmetrum;
+ case AO_LOG_FORMAT_TELEMEGA_4:
+ return product_telemega;
+ case AO_LOG_FORMAT_EASYMOTOR:
+ return product_easymotor;
+ case AO_LOG_FORMAT_TELEMEGA_5:
+ return product_telemega;
+ case AO_LOG_FORMAT_TELEMEGA_6:
+ return product_telemega;
+ case AO_LOG_FORMAT_NONE:
+ return product_altusmetrum;
+ default:
+ return product_altusmetrum;
+ }
+ }
+
+ public static String igniter_name(int i) {
+ return String.format("Igniter %c", 'A' + i);
+ }
+
+ public static String igniter_short_name(int i) {
+ return String.format("igniter_%c", 'a' + i);
+ }
+
+ public static AltosRecordSet record_set(File file) throws FileNotFoundException, IOException {
+ FileInputStream in;
+ in = new FileInputStream(file);
+ if (file.getName().endsWith("telem")) {
+ return new AltosTelemetryFile(in);
+ } else if (file.getName().endsWith("eeprom")) {
+ return new AltosEepromFile(in);
+ } else {
+ String name = file.getName();
+ int dot = name.lastIndexOf('.');
+ String extension;
+
+ if (dot == -1)
+ throw new IOException(String.format("%s (Missing extension)", file.toString()));
+ else {
+ extension = name.substring(dot);
+ throw new IOException(String.format("%s (Invalid extension '%s')",
+ file.toString(),
+ extension));
+ }
+ }
+ }
+