diff --git a/Makefile.install b/Makefile.install index dba706c4c5..50342ea339 100644 --- a/Makefile.install +++ b/Makefile.install @@ -7,7 +7,8 @@ DESTDIR=$(PREFIX)/usr/share/paparazzi INSTALL=install -o root INSTALLDATA=install -o root -m 644 -install : install_files post_install +install : install_files +# post_install install_files: install_data install_conf install_bin install_libs install_tools install_airborne_sources diff --git a/sw/ground_segment/cockpit/Makefile b/sw/ground_segment/cockpit/Makefile index c497be2f21..0b09e50456 100644 --- a/sw/ground_segment/cockpit/Makefile +++ b/sw/ground_segment/cockpit/Makefile @@ -27,11 +27,11 @@ OCAMLC=ocamlc OCAMLCFLAGS=-thread OCAMLOPT=ocamlopt OCAMLOPTFLAGS=-thread -INCLUDES=-I +lablgtk2 -I ../../lib/ocaml -I +xml-light -LIBS=glibivy-ocaml.cma lablgtk.cma lablglade.cma lib-pprz.cma lablgnomecanvas.cma xlib-pprz.cma +INCLUDES=-I +lablgtk2 -I ../../lib/ocaml -I +xml-light -I +netstring -I +pcre +LIBS=pcre.cma netstring.cma glibivy-ocaml.cma lablgtk.cma lablglade.cma lib-pprz.cma lablgnomecanvas.cma xlib-pprz.cma CMXA=$(LIBS:.cma=.cmxa) -ML= gtk_setting_time.ml gtk_strip.ml horizon.ml strip.ml pages.ml speech.ml plugin.ml sectors.ml map2d.ml editFP.ml live.ml particules.ml gcs.ml +ML= gtk_setting_time.ml gtk_strip.ml horizon.ml strip.ml gtk_save_settings.ml saveSettings.ml pages.ml speech.ml plugin.ml sectors.ml map2d.ml editFP.ml live.ml particules.ml gcs.ml MAIN=gcs CMO=$(ML:.ml=.cmo) CMX=$(ML:.ml=.cmx) @@ -65,6 +65,9 @@ gtk_strip.ml : gcs.glade gtk_setting_time.ml : gcs.glade lablgladecc2 -root setting_time -hide-default $< | grep -B 1000000 " end" > $@ +gtk_save_settings.ml : gcs.glade + lablgladecc2 -root save_settings -hide-default $< | grep -B 1000000 " end" > $@ + strip.cmo : gtk_strip.cmo gtk_setting_time.cmo compass : compass.ml @@ -72,7 +75,7 @@ compass : compass.ml clean: - rm -f *~* *.cm* *.o *.out *.opt map2d gcs .depend gtk_strip.ml gtk_setting_time.ml + rm -f *~* *.cm* *.o *.out *.opt map2d gcs .depend gtk_strip.ml gtk_setting_time.ml gtk_save_settings.ml diff --git a/sw/ground_segment/cockpit/live.ml b/sw/ground_segment/cockpit/live.ml index fdb6df5243..4ae7ed896d 100644 --- a/sw/ground_segment/cockpit/live.ml +++ b/sw/ground_segment/cockpit/live.ml @@ -480,8 +480,13 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id let xml_settings = Xml.children (ExtXml.child settings_xml "dl_settings") in let settings_tab = new Pages.settings ~visible xml_settings dl_setting_callback (fun x -> strip#add_widget x) in - let tab_label = (GMisc.label ~text:"Settings" ())#coerce in - ignore (ac_notebook#append_page ~tab_label settings_tab#widget); + let tab_label = GPack.hbox () in + let _label = (GMisc.label ~text:"Settings" ~packing:tab_label#pack ()) in + let button_save_settings = GButton.button ~packing:tab_label#pack () in + ignore (GMisc.image ~stock:`SAVE ~packing:button_save_settings#add ()); + button_save_settings#set_border_width 0; + ignore (button_save_settings#connect#clicked (fun () -> settings_tab#save af_file)); + ignore (ac_notebook#append_page ~tab_label:tab_label#coerce settings_tab#widget); Some settings_tab with exc -> log alert ac_id (Printexc.to_string exc); @@ -564,7 +569,7 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id (** Connect the strip buttons *) let connect = fun ?(warning=true) setting_name strip_connect -> try - let id, _label = settings_tab#assoc setting_name in + let id = settings_tab#assoc setting_name in strip_connect (fun x -> dl_setting_callback id x) with Not_found -> if warning then @@ -580,7 +585,7 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id connect ~warning:false "snav_desired_tow" (ac.strip#connect_apt get_ac_unix_time); begin (* Periodically update the appointment *) try - let id, _label = settings_tab#assoc "snav_desired_tow" in + let id = settings_tab#assoc "snav_desired_tow" in let set_appointment = fun _ -> begin try let v = ac.dl_values.(id) in @@ -596,7 +601,7 @@ let create_ac = fun alert (geomap:G.widget) (acs_notebook:GPack.notebook) (ac_id (** Connect the GPS reset button *) begin try - let gps_reset_id, _ = settings_tab#assoc "gps_reset" in + let gps_reset_id = settings_tab#assoc "gps_reset" in gps_page#connect_reset (fun x -> dl_setting_callback gps_reset_id (float x)) with Not_found -> diff --git a/sw/ground_segment/cockpit/pages.ml b/sw/ground_segment/cockpit/pages.ml index 4c36978a84..52c291dc02 100644 --- a/sw/ground_segment/cockpit/pages.ml +++ b/sw/ground_segment/cockpit/pages.ml @@ -223,18 +223,18 @@ class misc ~packing (widget: GBin.frame) = (*****************************************************************************) (* Dataling settings paged *) (*****************************************************************************) -let one_setting = fun i do_change packing s (tooltips:GData.tooltips) strip -> - let f = fun a -> float_of_string (ExtXml.attrib s a) in +let one_setting = fun i do_change packing dl_setting (tooltips:GData.tooltips) strip -> + let f = fun a -> float_of_string (ExtXml.attrib dl_setting a) in let lower = f "min" and upper = f "max" and step_incr = f "step" and page_incr = f "step" and page_size = f "step" - and show_auto = try ExtXml.attrib s "auto" = "true" with _ -> false in + and show_auto = try ExtXml.attrib dl_setting "auto" = "true" with _ -> false in let hbox = GPack.hbox ~packing () in - let varname = ExtXml.attrib s "var" in - let text = try ExtXml.attrib s "shortname" with _ -> varname in + let varname = ExtXml.attrib dl_setting "var" in + let text = try ExtXml.attrib dl_setting "shortname" with _ -> varname in let _l = GMisc.label ~width:100 ~text ~packing:hbox#pack () in let _v = GMisc.label ~width:50 ~text:"N/A" ~packing:hbox#pack () in @@ -247,17 +247,21 @@ let one_setting = fun i do_change packing s (tooltips:GData.tooltips) strip -> (* Discrete values: radio buttons *) let ilower = truncate lower and iupper = truncate upper in - let label = Printf.sprintf "%d" ilower in - let first = GButton.radio_button ~label ~packing:hbox#add () in let value = ref lower in - ignore (first#connect#clicked (fun () -> value := lower)); - let group = first#group in - for j = ilower+1 to iupper do + let callback = fun _ -> do_change i !value in + let group = (GButton.radio_button ())#group in (* Group shared by the buttons *) + for j = ilower to iupper do + (* Build the button *) let label = Printf.sprintf "%d" j in let b = GButton.radio_button ~group ~label ~packing:hbox#add () in - ignore (b#connect#clicked (fun () -> value := float j)) + + (* Connect the event *) + ignore (b#connect#pressed + (fun () -> + value := float j; + if auto_but#active then callback ())) done; - (fun _ -> do_change i !value) + callback else (* slider *) let value = (lower +. upper) /. 2. in let adj = GData.adjustment ~value ~lower ~upper:(upper+.step_incr) ~step_incr ~page_incr ~page_size () in @@ -321,19 +325,21 @@ let one_setting = fun i do_change packing s (tooltips:GData.tooltips) strip -> GButton.button ~label () in (strip b#coerce : unit); ignore (b#connect#clicked (fun _ -> do_change i sp_value))) - (Xml.children s); - (i, varname, _v) + (Xml.children dl_setting); + (i, dl_setting, _v) let rec build_settings = fun do_change i flat_list xml_settings packing tooltips strip -> match xml_settings with [] -> () | x::xs -> + (* All the node have the same tag *) List.iter (fun y -> assert(ExtXml.tag_is y (Xml.tag x))) xs; + if ExtXml.tag_is x "dl_setting" then List.iter - (fun s -> - let label_value = one_setting !i do_change packing s tooltips strip in + (fun dl_setting -> + let label_value = one_setting !i do_change packing dl_setting tooltips strip in flat_list := label_value :: !flat_list; incr i) xml_settings @@ -365,17 +371,21 @@ class settings = fun ?(visible = fun _ -> true) xml_settings do_change strip -> build_settings do_change i l xml_settings vbox#add tooltips strip; List.rev !l in let variables = Array.of_list ordered_list in - let assocs = List.map (fun (i,var,_v) -> (var, (i, _v))) ordered_list in + let length = Array.length variables in + let assocs = List.map (fun (i,dl_setting,_label) -> (ExtXml.attrib dl_setting "var", i)) ordered_list in object (self) method widget = sw#coerce - method length = !i + method length = length method set = fun i v -> if visible self#widget then let s = string_of_float v in - let (_, _, current_value) = variables.(i) in - if current_value#text <> s then - current_value#set_text s + let (_, _, label_current_value) = variables.(i) in + if label_current_value#text <> s then + label_current_value#set_text s method assoc var = List.assoc var assocs + method save = fun airframe_filename -> + let settings = Array.map (fun (_i, dl_setting, label) -> (dl_setting, float_of_string label#text)) variables in + SaveSettings.popup airframe_filename settings end diff --git a/sw/ground_segment/cockpit/pages.mli b/sw/ground_segment/cockpit/pages.mli index e1618d722f..7643b84ef0 100644 --- a/sw/ground_segment/cockpit/pages.mli +++ b/sw/ground_segment/cockpit/pages.mli @@ -20,10 +20,12 @@ class gps : ?visible:(GBin.frame -> bool) -> GBin.frame -> (** [new Pages.settings ?visible dl_settings callback short_button_receiver] *) class settings : ?visible:(GObj.widget -> bool) -> Xml.xml list -> (int -> float -> unit) -> (GObj.widget -> unit) -> object - method length : int - method set : int -> float -> unit - method assoc : string -> int * GMisc.label + method length : int (** Total number of settings *) + method set : int -> float -> unit (** Set the current value *) + method assoc : string -> int method widget : GObj.widget + method save : string -> unit + (** [save airframe_filename] *) end class misc : diff --git a/sw/ground_segment/tmtc/Makefile b/sw/ground_segment/tmtc/Makefile index 6fe4fef408..518fafa9c1 100644 --- a/sw/ground_segment/tmtc/Makefile +++ b/sw/ground_segment/tmtc/Makefile @@ -35,7 +35,7 @@ clean: OCAMLC = ocamlc OCAMLOPT = ocamlopt OCAMLLIB = ../../lib/ocaml -INCLUDES= -I $(OCAMLLIB) -I ../multimon -I +lablgtk2 -I +xml-light +INCLUDES= -I $(OCAMLLIB) -I ../multimon -I +lablgtk2 -I +xml-light -I +netstring -I +pcre LIBPPRZCMA=$(OCAMLLIB)/lib-pprz.cma SERVERCMO = aircraft.cmo wind.cmo airprox.cmo kml.cmo server.cmo @@ -54,7 +54,7 @@ messages : messages.cmo ../../lib/ocaml/xlib-pprz.cma ../../lib/ocaml/lib-pprz.c settings : settings.cmo ../../lib/ocaml/xlib-pprz.cma ../../lib/ocaml/lib-pprz.cma @echo OL $@ - $(Q)$(OCAMLC) -custom $(INCLUDES) -I ../cockpit -o $@ unix.cma str.cma xml-light.cma lablgtk.cma glibivy-ocaml.cma lib-pprz.cma gtkInit.cmo pages.cmo $< + $(Q)$(OCAMLC) -custom $(INCLUDES) -I ../cockpit -o $@ unix.cma str.cma xml-light.cma lablgtk.cma lablglade.cma pcre.cma netstring.cma glibivy-ocaml.cma lib-pprz.cma gtkInit.cmo gtk_save_settings.cmo saveSettings.cmo pages.cmo $< server : $(SERVERCMO) ../../lib/ocaml/lib-pprz.cma diff --git a/sw/lib/ocaml/Makefile b/sw/lib/ocaml/Makefile index 786ddd029d..69631148d3 100644 --- a/sw/lib/ocaml/Makefile +++ b/sw/lib/ocaml/Makefile @@ -22,13 +22,13 @@ Q=@ -INCLUDES= -I +xml-light +INCLUDES= -I +xml-light -I +pcre -I +netstring XINCLUDES= -I +lablgl -I +lablgtk2 -I +xml-light OCAMLC=ocamlc OCAMLOPT=ocamlopt -SRC = debug.ml base64.ml serial.ml ocaml_tools.ml extXml.ml env.ml xml2h.ml latlong.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o convert.o ubx.ml pprz.ml xbee.ml +SRC = debug.ml base64.ml serial.ml ocaml_tools.ml extXml.ml env.ml xml2h.ml latlong.ml srtm.ml http.ml gm.ml iGN.ml geometry_2d.ml cserial.o convert.o ubx.ml pprz.ml xbee.ml xmlCom.ml editAirframe.ml CMO = $(SRC:.ml=.cmo) CMX = $(SRC:.ml=.cmx) @@ -87,7 +87,7 @@ ml_gtkgl_hack.o : ml_gtkgl_hack.c %.cmi : %.mli @echo OC $< - $(Q)$(OCAMLC) $(XINCLUDES) $< + $(Q)$(OCAMLC) $(XINCLUDES) $(INCLUDES) $< %.cmi : %.ml @echo OC $< diff --git a/sw/tools/Makefile b/sw/tools/Makefile index bc7351725e..e6a348ad93 100644 --- a/sw/tools/Makefile +++ b/sw/tools/Makefile @@ -49,7 +49,7 @@ fp_syntax.cmo : fp_syntax.cmi @echo OC $< $(Q)$(OCAMLC) $(INCLUDES) -o $@ unix.cma str.cma ivy-ocaml.cma xml-light.cma lib-pprz.cma $< @cat ../../pprz_src_test.sh > $@ - @echo '$(OCAML) -I +xml-light -I $$PAPARAZZI_SRC/sw/lib/ocaml unix.cma str.cma ivy-ocaml.cma xml-light.cma lib-pprz.cma $$PAPARAZZI_BIN/$< $$*' >> $@ + @echo '$(OCAML) -I +xml-light -I +pcre -I +netstring -I $$PAPARAZZI_SRC/sw/lib/ocaml unix.cma str.cma ivy-ocaml.cma xml-light.cma pcre.cma netstring.cma lib-pprz.cma $$PAPARAZZI_BIN/$< $$*' >> $@ @chmod a+x $@ %.cmo : %.ml ../lib/ocaml/lib-pprz.cma