diff options
-rw-r--r-- | altosui/AltosEepromBlock.java | 111 | ||||
-rw-r--r-- | altosui/AltosEepromDownload.java | 89 | ||||
-rw-r--r-- | altosui/AltosEepromLog.java | 49 | ||||
-rw-r--r-- | altosui/Makefile.am | 3 |
4 files changed, 69 insertions, 183 deletions
diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java deleted file mode 100644 index 650920d1..00000000 --- a/altosui/AltosEepromBlock.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright © 2011 Keith Packard <keithp@keithp.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.table.*; -import java.io.*; -import java.util.*; -import java.text.*; -import java.util.prefs.*; -import java.util.concurrent.*; -import java.lang.reflect.Array; - -import libaltosJNI.*; - -public class AltosEepromBlock extends ArrayList<AltosEepromRecord> { - boolean has_flight; - int flight; - boolean has_state; - int state; - boolean has_date; - int year, month, day; - boolean has_lat; - double lat; - boolean has_lon; - double lon; - boolean has_time; - int hour, minute, second; - ParseException parse_exception = null; - - public AltosEepromBlock (AltosEepromChunk chunk) { - int addr; - boolean done = false; - - has_flight = false; - has_state = false; - has_date = false; - has_lat = false; - has_lon = false; - has_time = false; - for (addr = 0; addr < chunk.chunk_size;) { - try { - AltosEepromRecord r = new AltosEepromRecord(chunk, addr); - - if (r.cmd == Altos.AO_LOG_FLIGHT) { - flight = r.b; - has_flight = true; - } - - /* Monitor state transitions to update display */ - if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) { - if (!has_state || r.a > state) { - state = r.a; - has_state = true; - } - } - - if (r.cmd == Altos.AO_LOG_GPS_DATE) { - year = 2000 + (r.a & 0xff); - month = (r.a >> 8) & 0xff; - day = (r.b & 0xff); - has_date = true; - } - if (r.cmd == Altos.AO_LOG_GPS_TIME) { - hour = (r.a & 0xff); - minute = (r.a >> 8); - second = (r.b & 0xff); - has_time = true; - } - if (r.cmd == Altos.AO_LOG_GPS_LAT) { - lat = (double) (r.a | (r.b << 16)) / 1e7; - has_lat = true; - } - if (r.cmd == Altos.AO_LOG_GPS_LON) { - lon = (double) (r.a | (r.b << 16)) / 1e7; - has_lon = true; - } - if (!done) - add(addr / 8, r); - if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed) - done = true; - } catch (ParseException pe) { - AltosEepromRecord r = new AltosEepromRecord(Altos.AO_LOG_INVALID, - 0, 0, 0); - if (parse_exception == null) - parse_exception = pe; - if (!done) - add(addr/8, r); - } - addr += 8; - } - } -}
\ No newline at end of file diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index f96a3dc9..a03d2b43 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -96,77 +96,88 @@ public class AltosEepromDownload implements Runnable { int state; void CaptureFull(AltosEepromChunk eechunk) throws IOException { - AltosEepromBlock eeblock = new AltosEepromBlock(eechunk); - - if (eeblock.has_flight) { - flight = eeblock.flight; - monitor.set_flight(flight); - } - if (eeblock.has_date) { - year = eeblock.year; - month = eeblock.month; - day = eeblock.day; - want_file = true; - } + boolean any_valid = false; + for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromRecord.record_length) { + try { + AltosEepromRecord r = new AltosEepromRecord(eechunk, i); + if (r.cmd == Altos.AO_LOG_FLIGHT) { + flight = r.b; + monitor.set_flight(flight); + } - if (eeblock.size() == 0 || - eeblock.has_state && eeblock.state == Altos.ao_flight_landed) - done = true; + /* Monitor state transitions to update display */ + if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) { + state = r.a; + if (state > Altos.ao_flight_pad) + want_file = true; + } - /* Monitor state transitions to update display */ - if (eeblock.has_state) { - if (eeblock.state > Altos.ao_flight_pad) - want_file = true; - if (eeblock.state > state) - state = eeblock.state; + if (r.cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (r.a & 0xff); + month = (r.a >> 8) & 0xff; + day = (r.b & 0xff); + want_file = true; + } + if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed) + done = true; + any_valid = true; + Log(r); + } catch (ParseException pe) { + if (parse_exception == null) + parse_exception = pe; + } } - if (parse_exception == null && eeblock.parse_exception != null) - parse_exception = eeblock.parse_exception; + if (!any_valid) + done = true; CheckFile(false); - - for (int record = 0; record < eeblock.size(); record++) - Log(eeblock.get(record)); } boolean start; int tiny_tick; void CaptureTiny (AltosEepromChunk eechunk) throws IOException { - boolean some_reasonable_data = false; + boolean any_valid = false; - for (int i = 0; i < eechunk.data.length; i += 2) { - int v = eechunk.data16(i); + for (int i = 0; i < eechunk.data.length && !done; i += 2) { + int v = eechunk.data16(i); + AltosEepromRecord r; if (i == 0 && start) { tiny_tick = 0; start = false; flight = v; - Log(new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v)); - some_reasonable_data = true; + monitor.set_flight(flight); + r = new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v); + any_valid = true; } else { int s = v ^ 0x8000; + if (Altos.ao_flight_startup <= s && s <= Altos.ao_flight_invalid) { - Log(new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0)); - if (s == Altos.ao_flight_landed) { + r = new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0); + if (s == Altos.ao_flight_landed) done = true; - break; - } - some_reasonable_data = true; + any_valid = true; } else { if (v != 0xffff) - some_reasonable_data = true; - Log(new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0)); + any_valid = true; + r = new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0); + + /* + * The flight software records ascent data every 100ms, and descent + * data every 1s. + */ if (state < Altos.ao_flight_drogue) tiny_tick += 10; else tiny_tick += 100; } } + Log(r); } CheckFile(false); - if (!some_reasonable_data) + if (!any_valid) done = true; } diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index 4c6deaa0..f7fb39e1 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -41,10 +41,7 @@ public class AltosEepromLog { int start_block; int end_block; - boolean has_gps; int year, month, day; - int hour, minute, second; - double lat, lon; boolean download; boolean delete; @@ -54,7 +51,7 @@ public class AltosEepromLog { throws InterruptedException, TimeoutException { int block; - boolean has_date = false, has_time = false, has_lat = false, has_lon = false; + boolean has_date = false; start_block = in_start_block; end_block = in_end_block; @@ -82,34 +79,24 @@ public class AltosEepromLog { break; } } - AltosEepromBlock eeblock = new AltosEepromBlock(eechunk); - if (eeblock.has_flight) { - flight = eeblock.flight; - has_flight = true; - } - if (eeblock.has_date) { - year = eeblock.year; - month = eeblock.month; - day = eeblock.day; - has_date = true; - } - if (eeblock.has_time) { - hour = eeblock.hour; - minute = eeblock.minute; - second = eeblock.second; - has_time = true; - } - if (eeblock.has_lat) { - lat = eeblock.lat; - has_lat = true; - } - if (eeblock.has_lon) { - lon = eeblock.lon; - has_lon = true; + for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) { + try { + AltosEepromRecord r = new AltosEepromRecord(eechunk, i); + + if (r.cmd == Altos.AO_LOG_FLIGHT) { + flight = r.b; + has_flight = true; + } + if (r.cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (r.a & 0xff); + month = (r.a >> 8) & 0xff; + day = (r.b & 0xff); + has_date = true; + } + } catch (ParseException pe) { + } } - if (has_date && has_time && has_lat && has_lon) - has_gps = true; - if (has_gps && has_flight) + if (has_date && has_flight) break; } } diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 9a9d0d36..01fe50c8 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS=libaltos JAVAROOT=classes -AM_JAVACFLAGS=-encoding UTF-8 +AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation man_MANS=altosui.1 @@ -27,7 +27,6 @@ altosui_JAVA = \ AltosDeviceDialog.java \ AltosDevice.java \ AltosDisplayThread.java \ - AltosEepromBlock.java \ AltosEepromChunk.java \ AltosEepromDelete.java \ AltosEepromDownload.java \ |