summaryrefslogtreecommitdiff
path: root/altosui
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-09-02 23:10:23 -0600
committerKeith Packard <keithp@keithp.com>2013-09-02 23:11:52 -0600
commit528e2e41112cad8a81bccbb89c3bd202b818a506 (patch)
tree2c2076a5d1972681ba3300e9a44636b526efaa82 /altosui
parent224a1e01bacb7db0076129906ed58e1c785e1b14 (diff)
altoslib: More AltosState hacking
EasyMini graphs are looking good now. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui')
-rw-r--r--altosui/AltosAscent.java6
-rw-r--r--altosui/AltosCSV.java12
-rw-r--r--altosui/AltosDescent.java4
-rw-r--r--altosui/AltosDisplayThread.java10
-rw-r--r--altosui/AltosFlightStats.java18
-rw-r--r--altosui/AltosFlightStatsTable.java6
-rw-r--r--altosui/AltosGraphDataPoint.java6
-rw-r--r--altosui/AltosInfoTable.java28
-rw-r--r--altosui/AltosKML.java4
-rw-r--r--altosui/AltosLanded.java4
-rw-r--r--altosui/AltosUI.java2
11 files changed, 50 insertions, 50 deletions
diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java
index ceba2d1d..20474f52 100644
--- a/altosui/AltosAscent.java
+++ b/altosui/AltosAscent.java
@@ -240,7 +240,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Height extends AscentValueHold {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.height, state.height);
+ show(AltosConvert.height, state.height());
}
public Height (GridBagLayout layout, int y) {
super (layout, y, "Height");
@@ -251,7 +251,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Speed extends AscentValueHold {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.speed, state.speed);
+ show(AltosConvert.speed, state.speed());
}
public Speed (GridBagLayout layout, int y) {
super (layout, y, "Speed");
@@ -262,7 +262,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay {
class Accel extends AscentValueHold {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.accel, state.acceleration);
+ show(AltosConvert.accel, state.acceleration());
}
public Accel (GridBagLayout layout, int y) {
super (layout, y, "Acceleration");
diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java
index c96c815e..bcff393f 100644
--- a/altosui/AltosCSV.java
+++ b/altosui/AltosCSV.java
@@ -127,12 +127,12 @@ public class AltosCSV implements AltosWriter {
void write_basic(AltosState state) {
out.printf("%8.2f,%10.2f,%8.2f,%8.2f,%8.2f,%8.2f,%5.1f,%5.2f,%5.2f,%5.2f",
- state.acceleration,
- state.pressure,
- state.altitude,
- state.height,
- state.speed,
- state.speed,
+ state.acceleration(),
+ state.pressure(),
+ state.altitude(),
+ state.height(),
+ state.speed(),
+ state.speed(),
state.temperature,
state.battery_voltage,
state.apogee_voltage,
diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java
index 35efce16..e85717bb 100644
--- a/altosui/AltosDescent.java
+++ b/altosui/AltosDescent.java
@@ -245,7 +245,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Height extends DescentValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.height, state.height);
+ show(AltosConvert.height, state.height());
}
public Height (GridBagLayout layout, int x, int y) {
super (layout, x, y, "Height");
@@ -256,7 +256,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay {
class Speed extends DescentValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.speed, state.speed);
+ show(AltosConvert.speed, state.speed());
}
public Speed (GridBagLayout layout, int x, int y) {
super (layout, x, y, "Speed");
diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java
index 7a750c86..c894c2d0 100644
--- a/altosui/AltosDisplayThread.java
+++ b/altosui/AltosDisplayThread.java
@@ -92,14 +92,14 @@ public class AltosDisplayThread extends Thread {
state.range >= 0)
{
voice.speak("Height %s, bearing %s %d, elevation %d, range %s.\n",
- AltosConvert.height.say(state.height),
+ AltosConvert.height.say(state.height()),
state.from_pad.bearing_words(
AltosGreatCircle.BEARING_VOICE),
(int) (state.from_pad.bearing + 0.5),
(int) (state.elevation + 0.5),
AltosConvert.distance.say(state.range));
} else if (state.state > Altos.ao_flight_pad) {
- voice.speak(AltosConvert.height.say_units(state.height));
+ voice.speak(AltosConvert.height.say_units(state.height()));
} else {
reported_landing = 0;
}
@@ -113,7 +113,7 @@ public class AltosDisplayThread extends Thread {
System.currentTimeMillis() - state.received_time >= 15000 ||
state.state == Altos.ao_flight_landed))
{
- if (Math.abs(state.speed) < 20 && state.height < 100)
+ if (Math.abs(state.speed()) < 20 && state.height() < 100)
voice.speak("rocket landed safely");
else
voice.speak("rocket may have crashed");
@@ -185,12 +185,12 @@ public class AltosDisplayThread extends Thread {
if ((old_state == null || old_state.state <= Altos.ao_flight_boost) &&
state.state > Altos.ao_flight_boost) {
voice.speak("max speed: %s.",
- AltosConvert.speed.say_units(state.max_speed + 0.5));
+ AltosConvert.speed.say_units(state.max_speed() + 0.5));
ret = true;
} else if ((old_state == null || old_state.state < Altos.ao_flight_drogue) &&
state.state >= Altos.ao_flight_drogue) {
voice.speak("max height: %s.",
- AltosConvert.height.say_units(state.max_height + 0.5));
+ AltosConvert.height.say_units(state.max_height() + 0.5));
ret = true;
}
}
diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java
index 50deb6c8..f278012f 100644
--- a/altosui/AltosFlightStats.java
+++ b/altosui/AltosFlightStats.java
@@ -51,7 +51,7 @@ public class AltosFlightStats {
if (state == null)
return 0;
- double landed_height = state.height;
+ double landed_height = state.height();
state = null;
@@ -62,10 +62,10 @@ public class AltosFlightStats {
for (AltosState s : states) {
state = s;
- if (state.height > landed_height + 10) {
+ if (state.height() > landed_height + 10) {
above = true;
} else {
- if (above && state.height < landed_height + 2) {
+ if (above && state.height() < landed_height + 2) {
above = false;
landed_time = state.time;
}
@@ -82,7 +82,7 @@ public class AltosFlightStats {
for (AltosState s : states) {
state = s;
- if (state.acceleration < 1)
+ if (state.acceleration() < 1)
boost_time = state.time;
if (state.state >= Altos.ao_flight_boost)
break;
@@ -131,16 +131,16 @@ public class AltosFlightStats {
second = state.gps.second;
}
if (0 <= state.state && state.state < Altos.ao_flight_invalid) {
- state_accel[state.state] += state.acceleration;
- state_speed[state.state] += state.speed;
+ state_accel[state.state] += state.acceleration();
+ state_speed[state.state] += state.speed();
state_count[state.state]++;
if (state_start[state.state] == 0.0)
state_start[state.state] = state.time;
if (state_end[state.state] < state.time)
state_end[state.state] = state.time;
- max_height = state.max_height;
- max_speed = state.max_speed;
- max_acceleration = state.max_acceleration;
+ max_height = state.max_height();
+ max_speed = state.max_speed();
+ max_acceleration = state.max_acceleration();
}
if (state.gps != null && state.gps.locked && state.gps.nsat >= 4) {
if (state.state <= Altos.ao_flight_pad) {
diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java
index f8a2d4de..b5a92683 100644
--- a/altosui/AltosFlightStatsTable.java
+++ b/altosui/AltosFlightStatsTable.java
@@ -76,15 +76,15 @@ public class AltosFlightStatsTable extends JComponent {
int y = 0;
new FlightStat(layout, y++, "Serial", String.format("%d", stats.serial));
new FlightStat(layout, y++, "Flight", String.format("%d", stats.flight));
- if (stats.year > 0 && stats.hour > 0)
+ if (stats.year != AltosRecord.MISSING && stats.hour != AltosRecord.MISSING)
new FlightStat(layout, y++, "Date/Time",
String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day),
String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second));
else {
- if (stats.year > 0)
+ if (stats.year != AltosRecord.MISSING)
new FlightStat(layout, y++, "Date",
String.format("%04d-%02d-%02d", stats.year, stats.month, stats.day));
- if (stats.hour > 0)
+ if (stats.hour != AltosRecord.MISSING)
new FlightStat(layout, y++, "Time",
String.format("%02d:%02d:%02d UTC", stats.hour, stats.minute, stats.second));
}
diff --git a/altosui/AltosGraphDataPoint.java b/altosui/AltosGraphDataPoint.java
index 537efc44..85a19b00 100644
--- a/altosui/AltosGraphDataPoint.java
+++ b/altosui/AltosGraphDataPoint.java
@@ -52,13 +52,13 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
double y = AltosRecord.MISSING;
switch (index) {
case data_height:
- y = state.height;
+ y = state.height();
break;
case data_speed:
y = state.speed();
break;
case data_accel:
- y = state.acceleration;
+ y = state.acceleration();
break;
case data_temp:
y = state.temperature;
@@ -97,7 +97,7 @@ public class AltosGraphDataPoint implements AltosUIDataPoint {
y = state.from_pad.distance;
break;
case data_pressure:
- y = state.pressure;
+ y = state.pressure();
break;
}
if (y == AltosRecord.MISSING)
diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java
index 8906920b..cf4642bc 100644
--- a/altosui/AltosInfoTable.java
+++ b/altosui/AltosInfoTable.java
@@ -107,22 +107,22 @@ public class AltosInfoTable extends JTable {
public void show(AltosState state, AltosListenerState listener_state) {
info_reset();
if (state != null) {
- if (state.altitude != AltosRecord.MISSING)
- info_add_row(0, "Altitude", "%6.0f m", state.altitude);
- if (state.ground_altitude != AltosRecord.MISSING)
- info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude);
- if (state.height != AltosRecord.MISSING)
- info_add_row(0, "Height", "%6.0f m", state.height);
- if (state.height != AltosRecord.MISSING)
- info_add_row(0, "Max height", "%6.0f m", state.max_height);
- if (state.acceleration != AltosRecord.MISSING)
- info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration);
- if (state.acceleration != AltosRecord.MISSING)
- info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration);
+ if (state.altitude() != AltosRecord.MISSING)
+ info_add_row(0, "Altitude", "%6.0f m", state.altitude());
+ if (state.ground_altitude() != AltosRecord.MISSING)
+ info_add_row(0, "Pad altitude", "%6.0f m", state.ground_altitude());
+ if (state.height() != AltosRecord.MISSING)
+ info_add_row(0, "Height", "%6.0f m", state.height());
+ if (state.max_height() != AltosRecord.MISSING)
+ info_add_row(0, "Max height", "%6.0f m", state.max_height());
+ if (state.acceleration() != AltosRecord.MISSING)
+ info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration());
+ if (state.max_acceleration() != AltosRecord.MISSING)
+ info_add_row(0, "Max acceleration", "%8.1f m/s²", state.max_acceleration());
if (state.speed() != AltosRecord.MISSING)
info_add_row(0, "Speed", "%8.1f m/s", state.speed());
- if (state.speed() != AltosRecord.MISSING)
- info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed);
+ if (state.max_speed() != AltosRecord.MISSING)
+ info_add_row(0, "Max Speed", "%8.1f m/s", state.max_speed());
if (state.temperature != AltosRecord.MISSING)
info_add_row(0, "Temperature", "%9.2f °C", state.temperature);
if (state.battery_voltage != AltosRecord.MISSING)
diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java
index b79f5c9e..8679178f 100644
--- a/altosui/AltosKML.java
+++ b/altosui/AltosKML.java
@@ -110,8 +110,8 @@ public class AltosKML implements AltosWriter {
AltosGPS gps = state.gps;
double altitude;
- if (state.height != AltosRecord.MISSING)
- altitude = state.height + gps_start_altitude;
+ if (state.height() != AltosRecord.MISSING)
+ altitude = state.height() + gps_start_altitude;
else
altitude = gps.alt;
out.printf(kml_coord_fmt,
diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java
index 4cdaa3df..630527a0 100644
--- a/altosui/AltosLanded.java
+++ b/altosui/AltosLanded.java
@@ -163,7 +163,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
class Height extends LandedValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.height, state.max_height);
+ show(AltosConvert.height, state.max_height());
}
public Height (GridBagLayout layout, int y) {
super (layout, y, "Maximum Height");
@@ -185,7 +185,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio
class Accel extends LandedValue {
void show (AltosState state, AltosListenerState listener_state) {
- show(AltosConvert.accel, state.max_acceleration);
+ show(AltosConvert.accel, state.max_acceleration());
}
public Accel (GridBagLayout layout, int y) {
super (layout, y, "Maximum Acceleration");
diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java
index 151f68fd..31d5a54d 100644
--- a/altosui/AltosUI.java
+++ b/altosui/AltosUI.java
@@ -521,7 +521,7 @@ public class AltosUI extends AltosUIFrame {
System.out.printf ("process cat\n");
for (AltosState state : eef) {
System.out.printf ("tick %d state %d height %g\n",
- state.tick, state.state, state.height);
+ state.tick, state.state, state.height());
if ((state.set & AltosState.set_gps) != 0)
System.out.printf ("time %g lat %g lon %g alt %g\n",
state.time_since_boost(),