altosui: Display block number while downloading flights. Track #51
authorKeith Packard <keithp@keithp.com>
Sun, 10 Feb 2013 22:51:46 +0000 (14:51 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 10 Feb 2013 22:57:27 +0000 (14:57 -0800)
We don't know how long the flight log is, but we can at least provide
a block number in the pacifier to let the user know it's not wedged.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosEepromDownload.java
altosui/AltosEepromMonitor.java

index 8fbd661ba1f563992b40350146b809830a7daa20..801d4ec0ec4d874908d811e22f4d9eecba2faa47 100644 (file)
@@ -331,7 +331,7 @@ public class AltosEepromDownload implements Runnable {
 
                state = 0; state_block = log.start_block;
                for (block = log.start_block; !done && block < log.end_block; block++) {
-                       monitor.set_value(AltosLib.state_name(state), state, block - state_block);
+                       monitor.set_value(AltosLib.state_name(state), state, block - state_block, block - log.start_block);
 
                        AltosEepromChunk        eechunk = new AltosEepromChunk(serial_line, block, block == log.start_block);
 
index 5b9e5171bc8b89586fef1f44bafc8e7c1eebd82f..50921da17df203d645038ac116de5cb692951ebb 100644 (file)
@@ -101,7 +101,7 @@ public class AltosEepromMonitor extends AltosUIDialog {
                max_state = in_max_state;
                pbar = new JProgressBar();
                pbar.setMinimum(0);
-               pbar.setMaximum((max_state - min_state) * 100);
+               pbar.setMaximum(1000);
                pbar.setValue(0);
                pbar.setString("startup");
                pbar.setStringPainted(true);
@@ -135,30 +135,28 @@ public class AltosEepromMonitor extends AltosUIDialog {
                cancel.addActionListener(l);
        }
 
-       private void set_value_internal(String state_name, int in_state, int in_block) {
-               int block = in_block;
-               int state = in_state;
-
-               if (block > 100)
-                       block = 100;
+       private void set_value_internal(String state_name, int state, int state_block, int block) {
+               if (state_block > 100)
+                       state_block = 100;
                if (state < min_state) state = min_state;
                if (state >= max_state) state = max_state - 1;
                state -= min_state;
 
-               int pos = state * 100 + block;
+               int pos = state * 100 + state_block;
 
-               pbar.setString(state_name);
+               pbar.setString(String.format("block %d state %s", block, state_name));
                pbar.setValue(pos);
        }
 
-       public void set_value(String in_state_name, int in_state, int in_block) {
+       public void set_value(String in_state_name, int in_state, int in_state_block, int in_block) {
                final String state_name = in_state_name;
                final int state = in_state;
+               final int state_block = in_state_block;
                final int block = in_block;
                Runnable r = new Runnable() {
                                public void run() {
                                        try {
-                                               set_value_internal(state_name, state, block);
+                                               set_value_internal(state_name, state, state_block, block);
                                        } catch (Exception ex) {
                                        }
                                }
@@ -235,7 +233,7 @@ public class AltosEepromMonitor extends AltosUIDialog {
        }
 
        private void reset_internal() {
-               set_value_internal("startup",min_state,0);
+               set_value_internal("startup",min_state,0, 0);
                set_flight_internal(0);
                set_file_internal("");
        }