From 780c03c05acf93e687f7627b8af8f4a92b919fc4 Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Thu, 3 Oct 2013 14:53:20 +0200 Subject: [PATCH] [generator] generate arrays of the settings and fp blocks names not used yet, but it can be later to send the settings and block names to the ground of to implement to associate a name to an index at runtime --- sw/tools/gen_flight_plan.ml | 12 +++--------- sw/tools/gen_settings.ml | 12 ++++-------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/sw/tools/gen_flight_plan.ml b/sw/tools/gen_flight_plan.ml index f283e4786f..ade969b63c 100644 --- a/sw/tools/gen_flight_plan.ml +++ b/sw/tools/gen_flight_plan.ml @@ -785,6 +785,9 @@ let () = lprintf "};\n"; Xml2h.define "NB_WAYPOINT" (string_of_int (List.length waypoints)); + Xml2h.define "FP_BLOCKS" "{ \\"; + List.iter (fun b -> printf " { \"%s\" }, \\\n" (ExtXml.attrib b "name")) blocks; + lprintf "};\n"; Xml2h.define "NB_BLOCK" (string_of_int (List.length blocks)); Xml2h.define "GROUND_ALT" (sof !ground_alt); @@ -794,15 +797,6 @@ let () = Xml2h.define "HOME_MODE_HEIGHT" (sof home_mode_height); Xml2h.define "MAX_DIST_FROM_HOME" (sof mdfh); - (** Print defines for blocks **) - lprintf "\n"; - let idx = ref 0 in - List.iter - (fun s -> - let v = ExtXml.attrib s "name" in - lprintf "#define BLOCK_%s %d\n" (Str.global_replace (Str.regexp "[^A-Za-z0-9]") "_" v) !idx; incr idx) blocks; - lprintf "\n"; - let index_of_waypoints = let i = ref (-1) in List.map (fun w -> incr i; (name_of w, !i)) waypoints in diff --git a/sw/tools/gen_settings.ml b/sw/tools/gen_settings.ml index 2413805309..e959b8e400 100644 --- a/sw/tools/gen_settings.ml +++ b/sw/tools/gen_settings.ml @@ -69,14 +69,10 @@ let print_dl_settings = fun settings -> lprintf "\n"; (** Datalink knowing what settings mean **) - let idx = ref 0 in - lprintf "\n"; - List.iter - (fun s -> - let v = ExtXml.attrib s "var" in - lprintf "#define SETTINGS_%s %d\n" (Str.global_replace (Str.regexp "[^A-Za-z0-9]") "_" v) !idx; incr idx) - settings; - lprintf "\n"; + Xml2h.define "SETTINGS" "{ \\"; + List.iter (fun b -> printf " { \"%s\" }, \\\n" (ExtXml.attrib b "var")) settings; + lprintf "};\n"; + Xml2h.define "NB_SETTING" (string_of_int (List.length settings)); (** Macro to call to set one variable *) lprintf "#define DlSetting(_idx, _value) { \\\n";