diff --git a/sw/ground_segment/tmtc/messages.ml b/sw/ground_segment/tmtc/messages.ml index c46aad1653..47a183d0ae 100644 --- a/sw/ground_segment/tmtc/messages.ml +++ b/sw/ground_segment/tmtc/messages.ml @@ -26,7 +26,7 @@ open Printf -let update_delay = 1. (* Min time in second before two updates *) +let update_delay = 0.25 (* Min time in second before two updates *) let led_delay = 500 (* Time in milliseconds while the green led is displayed *) @@ -36,37 +36,6 @@ let (//) = Filename.concat let xml_file = Env.paparazzi_src // "conf" // "messages.xml" -let green = "#00e000" -let red = "#ff0000" -let black = "#000000" -let yellow = "#ffff00" - -let led2 color1 color2 = [| - "16 16 5 1"; - " c None"; - ". c black"; - "X c white"; - "o c "^color1; - "O c "^color2; - " ...... "; - " ........XX "; - " ...ooooooXXX "; - " ..ooooooooooXX "; - " ..oooXXXooooXX "; - "..oooXXXooooooXX"; - "..ooXXooooooooXX"; - "..ooXXooooooooXX"; - "..ooXoooooooooXX"; - "..ooooooooooooXX"; - "..ooooooooooooXX"; - " ..ooooooooooXX "; - " ..ooooooooooXX "; - " ...ooooooXXX "; - " ..XXXXXXXX "; - " XXXXXX "|] - -let led color = led2 color "None" - let format = fun field -> try match Xml.attrib field "type", Xml.attrib field "format" with @@ -100,21 +69,17 @@ let _ = let notebook = GPack.notebook ~packing:window#add ~tab_pos:`TOP () in - let pm = fun color -> - GDraw.pixmap_from_xpm_d ~data:(led color) ~window:window () in - let black_led = pm black - and green_led = pm green - and yellow_led = pm yellow - and red_led = pm red in let one_page = fun (notebook:GPack.notebook) bind m -> let id = (Xml.attrib m "name") in let h = GPack.hbox () in let v = GPack.vbox ~width:200 () in let l = GMisc.label ~text:id ~packing:h#add () in - let led = GMisc.pixmap black_led ~packing:h#pack () in - let time = GMisc.label ~text:"___" ~packing:h#pack () in - notebook#append_page ~tab_label:h#coerce v#coerce; + let eb = GBin.event_box ~packing:h#pack () in + let time = GMisc.label ~width:40 ~packing:eb#add () in + eb#coerce#misc#modify_bg [`SELECTED, `NAME "green"]; + notebook#append_page ~tab_label:h#coerce v#coerce; + let page_num = notebook#page_num v#coerce in let fields = List.fold_left (fun rest f -> @@ -125,8 +90,9 @@ let one_page = fun (notebook:GPack.notebook) bind m -> let _ = GMisc.label ~text:name ~packing:h#pack () in let l = GMisc.label ~text:"XXXX" ~packing:h#pack () in let update = fun (a, x) -> - let fx = Pprz.string_of_value x in - if l#label <> fx then l#set_text fx in + if notebook#current_page = page_num then + let fx = Pprz.string_of_value x in + if l#label <> fx then l#set_text fx in update::rest with _ -> @@ -139,7 +105,10 @@ let one_page = fun (notebook:GPack.notebook) bind m -> let n = List.length fields in let last_update = ref (Unix.gettimeofday ()) in let time_since_last = ref 0 in - ignore (GMain.Timeout.add 1000 (fun () -> incr time_since_last; time#set_text (sprintf "%2d" !time_since_last); true)); + let update_time = fun () -> + incr time_since_last; + time#set_text (sprintf "%2d" !time_since_last); true in + ignore (GMain.Timeout.add 1000 update_time); let display = fun sender values -> time_since_last := 0; let t = Unix.gettimeofday () in @@ -148,16 +117,15 @@ let one_page = fun (notebook:GPack.notebook) bind m -> try List.iter2 (fun f x -> f x) fields (List.rev values); - led#set_pixmap green_led; - ignore (GMain.Timeout.add led_delay (fun () -> led#set_pixmap yellow_led; false)) + eb#coerce#misc#set_state `SELECTED; + ignore (GMain.Timeout.add led_delay (fun () -> eb#coerce#misc#set_state `NORMAL; false)) with Invalid_argument "List.iter2" -> - led#set_pixmap red_led; Printf.fprintf stderr "%s: expected %d, got %d\n" id n (List.length values); flush stderr end in ignore (bind id display); - (id, (led, fields)) in + (id, fields) in let xml_classes = diff --git a/sw/simulator/sim_ap.c b/sw/simulator/sim_ap.c index b1e9af2bf2..2d00be98b4 100644 --- a/sw/simulator/sim_ap.c +++ b/sw/simulator/sim_ap.c @@ -41,9 +41,21 @@ value sim_periodic_task(value unit) { return Val_unit; } +static int radio_status = 1; +static int radio_really_lost; + +value set_radio_status(value on) { + radio_status = Int_val(on); + if (! radio_status) radio_really_lost = FALSE; +} + + +value set_really_lost(value on) { + radio_really_lost = Int_val(on); +} value sim_rc_task(value unit) { - from_fbw.status = (1 << STATUS_RADIO_OK) | (1 << AVERAGED_CHANNELS_SENT); + from_fbw.status = (radio_status << STATUS_RADIO_OK) | (radio_really_lost << RADIO_REALLY_LOST) | (1 << AVERAGED_CHANNELS_SENT); link_fbw_receive_valid = TRUE; radio_control_task(); return Val_unit; diff --git a/sw/simulator/sitl.ml b/sw/simulator/sitl.ml index 8e5acc6157..d6a874b3d5 100644 --- a/sw/simulator/sitl.ml +++ b/sw/simulator/sitl.ml @@ -78,19 +78,23 @@ module Make(A:Data.MISSION) = struct (* Radio command handling *) external update_channel : int -> float -> unit = "update_rc_channel" + external set_radio_status : bool -> unit = "set_radio_status" + external set_really_lost : bool -> unit = "set_really_lost" let inverted = ["ROLL"; "PITCH"; "YAW"; "GAIN1"; "GAIN2"] let rc = fun () -> let name = Xml.attrib A.ac.Data.radio "name" ^ " " ^ A.ac.Data.name in - let window = GWindow.window ~title:name ~border_width:0 ~width:400 ~height:400 () in + let window = GWindow.window ~title:name ~border_width:0 ~width:200 ~height:400 () in let quit = fun () -> GMain.Main.quit (); exit 0 in ignore (window#connect#destroy ~callback:quit); - let vbox = GPack.vbox ~packing:window#add () in + let vbox = GPack.vbox ~height:10 ~spacing: 1 ~border_width: 1 ~packing:window#add () in + let on_off = GButton.check_button ~label:"On" ~active:true ~packing:vbox#pack () in + let sliders = GPack.vbox ~packing:vbox#add () in Array.iteri (fun i c -> let adj = GData.adjustment ~value:0. ~lower:(-100.) ~upper:110. ~step_incr:1.0 () in - let hbox = GPack.hbox ~packing:vbox#add () in + let hbox = GPack.hbox ~packing:sliders#add () in let f = (ExtXml.attrib c "function") in let l = GMisc.label ~width:75 ~text:f ~packing:hbox#pack () in let inv = List.mem f inverted in @@ -100,7 +104,15 @@ module Make(A:Data.MISSION) = struct ignore (adj#connect#value_changed update); update ()) rc_channels; + ignore (on_off#connect#toggled (fun () -> sliders#coerce#misc#set_sensitive on_off#active; set_radio_status on_off#active)); + let monitor_on_off = + let t = ref 0 in + fun () -> + incr t; + if on_off#active then t := 0; + set_really_lost (!t > 2) in + periodic 1000 monitor_on_off; window#show () external periodic_task : unit -> unit = "sim_periodic_task"