From: Keith Packard Date: Sun, 8 Feb 2015 04:22:19 +0000 (-0800) Subject: altosuilib: Get the Eeprom download progress bar working again X-Git-Tag: 1.6~4 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=426bacbbd6e0573b143e7c48d71db977e53181fc altosuilib: Get the Eeprom download progress bar working again The eeprom download code wasn't computing the start of each state transition correctly, so the progress bar was snapping to the end of the chunk for each state. Invalid state values would snap the bar to the right side. Landed state wasn't ever seen, so the bar would not ever fill. Signed-off-by: Keith Packard --- diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 78a1f4be..00b20272 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -75,7 +75,8 @@ public class AltosEepromDownload implements Runnable { } boolean done; - boolean start; + int prev_state; + int state_block; void LogEeprom(AltosEeprom r) throws IOException { if (r.cmd != AltosLib.AO_LOG_INVALID) { @@ -140,7 +141,6 @@ public class AltosEepromDownload implements Runnable { state = new AltosState(); done = false; - start = true; if (flights.config_data.serial < 0) throw new IOException("no serial number found"); @@ -154,12 +154,8 @@ public class AltosEepromDownload implements Runnable { /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ state_block = log.start_block; + prev_state = AltosLib.ao_flight_startup; for (block = log.start_block; !done && block < log.end_block; block++) { - monitor.set_value(state.state_name(), - state.state, - block - state_block, - block - log.start_block); - AltosEepromChunk eechunk = new AltosEepromChunk(link, block, block == log.start_block); /* @@ -177,6 +173,16 @@ public class AltosEepromDownload implements Runnable { } CaptureEeprom (eechunk, log_format); + + if (state.state != prev_state && state.state != AltosLib.ao_flight_invalid) { + state_block = block; + prev_state = state.state; + } + + monitor.set_value(state.state_name(), + state.state, + block - state_block, + block - log.start_block); } CheckFile(true); if (eeprom_file != null) { diff --git a/altosuilib/AltosEepromMonitorUI.java b/altosuilib/AltosEepromMonitorUI.java index b72dfdf4..d2d95678 100644 --- a/altosuilib/AltosEepromMonitorUI.java +++ b/altosuilib/AltosEepromMonitorUI.java @@ -167,15 +167,21 @@ public class AltosEepromMonitorUI extends AltosUIDialog implements AltosEepromMo pos = lblock / 1000.0; s = String.format("block %d", block); } else { + if (state == AltosLib.ao_flight_invalid) + state = 0; if (state_block > 100) state_block = 100; if (state < min_state) state = min_state; - if (state >= max_state) state = max_state - 1; + if (state > max_state) state = max_state; + + if (state == max_state) + state_block = 0; + state -= min_state; int nstate = max_state - min_state; - double spos = (double) (state - min_state) / (double) nstate; + double spos = (double) state / (double) nstate; double bpos = state_block / 100.0; pos = spos + bpos / nstate;