diff --git a/sw/ground_segment/tmtc/messages.ml b/sw/ground_segment/tmtc/messages.ml index dee21fb56f..48c3dc7d27 100644 --- a/sw/ground_segment/tmtc/messages.ml +++ b/sw/ground_segment/tmtc/messages.ml @@ -93,15 +93,18 @@ let one_page = fun sender class_name (notebook:GPack.notebook) (help_label:GObj. field_label#drag#source_set dnd_targets ~modi:[`BUTTON1] ~actions:[`COPY]; let data_get = fun _ (sel:GObj.selection_context) ~info ~time -> let scale = Pprz.alt_unit_coef_of_xml ~auto:"display" f 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 + let v = List.hd (Str.split (Str.regexp " ") l#text) in (* get value *) + let nb = List.length (Str.split (Str.regexp ",") v) in (* get number of values if array *) + let range = if nb > 1 then sprintf "0-%d" (nb-1) else "0" in + if Pprz.is_array_type type_ then + match GToolbox.input_string ~title:"Index of value to drag" ~text:range "Index or range in the array ?" with + None -> () + | Some i -> sel#return (sprintf "%s:%s:%s:%s[%s]:%s" sender class_name id field_name i scale) else - field_name in - sel#return (sprintf "%s:%s:%s:%s:%s" sender class_name id field_descr scale) in + sel#return (sprintf "%s:%s:%s:%s:%s" sender class_name id field_name scale) + in ignore (field_label#drag#connect#data_get ~callback:data_get); + (* hide notebook and display help during drag *) let begin_drag = fun _ -> notebook#coerce#misc#hide (); diff --git a/sw/logalizer/plotter.ml b/sw/logalizer/plotter.ml index 977329efe9..02f615adbe 100644 --- a/sw/logalizer/plotter.ml +++ b/sw/logalizer/plotter.ml @@ -517,7 +517,28 @@ let rec plot_window = fun window -> let factor = Ocaml_tools.affine_transform factor#text in try let name = data#data in - add_curve ~factor name + let (sender, class_name, msg_name, field_descr, (a',b')) = parse_dnd name in + (* test if several curves need to be added with x[min-max] format *) + if Str.string_match (Str.regexp "\\([^\\.]+\\)\\[\\([0-9]+\\)-\\([0-9]+\\)\\]") field_descr 0 then + begin + (* get name and range in correct order *) + let field_name = Str.matched_group 1 field_descr + and min_range = int_of_string (Str.matched_group 2 field_descr) + and max_range = int_of_string (Str.matched_group 3 field_descr) in + let min_range, max_range = if min_range > max_range then + max_range, min_range + else + min_range, max_range + in + (* add all curves *) + for i = min_range to max_range do + let offset = if a' <> 0. then sprintf "+%.2f" b' else "" in + let name = (sprintf "%s:%s:%s:%s[%d]:%f%s" sender class_name msg_name field_name i a' offset) in + add_curve ~factor name + done + end + else + add_curve ~factor name with exc -> prerr_endline (Printexc.to_string exc) in