diff --git a/sw/ground_segment/tmtc/messages.ml b/sw/ground_segment/tmtc/messages.ml index 5223c11129..e12253a037 100644 --- a/sw/ground_segment/tmtc/messages.ml +++ b/sw/ground_segment/tmtc/messages.ml @@ -57,12 +57,14 @@ let one_page = fun sender class_name (notebook:GPack.notebook) bind m -> try let unit = try "("^Xml.attrib f "unit"^")" with _ -> "" in let field_name = Xml.attrib f "name" in - let name = Printf.sprintf "%s %s %s: " (ExtXml.attrib f "type") field_name unit in + let type_ = ExtXml.attrib f "type" in + let name = Printf.sprintf "%s %s %s: " type_ field_name unit in let h = GPack.hbox ~packing:v#pack () in let field_label = GButton.button ~label:name ~packing:h#pack () in + let value = ref "XXXX" in let l = GMisc.label ~text: !value ~packing:h#pack () in - let values = values_of_field f in + let literal_values = values_of_field f in let alt_value = try let coeff = ExtXml.float_attrib f "alt_unit_coef" @@ -74,7 +76,7 @@ let one_page = fun sender class_name (notebook:GPack.notebook) bind m -> value := try let i = Pprz.int_of_value x in - sprintf "%s (%d)" values.(i) i + sprintf "%s (%d)" literal_values.(i) i with _ -> alt_value (Pprz.string_of_value x) and display_value = fun () -> @@ -85,7 +87,14 @@ let one_page = fun sender class_name (notebook:GPack.notebook) bind m -> field_label#drag#source_set dnd_targets ~modi:[`BUTTON1] ~actions:[`COPY]; let data_get = fun _ (sel:GObj.selection_context) ~info ~time -> let scale = ExtXml.attrib_or_default f "alt_unit_coef" "1" in - sel#return (sprintf "%s:%s:%s:%s:%s" sender class_name id field_name scale) in + let field_descr = + if Pprz.is_array_type type_ then + match GToolbox.input_string ~title:"Index of value to drag" ~text:"0" "Index in the array ?" with + None -> field_name + | Some i -> sprintf "%s[%s]" field_name i + else + field_name in + sel#return (sprintf "%s:%s:%s:%s:%s" sender class_name id field_descr scale) in ignore (field_label#drag#connect#data_get ~callback:data_get); (update, display_value)::rest diff --git a/sw/lib/ocaml/pprz.mli b/sw/lib/ocaml/pprz.mli index 404f8e4809..fd0256e4e8 100644 --- a/sw/lib/ocaml/pprz.mli +++ b/sw/lib/ocaml/pprz.mli @@ -56,6 +56,8 @@ external int32_of_bytes : string -> int -> int32 = "c_int32_of_indexed_bytes" val separator : string (** Separator in array values *) +val is_array_type : string -> bool + val size_of_field : field -> int val string_of_value : value -> string val int_of_value : value -> int (* May raise Invalid_argument *) diff --git a/sw/logalizer/plotter.ml b/sw/logalizer/plotter.ml index 14f34457d8..cdbb1241ca 100644 --- a/sw/logalizer/plotter.ml +++ b/sw/logalizer/plotter.ml @@ -299,7 +299,7 @@ let default_window = {title="Plotter"; geometry=""; curves=[]} (** [index_of_fields s] Returns i if s matches x[i] else 0. *) let base_and_index = - let field_regexp = Str.regexp "\\([^\\.]+\\)\\.\\[\\([0-9]+\\)\\]" in + let field_regexp = Str.regexp "\\([^\\.]+\\)\\[\\([0-9]+\\)\\]" in fun field_descr -> if Str.string_match field_regexp field_descr 0 then ( Str.matched_group 1 field_descr,