2 * Copyright © 2017 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 package org.altusmetrum.altoslib_11;
20 public class AltosEepromRecordSet implements AltosRecordSet {
21 AltosEepromNew eeprom;
22 TreeSet<AltosEepromRecord> ordered;
23 AltosCalData cal_data;
25 public AltosConfigData config_data() {
26 return eeprom.config_data();
29 public AltosCalData cal_data() {
30 if (cal_data == null) {
31 cal_data = new AltosCalData(config_data());
32 for (AltosEepromRecord record : ordered) {
33 if (record.cmd() == AltosLib.AO_LOG_FLIGHT) {
34 cal_data.set_tick(record.tick());
35 cal_data.set_boost_tick();
42 public void capture_series(AltosDataListener listener) {
43 AltosCalData cal_data = cal_data();
44 for (AltosEepromRecord record : ordered) {
45 record.provide_data(listener, cal_data);
49 public AltosEepromRecordSet(AltosEepromNew eeprom) {
52 AltosConfigData config_data = eeprom.config_data();
54 AltosEepromRecord record = null;
56 switch (config_data.log_format) {
57 case AltosLib.AO_LOG_FORMAT_FULL:
58 record = new AltosEepromRecordFull(eeprom);
60 case AltosLib.AO_LOG_FORMAT_TINY:
61 record = new AltosEepromRecordTiny(eeprom);
63 case AltosLib.AO_LOG_FORMAT_TELEMETRY:
64 case AltosLib.AO_LOG_FORMAT_TELESCIENCE:
65 case AltosLib.AO_LOG_FORMAT_TELEMEGA:
66 case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD:
67 record = new AltosEepromRecordMega(eeprom);
69 case AltosLib.AO_LOG_FORMAT_TELEMETRUM:
70 record = new AltosEepromRecordMetrum(eeprom);
72 case AltosLib.AO_LOG_FORMAT_TELEMINI2:
73 case AltosLib.AO_LOG_FORMAT_TELEMINI3:
74 case AltosLib.AO_LOG_FORMAT_EASYMINI:
75 record = new AltosEepromRecordMini(eeprom);
77 case AltosLib.AO_LOG_FORMAT_TELEGPS:
78 record = new AltosEepromRecordGps(eeprom);
80 case AltosLib.AO_LOG_FORMAT_TELEFIRETWO:
81 record = new AltosEepromRecordFireTwo(eeprom);
86 System.out.printf("failed to parse log format %d\n", config_data.log_format);
89 ordered = new TreeSet<AltosEepromRecord>();
94 int t = record.tick();
100 while (t < tick - 32767)
104 record.wide_tick = tick;
106 if (!record.hasNext())
108 record = record.next();
112 public AltosEepromRecordSet(Reader input) throws IOException {
113 this(new AltosEepromNew(input));