[log/replay] this should allow to replay logs including procedures

fix #227
This commit is contained in:
Gautier Hattenberger
2013-02-20 18:26:12 +01:00
parent 8b9266fb46
commit 9528a702ee
2 changed files with 41 additions and 9 deletions
+26 -2
View File
@@ -51,6 +51,8 @@ let gconf_file = paparazzi_home // "conf" // "%gconf.xml"
let gcs_icons_path = paparazzi_home // "data" // "pictures" // "gcs_icons"
let dump_fp = paparazzi_src // "sw" // "tools" // "gen_flight_plan.out -dump"
let expand_ac_xml = fun ?(raise_exception = true) ac_conf ->
let prefix = fun s -> sprintf "%s/conf/%s" paparazzi_home s in
let parse_file = fun a file ->
@@ -67,14 +69,36 @@ let expand_ac_xml = fun ?(raise_exception = true) ac_conf ->
let parse = fun a ->
List.map
(fun filename ->parse_file a (prefix filename))
(fun filename -> parse_file a (prefix filename))
(Str.split space_regexp (ExtXml.attrib ac_conf a)) in
let parse_opt = fun a ->
try parse a with ExtXml.Error _ -> [] in
(* dump expanded version of flight plan before parsing *)
let parse_fp = fun a ->
try
(* get full path file name *)
let fp = prefix (ExtXml.attrib ac_conf a) in
(* create a temporary dump file *)
let dump = Filename.temp_file "fp_dump" ".xml" in
(* set command then call it *)
let c = sprintf "%s %s > %s" dump_fp fp dump in
if Sys.command c <> 0 then
begin
Sys.remove dump;
failwith c
end;
(* parse temp fp file and then remove it *)
let fp_xml = parse_file a dump in
Sys.remove dump;
(* return Xml list *)
[fp_xml]
with _ -> []
in
let pervasives = parse "airframe" @ parse "telemetry" @ parse "settings" in
let optionals = parse_opt "radio" @ parse_opt "flight_plan" @ pervasives in
let optionals = parse_opt "radio" @ parse_fp "flight_plan" @ pervasives in
let children = Xml.children ac_conf@optionals in
make_element (Xml.tag ac_conf) (Xml.attribs ac_conf) children
+15 -7
View File
@@ -59,13 +59,21 @@ let store_conf = fun conf acs ->
f in
ignore (w "airframe");
ignore (w "radio");
let fp = w "flight_plan" in
(** We must "dump" the flight plan from the original one *)
ignore (Sys.command (sprintf "mkdir -p %s" ac_dir));
let dump = ac_dir // "flight_plan.xml" in
let c = sprintf "%s %s > %s" dump_fp fp dump in
if Sys.command c <> 0 then
failwith c;
(* test if flight plan is an original one or the dumped version *)
let orig_fp = List.exists (fun e -> compare (Xml.tag e) "flight_plan" = 0) (Xml.children x) in
if orig_fp then begin
let fp = w "flight_plan" in
(** We must "dump" the flight plan from the original one *)
ignore (Sys.command (sprintf "mkdir -p %s" ac_dir));
let dump = ac_dir // "flight_plan.xml" in
let c = sprintf "%s %s > %s" dump_fp fp dump in
if Sys.command c <> 0 then
failwith c;
end
else begin
let f = ac_dir // "flight_plan.xml" in
write_xml f (ExtXml.child x "dump");
end;
Xml.Element ("aircraft", Xml.attribs x, [])::r
else r
else (** Keep ground section *)