mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 21:07:40 +08:00
[gen_fligtplan] 'call' statement can be configured to loop and/or break
default behavior: - the function is called until returning FALSE (same as before) - at the end of the call, go to next stage immediately (new) this is related to #830
This commit is contained in:
@@ -162,7 +162,9 @@ value CDATA #REQUIRED>
|
|||||||
|
|
||||||
<!ATTLIST call
|
<!ATTLIST call
|
||||||
fun CDATA #REQUIRED
|
fun CDATA #REQUIRED
|
||||||
until CDATA #IMPLIED>
|
until CDATA #IMPLIED
|
||||||
|
loop CDATA #IMPLIED
|
||||||
|
break CDATA #IMPLIED>
|
||||||
|
|
||||||
<!ATTLIST follow
|
<!ATTLIST follow
|
||||||
ac_id CDATA #REQUIRED
|
ac_id CDATA #REQUIRED
|
||||||
|
|||||||
@@ -494,16 +494,38 @@ let rec print_stage = fun index_of_waypoints x ->
|
|||||||
| "call" ->
|
| "call" ->
|
||||||
stage ();
|
stage ();
|
||||||
let statement = ExtXml.attrib x "fun" in
|
let statement = ExtXml.attrib x "fun" in
|
||||||
lprintf "if (! (%s))\n" statement;
|
(* by default, function is called while returning TRUE *)
|
||||||
lprintf " NextStageAndBreak();\n";
|
(* otherwise, function is called once and returned value is ignored *)
|
||||||
begin
|
let loop = String.uppercase (ExtXml.attrib_or_default x "loop" "TRUE") in
|
||||||
try
|
(* be default, go to next stage immediately *)
|
||||||
let c = parsed_attrib x "until" in
|
let break = String.uppercase (ExtXml.attrib_or_default x "break" "FALSE") in
|
||||||
lprintf "if (%s) NextStageAndBreak();\n" c
|
begin match loop with
|
||||||
with
|
| "TRUE" ->
|
||||||
ExtXml.Error _ -> ()
|
lprintf "if (! (%s)) {\n" statement;
|
||||||
end;
|
begin match break with
|
||||||
lprintf "break;\n"
|
| "TRUE" -> lprintf " NextStageAndBreak();\n";
|
||||||
|
| "FALSE" -> lprintf " NextStage();\n";
|
||||||
|
| _ -> failwith "FP: 'call' break attribute must be TRUE or FALSE";
|
||||||
|
end;
|
||||||
|
lprintf "} else {\n";
|
||||||
|
begin
|
||||||
|
try
|
||||||
|
let c = parsed_attrib x "until" in
|
||||||
|
lprintf " if (%s) NextStageAndBreak();\n" c
|
||||||
|
with
|
||||||
|
ExtXml.Error _ -> ()
|
||||||
|
end;
|
||||||
|
lprintf " break;\n";
|
||||||
|
lprintf "}\n"
|
||||||
|
| "FALSE" ->
|
||||||
|
lprintf "%s\n" statement;
|
||||||
|
begin match break with
|
||||||
|
| "TRUE" -> lprintf "NextStageAndBreak();\n";
|
||||||
|
| "FALSE" -> lprintf "NextStage();\n";
|
||||||
|
| _ -> failwith "FP: 'call' break attribute must be TRUE or FALSE";
|
||||||
|
end;
|
||||||
|
| _ -> failwith "FP: 'call' loop attribute must be TRUE or FALSE"
|
||||||
|
end
|
||||||
| "survey_rectangle" ->
|
| "survey_rectangle" ->
|
||||||
let grid = parsed_attrib x "grid"
|
let grid = parsed_attrib x "grid"
|
||||||
and wp1 = get_index_waypoint (ExtXml.attrib x "wp1") index_of_waypoints
|
and wp1 = get_index_waypoint (ExtXml.attrib x "wp1") index_of_waypoints
|
||||||
|
|||||||
Reference in New Issue
Block a user