altosui: Remove extra AltosEepromBlock layer
authorKeith Packard <keithp@keithp.com>
Sat, 26 Mar 2011 05:01:18 +0000 (22:01 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 26 Mar 2011 05:04:00 +0000 (22:04 -0700)
This was interposed between the download layer and the eeprom layer to
hold a eeprom block full of flight log records. The addition of the tiny
log format required reworking the code to hold chunks full of eeprom
data without regard to their content, so this content-specific layer
didn't seem useful anymore.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosEepromBlock.java [deleted file]
altosui/AltosEepromDownload.java
altosui/AltosEepromLog.java
altosui/Makefile.am

diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java
deleted file mode 100644 (file)
index 650920d..0000000
+++ /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
index f96a3dc90527559b685d2c28b94a090a53ba9467..a03d2b43c952e963cc470a947c25c9bce0c268ec 100644 (file)
@@ -96,77 +96,88 @@ public class AltosEepromDownload implements Runnable {
        int                     state;
 
        void CaptureFull(AltosEepromChunk eechunk) throws IOException {
        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);
 
                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 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;
 
                        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;
                        } else {
                                int     s = v ^ 0x8000;
+
                                if (Altos.ao_flight_startup <= s && s <= Altos.ao_flight_invalid) {
                                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;
                                                done = true;
-                                               break;
-                                       }
-                                       some_reasonable_data = true;
+                                       any_valid = true;
                                } else {
                                        if (v != 0xffff)
                                } 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;
                                }
                        }
                                        if (state < Altos.ao_flight_drogue)
                                                tiny_tick += 10;
                                        else
                                                tiny_tick += 100;
                                }
                        }
+                       Log(r);
                }
                CheckFile(false);
                }
                CheckFile(false);
-               if (!some_reasonable_data)
+               if (!any_valid)
                        done = true;
        }
 
                        done = true;
        }
 
index 4c6deaa065f232dd09f63119e7297708e3d08cf2..f7fb39e1e19c33e91ab0ee314007132c17bf212c 100644 (file)
@@ -41,10 +41,7 @@ public class AltosEepromLog {
        int             start_block;
        int             end_block;
 
        int             start_block;
        int             end_block;
 
-       boolean         has_gps;
        int             year, month, day;
        int             year, month, day;
-       int             hour, minute, second;
-       double          lat, lon;
 
        boolean         download;
        boolean         delete;
 
        boolean         download;
        boolean         delete;
@@ -54,7 +51,7 @@ public class AltosEepromLog {
                throws InterruptedException, TimeoutException {
 
                int             block;
                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;
 
                start_block = in_start_block;
                end_block = in_end_block;
@@ -82,34 +79,24 @@ public class AltosEepromLog {
                                        break;
                                }
                        }
                                        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;
                }
        }
                                break;
                }
        }
index 9a9d0d362f250a0b66a2c491e0f5b0538670fa79..01fe50c8560924d0efab5546892351c15a64b02f 100644 (file)
@@ -1,6 +1,6 @@
 SUBDIRS=libaltos
 JAVAROOT=classes
 SUBDIRS=libaltos
 JAVAROOT=classes
-AM_JAVACFLAGS=-encoding UTF-8
+AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation
 
 man_MANS=altosui.1
 
 
 man_MANS=altosui.1
 
@@ -27,7 +27,6 @@ altosui_JAVA = \
        AltosDeviceDialog.java \
        AltosDevice.java \
        AltosDisplayThread.java \
        AltosDeviceDialog.java \
        AltosDevice.java \
        AltosDisplayThread.java \
-       AltosEepromBlock.java \
        AltosEepromChunk.java \
        AltosEepromDelete.java \
        AltosEepromDownload.java \
        AltosEepromChunk.java \
        AltosEepromDelete.java \
        AltosEepromDownload.java \