[settings] fix GCS settings page when only one mode in a process

This solves the case where a process as only one mode by removing the
corresponding setting (since there is nothing to change) and by removing
the complete telemetry page if no more process.
The case without modes in a process fails at code generation since at
least one mode is required.

fix #553
This commit is contained in:
Gautier Hattenberger
2013-10-15 13:50:42 +02:00
parent 131f63a5dd
commit 0d6db6469a
2 changed files with 25 additions and 21 deletions
+1 -1
View File
@@ -222,7 +222,7 @@ let one_setting = fun (i:int) (do_change:int -> float -> unit) packing dl_settin
let same_tag_for_all = function
[] -> failwith "Page_settings: unreachable, empty dl_settings element"
[] -> failwith "Page_settings: unreachable, empty dl_settings element"
| x::xs ->
let tag_first = Xml.tag x in
List.iter (fun y -> assert(ExtXml.tag_is y tag_first)) xs;
+7 -3
View File
@@ -92,19 +92,22 @@ let output_modes = fun out_h process_name modes freq modules ->
modes
let write_settings = fun xml_file out_set telemetry_xml ->
(* filter xml file to remove unneeded process and modes (more than 1 mode per process) *)
let filtered_xml = List.filter (fun p -> List.length (Xml.children p) > 1) (Xml.children telemetry_xml) in
fprintf out_set "<!-- This file has been generated from %s -->\n" xml_file;
fprintf out_set "<!-- Please DO NOT EDIT -->\n\n";
fprintf out_set "<settings>\n";
if List.length filtered_xml > 0 then begin
fprintf out_set " <dl_settings>\n";
fprintf out_set " <dl_settings name=\"Telemetry\">\n";
List.iter (fun p ->
(* for each process *)
(* for each (pre-filtered) process *)
let process_name = Xml.attrib p "name" in
(* convert the xml list of mode to a string list *)
let modes = List.map (fun m -> Xml.attrib m "name") (Xml.children p) in
let nb_modes = List.length modes in
match nb_modes with
0 | 1 -> () (* Nothing to do if 1 or zero mode *)
| 0 | 1 -> () (* Nothing to do if 1 or zero mode *)
| _ -> (* add settings with all modes *)
fprintf out_set " <dl_setting min=\"0\" step=\"1\" max=\"%d\" var=\"telemetry_mode_%s\" shortname=\"%s\" values=\"%s\">\n" (nb_modes-1) process_name process_name (String.concat "|" modes);
let i = ref 0 in
@@ -114,9 +117,10 @@ let write_settings = fun xml_file out_set telemetry_xml ->
incr i
with _ -> incr i) (Xml.children p);
fprintf out_set " </dl_setting>\n"
) (Xml.children telemetry_xml);
) filtered_xml;
fprintf out_set " </dl_settings>\n";
fprintf out_set " </dl_settings>\n";
end;
fprintf out_set "</settings>\n"