mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-27 17:06:31 +08:00
[log/replay] this should allow to replay logs including procedures
fix #227
This commit is contained in:
+26
-2
@@ -51,6 +51,8 @@ let gconf_file = paparazzi_home // "conf" // "%gconf.xml"
|
|||||||
|
|
||||||
let gcs_icons_path = paparazzi_home // "data" // "pictures" // "gcs_icons"
|
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 expand_ac_xml = fun ?(raise_exception = true) ac_conf ->
|
||||||
let prefix = fun s -> sprintf "%s/conf/%s" paparazzi_home s in
|
let prefix = fun s -> sprintf "%s/conf/%s" paparazzi_home s in
|
||||||
let parse_file = fun a file ->
|
let parse_file = fun a file ->
|
||||||
@@ -67,14 +69,36 @@ let expand_ac_xml = fun ?(raise_exception = true) ac_conf ->
|
|||||||
|
|
||||||
let parse = fun a ->
|
let parse = fun a ->
|
||||||
List.map
|
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
|
(Str.split space_regexp (ExtXml.attrib ac_conf a)) in
|
||||||
|
|
||||||
let parse_opt = fun a ->
|
let parse_opt = fun a ->
|
||||||
try parse a with ExtXml.Error _ -> [] in
|
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 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
|
let children = Xml.children ac_conf@optionals in
|
||||||
make_element (Xml.tag ac_conf) (Xml.attribs ac_conf) children
|
make_element (Xml.tag ac_conf) (Xml.attribs ac_conf) children
|
||||||
|
|||||||
@@ -59,13 +59,21 @@ let store_conf = fun conf acs ->
|
|||||||
f in
|
f in
|
||||||
ignore (w "airframe");
|
ignore (w "airframe");
|
||||||
ignore (w "radio");
|
ignore (w "radio");
|
||||||
let fp = w "flight_plan" in
|
(* test if flight plan is an original one or the dumped version *)
|
||||||
(** We must "dump" the flight plan from the original one *)
|
let orig_fp = List.exists (fun e -> compare (Xml.tag e) "flight_plan" = 0) (Xml.children x) in
|
||||||
ignore (Sys.command (sprintf "mkdir -p %s" ac_dir));
|
if orig_fp then begin
|
||||||
let dump = ac_dir // "flight_plan.xml" in
|
let fp = w "flight_plan" in
|
||||||
let c = sprintf "%s %s > %s" dump_fp fp dump in
|
(** We must "dump" the flight plan from the original one *)
|
||||||
if Sys.command c <> 0 then
|
ignore (Sys.command (sprintf "mkdir -p %s" ac_dir));
|
||||||
failwith c;
|
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
|
Xml.Element ("aircraft", Xml.attribs x, [])::r
|
||||||
else r
|
else r
|
||||||
else (** Keep ground section *)
|
else (** Keep ground section *)
|
||||||
|
|||||||
Reference in New Issue
Block a user