projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ao-bringup: Delay before testing easymini for 0.25 seconds
[fw/altos]
/
altosui
/
AltosIgniteUI.java
diff --git
a/altosui/AltosIgniteUI.java
b/altosui/AltosIgniteUI.java
index c251bbe219e90a92d7fbaf378c8c4e4ad9a677ac..5a09252ecc14babaa5d101a7758ae3e33ff4d970 100644
(file)
--- a/
altosui/AltosIgniteUI.java
+++ b/
altosui/AltosIgniteUI.java
@@
-3,7
+3,8
@@
*
* 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
*
* 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.
+ * 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
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-24,8
+25,8
@@
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
-import org.altusmetrum.altoslib_4.*;
-import org.altusmetrum.altosuilib_
2
.*;
+import org.altusmetrum.altoslib_
1
4.*;
+import org.altusmetrum.altosuilib_
14
.*;
public class AltosIgniteUI
extends AltosUIDialog
public class AltosIgniteUI
extends AltosUIDialog
@@
-41,6
+42,7
@@
public class AltosIgniteUI
ButtonGroup group;
Boolean opened;
ButtonGroup group;
Boolean opened;
+ boolean has_standard;
int npyro;
final static int timeout = 1 * 1000;
int npyro;
final static int timeout = 1 * 1000;
@@
-48,9
+50,9
@@
public class AltosIgniteUI
int time_remaining;
boolean timer_running;
int time_remaining;
boolean timer_running;
-
LinkedBlockingQueue<String> command_queue
;
+
int poll_remaining
;
- LinkedBlockingQueue<String>
reply
_queue;
+ LinkedBlockingQueue<String>
command
_queue;
class Igniter {
JRadioButton button;
class Igniter {
JRadioButton button;
@@
-64,7
+66,7
@@
public class AltosIgniteUI
}
Igniter(AltosIgniteUI ui, String label, String name, int y) {
}
Igniter(AltosIgniteUI ui, String label, String name, int y) {
- Container pane = get
Content
Pane();
+ Container pane = get
Scrollable
Pane();
GridBagConstraints c = new GridBagConstraints();
Insets i = new Insets(4,4,4,4);
GridBagConstraints c = new GridBagConstraints();
Insets i = new Insets(4,4,4,4);
@@
-126,7
+128,7
@@
public class AltosIgniteUI
public void run () {
try {
ignite = new AltosIgnite(link,
public void run () {
try {
ignite = new AltosIgnite(link,
-
!device.matchProduct(Altos.product_altimeter
));
+
device.matchProduct(Altos.product_basestation
));
} catch (Exception e) {
send_exception(e);
} catch (Exception e) {
send_exception(e);
@@
-150,8
+152,7
@@
public class AltosIgniteUI
}
reply = "status";
} else if (command.equals("get_npyro")) {
}
reply = "status";
} else if (command.equals("get_npyro")) {
- put_reply(String.format("%d", ignite.npyro()));
- continue;
+ reply = String.format("npyro %d %d", ignite.npyro(), ignite.has_standard() ? 1 : 0);
} else if (command.equals("quit")) {
ignite.close();
break;
} else if (command.equals("quit")) {
ignite.close();
break;
@@
-211,6
+212,13
@@
public class AltosIgniteUI
set_ignite_status();
} else if (reply.equals("fired")) {
fired();
set_ignite_status();
} else if (reply.equals("fired")) {
fired();
+ } else if (reply.startsWith("npyro")) {
+ String items[] = reply.split("\\s+");
+ npyro = Integer.parseInt(items[1]);
+ if (npyro == AltosLib.MISSING)
+ npyro = 0;
+ has_standard = Integer.parseInt(items[2]) != 0;
+ make_ui();
}
}
}
}
@@
-250,49
+258,26
@@
public class AltosIgniteUI
}
}
}
}
- void put_reply(String reply) {
- try {
- reply_queue.put(reply);
- } catch (Exception ex) {
- ignite_exception(ex);
- }
- }
-
- String get_reply() {
- String reply = "";
- try {
- reply = reply_queue.take();
- } catch (Exception ex) {
- ignite_exception(ex);
- }
- return reply;
- }
-
boolean getting_status = false;
boolean getting_status = false;
- boolean visible = false;
-
void set_ignite_status() {
getting_status = false;
void set_ignite_status() {
getting_status = false;
- if (!visible) {
- visible = true;
+ poll_remaining = 2;
+ if (!isVisible())
setVisible(true);
setVisible(true);
- }
}
void poll_ignite_status() {
}
void poll_ignite_status() {
+ if (poll_remaining > 0) {
+ --poll_remaining;
+ return;
+ }
if (!getting_status) {
getting_status = true;
send_command("get_status");
}
}
if (!getting_status) {
getting_status = true;
send_command("get_status");
}
}
- int get_npyro() {
- send_command("get_npyro");
- String reply = get_reply();
- return Integer.parseInt(reply);
- }
-
boolean firing = false;
void start_fire(String which) {
boolean firing = false;
void start_fire(String which) {
@@
-310,8
+295,9
@@
public class AltosIgniteUI
void close() {
if (opened) {
send_command("quit");
void close() {
if (opened) {
send_command("quit");
- timer.stop();
}
}
+ if (timer != null)
+ timer.stop();
setVisible(false);
dispose();
}
setVisible(false);
dispose();
}
@@
-383,7
+369,6
@@
public class AltosIgniteUI
private boolean open() {
command_queue = new LinkedBlockingQueue<String>();
private boolean open() {
command_queue = new LinkedBlockingQueue<String>();
- reply_queue = new LinkedBlockingQueue<String>();
opened = false;
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
opened = false;
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
@@
-403,16
+388,10
@@
public class AltosIgniteUI
return false;
}
return false;
}
- public AltosIgniteUI(JFrame in_owner) {
-
- owner = in_owner;
-
- if (!open())
- return;
-
+ private void make_ui() {
group = new ButtonGroup();
group = new ButtonGroup();
- Container pane = get
Content
Pane();
+ Container pane = get
Scrollable
Pane();
GridBagConstraints c = new GridBagConstraints();
Insets i = new Insets(4,4,4,4);
GridBagConstraints c = new GridBagConstraints();
Insets i = new Insets(4,4,4,4);
@@
-422,8
+401,6
@@
public class AltosIgniteUI
timer_running = false;
timer.restart();
timer_running = false;
timer.restart();
- owner = in_owner;
-
pane.setLayout(new GridBagLayout());
c.fill = GridBagConstraints.NONE;
pane.setLayout(new GridBagLayout());
c.fill = GridBagConstraints.NONE;
@@
-443,17
+420,21
@@
public class AltosIgniteUI
y++;
y++;
- int npyro = get_npyro();
+ int nstandard = 0;
+ if (has_standard)
+ nstandard = 2;
- igniters = new Igniter[
2
+ npyro];
+ igniters = new Igniter[
nstandard
+ npyro];
- igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
- igniters[1] = new Igniter(this, "Main", AltosIgnite.Main, y++);
+ if (has_standard) {
+ igniters[0] = new Igniter(this, "Apogee", AltosIgnite.Apogee, y++);
+ igniters[1] = new Igniter(this, "Main", AltosIgnite.Main, y++);
+ }
for (int p = 0; p < npyro; p++) {
String name = String.format("%d", p);
String label = String.format("%c", 'A' + p);
for (int p = 0; p < npyro; p++) {
String name = String.format("%d", p);
String label = String.format("%c", 'A' + p);
- igniters[
2
+p] = new Igniter(this, label, name, y++);
+ igniters[
nstandard
+p] = new Igniter(this, label, name, y++);
}
c.gridx = 0;
}
c.gridx = 0;
@@
-492,4
+473,14
@@
public class AltosIgniteUI
addWindowListener(new ConfigListener(this));
}
addWindowListener(new ConfigListener(this));
}
-}
\ No newline at end of file
+
+ public AltosIgniteUI(JFrame in_owner) {
+
+ owner = in_owner;
+
+ if (!open())
+ return;
+
+ send_command("get_npyro");
+ }
+}