Skip to content

Commit

Permalink
[flight_plan] add call_once primitive
Browse files Browse the repository at this point in the history
<set needs a variable name and <call needs a function that returns a bool.
There is no elegant solution for handlers, while paparazzi has more and more handlers.
So we introduce the flightplan <call_once fun="KillThrottle()"/> block. It does also not cause a delay and moves to the next statement.
  • Loading branch information
dewagter authored and flixr committed Sep 15, 2014
1 parent 4219221 commit 4aab8e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions conf/flight_plans/flight_plan.dtd
Expand Up @@ -19,21 +19,22 @@
<!ELEMENT exceptions (exception*)>

<!ELEMENT blocks (block+)>
<!ELEMENT block (exception|while|heading|attitude|go|xyz|set|call|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|home|path)*>
<!ELEMENT block (exception|while|heading|attitude|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|home|path)*>

<!ELEMENT include (arg|with)*>
<!ELEMENT arg EMPTY>
<!ELEMENT with EMPTY>

<!ELEMENT while (exception|while|heading|attitude|go|xyz|set|call|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path)*>
<!ELEMENT for (exception|while|heading|attitude|go|xyz|set|call|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path)*>
<!ELEMENT for (exception|while|heading|attitude|go|xyz|set|call|call_once|circle|deroute|stay|follow|survey_rectangle|for|return|eight|oval|path)*>
<!ELEMENT exception EMPTY>
<!ELEMENT heading EMPTY>
<!ELEMENT attitude EMPTY>
<!ELEMENT go EMPTY>
<!ELEMENT xyz EMPTY>
<!ELEMENT set EMPTY>
<!ELEMENT call EMPTY>
<!ELEMENT call_once EMPTY>
<!ELEMENT circle EMPTY>
<!ELEMENT home EMPTY>
<!ELEMENT eight EMPTY>
Expand Down Expand Up @@ -164,6 +165,9 @@ value CDATA #REQUIRED>
fun CDATA #REQUIRED
until CDATA #IMPLIED>

<!ATTLIST call_once
fun CDATA #REQUIRED>

<!ATTLIST follow
ac_id CDATA #REQUIRED
distance CDATA #REQUIRED
Expand Down
2 changes: 1 addition & 1 deletion sw/lib/ocaml/fp_proc.ml
Expand Up @@ -144,7 +144,7 @@ let transform_stage = fun prefix reroutes env xml ->
assert (children=[]);
let attribs = transform_values ["wp"; "vmode"] env attribs in
Xml.Element (tag, attribs, children)
| "call" | "set" ->
| "call" | "set" | "call_once" ->
let attribs = transform_values ["var"] env attribs in
Xml.Element (tag, attribs, children)
| _ -> failwith (sprintf "Fp_proc: Unexpected tag: '%s'" tag)
Expand Down
7 changes: 6 additions & 1 deletion sw/tools/generators/gen_flight_plan.ml
Expand Up @@ -265,7 +265,7 @@ let rec index_stage = fun x ->
incr stage; (* To count the loop stage *)
Xml.Element (Xml.tag x, Xml.attribs x@["no", soi n], l)
| "return" | "goto" | "deroute" | "exit_block" | "follow" | "call" | "home"
| "heading" | "attitude" | "go" | "stay" | "xyz" | "set" | "circle" ->
| "heading" | "attitude" | "go" | "stay" | "xyz" | "set" | "call_once" | "circle" ->
incr stage;
Xml.Element (Xml.tag x, Xml.attribs x@["no", soi !stage], Xml.children x)
| "survey_rectangle" | "eight" | "oval"->
Expand Down Expand Up @@ -491,6 +491,11 @@ let rec print_stage = fun index_of_waypoints x ->
and value = parsed_attrib x "value" in
lprintf "%s = %s;\n" var value;
lprintf "NextStage();\n"
| "call_once" ->
stage ();
let func = ExtXml.attrib x "fun" in
lprintf "%s;\n" func;
lprintf "NextStage();\n"
| "call" ->
stage ();
let statement = ExtXml.attrib x "fun" in
Expand Down

0 comments on commit 4aab8e1

Please sign in to comment.