}
static void
-aoview_state_add_deg(char *label, double deg)
+aoview_state_add_deg(char *label, double deg, char pos, char neg)
{
double int_part;
double min;
+ char sign = pos;
+ if (deg < 0) {
+ deg = -deg;
+ sign = neg;
+ }
int_part = floor (deg);
min = (deg - int_part) * 60.0;
- aoview_table_add_row(label, "%d°%lf'",
- (int) int_part, min);
+ aoview_table_add_row(label, "%d°%lf'%c",
+ (int) int_part, min, sign);
+
+}
+
+static char *ascent_states[] = {
+ "boost",
+ "fast",
+ "coast",
+ 0,
+};
+
+void
+aoview_state_speak(struct aostate *state)
+{
+ static char last_state[32];
+ int i;
+ gboolean report = FALSE;
+ static time_t last_time;
+ time_t this_time;
+ static int last_altitude;
+ int this_altitude;
+
+ if (strcmp(state->state, last_state)) {
+ aoview_voice_speak("rocket state now %s\n", state->state);
+ if (!strcmp(state->state, "drogue"))
+ aoview_voice_speak("maximum altitude %d meters\n",
+ aoview_pres_to_altitude(min_pres) -
+ aoview_pres_to_altitude(state->ground_pres));
+ report = TRUE;
+ strcpy(last_state, state->state);
+ }
+ this_time = time(NULL);
+ this_altitude = aoview_pres_to_altitude(state->flight_pres) - aoview_pres_to_altitude(state->ground_pres);
+ if (this_time - last_time >= 10)
+ report = TRUE;
+ if (this_altitude / 1000 != last_altitude / 1000)
+ report = TRUE;
+
+ if (report) {
+ aoview_voice_speak("altitude %d meters\n",
+ this_altitude);
+ for (i = 0; ascent_states[i]; i++)
+ if (!strcmp(ascent_states[i], state->state)) {
+ aoview_voice_speak("speed %d meters per second\n",
+ state->flight_vel / 2700);
+ break;
+ }
+ }
+ last_time = this_time;
+ last_altitude = this_altitude;
}
void
aoview_table_add_row("Pad altitude", "%dm", aoview_pres_to_altitude(state->ground_pres));
aoview_table_add_row("Satellites", "%d", state->nsat);
if (state->locked) {
- aoview_state_add_deg("Latitude", state->lat);
- aoview_state_add_deg("Longitude", state->lon);
+ aoview_state_add_deg("Latitude", state->lat, 'N', 'S');
+ aoview_state_add_deg("Longitude", state->lon, 'E', 'W');
aoview_table_add_row("GPS alt", "%d", state->alt);
aoview_table_add_row("GPS time", "%02d:%02d:%02d",
state->gps_time.hour,
state->gps_time.minute,
state->gps_time.second);
+ aoview_table_add_row("GPS ground speed", "%fm/s %d°",
+ state->ground_speed,
+ state->course);
+ aoview_table_add_row("GPS climb rate", "%fm/s",
+ state->climb_rate);
+ aoview_table_add_row("GPS precision", "%f(hdop) %dm(h) %dm(v)\n",
+ state->hdop, state->h_error, state->v_error);
aoview_great_circle(pad_lat, pad_lon, state->lat, state->lon,
&dist, &bearing);
aoview_table_add_row("Distance from pad", "%gm", dist * 1000);
aoview_table_add_row("GPS", "unlocked");
}
if (npad_gps) {
- aoview_state_add_deg("Pad latitude", pad_lat);
- aoview_state_add_deg("Pad longitude", pad_lon);
+ aoview_state_add_deg("Pad latitude", pad_lat, 'N', 'S');
+ aoview_state_add_deg("Pad longitude", pad_lon, 'E', 'W');
aoview_table_add_row("Pad GPS alt", "%gm", pad_alt);
}
aoview_table_finish();
+ aoview_state_speak(state);
}
void
aoview_state_init(GladeXML *xml)
{
aoview_state_new();
+ aoview_voice_speak("initializing rocket flight monitoring system\n");
}