mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 04:46:51 +08:00
Add some functionalities in FlightPlan parser
This commit is contained in:
@@ -47,6 +47,11 @@ sub populate {
|
|||||||
-nb_waypoints => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
-nb_waypoints => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||||
-mission => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, {}],
|
-mission => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, {}],
|
||||||
-compiled_xml => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""],
|
-compiled_xml => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""],
|
||||||
|
-qfu => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||||
|
-security_height => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||||
|
-alt => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||||
|
-name => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""],
|
||||||
|
-ground_alt => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +59,7 @@ sub populate {
|
|||||||
# nav_utm_east0
|
# nav_utm_east0
|
||||||
# nav_utm_north0
|
# nav_utm_north0
|
||||||
# max_dist_from_home
|
# max_dist_from_home
|
||||||
|
# rc_control
|
||||||
# waypoints
|
# waypoints
|
||||||
# |-- name
|
# |-- name
|
||||||
# |-- x
|
# |-- x
|
||||||
@@ -64,10 +70,13 @@ sub populate {
|
|||||||
# |-- number
|
# |-- number
|
||||||
# nb_waypoints
|
# nb_waypoints
|
||||||
# mission
|
# mission
|
||||||
|
# |-- nb_block
|
||||||
# |-- block_ID
|
# |-- block_ID
|
||||||
# |-- stage
|
# |-- stage
|
||||||
# |-- stage_ID
|
# |-- stage_ID
|
||||||
# |-- text
|
# |-- text
|
||||||
|
# |-- type
|
||||||
|
# |-- [attributes]
|
||||||
# |-- nb_exceptions
|
# |-- nb_exceptions
|
||||||
# |-- exception
|
# |-- exception
|
||||||
# |-- n°
|
# |-- n°
|
||||||
@@ -77,6 +86,12 @@ sub populate {
|
|||||||
# |-- description
|
# |-- description
|
||||||
# |-- is_deroute
|
# |-- is_deroute
|
||||||
# |-- [deroute_block]
|
# |-- [deroute_block]
|
||||||
|
# compiled_xml
|
||||||
|
# qfu
|
||||||
|
# security_height
|
||||||
|
# alt
|
||||||
|
# ground_alt
|
||||||
|
# name
|
||||||
|
|
||||||
|
|
||||||
sub completeinit {
|
sub completeinit {
|
||||||
@@ -184,6 +199,7 @@ sub parse_mission {
|
|||||||
my ($blocks, $blocks_stages);
|
my ($blocks, $blocks_stages);
|
||||||
my ($nb_excep, $excep_cond, $excep_deroute);
|
my ($nb_excep, $excep_cond, $excep_deroute);
|
||||||
my (@deroute, $deroute_block);
|
my (@deroute, $deroute_block);
|
||||||
|
my ($block_id, $stage_id);
|
||||||
|
|
||||||
foreach my $stage ($doc->getElementsByTagName('stage')) {
|
foreach my $stage ($doc->getElementsByTagName('stage')) {
|
||||||
my $block_name = $stage->getAttribute('block_name');
|
my $block_name = $stage->getAttribute('block_name');
|
||||||
@@ -191,14 +207,36 @@ sub parse_mission {
|
|||||||
my $stage_no = $stage->getAttribute('stage');
|
my $stage_no = $stage->getAttribute('stage');
|
||||||
my $stage_text = "";
|
my $stage_text = "";
|
||||||
my $stage_kids = $stage->getChildNodes();
|
my $stage_kids = $stage->getChildNodes();
|
||||||
|
$block_id = get_block_id($block_no);
|
||||||
|
$stage_id = get_stage_id($block_no, $stage_no);
|
||||||
foreach my $kid (@{$stage_kids}) {
|
foreach my $kid (@{$stage_kids}) {
|
||||||
|
if ($kid->getNodeType() != TEXT_NODE) {
|
||||||
$stage_text = $stage_text.$kid->toString() if $kid->getNodeType() != TEXT_NODE;
|
$stage_text = $stage_text.$kid->toString() if $kid->getNodeType() != TEXT_NODE;
|
||||||
|
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{type} = $kid->getNodeName()
|
||||||
|
if $kid->getNodeName() ne "#text";
|
||||||
|
|
||||||
|
# if ($stage_text ne "" and $kid->getNodeName() ne "#text") {
|
||||||
|
# printf "stage_id: $stage_id stage_text: $stage_text NodeName: %s \n", $kid->getNodeName();
|
||||||
|
my $kid_attributes = $kid->getAttributes();
|
||||||
|
my ($attrib_name, $attrib_value);
|
||||||
|
my $atributes_nb = $kid_attributes->getLength();
|
||||||
|
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{nb_attribute} = $atributes_nb;
|
||||||
|
for (my $i=0; $i<$atributes_nb; $i++) {
|
||||||
|
$attrib_name = $kid_attributes->item($i)->getNodeName();
|
||||||
|
$attrib_value = $kid_attributes->item($i)->getNodeValue();
|
||||||
|
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{$attrib_name} = $attrib_value;
|
||||||
|
# print "attribute '$attrib_name' valueing '$attrib_value' \n";
|
||||||
}
|
}
|
||||||
$blocks_stages->{$block_name}->{$stage_text} = get_stage_id($block_no, $stage_no);
|
}
|
||||||
$blocks->{$block_name} = get_block_id($block_no) unless defined $blocks->{block_name};
|
# else { print "Marche pas... stage_id: $stage_id \n"; }
|
||||||
|
}
|
||||||
|
$blocks_stages->{$block_name}->{$stage_text} = $stage_id;
|
||||||
|
$blocks->{$block_name} = $block_id unless defined $blocks->{block_name};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $nb_block = 0;
|
||||||
foreach my $block ($doc->getElementsByTagName('block')) {
|
foreach my $block ($doc->getElementsByTagName('block')) {
|
||||||
|
$nb_block++;
|
||||||
my $block_name = $block->getAttribute('NAME').$block->getAttribute('name');
|
my $block_name = $block->getAttribute('NAME').$block->getAttribute('name');
|
||||||
my $block_description = $block->getAttribute('description');
|
my $block_description = $block->getAttribute('description');
|
||||||
my $block_id = $blocks->{$block_name};
|
my $block_id = $blocks->{$block_name};
|
||||||
@@ -224,6 +262,7 @@ sub parse_mission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# I think we can do this better...
|
# I think we can do this better...
|
||||||
|
# It is in progess few lines above.
|
||||||
my $type = $line;
|
my $type = $line;
|
||||||
if ($type =~ /^.*<xyz.*$/) {
|
if ($type =~ /^.*<xyz.*$/) {
|
||||||
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{type} = 'xyz';
|
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{type} = 'xyz';
|
||||||
@@ -237,10 +276,11 @@ sub parse_mission {
|
|||||||
if ($type =~ /^.*<attitude.*$/) {
|
if ($type =~ /^.*<attitude.*$/) {
|
||||||
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{type} = 'go';
|
$self->{mission}->{$block_id}->{stage}->{$stage_id}->{type} = 'go';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$self->{mission}->{nb_block} = $nb_block;
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$nb_excep = 0;
|
$nb_excep = 0;
|
||||||
foreach my $except ($block->getElementsByTagName('exception')) {
|
foreach my $except ($block->getElementsByTagName('exception')) {
|
||||||
$nb_excep++;
|
$nb_excep++;
|
||||||
|
|||||||
Reference in New Issue
Block a user