diff --git a/Makefile.ac b/Makefile.ac index 16d5b18b43..a2bef0cdc1 100644 --- a/Makefile.ac +++ b/Makefile.ac @@ -42,6 +42,7 @@ FLIGHT_PLAN_H=$(AC_GENERATED)/flight_plan.h FLIGHT_PLAN_XML=$(AIRCRAFT_BUILD_DIR)/flight_plan.xml SETTINGS_H=$(AC_GENERATED)/settings.h SETTINGS_XMLS=$(patsubst %,$(CONF)/%,$(SETTINGS)) +SETTINGS_XMLS_DEP=$(filter-out %~,$(SETTINGS_XMLS)) SETTINGS_XML=$(AIRCRAFT_BUILD_DIR)/settings.xml SETTINGS_MODULES=$(AIRCRAFT_BUILD_DIR)/settings_modules.xml SETTINGS_TELEMETRY=$(AIRCRAFT_BUILD_DIR)/settings_telemetry.xml @@ -164,14 +165,14 @@ $(FLIGHT_PLAN_XML) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) $(GENERATORS)/gen_flight $(Q)mv $($@_TMP) $@ $(Q)chmod a+r $@ -$(SETTINGS_H) : $(SETTINGS_XMLS) $(CONF_XML) $(SETTINGS_MODULES) $(SETTINGS_TELEMETRY) $(GENERATORS)/gen_settings.out +$(SETTINGS_H) : $(SETTINGS_XMLS_DEP) $(CONF_XML) $(SETTINGS_MODULES) $(SETTINGS_TELEMETRY) $(GENERATORS)/gen_settings.out $(Q)test -d $(AC_GENERATED) || mkdir -p $(AC_GENERATED) @echo GENERATE $@ $(eval $@_TMP := $(shell $(MKTEMP))) $(Q)$(GENERATORS)/gen_settings.out $(SETTINGS_XML) $(SETTINGS_TELEMETRY) $(SETTINGS_XMLS) $(SETTINGS_MODULES) > $($@_TMP) $(Q)mv $($@_TMP) $@ $(Q)chmod a+r $@ - $(Q)cp $(SETTINGS_XMLS) $(AIRCRAFT_CONF_DIR)/settings + $(Q)cp $(SETTINGS_XMLS_DEP) $(AIRCRAFT_CONF_DIR)/settings $(MODULES_H) : $(CONF)/$(AIRFRAME_XML) $(GENERATORS)/gen_modules.out $(CONF)/modules/*.xml $(Q)test -d $(AC_GENERATED) || mkdir -p $(AC_GENERATED) diff --git a/conf/modules/hackhd.xml b/conf/modules/hackhd.xml index e4c705794d..59d08c4af2 100644 --- a/conf/modules/hackhd.xml +++ b/conf/modules/hackhd.xml @@ -22,6 +22,13 @@ + + + + + + +
diff --git a/conf/modules/module.dtd b/conf/modules/module.dtd index 350ede115e..609b04f5d7 100644 --- a/conf/modules/module.dtd +++ b/conf/modules/module.dtd @@ -1,6 +1,6 @@ - + @@ -92,6 +92,10 @@ dir CDATA #IMPLIED> name CDATA #REQUIRED > + + diff --git a/sw/supervision/pc_aircraft.ml b/sw/supervision/pc_aircraft.ml index 2c1149d9db..9f13eb286f 100644 --- a/sw/supervision/pc_aircraft.ml +++ b/sw/supervision/pc_aircraft.ml @@ -167,14 +167,24 @@ let get_settings_modules = fun ac_xml settings_modules -> (* get list of settings files *) let settings = List.fold_left (fun l (m, f) -> (* get list of settings_file xml node if any *) - let set_list = List.filter (fun t -> Xml.tag t = "settings_file") (Xml.children m) in - let file_list = List.map (fun s -> "settings/"^(Xml.attrib s "name")) set_list in + let settings_file_list = List.filter (fun t -> Xml.tag t = "settings_file") (Xml.children m) in + let file_list = List.map (fun s -> "settings/"^(Xml.attrib s "name")) settings_file_list in (* include module file in the list only if it has a 'settings' node *) - let module_file = - if List.exists (fun t -> Xml.tag t = "settings") (Xml.children m) - then [Env.filter_absolute_path f] - else [] in - l @ file_list @ module_file + let settings_list = List.filter (fun t -> Xml.tag t = "settings") (Xml.children m) in + let module_file = if List.length settings_list > 0 then [Env.filter_absolute_path f] else [] in + (* include module file with specific name if they exist *) + let settings_list = List.fold_left (fun l s -> + try + let name = Xml.attrib s "name" in + (* test if there is no white space in settings name *) + if Str.string_match (Str.regexp ".* .*") name 0 + then failwith "Paparazzicenter: no white space allowed in modules settings name"; + l @ [(Env.filter_absolute_path f)^"~"^name^"~"] + with + | Failure x -> prerr_endline x; l + | _ -> l + ) [] settings_list in + l @ file_list @ module_file @ settings_list ) [] modules in (* store current state in a hashtable *) let current = Hashtbl.create 7 in diff --git a/sw/tools/generators/gen_settings.ml b/sw/tools/generators/gen_settings.ml index 1b23f20ef2..142f9cc9de 100644 --- a/sw/tools/generators/gen_settings.ml +++ b/sw/tools/generators/gen_settings.ml @@ -270,6 +270,12 @@ let join_xml_files = fun xml_files -> let dl_settings = ref [] and rc_settings = ref [] in List.iter (fun xml_file -> + (* look for a specific name after settings file (in case of modules) *) + let split = Str.split (Str.regexp "~") xml_file in + let xml_file, name = match split with + | [f; n] -> f, n + | _ -> xml_file, "" + in let xml = Xml.parse_file xml_file in let these_rc_settings = try Xml.children (ExtXml.child xml "rc_settings") with @@ -277,9 +283,19 @@ let join_xml_files = fun xml_files -> let these_dl_settings = try (* test if the file is plain settings file or a module file *) - let xml = if Xml.tag xml = "module" then (ExtXml.child xml "settings") else xml in - Xml.children (ExtXml.child xml "dl_settings") with - Not_found -> [] in + let xml = + if Xml.tag xml = "module" + then List.filter (fun t -> Xml.tag t = "settings") (Xml.children xml) + else [xml] + in + (* include settings if name is matching *) + List.fold_left (fun l x -> + if (ExtXml.attrib_or_default x "name" "") = name then + l @ (Xml.children (ExtXml.child x "dl_settings")) + else l + ) [] xml + with + | Not_found -> [] in rc_settings := these_rc_settings @ !rc_settings; dl_settings := these_dl_settings @ !dl_settings) xml_files;