From f151d5dffbab43bb615466cd5b52c8a770442072 Mon Sep 17 00:00:00 2001 From: Antoine Drouin Date: Fri, 7 Apr 2006 01:53:38 +0000 Subject: [PATCH] *** empty log message *** --- sw/airborne/modem.h | 6 +- sw/cgi/configuration.cgi | 2 +- sw/ground_segment/cockpit/Paparazzi/Strip.pm | 88 +++++++++++-------- .../cockpit/Paparazzi/StripPanel.pm | 17 +++- sw/ground_segment/cockpit/cockpit.pl | 8 +- sw/lib/ocaml/Makefile | 2 +- sw/lib/perl/Paparazzi/Aircraft.pm | 2 + sw/simulator/fg.c | 2 +- sw/supervision/Paparazzi/CpSessionMgr.pm | 28 +++++- 9 files changed, 103 insertions(+), 52 deletions(-) diff --git a/sw/airborne/modem.h b/sw/airborne/modem.h index 99513140ce..e7af1650bf 100644 --- a/sw/airborne/modem.h +++ b/sw/airborne/modem.h @@ -61,12 +61,12 @@ extern uint8_t ck_a, ck_b; #if TX_BUF_SIZE == 256 #define UPDATE_HEAD() { \ - tx_head++; \ - if (tx_head >= TX_BUF_SIZE) tx_head = 0; \ + tx_head++; \ } #else #define UPDATE_HEAD() { \ - tx_head++; \ + tx_head++; \ + if (tx_head >= TX_BUF_SIZE) tx_head = 0; \ } #endif diff --git a/sw/cgi/configuration.cgi b/sw/cgi/configuration.cgi index 17dbfea7ae..089040cd00 100755 --- a/sw/cgi/configuration.cgi +++ b/sw/cgi/configuration.cgi @@ -35,7 +35,7 @@ print Tr(th(["Id", "Name", "Airframe", "Radio", "Flight plan"])); foreach my $ac (@{$configuration->{aircrafts}}) { print - Tr(td([$ac->{ac_id}, $ac->{name}, + Tr(td([$ac->{ac_id}, $ac->{name}, a({href=>"../conf/$ac->{airframe}"}, foo($ac->{airframe}) ), a({href=>"../conf/$ac->{radio}"}, foo($ac->{radio}) ), a({href=>"../conf/$ac->{flight_plan}"}, foo($ac->{flight_plan}) )])); diff --git a/sw/ground_segment/cockpit/Paparazzi/Strip.pm b/sw/ground_segment/cockpit/Paparazzi/Strip.pm index 6843afcee9..bd9042393c 100644 --- a/sw/ground_segment/cockpit/Paparazzi/Strip.pm +++ b/sw/ground_segment/cockpit/Paparazzi/Strip.pm @@ -31,7 +31,6 @@ use Subject; use Tk; use Tk::Zinc; -use XML::DOM; use Data::Dumper; use strict; @@ -40,10 +39,18 @@ use warnings; use Paparazzi::Traces; use Paparazzi::Utils; use Paparazzi::GuiConfig; +use Paparazzi::SimpleLinearGauge; + + +my $modes_data = + { + ap_mode => { 'MANUAL' => 'sienna', 'AUTO1' => 'blue', 'AUTO2' => 'brown', 'HOME' => 'red'}, + rc_status => {'OK' => 'brown', 'LOST' => 'orange', 'REALLY_LOST' => 'red'}, + rc_mode => {'AUTO'=> 'orange', 'MANUAL' => 'brown', 'FAILSAFE' => 'red'}, + contrast_status => {'DEFAULT' => 'orange', 'WAITING' => 'brown', 'SET' => 'green'}, + gps_mode => {'NOFIX' => 'red', 'DRO' => 'red', '2D' => 'orange', '3D' => 'brown', 'GPSDRO' => 'red'}, + }; -# populate: -# this sub is the subject constructor method -############################################################################## sub populate { my ($self, $args) = @_; $self->SUPER::populate($args); @@ -57,24 +64,12 @@ sub populate { ); } -# completeinit: -# this sub complete the init of subject object -############################################################################## sub completeinit { my $self = shift; $self->SUPER::completeinit(); my $zinc = $self->get(-zinc); - $self->{new_modes} = - { - ap_mode => { 'MANUAL' => 'sienna', 'AUTO1' => 'blue', 'AUTO2' => 'brown', 'HOME' => 'red'}, - rc_status => {'OK' => 'brown', 'LOST' => 'orange', 'REALLY_LOST' => 'red'}, - rc_mode => {'AUTO'=> 'orange', 'MANUAL' => 'brown', 'FAILSAFE' => 'red'}, - contrast_status => {'DEFAULT' => 'orange', 'WAITING' => 'brown', 'SET' => 'green'}, - gps_mode => {'NOFIX' => 'red', 'DRO' => 'red', '2D' => 'orange', '3D' => 'brown', 'GPSDRO' => 'red'}, - }; - $self->{frame} = undef; $self->{frame_clip} = undef; @@ -103,13 +98,15 @@ sub completeinit { # draw # draw elements of the strip ############################################################################## + +use constant MARGIN => 3; sub draw { my $self = shift; my $zinc = $self->get(-zinc); my $ident = $self->get(-aircraft)->get('-ac_id'); my ($x, $y) = @{$self->get('-origin')}; - my $width = 300; - + my $width = $self->get('-width'); + my $height = $self->get('-height'); ## main group of the strip $self->{topgroup} = $zinc->add('group', scalar $self->get('-parent_grp'), -sensitive => 1, @@ -117,9 +114,18 @@ sub draw { $self->{contentgroup} = $zinc->add('group', $self->{topgroup}, -composealpha=>0, -sensitive=>1); ## the strip - $self->{frame} = $zinc->add('rectangle', $self->{topgroup}, [5,5,$width, 95], -fillcolor => $self->{options}->{background_color}, -filled=>1, -linecolor => $self->{options}->{border_color}, -sensitive => 1, -tags => ["strip_".$ident]); + my ($actual_width, $actual_height) = ($width - 2 * MARGIN, $height - 2 * MARGIN); + my $strip_rect= [MARGIN, MARGIN, $actual_width , $actual_height]; + $self->{frame} = $zinc->add('rectangle', $self->{topgroup}, + , $strip_rect, + -fillcolor => $self->{options}->{background_color}, + -filled=>1, -linecolor => $self->{options}->{border_color}, + -sensitive => 1, + -tags => ["strip_".$ident] + ); # cliping contour of the strip - $self->{frame_clip} = $zinc->add('rectangle', $self->{contentgroup}, [5,5,$width, 95], -visible=>0); + $self->{frame_clip} = $zinc->add('rectangle', $self->{contentgroup}, + $strip_rect, -visible=>0); $zinc->itemconfigure($self->{contentgroup}, -clip=> $self->{frame_clip}); ## bindings to highlight the strip when the mouse is over @@ -127,20 +133,26 @@ sub draw { $zinc->bind($self->{frame}, '', sub { $zinc->itemconfigure($self->{frame}, -linecolor => 'sienna'); }); $zinc->bind($self->{frame}, '<1>', [\&onStripPressed, $self, $ident]); + my @col_x = ($actual_width * 0.03, $actual_width * 0.23, $actual_width * 0.53); + my @row_y = ($actual_height * 0.03, $actual_height * 0.23, $actual_height * 0.36, + $actual_height * 0.48, $actual_height * 0.61, $actual_height * 0.74); + ## ident of the plane - $self->{ident} = $zinc->add('text', $self->{contentgroup}, -text => uc($ident), -position=>[10,10], -font => $self->{options}->{normal_font}, -color => "midnightblue"); + $self->{ident} = $zinc->add('text', $self->{contentgroup}, -text => uc($ident), + -position=>[$col_x[0],$row_y[0]], -font => $self->{options}->{normal_font}, + -color => "midnightblue"); - my @label_attr = (['AP', 'ap_mode', 70, 10], - ['RC', 'rc_status', 70, 22], - ['GPS', 'gps_mode', 70, 34], - ['Wind','dir', 70, 46], - [' ', 'wspeed', 70, 58], - ['Mas', 'mean_aspeed', 70, 70], - ['alt:', 'alt', 160, 10], - ['desired:','target_alt', 160, 22], - ['throttle:', 'throttle', 160, 34], - ['speed:', 'speed', 160, 46], - ['climb:', 'climb', 160, 58], + my @label_attr = (['AP', 'ap_mode', $col_x[1], $row_y[0]], + ['RC', 'rc_status', $col_x[1], $row_y[1]], + ['GPS', 'gps_mode', $col_x[1], $row_y[2]], + ['Wind','dir', $col_x[1], $row_y[3]], + [' ', 'wspeed', $col_x[1], $row_y[4]], + ['Mas', 'mean_aspeed', $col_x[1], $row_y[5]], + ['alt:', 'alt', $col_x[2], $row_y[0]], + ['desired:','target_alt', $col_x[2], $row_y[1]], + ['throttle:', 'throttle', $col_x[2], $row_y[2]], + ['speed:', 'speed', $col_x[2], $row_y[3]], + ['climb:', 'climb', $col_x[2], $row_y[4]], ); foreach my $attr (@label_attr) { $self->add_label($attr->[0], $attr->[1], $attr->[2], $attr->[3]); @@ -160,10 +172,16 @@ sub draw { $self->{zinc_bat_value} = $zinc->add('text', $self->{contentgroup}, -text => sprintf("%s",$self->{battery}), -position=>[12,40], -font => $self->{options}->{small_font}); +# my $bat_gauge = Paparazzi::SimpleLinearGauge->new(-zinc => $zinc, -parent_grp => $self->{contentgroup}, +# -origin => [10,25], -width => 30, -height => 60 ); + + $zinc->translate($self->{topgroup}, $x, $y); $zinc->raise($self->{topgroup}); $zinc->raise($self->{contentgroup}); + + return $self->{topgroup}; } @@ -231,18 +249,16 @@ sub attach_to_aircraft { } } - sub get_color { my ($self, $mode, $value) = @_; - if (defined $self->{new_modes}->{$mode}->{$value}) { - return $self->{new_modes}->{$mode}->{$value}; + if (defined $modes_data->{$mode}->{$value}) { + return $modes_data->{$mode}->{$value}; } else { return 'black'; } } - sub aircraft_config_changed { my ($self, $aircraft, $event, $new_value) = @_; # print "in strip aircraft_config_changed $event $new_value\n"; diff --git a/sw/ground_segment/cockpit/Paparazzi/StripPanel.pm b/sw/ground_segment/cockpit/Paparazzi/StripPanel.pm index 6b150fefb7..ae9999b28b 100644 --- a/sw/ground_segment/cockpit/Paparazzi/StripPanel.pm +++ b/sw/ground_segment/cockpit/Paparazzi/StripPanel.pm @@ -29,6 +29,9 @@ sub completeinit { $self->build_gui(); } +use constant H_MARGIN => 5; +use constant V_MARGIN => 7; + sub build_gui { my ($self) = @_; my $zinc = $self->get('-zinc'); @@ -40,7 +43,7 @@ sub build_gui { $zinc->coords($self->{sp_main_group}, $origin); my $board = $zinc->add('rectangle', $self->{sp_main_group} , - [0, 0, $width-5, $height-7], + [0, 0, $width - H_MARGIN , $height - V_MARGIN], -linewidth => 0, -filled => 1, -fillcolor => 'blue', @@ -52,21 +55,27 @@ sub build_gui { } +use constant NB_STRIP => 3; + sub add_strip { my ($self, $aircraft) = @_; # add strip only once return if (defined $self->{strips}->{$aircraft->get('-ac_id')}); my $zinc = $self->get('-zinc'); - use constant NB_STRIP => 3; - my $step = $self->get('-height') / NB_STRIP; + my $strip_vspacing = ($self->get('-height') - 2 * V_MARGIN) / NB_STRIP; + my $strip_width = $self->get('-width') - H_MARGIN; + my $strip_height = $strip_vspacing; my $nb_strips = keys %{$self->{strips}}; - my ($p, $w, $h) = ([5, 5 + $step * $nb_strips], 120, 45); + my ($p, $w, $h) = ([H_MARGIN, V_MARGIN + $strip_vspacing * $nb_strips], $strip_width, $strip_height); my $strip = Paparazzi::Strip->new( -zinc => $zinc, -parent_grp => $self->{sp_main_group}, -origin => $p, -width => $w, -height => $h, -aircraft => $aircraft); my $ac_id = $aircraft->get('-ac_id'); $zinc->bind($strip->{'frame'},'',[\&OnStripPressed,$self, $ac_id]); $self->{strips}->{$ac_id} = $strip; + if ($nb_strips == 0) { + OnStripPressed($zinc, $self, $ac_id); + } } sub OnStripPressed { diff --git a/sw/ground_segment/cockpit/cockpit.pl b/sw/ground_segment/cockpit/cockpit.pl index 8151688d1e..3c82b871db 100755 --- a/sw/ground_segment/cockpit/cockpit.pl +++ b/sw/ground_segment/cockpit/cockpit.pl @@ -41,6 +41,8 @@ my $options = render => 1, vertical => 0, tracelevel => 1, + width => 250, + height => 750, }; sub populate { @@ -81,17 +83,17 @@ sub on_new_aircraft { sub build_gui { my ($self) = @_; $self->{mw} = MainWindow->new(); - my $size = 250; + my $size = $options->{width}; my $top_frame = $self->{mw}->Frame()->pack(-side => 'top', -fill => 'both'); my ($stp_p, $stp_w, $stp_h) = ([0, 0], $size, $size); my ($pfd_p, $pfd_w, $pfd_h) = ([$stp_w, 0] , $size, $size); my ($nd_p, $nd_w, $nd_h) = ([$pfd_p->[0]+ $pfd_w, 0], $size, $size); - my ($z_w, $z_h) = ($stp_w + $pfd_w + $nd_w, $nd_h); + my ($z_w, $z_h) = ($stp_w + $pfd_w + $nd_w, $size); if ($options->{vertical}) { ($pfd_p, $pfd_w, $pfd_h) = ([0, $stp_h] , $size, $size); ($nd_p, $nd_w, $nd_h) = ([0, $pfd_p->[1]+ $pfd_h], $size, $size); - ($z_w, $z_h) = ($stp_w, $stp_h + $pfd_h + $nd_h) + ($z_w, $z_h) = ($size, $stp_h + $pfd_h + $nd_h) } my $zinc = $top_frame->Zinc(-width => $z_w , diff --git a/sw/lib/ocaml/Makefile b/sw/lib/ocaml/Makefile index f896f9ac2b..4b99c9f8f2 100644 --- a/sw/lib/ocaml/Makefile +++ b/sw/lib/ocaml/Makefile @@ -61,7 +61,7 @@ ignutm.opt : latlong.cmx ignutm.ml utm_of.opt : latlong.cmx utm_of.ml $(OCAMLOPT) -o $@ $^ -GTKCFLAGS := -I /usr/lib/gtk-2.0/include -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 +GTKCFLAGS := -I /usr/lib/gtk-2.0/include -I/usr/include/gtk-2.0 -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pango-1.0 -I /usr/include/cairo # GTKCFLAGS := $(shell gtk-config --cflags) %.o : %.c diff --git a/sw/lib/perl/Paparazzi/Aircraft.pm b/sw/lib/perl/Paparazzi/Aircraft.pm index e55236dd83..2cec3443be 100644 --- a/sw/lib/perl/Paparazzi/Aircraft.pm +++ b/sw/lib/perl/Paparazzi/Aircraft.pm @@ -34,6 +34,8 @@ sub populate { $self->configspec( -ac_id => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef], -callsign => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""], + ac_name => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""], + default_gui_color => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""], flight_plan => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef], airframe => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef], diff --git a/sw/simulator/fg.c b/sw/simulator/fg.c index 838a509cc5..77157ee975 100644 --- a/sw/simulator/fg.c +++ b/sw/simulator/fg.c @@ -29,7 +29,7 @@ value fg_msg_native(value s, value lat, value lon, value z, value phi, value the msg.longitude = Double_val(lon); msg.latitude = Double_val(lat); - msg.altitude = Double_val(z) + 20; + msg.altitude = Double_val(z) + 50; msg.agl = 0.; msg.phi = Double_val(phi); msg.theta = Double_val(theta); diff --git a/sw/supervision/Paparazzi/CpSessionMgr.pm b/sw/supervision/Paparazzi/CpSessionMgr.pm index 56e998388a..798df5ca52 100644 --- a/sw/supervision/Paparazzi/CpSessionMgr.pm +++ b/sw/supervision/Paparazzi/CpSessionMgr.pm @@ -25,9 +25,10 @@ sub populate { sub completeinit { my ($self) = @_; $self->SUPER::completeinit(); - my $cfg_file = $self->get('-config_file'); - my $variables = $self->get('-variables'); - $self->read_cfg($cfg_file); +# my $cfg_file = $self->get('-config_file'); +# my $variables = $self->get('-variables'); +# $self->read_cfg($cfg_file); + $self->check_config(); } sub prepare_args { @@ -89,6 +90,7 @@ sub toggle_program { sub toggle_program_in_session { my ($self, $session_name, $pgm_idx) = @_; + $self->check_config(); my $session = $self->get('-sessions')->{$session_name}; my $session_program = $session->{pgms}->[$pgm_idx]; # print "processing program in session context\n".Dumper($session); @@ -114,6 +116,7 @@ sub toggle_program_in_session { sub start_session { my ($self, $session_name) = @_; + $self->check_config(); # print "starting session $session_name\n"; my $sessions = $self->get('-sessions'); my $session = $sessions->{$session_name}; @@ -140,6 +143,25 @@ sub get_session_program_status { return (defined $session_program->{pid}); } + +# +# check if the config file has been modified since we parsed it and +# eventually reread it +# +sub check_config { + my ($self) = @_; + my $cfg_file = $self->get('-config_file'); + my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) + = stat($cfg_file); + + if (not exists $self->{last_cfg_read_time} or $mtime > $self->{last_cfg_read_time}) { + print("(re) reading config\n"); + $self->read_cfg($cfg_file); + $self->{last_cfg_read_time} = $mtime; + } +} + sub xml_parse_args { my ($args) = @_; my @args_a;