[sim] check targets and ask which simulator to use

This commit is contained in:
Gautier Hattenberger
2013-01-24 11:35:41 +01:00
parent 419f68b0f2
commit c3f63ca63b
5 changed files with 33 additions and 15 deletions

View File

@@ -68,6 +68,14 @@ let combo_value = fun ((combo: #GEdit.combo_box), (_,column)) ->
| None -> raise Not_found
| Some row -> combo#model#get ~row ~column
let combo_values_list = fun (combo : combo) ->
let (store, column) = combo_model combo in
let values = ref [] in
store#foreach (fun _ row ->
values := !values @ [store#get ~row ~column];
false);
!values
let combo_separator = "--"
let combo = fun strings vbox ->

View File

@@ -54,6 +54,7 @@ val add_to_combo : combo -> string -> unit
val combo_separator : string
val combo_value : combo -> string
val combo_values_list : combo -> string list
val select_in_combo : combo -> string -> unit
val combo_connect : combo -> (string -> unit) -> unit

View File

@@ -39,9 +39,9 @@ def main():
action="store",
help="aircraft name to use")
parser.add_option("-t", "--type", dest="simtype",
type='choice', choices=['simple_fw', 'jsbsim', 'nps'],
action="store", default="simple_fw",
help="Simlator type to start: simple_fw, jsbsim or nps (Default: %default)")
type='choice', choices=['sim', 'jsbsim', 'nps'],
action="store", default="sim",
help="Simlator type to start: sim, jsbsim or nps (Default: %default)")
parser.add_option("-b", "--ivy_bus", dest="ivy_bus", action="store",
help="Ivy Bus broadcast address.")
parser.add_option("-f", "--fg_host", dest="fg_host", action="store",
@@ -84,7 +84,7 @@ def main():
simargs = []
if options.simtype == "simple_fw":
if options.simtype == "sim":
simdir = "sim"
if options.boot:
simargs.append("-boot")

View File

@@ -236,7 +236,7 @@ let () =
AC.build_handler ~file gui ac_combo target_combo log;
let session_combo, execute_session = CP.supervision ~file gui log ac_combo in
let session_combo, execute_session = CP.supervision ~file gui log ac_combo target_combo in
(* Quit button *)
ignore (gui#menu_item_quit#connect#activate ~callback:(quit_button_callback gui ac_combo session_combo target_combo));

View File

@@ -141,27 +141,36 @@ let double_quote = fun s ->
else
s
let get_simtype = fun () ->
match GToolbox.question_box ~title:"Simulator type" ~buttons:["Simple (fixedwing)"; "JSBSim"; "NPS (rotorcraft)"] "Choose the simulator type:" with
1 -> "simple_fw"
| 2 -> "jsbsim"
| 3 -> "nps"
| _ -> "none"
let get_simtype = fun (target_combo : Gtk_tools.combo) ->
(* get the list of possible targets *)
let targets = Gtk_tools.combo_values_list target_combo in
(* filter non simulator targets *)
let sim_targets = ["sim"; "jsbsim"; "nps"] in
let targets = List.filter (fun t -> List.mem t sim_targets) targets in
(* open question box and return corresponding simulator type *)
match targets with
[] -> "none"
| [t] -> t
| l ->
match GToolbox.question_box ~title:"Simulator type" ~buttons:l "Choose the simulator type:" with
| 0 -> "none"
| choice -> List.nth targets (choice-1)
let supervision = fun ?file gui log (ac_combo : Gtk_tools.combo) ->
let supervision = fun ?file gui log (ac_combo : Gtk_tools.combo) (target_combo : Gtk_tools.combo) ->
let run_gcs = fun () ->
run_and_monitor ?file gui log "GCS" ""
and run_server = fun args ->
run_and_monitor ?file gui log "Server" args
and run_sitl = fun ac_name ->
let get_args = fun simtype ac_name->
let get_args = fun simtype ac_name ->
match simtype with
"simple_fw" -> sprintf "-a %s -t %s --boot --norc" ac_name simtype
"sim" -> sprintf "-a %s -t %s --boot --norc" ac_name simtype
| "jsbsim" -> sprintf "-a %s -t %s" ac_name simtype
| "nps" -> sprintf "-a %s -t %s" ac_name simtype
| _ -> sprintf "-a %s" ac_name
in
let sim_type = get_simtype () in
let sim_type = get_simtype target_combo in
prerr_endline sim_type;
let args = get_args sim_type ac_name in
run_and_monitor ?file gui log "Simulator" args
in