[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:
Gautier Hattenberger
2014-10-31 00:18:18 +01:00
parent 43dc0c8154
commit 295714793d
2 changed files with 35 additions and 11 deletions
+3 -1
View File
@@ -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
+32 -10
View File
@@ -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