mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
[ground_segment] represent unconfirmed settings with infinity
proposal to fix #1012: - server: represent initial/unknown/unconfirmed settings with infinity - page_settings: set label text to "?" upon commit and on update if value is "inf", also set label to "?"
This commit is contained in:
@@ -36,10 +36,14 @@ object
|
|||||||
let (alt_a, alt_b) = Ocaml_tools.affine_transform auc in
|
let (alt_a, alt_b) = Ocaml_tools.affine_transform auc in
|
||||||
(float_of_string current_value#text -. alt_b) /. alt_a
|
(float_of_string current_value#text -. alt_b) /. alt_a
|
||||||
method update = fun s ->
|
method update = fun s ->
|
||||||
if current_value#text <> s then begin
|
(* value of infinity (string "inf") means it is not yet confirmed, so display "?" *)
|
||||||
current_value#set_text s;
|
if s = "inf" then
|
||||||
try set_default (float_of_string s) with Failure "float_of_string" -> ()
|
current_value#set_text "?"
|
||||||
end
|
else
|
||||||
|
if current_value#text <> s then begin
|
||||||
|
current_value#set_text s;
|
||||||
|
try set_default (float_of_string s) with Failure "float_of_string" -> ()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
let pipe_regexp = Str.regexp "|"
|
let pipe_regexp = Str.regexp "|"
|
||||||
@@ -199,7 +203,8 @@ let one_setting = fun (i:int) (do_change:int -> float -> unit) packing dl_settin
|
|||||||
let _icon = GMisc.image ~stock:`APPLY ~packing:commit_but#add () in
|
let _icon = GMisc.image ~stock:`APPLY ~packing:commit_but#add () in
|
||||||
let callback = fun x ->
|
let callback = fun x ->
|
||||||
prev_value := (try Some ((float_of_string current_value#text-.alt_b)/.alt_a) with _ -> None);
|
prev_value := (try Some ((float_of_string current_value#text-.alt_b)/.alt_a) with _ -> None);
|
||||||
commit x
|
commit x;
|
||||||
|
current_value#set_text "?"
|
||||||
in
|
in
|
||||||
ignore (commit_but#connect#clicked ~callback);
|
ignore (commit_but#connect#clicked ~callback);
|
||||||
tooltips#set_tip commit_but#coerce ~text:"Commit";
|
tooltips#set_tip commit_but#coerce ~text:"Commit";
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ let new_aircraft = fun id name fp airframe ->
|
|||||||
cam = { phi = 0.; theta = 0. ; target=(0.,0.)};
|
cam = { phi = 0.; theta = 0. ; target=(0.,0.)};
|
||||||
fbw = { rc_status = "???"; rc_mode = "???"; rc_rate=0; pprz_mode_msgs_since_last_fbw_status_msg=0 };
|
fbw = { rc_status = "???"; rc_mode = "???"; rc_rate=0; pprz_mode_msgs_since_last_fbw_status_msg=0 };
|
||||||
svinfo = svsinfo_init;
|
svinfo = svsinfo_init;
|
||||||
dl_setting_values = Array.create max_nb_dl_setting_values 42.;
|
dl_setting_values = Array.create max_nb_dl_setting_values infinity;
|
||||||
nb_dl_setting_values = 0;
|
nb_dl_setting_values = 0;
|
||||||
horiz_mode = UnknownHorizMode;
|
horiz_mode = UnknownHorizMode;
|
||||||
horizontal_mode = 0;
|
horizontal_mode = 0;
|
||||||
|
|||||||
@@ -677,7 +677,11 @@ let setting = fun logging _sender vs ->
|
|||||||
"ac_id", Pprz.String ac_id;
|
"ac_id", Pprz.String ac_id;
|
||||||
"value", List.assoc "value" vs] in
|
"value", List.assoc "value" vs] in
|
||||||
Dl_Pprz.message_send dl_id "SETTING" vs;
|
Dl_Pprz.message_send dl_id "SETTING" vs;
|
||||||
log logging ac_id "SETTING" vs
|
log logging ac_id "SETTING" vs;
|
||||||
|
(* mark the setting as not yet confirmed *)
|
||||||
|
let ac = Hashtbl.find aircrafts ac_id in
|
||||||
|
let idx = Pprz.int_of_value (List.assoc "index" vs) in
|
||||||
|
ac.dl_setting_values.(idx) <- infinity
|
||||||
|
|
||||||
|
|
||||||
(** Got a GET_DL_SETTING, and send an GET_SETTING *)
|
(** Got a GET_DL_SETTING, and send an GET_SETTING *)
|
||||||
|
|||||||
Reference in New Issue
Block a user