telemetry status indicator in strip

This commit is contained in:
Pascal Brisset
2006-08-01 12:48:46 +00:00
parent c60ce87b6d
commit 5e2507895a
8 changed files with 51 additions and 9 deletions
+8
View File
@@ -601,8 +601,16 @@
<field name="west_long" type="float" unit="deg"/>
<field name="south_lat" type="float" unit="deg"/>
</message>
<message name="TELEMETRY_STATUS" ID="32">
<field name="ac_id" type="uint8"/>
<field name="time_since_last_bat_msg" type="float" unit="s"/>
</message>
</class>
<class name="alert">
<message name="BAT_LOW" ID="1">
<field name="ac_id" type="string"/>
+1
View File
@@ -575,6 +575,7 @@ let _main =
Live.listen_waypoint_moved ();
Live.listen_infrared ();
Live.listen_svsinfo ();
Live.listen_telemetry_status ();
Live.listen_alert my_alert;
(** Display the window *)
+10
View File
@@ -643,3 +643,13 @@ let get_svsinfo = fun _sender vs ->
let listen_svsinfo = fun () -> safe_bind "SVSINFO" get_svsinfo
let message_request = Ground_Pprz.message_req
let get_ts = fun _sender vs ->
let ac = get_ac vs in
let t = Pprz.float_assoc "time_since_last_bat_msg" vs in
Strip.set_label ac.strip "telemetry_status" (if t > 2. then sprintf "%.1f" t else " ");
Strip.set_color ac.strip "telemetry_status" (if t > 5. then "red" else "green")
let listen_telemetry_status = fun () ->
safe_bind "TELEMETRY_STATUS" get_ts
+1
View File
@@ -13,3 +13,4 @@ val listen_waypoint_moved : unit -> unit
val listen_infrared : unit -> unit
val listen_svsinfo : unit -> unit
val listen_alert : < add : string -> unit; .. > -> unit
val listen_telemetry_status : unit -> unit
+11 -3
View File
@@ -38,6 +38,8 @@ let add config color select center_ac commit_moves mark =
let ac_name = Pprz.string_assoc "ac_name" config in
let tooltips = GData.tooltips () in
(* frame of the strip *)
let frame = GBin.frame ~shadow_type: `IN ~packing: (widget#attach ~top: (strip_number) ~left: 0) () in
let strip = GPack.table ~rows:2 ~columns: 2 ~col_spacings: 10 ~packing: frame#add () in
@@ -53,12 +55,18 @@ let add config color select center_ac commit_moves mark =
let block_name = GMisc.label ~text: "______" ~packing:h#add () in
add_label ("block_name_value") (plane_color, block_name);
(* battery and flight time *)
let pb = GRange.progress_bar ~orientation: `BOTTOM_TO_TOP ~packing:(strip#attach ~top:1 ~left:0) () in
(* battery and telemetry status *)
let vb = GPack.vbox ~packing:(strip#attach ~top:1 ~left:0) () in
let pb = GRange.progress_bar ~orientation: `BOTTOM_TO_TOP ~packing:vb#add () in
pb#misc#set_size_request ~height:50 ();
pb#coerce#misc#modify_fg [`PRELIGHT, `NAME "green"];
pb#coerce#misc#modify_font_by_name "sans 12";
let eb = GBin.event_box ~packing:vb#add () in
let ts = GMisc.label ~text:"N/A" ~packing:eb#add () in
add_label "telemetry_status_value" (eb, ts);
tooltips#set_tip eb#coerce ~text:"Telemetry status\nGreen if time since last bat message < 5s";
let left_box = GPack.table ~rows ~columns: 6 ~col_spacings: 5
~packing: (strip#attach ~top: 1 ~left: 1) () in
+2 -1
View File
@@ -116,5 +116,6 @@ type aircraft = {
mutable horiz_mode : horiz_mode;
dl_setting_values : float array;
mutable nb_dl_setting_values : int;
mutable survey : (Latlong.geographic * Latlong.geographic) option
mutable survey : (Latlong.geographic * Latlong.geographic) option;
mutable last_bat_msg_date : float
}
+2 -1
View File
@@ -103,5 +103,6 @@ type aircraft = {
mutable horiz_mode : horiz_mode;
dl_setting_values : float array;
mutable nb_dl_setting_values : int;
mutable survey : (Latlong.geographic * Latlong.geographic) option
mutable survey : (Latlong.geographic * Latlong.geographic) option;
mutable last_bat_msg_date : float
}
+14 -2
View File
@@ -189,6 +189,7 @@ let log_and_parse = fun logging ac_name a msg values ->
a.cur_stage <- ivalue "cur_stage";
a.desired_course <- norm_course ((Deg>>Rad)(fvalue "desired_course" /. 10.));
| "BAT" ->
a.last_bat_msg_date <- U.gettimeofday ();
a.throttle <- fvalue "desired_gaz" /. 9600. *. 100.;
a.flight_time <- ivalue "flight_time";
a.rpm <- a.throttle *. 100.;
@@ -429,6 +430,16 @@ let send_wind = fun a ->
with
_exc -> ()
let send_telemetry_status = fun a ->
let id = a.id in
try
let vs =
["ac_id", Pprz.String id;
"time_since_last_bat_msg", Pprz.Float (U.gettimeofday () -. a.last_bat_msg_date)] in
Ground_Pprz.message_send my_id "TELEMETRY_STATUS" vs
with
_exc -> ()
let send_moved_waypoints = fun a ->
Hashtbl.iter
(fun wp_id wp ->
@@ -511,7 +522,8 @@ let send_aircraft_msg = fun ac ->
send_horiz_status a;
send_survey_status a;
send_dl_values a;
send_moved_waypoints a
send_moved_waypoints a;
send_telemetry_status a
with
Not_found -> prerr_endline ac
| x -> prerr_endline (Printexc.to_string x)
@@ -539,7 +551,7 @@ let new_aircraft = fun id ->
flight_time = 0; stage_time = 0; block_time = 0;
horiz_mode = UnknownHorizMode;
horizontal_mode = 0;
waypoints = Hashtbl.create 3; survey = None
waypoints = Hashtbl.create 3; survey = None; last_bat_msg_date = 0.
}
let check_alerts = fun a ->