Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altosui / AltosConfig.java
index 1c42870f8d7ff61519a2df97b9eb88404cfab6cd..47de6156dd005003ee5ea8b9b741a36ecf6d5fb3 100644 (file)
@@ -30,7 +30,7 @@ import java.util.concurrent.*;
 
 import libaltosJNI.*;
 
-public class AltosConfig implements Runnable, ActionListener {
+public class AltosConfig implements ActionListener {
 
        class int_ref {
                int     value;
@@ -64,12 +64,12 @@ public class AltosConfig implements Runnable, ActionListener {
        AltosDevice     device;
        AltosSerial     serial_line;
        boolean         remote;
-       Thread          config_thread;
        int_ref         serial;
        int_ref         main_deploy;
        int_ref         apogee_delay;
        int_ref         radio_channel;
        int_ref         radio_calibration;
+       int_ref         flight_log_max;
        string_ref      version;
        string_ref      product;
        string_ref      callsign;
@@ -139,6 +139,7 @@ public class AltosConfig implements Runnable, ActionListener {
                                get_int(line, "Apogee delay:", apogee_delay);
                                get_int(line, "Radio channel:", radio_channel);
                                get_int(line, "Radio cal:", radio_calibration);
+                               get_int(line, "Max flight log:", flight_log_max);
                                get_string(line, "Callsign:", callsign);
                                get_string(line,"software-version", version);
                                get_string(line,"product", product);
@@ -182,6 +183,7 @@ public class AltosConfig implements Runnable, ActionListener {
                config_ui.set_apogee_delay(apogee_delay.get());
                config_ui.set_radio_channel(radio_channel.get());
                config_ui.set_radio_calibration(radio_calibration.get());
+               config_ui.set_flight_log_max(flight_log_max.get());
                config_ui.set_callsign(callsign.get());
                config_ui.set_clean();
        }
@@ -194,6 +196,7 @@ public class AltosConfig implements Runnable, ActionListener {
                apogee_delay.set(config_ui.apogee_delay());
                radio_channel.set(config_ui.radio_channel());
                radio_calibration.set(config_ui.radio_calibration());
+               flight_log_max.set(config_ui.flight_log_max());
                callsign.set(config_ui.callsign());
                try {
                        start_serial();
@@ -204,6 +207,8 @@ public class AltosConfig implements Runnable, ActionListener {
                                serial_line.printf("c f %d\n", radio_calibration.get());
                        }
                        serial_line.printf("c c %s\n", callsign.get());
+                       if (flight_log_max.get() != 0)
+                               serial_line.printf("c l %d\n", flight_log_max.get());
                        serial_line.printf("c w\n");
                } catch (InterruptedException ie) {
                } finally {
@@ -241,17 +246,6 @@ public class AltosConfig implements Runnable, ActionListener {
                }
        }
 
-       public void run () {
-               try {
-                       init_ui();
-                       config_ui.make_visible();
-               } catch (InterruptedException ie) {
-                       abort();
-               } catch (TimeoutException te) {
-                       abort();
-               }
-       }
-
        public AltosConfig(JFrame given_owner) {
                owner = given_owner;
 
@@ -260,6 +254,7 @@ public class AltosConfig implements Runnable, ActionListener {
                apogee_delay = new int_ref(0);
                radio_channel = new int_ref(0);
                radio_calibration = new int_ref(1186611);
+               flight_log_max = new int_ref(0);
                callsign = new string_ref("N0CALL");
                version = new string_ref("unknown");
                product = new string_ref("unknown");
@@ -270,8 +265,14 @@ public class AltosConfig implements Runnable, ActionListener {
                                serial_line = new AltosSerial(device);
                                if (!device.matchProduct(AltosDevice.product_telemetrum))
                                        remote = true;
-                               config_thread = new Thread(this);
-                               config_thread.start();
+                               try {
+                                       init_ui();
+                                       config_ui.make_visible();
+                               } catch (InterruptedException ie) {
+                                       abort();
+                               } catch (TimeoutException te) {
+                                       abort();
+                               }
                        } catch (FileNotFoundException ee) {
                                JOptionPane.showMessageDialog(owner,
                                                              String.format("Cannot open device \"%s\"",