*** empty log message ***

This commit is contained in:
Antoine Drouin
2005-08-26 00:50:26 +00:00
parent 8e2df32691
commit e16396bd27
11 changed files with 136 additions and 117 deletions
+25 -15
View File
@@ -5,26 +5,31 @@ use strict;
use Subject; use Subject;
use Data::Dumper; use Data::Dumper;
use Paparazzi::Utils;
use constant TITLE => "Autopilot"; use constant TITLE => "Autopilot";
my @fields = ('ap_mode', 'lat_mode', 'horiz_mode', 'gaz_mode', 'gps_mode', 'flight_time');
sub populate { sub populate {
my ($self, $args) = @_; my ($self, $args) = @_;
$args->{-title} = TITLE; $args->{-title} = TITLE;
$self->SUPER::populate($args); $self->SUPER::populate($args);
$self->configspec(
-ap_status => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, {}],
);
} }
sub ap_status { sub set_aircraft {
my ($self, $old_val, $new_val) = @_; my ($self, $prev_ac, $new_ac) = @_;
return unless defined $new_val; foreach my $field (@fields) {
# print "in APPage ap_status\n".Dumper($new_val); $prev_ac->detach($self, $field, [\&update_field]) if ($prev_ac);
my $zinc = $self->get('-zinc'); $new_ac->attach($self, $field, [\&update_field]) if ($new_ac);
foreach my $field (keys %{$new_val}) { }
$zinc->itemconfigure ($self->{'text_'.$field}, }
-text => sprintf("%s : %.1f", $field, $new_val->{$field})) if defined $self->{'text_'.$field};
} sub update_field {
my ($self, $aircraft, $field, $new_value) = @_;
my $text = $new_value;
$text = Utils::hhmmss_of_s($text) if ($field eq 'flight_time');
$self->get('-zinc')->itemconfigure($self->{'text_'.$field}, -text => $text);
} }
sub build_gui { sub build_gui {
@@ -34,12 +39,17 @@ sub build_gui {
my $dy = $self->get('-height')/10; my $dy = $self->get('-height')/10;
my $y=10; my $y=10;
my $x=10; my $x=10;
foreach my $field ('mode', 'h_mode', 'v_mode', 'target_climb', 'target_alt', 'target_heading') { foreach my $field (@fields) {
$zinc->add('text', $self->{main_group},
-position => [$x, $y+$self->{vmargin}],
-color => 'white',
-anchor => 'w',
-text => $field);
$self->{'text_'.$field} = $zinc->add('text', $self->{main_group}, $self->{'text_'.$field} = $zinc->add('text', $self->{main_group},
-position => [$x, $y+$self->{vmargin}], -position => [$x + 100, $y+$self->{vmargin}],
-color => 'white', -color => 'white',
-anchor => 'w', -anchor => 'w',
-text => $field); -text => 'NA');
$y+=$dy; $y+=$dy;
} }
} }
+5 -7
View File
@@ -21,10 +21,6 @@ sub populate {
-height => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef], -height => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef],
-selected_ac => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, undef], -selected_ac => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, undef],
-page => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, undef], -page => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, undef],
# -fix => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
# -ap_status => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
# -wind => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
# -lls => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
-svsinfo => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef], -svsinfo => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
-engine_status => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef], -engine_status => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
); );
@@ -39,7 +35,7 @@ sub completeinit {
sub page { sub page {
my ($self, $old_val, $new_val) = @_; my ($self, $old_val, $new_val) = @_;
print "in ND::page [$old_val $new_val]\n"; # print "in ND::page [$old_val $new_val]\n";
return unless defined $new_val and defined $self->{main_group}; return unless defined $new_val and defined $self->{main_group};
$self->{$old_val}->configure(-visible => 0) if defined $old_val; $self->{$old_val}->configure(-visible => 0) if defined $old_val;
$self->{$new_val}->configure(-visible => 1); $self->{$new_val}->configure(-visible => 1);
@@ -56,6 +52,8 @@ sub selected_ac {
$previous_ac->detach($self, $attr, [\&foo_cbk, $attr]) if ($previous_ac); $previous_ac->detach($self, $attr, [\&foo_cbk, $attr]) if ($previous_ac);
$new_ac->attach($self, $attr, [\&foo_cbk, $attr]); $new_ac->attach($self, $attr, [\&foo_cbk, $attr]);
} }
$self->{AP}->set_aircraft($previous_ac, $new_ac);
$self->{Settings}->set_aircraft($previous_ac, $new_ac);
} }
sub foo_cbk { sub foo_cbk {
@@ -81,8 +79,8 @@ sub build_gui() {
my $real_width = $page_width - 2*$margin; my $real_width = $page_width - 2*$margin;
my ($page_per_row, $row, $col) = (2, 0, 0); my ($page_per_row, $row, $col) = (2, 0, 0);
my $pages = ['Gps', 'Nav', 'Engine', 'IR']; my @pages = ('Gps', 'AP', 'Settings', 'Engine', 'IR');
foreach my $page (@{$pages}) { foreach my $page (@pages) {
$self->{$page} = $self->component('Paparazzi::'.$page.'Page', $self->{$page} = $self->component('Paparazzi::'.$page.'Page',
-zinc => $zinc, -zinc => $zinc,
-parent_grp => $self->{main_group}, -parent_grp => $self->{main_group},
@@ -1,46 +0,0 @@
package Paparazzi::NavPage;
use Paparazzi::NDPage;
@ISA = ("Paparazzi::NDPage");
use strict;
use Subject;
use Data::Dumper;
use constant TITLE => "Autopilot";
sub populate {
my ($self, $args) = @_;
$args->{-title} = TITLE;
$self->SUPER::populate($args);
$self->configspec(
-ap_status => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, {}],
);
}
sub ap_status {
my ($self, $old_val, $new_val) = @_;
return unless defined $new_val;
# print "in APPage ap_status\n".Dumper($new_val);
my $zinc = $self->get('-zinc');
foreach my $field (keys %{$new_val}) {
$zinc->itemconfigure ($self->{'text_'.$field},
-text => sprintf("%s : %.1f", $field, $new_val->{$field})) if defined $self->{'text_'.$field};
}
}
sub build_gui {
my ($self) = @_;
$self->SUPER::build_gui();
my $zinc = $self->get('-zinc');
my $dy = $self->get('-height')/10;
my $y=10;
my $x=10;
foreach my $field ('mode', 'h_mode', 'v_mode', 'target_climb', 'target_alt', 'target_heading') {
$self->{'text_'.$field} = $zinc->add('text', $self->{main_group},
-position => [$x, $y+$self->{vmargin}],
-color => 'white',
-anchor => 'w',
-text => $field);
$y+=$dy;
}
}
@@ -140,6 +140,7 @@ sub build_gui() {
-origin => [$p_x, $p_y], -origin => [$p_x, $p_y],
-width => $p_w, -width => $p_w,
-height => $p_h, -height => $p_h,
-pages => ['Gps', 'AP', 'Settings', 'Engine', 'IR']
); );
$component->attach($self, 'CLICKED', ['onPanelCLicked']); $component->attach($self, 'CLICKED', ['onPanelCLicked']);
@@ -4,7 +4,7 @@ package Paparazzi::PFD_Panel;
use Subject; use Subject;
@ISA = ("Subject"); @ISA = ("Subject");
use Tk; use Tk;
use Tk::Zinc; use Tk::Zinc;
use Data::Dumper; use Data::Dumper;
@@ -18,56 +18,16 @@ sub populate {
-origin => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef], -origin => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef],
-width => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef], -width => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef],
-height => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef], -height => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef],
-gps_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.], -pages => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, []],
-ap_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.], # -pubevts => [S_NEEDINIT, S_PASSIVE, S_RDWR, S_APPEND, S_NOPRPG,[]]
-rc_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-ctrst_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-ctrst_value => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-lls_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-lls_value => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-if_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
# -pubevts => [S_NEEDINIT, S_PASSIVE, S_RDWR, S_APPEND, S_NOPRPG,[]]
); );
} }
sub completeinit { sub completeinit {
my $self = shift; my $self = shift;
$self->SUPER::completeinit(); $self->SUPER::completeinit();
# $self->{modes} = [ { name => 'rc',
# str => ["lost","ok", "really lost", "not possible"],
# color => ["orange", "green", "red", "red"]
# },
# { name => 'cal',
# str => ["unkwn", "wait", "ok"],
# color =>["red", "orange", "green"]
# },
# { name => 'ap',
# str => ["manual", "auto1", "auto2", "home"],
# color =>["green", "green", "green", "orange"]
# },
# { name => 'gps',
# str => [ "No fix",
# "dead reckoning only",
# "2D-fix",
# "3D-fix",
# "GPS + dead reckoning combined"],
# color => ["red", "red", "orange", "green", "orange"]
# },
# { name => 'lls',
# str => ["OFF" , "ON"],
# color =>["orange", "green"]
# },
# { name => 'if',
# str => ["none", "down", "up"],
# color =>["green", "orange", "orange"]
# }
# ];
# $self->{modes_by_name} = {};
# foreach my $mode (@{$self->{modes}}) {
# $self->{modes_by_name}->{$mode->{name}} = $mode;
# }
$self->{pages} = ['Gps', 'Nav', 'Engine', 'IR']; $self->{pages} = ['Gps', 'AP', 'Settings', 'Engine', 'IR'];
$self->build_gui(); $self->build_gui();
$self->configure('-pubevts' => 'CLICKED'); $self->configure('-pubevts' => 'CLICKED');
} }
@@ -0,0 +1,61 @@
package Paparazzi::SettingsPage;
use Paparazzi::NDPage;
@ISA = ("Paparazzi::NDPage");
use strict;
use Subject;
use Data::Dumper;
use constant TITLE => "Settings";
my @fields = ('if_mode', 'if_value1', 'if_value2');
sub populate {
my ($self, $args) = @_;
$args->{-title} = TITLE;
$self->SUPER::populate($args);
$self->configspec(
-fields => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, []],
);
}
sub set_aircraft {
my ($self, $prev_ac, $new_ac) = @_;
foreach my $field (@fields) {
$prev_ac->detach($self, $field, [\&update_field]) if ($prev_ac);
$new_ac->attach($self, $field, [\&update_field]) if ($new_ac);
}
my $fligh_plan = $new_ac->get('flight_plan');
use Data::Dumper;
print "#####".Dumper(scalar $fligh_plan->get('-rc_control'));
}
sub update_field {
my ($self, $aircraft, $field, $new_value) = @_;
$self->get('-zinc')->itemconfigure($self->{'text_'.$field}, -text => $new_value);
}
sub build_gui {
my ($self) = @_;
$self->SUPER::build_gui();
my $zinc = $self->get('-zinc');
my $dy = $self->get('-height')/10;
my $y=10;
my $x=10;
foreach my $field (@fields) {
$zinc->add('text', $self->{main_group},
-position => [$x, $y+$self->{vmargin}],
-color => 'white',
-anchor => 'w',
-text => $field);
$self->{'text_'.$field} = $zinc->add('text', $self->{main_group},
-position => [$x + 100, $y+$self->{vmargin}],
-color => 'white',
-anchor => 'w',
-text => 'NA');
$y+=$dy;
}
}
+7 -3
View File
@@ -37,6 +37,8 @@ use Data::Dumper;
use strict; use strict;
use warnings; use warnings;
use Paparazzi::Traces;
# populate: # populate:
# this sub is the subject constructor method # this sub is the subject constructor method
############################################################################## ##############################################################################
@@ -361,7 +363,7 @@ sub string_of_time {
sub attach_to_aircraft { sub attach_to_aircraft {
my ($self) = @_; my ($self) = @_;
my @options = ('airframe', 'flight_plan', 'ap_mode', 'rc_status', 'gps_mode', 'contrast_status', 'contrast_value', my @options = ('airframe', 'flight_plan', 'ap_mode', 'rc_status', 'gps_mode', 'contrast_status', 'contrast_value',
'flight_time', 'alt', 'target_alt', 'speed', 'climb');#, 'bat'); 'flight_time', 'alt', 'target_alt', 'speed', 'climb', '-engine_status');
foreach my $option (@options) { foreach my $option (@options) {
$self->get('-aircraft')->attach($self, $option, [\&aircraft_config_changed]); $self->get('-aircraft')->attach($self, $option, [\&aircraft_config_changed]);
} }
@@ -371,6 +373,7 @@ sub attach_to_aircraft {
sub aircraft_config_changed { sub aircraft_config_changed {
my ($self, $aircraft, $event, $new_value) = @_; my ($self, $aircraft, $event, $new_value) = @_;
# print "in strip aircraft_config_changed $event $new_value\n"; # print "in strip aircraft_config_changed $event $new_value\n";
return unless defined $new_value;
if ($event eq 'flight_plan') { if ($event eq 'flight_plan') {
# $self->border_block() if (defined $new_value) ; # display blocks of flight plan # $self->border_block() if (defined $new_value) ; # display blocks of flight plan
} }
@@ -384,8 +387,9 @@ sub aircraft_config_changed {
elsif ($event eq 'flight_time') { elsif ($event eq 'flight_time') {
$self->set_item("flight_time",$self->string_of_time($new_value), $self->{options}->{value_color}); $self->set_item("flight_time",$self->string_of_time($new_value), $self->{options}->{value_color});
} }
elsif ($event eq 'bat') { elsif ($event eq '-engine_status') {
$self->set_bat($new_value); # Paparazzi::Traces::trace( Paparazzi::Traces::TRACE_DEBUG, "in Strip::aircraft_config_changed\n".Dumper($new_value));
$self->set_bat($new_value->{bat});
} }
elsif ( $event eq 'speed' or $event eq 'climb' or $event eq 'alt' or $event eq 'target_alt' or $event eq 'contrast_value') { elsif ( $event eq 'speed' or $event eq 'climb' or $event eq 'alt' or $event eq 'target_alt' or $event eq 'contrast_value') {
my $fmt = { speed => "%2.1fm/s", my $fmt = { speed => "%2.1fm/s",
-1
View File
@@ -71,7 +71,6 @@ sub populate {
target_north => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.], target_north => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-engine_status => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef], -engine_status => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef],
x
-svsinfo => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef], -svsinfo => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef],
rc_status => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 'REALLY_LOST'], rc_status => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 'REALLY_LOST'],
+2 -1
View File
@@ -20,8 +20,9 @@ sub completeinit {
my $self = shift; my $self = shift;
$self->SUPER::completeinit(); $self->SUPER::completeinit();
my $airframe_url = $self->get('-url'); my $airframe_url = $self->get('-url');
print "airframe url $airframe_url\n"; print "in Airframe::compleetinit url $airframe_url\n";
my $airframe_xml = LWP::Simple::get($airframe_url); my $airframe_xml = LWP::Simple::get($airframe_url);
$self->parse_airframe($airframe_xml) if defined $airframe_xml; $self->parse_airframe($airframe_xml) if defined $airframe_xml;
} }
+23
View File
@@ -27,6 +27,8 @@ use Subject;
@ISA = ("Subject"); @ISA = ("Subject");
use strict; use strict;
use Paparazzi::Traces;
require LWP::Simple; require LWP::Simple;
use XML::DOM; use XML::DOM;
use Math::Trig; use Math::Trig;
@@ -40,6 +42,7 @@ sub populate {
-nav_utm_east0 => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.], -nav_utm_east0 => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-nav_utm_north0 => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.], -nav_utm_north0 => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-max_dist_from_home => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.], -max_dist_from_home => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
-rc_control => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, {}],
-waypoints => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, {}], -waypoints => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, {}],
-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, {}],
@@ -114,6 +117,7 @@ sub parse_flight_plan {
$self->{nav_utm_east0} = $waypoints->getAttribute('utm_x0'); $self->{nav_utm_east0} = $waypoints->getAttribute('utm_x0');
$self->{nav_utm_north0} = $waypoints->getAttribute('utm_y0'); $self->{nav_utm_north0} = $waypoints->getAttribute('utm_y0');
$self->parse_rc_control($doc);
$self->parse_waypoints($doc); $self->parse_waypoints($doc);
$self->parse_mission($doc); $self->parse_mission($doc);
$self->configure_spec(); $self->configure_spec();
@@ -129,6 +133,25 @@ sub configure_spec {
-mission => $self->{mission}); -mission => $self->{mission});
} }
sub parse_rc_control {
my ($self, $doc) = @_;
my $rc_control = {};
my $rc_control_elt = $doc->getElementsByTagName('rc_control')->[0];
my @modes = $rc_control_elt->getElementsByTagName('mode');
foreach my $mode (@modes) {
my $mode_name = $mode->getAttribute('name');
my @settings = $mode->getElementsByTagName('setting');
foreach my $s (@settings) {
my ($var, $range, $rc, $type) = ($s->getAttribute('var'),
$s->getAttribute('range'),
$s->getAttribute('rc'),
$s->getAttribute('type'));
$rc_control->{$mode_name} = [$var, $range, $rc, $type];
}
}
$self->configure('-rc_control', $rc_control);
}
sub parse_waypoints { sub parse_waypoints {
my ($self, $doc) = @_; my ($self, $doc) = @_;
my $wp_nb = 0; my $wp_nb = 0;
+8
View File
@@ -37,4 +37,12 @@ sub min {
return $b; return $b;
} }
sub hhmmss_of_s {
my ($t) = @_;
my $hour = int($t/3600);
my $min = int(($t-$hour*3600)/60);
my $sec = $t-(3600*$hour)-($min*60);
sprintf("%02d:%02d:%02d",$hour, $min, $sec);
}
1; 1;