mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-31 12:23:23 +08:00
*** empty log message ***
This commit is contained in:
@@ -5,26 +5,31 @@ use strict;
|
||||
use Subject;
|
||||
use Data::Dumper;
|
||||
|
||||
use Paparazzi::Utils;
|
||||
|
||||
use constant TITLE => "Autopilot";
|
||||
|
||||
my @fields = ('ap_mode', 'lat_mode', 'horiz_mode', 'gaz_mode', 'gps_mode', 'flight_time');
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
@@ -34,12 +39,17 @@ sub build_gui {
|
||||
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') {
|
||||
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, $y+$self->{vmargin}],
|
||||
-position => [$x + 100, $y+$self->{vmargin}],
|
||||
-color => 'white',
|
||||
-anchor => 'w',
|
||||
-text => $field);
|
||||
-text => 'NA');
|
||||
$y+=$dy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,6 @@ sub populate {
|
||||
-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],
|
||||
-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],
|
||||
-engine_status => [S_NOINIT, S_PRPGONLY, S_RDWR, S_OVRWRT, S_CHILDREN, undef],
|
||||
);
|
||||
@@ -39,7 +35,7 @@ sub completeinit {
|
||||
|
||||
sub page {
|
||||
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};
|
||||
$self->{$old_val}->configure(-visible => 0) if defined $old_val;
|
||||
$self->{$new_val}->configure(-visible => 1);
|
||||
@@ -56,6 +52,8 @@ sub selected_ac {
|
||||
$previous_ac->detach($self, $attr, [\&foo_cbk, $attr]) if ($previous_ac);
|
||||
$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 {
|
||||
@@ -81,8 +79,8 @@ sub build_gui() {
|
||||
my $real_width = $page_width - 2*$margin;
|
||||
my ($page_per_row, $row, $col) = (2, 0, 0);
|
||||
|
||||
my $pages = ['Gps', 'Nav', 'Engine', 'IR'];
|
||||
foreach my $page (@{$pages}) {
|
||||
my @pages = ('Gps', 'AP', 'Settings', 'Engine', 'IR');
|
||||
foreach my $page (@pages) {
|
||||
$self->{$page} = $self->component('Paparazzi::'.$page.'Page',
|
||||
-zinc => $zinc,
|
||||
-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],
|
||||
-width => $p_w,
|
||||
-height => $p_h,
|
||||
-pages => ['Gps', 'AP', 'Settings', 'Engine', 'IR']
|
||||
);
|
||||
$component->attach($self, 'CLICKED', ['onPanelCLicked']);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ package Paparazzi::PFD_Panel;
|
||||
use Subject;
|
||||
@ISA = ("Subject");
|
||||
|
||||
use Tk;
|
||||
use Tk;
|
||||
use Tk::Zinc;
|
||||
use Data::Dumper;
|
||||
|
||||
@@ -18,56 +18,16 @@ sub populate {
|
||||
-origin => [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],
|
||||
-gps_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||
-ap_mode => [S_NOINIT, S_METHOD, S_RDWR, S_OVRWRT, S_NOPRPG, 0.],
|
||||
-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,[]]
|
||||
-pages => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, []],
|
||||
# -pubevts => [S_NEEDINIT, S_PASSIVE, S_RDWR, S_APPEND, S_NOPRPG,[]]
|
||||
);
|
||||
}
|
||||
|
||||
sub completeinit {
|
||||
my $self = shift;
|
||||
$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->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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ use Data::Dumper;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Paparazzi::Traces;
|
||||
|
||||
# populate:
|
||||
# this sub is the subject constructor method
|
||||
##############################################################################
|
||||
@@ -361,7 +363,7 @@ sub string_of_time {
|
||||
sub attach_to_aircraft {
|
||||
my ($self) = @_;
|
||||
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) {
|
||||
$self->get('-aircraft')->attach($self, $option, [\&aircraft_config_changed]);
|
||||
}
|
||||
@@ -371,6 +373,7 @@ sub attach_to_aircraft {
|
||||
sub aircraft_config_changed {
|
||||
my ($self, $aircraft, $event, $new_value) = @_;
|
||||
# print "in strip aircraft_config_changed $event $new_value\n";
|
||||
return unless defined $new_value;
|
||||
if ($event eq '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') {
|
||||
$self->set_item("flight_time",$self->string_of_time($new_value), $self->{options}->{value_color});
|
||||
}
|
||||
elsif ($event eq 'bat') {
|
||||
$self->set_bat($new_value);
|
||||
elsif ($event eq '-engine_status') {
|
||||
# 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') {
|
||||
my $fmt = { speed => "%2.1fm/s",
|
||||
|
||||
@@ -71,7 +71,6 @@ sub populate {
|
||||
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],
|
||||
x
|
||||
-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'],
|
||||
|
||||
@@ -20,8 +20,9 @@ sub completeinit {
|
||||
my $self = shift;
|
||||
$self->SUPER::completeinit();
|
||||
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);
|
||||
|
||||
$self->parse_airframe($airframe_xml) if defined $airframe_xml;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ use Subject;
|
||||
@ISA = ("Subject");
|
||||
use strict;
|
||||
|
||||
use Paparazzi::Traces;
|
||||
|
||||
require LWP::Simple;
|
||||
use XML::DOM;
|
||||
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_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.],
|
||||
-rc_control => [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.],
|
||||
-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_north0} = $waypoints->getAttribute('utm_y0');
|
||||
|
||||
$self->parse_rc_control($doc);
|
||||
$self->parse_waypoints($doc);
|
||||
$self->parse_mission($doc);
|
||||
$self->configure_spec();
|
||||
@@ -129,6 +133,25 @@ sub configure_spec {
|
||||
-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 {
|
||||
my ($self, $doc) = @_;
|
||||
my $wp_nb = 0;
|
||||
|
||||
@@ -37,4 +37,12 @@ sub min {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user