From 6eb14dcf8891a2ba31859cfe85be1de14609faf3 Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Thu, 16 Jul 2015 23:34:56 +0200 Subject: [PATCH 1/2] [pprz center] possibility to launch global commans from tools using $ prefix --- conf/control_panel_example.xml | 2 ++ sw/supervision/pc_control_panel.ml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/conf/control_panel_example.xml b/conf/control_panel_example.xml index 1bd85de39a5..d7ed08aa889 100644 --- a/conf/control_panel_example.xml +++ b/conf/control_panel_example.xml @@ -71,6 +71,8 @@ + + diff --git a/sw/supervision/pc_control_panel.ml b/sw/supervision/pc_control_panel.ml index 762fe59f4fe..3db4ff230ee 100644 --- a/sw/supervision/pc_control_panel.ml +++ b/sw/supervision/pc_control_panel.ml @@ -42,6 +42,8 @@ let program_command = fun x -> let cmd = ExtXml.attrib xml "command" in if cmd.[0] = '/' then cmd + else if cmd.[0] = '$' then + String.sub cmd 1 ((String.length cmd) - 1) else Env.paparazzi_src // cmd with Not_found -> From a224ba0aeb922f7a631211527636cd7aebee840c Mon Sep 17 00:00:00 2001 From: Felix Ruess Date: Fri, 17 Jul 2015 13:10:44 +0200 Subject: [PATCH 2/2] [pprz center] handle default prog args so that when you start a program via the tools menu, it will add the specified args. Also parses the @AIRCRAFT, @AC_ID updated control_panel_example.xml for some progs to make use of that. Removed the non working variables stuff... --- conf/control_panel_example.xml | 80 ++++++------------------------ sw/supervision/pc_control_panel.ml | 28 +++++++---- 2 files changed, 34 insertions(+), 74 deletions(-) diff --git a/conf/control_panel_example.xml b/conf/control_panel_example.xml index d7ed08aa889..659564fb223 100644 --- a/conf/control_panel_example.xml +++ b/conf/control_panel_example.xml @@ -2,101 +2,53 @@ -
- - - - - - -
-
- - - - + - + - - - - - - - - - - - + + + - + - - + - - - - - - - - - - - - - + + - - + + - - - - + + + + + - - - - - - - - - - - - - -
- - -
diff --git a/sw/supervision/pc_control_panel.ml b/sw/supervision/pc_control_panel.ml index 3db4ff230ee..429d5dfbd0d 100644 --- a/sw/supervision/pc_control_panel.ml +++ b/sw/supervision/pc_control_panel.ml @@ -36,6 +36,7 @@ let programs = (fun p -> Hashtbl.add h (ExtXml.attrib p "name") p) (Xml.children s); h + let program_command = fun x -> try let xml = Hashtbl.find programs x in @@ -236,22 +237,28 @@ let supervision = fun ?file gui log (ac_combo : Gtk_tools.combo) (target_combo : register_custom_sessions (); Gtk_tools.select_in_combo session_combo "Simulation"; - let execute_custom = fun session_name -> - let session = try Hashtbl.find sessions session_name with Not_found -> failwith (sprintf "Unknown session: %s" session_name) in + let get_program_args = fun program -> + let args = ref "" in List.iter - (fun program -> - let name = ExtXml.attrib program "name" in - let p = ref "" in - List.iter (fun arg -> let constant = match try double_quote (Xml.attrib arg "constant") with _ -> "" with "@AIRCRAFT" -> (Gtk_tools.combo_value ac_combo) | "@AC_ID" -> gui#entry_ac_id#text | const -> const in - p := sprintf "%s %s %s" !p (ExtXml.attrib arg "flag") constant) + args := sprintf "%s %s %s" !args (ExtXml.attrib arg "flag") constant) (Xml.children program); - run_and_monitor ?file gui log name !p) + !args + in + + + let execute_custom = fun session_name -> + let session = try Hashtbl.find sessions session_name with Not_found -> failwith (sprintf "Unknown session: %s" session_name) in + List.iter + (fun program -> + let name = ExtXml.attrib program "name" in + let args = get_program_args program in + run_and_monitor ?file gui log name args) (Xml.children session) in @@ -281,9 +288,10 @@ let supervision = fun ?file gui log (ac_combo : Gtk_tools.combo) (target_combo : (* Tools *) let entries = ref [] in Hashtbl.iter - (fun name _prog -> + (fun name prog -> let cb = fun () -> - run_and_monitor ?file gui log name "" in + let args = get_program_args prog in + run_and_monitor ?file gui log name args in entries := `I (name, cb) :: !entries) programs; let compare = fun x y ->