summaryrefslogtreecommitdiff
path: root/altoslib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-05-10 14:47:15 -0700
committerKeith Packard <keithp@keithp.com>2017-05-13 15:29:12 -0700
commit5ad767dd6b6c8d99bbe4b688e8cdbc230e01a7dc (patch)
treed8d231fae8034458415da92a0a8243e1712bcd20 /altoslib
parent0080e61e5f2e20ce45041e29dc039d042aa7f76e (diff)
altoslib: Another bit of altoslib for the old eeprom stuff
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r--altoslib/AltosEepromIterable.java127
-rw-r--r--altoslib/Makefile.am1
2 files changed, 0 insertions, 128 deletions
diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java
deleted file mode 100644
index 77632ac1..00000000
--- a/altoslib/AltosEepromIterable.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright © 2013 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; either version 2 of the License, or
- * (at your option) any later version.
- *
- * 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 org.altusmetrum.altoslib_11;
-
-import java.io.*;
-import java.util.*;
-import java.text.*;
-
-class AltosEepromOrdered implements Comparable<AltosEepromOrdered> {
- AltosEeprom eeprom;
- int index;
- int tick;
-
- int cmdi() {
- if (eeprom.cmd == AltosLib.AO_LOG_FLIGHT)
- return 0;
- return 1;
- }
-
- public int compareTo(AltosEepromOrdered o) {
- int cmd_diff = cmdi() - o.cmdi();
-
- if (cmd_diff != 0)
- return cmd_diff;
-
- if (eeprom.has_seconds() && o.eeprom.has_seconds()) {
- int seconds_diff = eeprom.seconds() - o.eeprom.seconds();
-
- if (seconds_diff != 0)
- return seconds_diff;
- }
-
- int tick_diff = tick - o.tick;
-
- if (tick_diff != 0)
- return tick_diff;
- return index - o.index;
- }
-
- AltosEepromOrdered (AltosEeprom eeprom, int index, int tick) {
- this.eeprom = eeprom;
- this.index = index;
- this.tick = tick;
- }
-}
-
-class AltosEepromOrderedIterator implements Iterator<AltosEeprom> {
- TreeSet<AltosEepromOrdered> olist;
- Iterator<AltosEepromOrdered> oiterator;
-
- public AltosEepromOrderedIterator(Iterable<AltosEeprom> eeproms) {
- olist = new TreeSet<AltosEepromOrdered>();
-
- int tick = 0;
- int index = 0;
- boolean first = true;
-
- for (AltosEeprom e : eeproms) {
- int t = e.tick;
- if (first)
- tick = t;
- else {
- while (t < tick - 32767)
- t += 65536;
- tick = t;
- }
- olist.add(new AltosEepromOrdered(e, index++, tick));
- first = false;
- }
-
- oiterator = olist.iterator();
- }
-
- public boolean hasNext() {
- return oiterator.hasNext();
- }
-
- public AltosEeprom next() {
- return oiterator.next().eeprom;
- }
-
- public void remove () {
- }
-}
-
-public class AltosEepromIterable implements Iterable<AltosEeprom> {
- public LinkedList<AltosEeprom> eeproms;
-
- public void write(PrintStream out) {
- for (AltosEeprom eeprom : eeproms)
- eeprom.write(out);
- }
-
- public AltosState state() {
- AltosState state = new AltosState();
-
- for (AltosEeprom header : eeproms)
- header.update_state(state);
- return state;
- }
-
- public AltosEepromIterable(LinkedList<AltosEeprom> eeproms) {
- this.eeproms = eeproms;
- }
-
- public Iterator<AltosEeprom> iterator() {
- if (eeproms == null)
- eeproms = new LinkedList<AltosEeprom>();
- return new AltosEepromOrderedIterator(eeproms);
- }
-}
diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am
index ad3fc682..b93d1f88 100644
--- a/altoslib/Makefile.am
+++ b/altoslib/Makefile.am
@@ -49,7 +49,6 @@ altoslib_JAVA = \
AltosEepromDownload.java \
AltosEepromMonitor.java \
AltosEepromFile.java \
- AltosEepromIterable.java \
AltosEepromList.java \
AltosEepromLog.java \
AltosFile.java \