diff --git a/sw/simulator/flightModel.ml b/sw/simulator/flightModel.ml index 4f2f26a502..0920f171d9 100644 --- a/sw/simulator/flightModel.ml +++ b/sw/simulator/flightModel.ml @@ -56,6 +56,7 @@ let get_time state = state.t let get_attitude state = (state.phi, state.theta, state.psi) let set_air_speed state x = state.nominal_air_speed <- x +let get_air_speed state = state.nominal_air_speed let drag = 0.45 let g = 9.81 diff --git a/sw/simulator/flightModel.mli b/sw/simulator/flightModel.mli index aee0a751e2..1435a01dc0 100644 --- a/sw/simulator/flightModel.mli +++ b/sw/simulator/flightModel.mli @@ -35,6 +35,7 @@ val get_time : state -> float val get_attitude : state -> radian * radian * radian val set_air_speed : state -> meter_s -> unit +val get_air_speed : state -> meter_s module Make : functor (A : Data.MISSION) -> diff --git a/sw/simulator/sim.ml b/sw/simulator/sim.ml index 620e04cf76..8898b17e0d 100644 --- a/sw/simulator/sim.ml +++ b/sw/simulator/sim.ml @@ -231,21 +231,40 @@ module Make(AircraftItl : AIRCRAFT_ITL) = struct let take_off = fun () -> FlightModel.set_air_speed !state FM.nominal_airspeed in let hbox = GPack.hbox ~spacing:4 ~packing:vbox#pack () in + let s = GButton.button ~label:"Set Pos" ~packing:hbox#pack () in + ignore (s#connect#clicked ~callback:set_pos); + + let set_pos_and_boot = fun () -> + s#misc#set_sensitive false; + boot () in + if not !autoboot then begin let s = GButton.button ~label:"Boot" ~packing:(hbox#pack) () in - ignore (s#connect#clicked ~callback:boot) + let callback = fun () -> + set_pos_and_boot (); + s#misc#set_sensitive false in + ignore (s#connect#clicked ~callback) end else - boot (); + set_pos_and_boot (); if not !autolaunch then begin let t = GButton.button ~label:"Launch" ~packing:hbox#pack () in - ignore (t#connect#clicked ~callback:take_off) + let callback = fun () -> + take_off (); + t#misc#set_sensitive false in + ignore (t#connect#clicked ~callback); + + (* Monitor an AUTO2 lauch to disable the button *) + let monitor = fun () -> + if FlightModel.get_air_speed !state > 0. then begin + t#misc#set_sensitive false; + false + end else + true in + ignore (GMain.Timeout.add 1000 monitor) end else take_off (); - let s = GButton.button ~label:"Set Pos" ~packing:hbox#pack () in - ignore (s#connect#clicked ~callback:set_pos); - let hbox = GPack.hbox ~packing:vbox#pack () in let l = fun s -> ignore(GMisc.label ~text:s ~packing:hbox#pack ()) in l "East:"; hbox#pack east_label#coerce;