*** empty log message ***

This commit is contained in:
Antoine Drouin
2006-04-07 01:53:38 +00:00
parent af09ba4706
commit f151d5dffb
9 changed files with 103 additions and 52 deletions
+1 -1
View File
@@ -62,11 +62,11 @@ extern uint8_t ck_a, ck_b;
#if TX_BUF_SIZE == 256 #if TX_BUF_SIZE == 256
#define UPDATE_HEAD() { \ #define UPDATE_HEAD() { \
tx_head++; \ tx_head++; \
if (tx_head >= TX_BUF_SIZE) tx_head = 0; \
} }
#else #else
#define UPDATE_HEAD() { \ #define UPDATE_HEAD() { \
tx_head++; \ tx_head++; \
if (tx_head >= TX_BUF_SIZE) tx_head = 0; \
} }
#endif #endif
+53 -37
View File
@@ -31,7 +31,6 @@ use Subject;
use Tk; use Tk;
use Tk::Zinc; use Tk::Zinc;
use XML::DOM;
use Data::Dumper; use Data::Dumper;
use strict; use strict;
@@ -40,10 +39,18 @@ use warnings;
use Paparazzi::Traces; use Paparazzi::Traces;
use Paparazzi::Utils; use Paparazzi::Utils;
use Paparazzi::GuiConfig; 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 { sub populate {
my ($self, $args) = @_; my ($self, $args) = @_;
$self->SUPER::populate($args); $self->SUPER::populate($args);
@@ -57,24 +64,12 @@ sub populate {
); );
} }
# completeinit:
# this sub complete the init of subject object
##############################################################################
sub completeinit { sub completeinit {
my $self = shift; my $self = shift;
$self->SUPER::completeinit(); $self->SUPER::completeinit();
my $zinc = $self->get(-zinc); 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} = undef;
$self->{frame_clip} = undef; $self->{frame_clip} = undef;
@@ -103,13 +98,15 @@ sub completeinit {
# draw # draw
# draw elements of the strip # draw elements of the strip
############################################################################## ##############################################################################
use constant MARGIN => 3;
sub draw { sub draw {
my $self = shift; my $self = shift;
my $zinc = $self->get(-zinc); my $zinc = $self->get(-zinc);
my $ident = $self->get(-aircraft)->get('-ac_id'); my $ident = $self->get(-aircraft)->get('-ac_id');
my ($x, $y) = @{$self->get('-origin')}; my ($x, $y) = @{$self->get('-origin')};
my $width = 300; my $width = $self->get('-width');
my $height = $self->get('-height');
## main group of the strip ## main group of the strip
$self->{topgroup} = $zinc->add('group', scalar $self->get('-parent_grp'), -sensitive => 1, $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); $self->{contentgroup} = $zinc->add('group', $self->{topgroup}, -composealpha=>0, -sensitive=>1);
## the strip ## 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 # 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}); $zinc->itemconfigure($self->{contentgroup}, -clip=> $self->{frame_clip});
## bindings to highlight the strip when the mouse is over ## bindings to highlight the strip when the mouse is over
@@ -127,20 +133,26 @@ sub draw {
$zinc->bind($self->{frame}, '<Leave>', sub { $zinc->itemconfigure($self->{frame}, -linecolor => 'sienna'); }); $zinc->bind($self->{frame}, '<Leave>', sub { $zinc->itemconfigure($self->{frame}, -linecolor => 'sienna'); });
$zinc->bind($self->{frame}, '<1>', [\&onStripPressed, $self, $ident]); $zinc->bind($self->{frame}, '<1>', [\&onStripPressed, $self, $ident]);
## ident of the plane my @col_x = ($actual_width * 0.03, $actual_width * 0.23, $actual_width * 0.53);
$self->{ident} = $zinc->add('text', $self->{contentgroup}, -text => uc($ident), -position=>[10,10], -font => $self->{options}->{normal_font}, -color => "midnightblue"); 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);
my @label_attr = (['AP', 'ap_mode', 70, 10], ## ident of the plane
['RC', 'rc_status', 70, 22], $self->{ident} = $zinc->add('text', $self->{contentgroup}, -text => uc($ident),
['GPS', 'gps_mode', 70, 34], -position=>[$col_x[0],$row_y[0]], -font => $self->{options}->{normal_font},
['Wind','dir', 70, 46], -color => "midnightblue");
[' ', 'wspeed', 70, 58],
['Mas', 'mean_aspeed', 70, 70], my @label_attr = (['AP', 'ap_mode', $col_x[1], $row_y[0]],
['alt:', 'alt', 160, 10], ['RC', 'rc_status', $col_x[1], $row_y[1]],
['desired:','target_alt', 160, 22], ['GPS', 'gps_mode', $col_x[1], $row_y[2]],
['throttle:', 'throttle', 160, 34], ['Wind','dir', $col_x[1], $row_y[3]],
['speed:', 'speed', 160, 46], [' ', 'wspeed', $col_x[1], $row_y[4]],
['climb:', 'climb', 160, 58], ['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) { foreach my $attr (@label_attr) {
$self->add_label($attr->[0], $attr->[1], $attr->[2], $attr->[3]); $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}); $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->translate($self->{topgroup}, $x, $y);
$zinc->raise($self->{topgroup}); $zinc->raise($self->{topgroup});
$zinc->raise($self->{contentgroup}); $zinc->raise($self->{contentgroup});
return $self->{topgroup}; return $self->{topgroup};
} }
@@ -231,18 +249,16 @@ sub attach_to_aircraft {
} }
} }
sub get_color { sub get_color {
my ($self, $mode, $value) = @_; my ($self, $mode, $value) = @_;
if (defined $self->{new_modes}->{$mode}->{$value}) { if (defined $modes_data->{$mode}->{$value}) {
return $self->{new_modes}->{$mode}->{$value}; return $modes_data->{$mode}->{$value};
} }
else { else {
return 'black'; return 'black';
} }
} }
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";
@@ -29,6 +29,9 @@ sub completeinit {
$self->build_gui(); $self->build_gui();
} }
use constant H_MARGIN => 5;
use constant V_MARGIN => 7;
sub build_gui { sub build_gui {
my ($self) = @_; my ($self) = @_;
my $zinc = $self->get('-zinc'); my $zinc = $self->get('-zinc');
@@ -40,7 +43,7 @@ sub build_gui {
$zinc->coords($self->{sp_main_group}, $origin); $zinc->coords($self->{sp_main_group}, $origin);
my $board = $zinc->add('rectangle', $self->{sp_main_group} , 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, -linewidth => 0,
-filled => 1, -filled => 1,
-fillcolor => 'blue', -fillcolor => 'blue',
@@ -52,21 +55,27 @@ sub build_gui {
} }
use constant NB_STRIP => 3;
sub add_strip { sub add_strip {
my ($self, $aircraft) = @_; my ($self, $aircraft) = @_;
# add strip only once # add strip only once
return if (defined $self->{strips}->{$aircraft->get('-ac_id')}); return if (defined $self->{strips}->{$aircraft->get('-ac_id')});
my $zinc = $self->get('-zinc'); my $zinc = $self->get('-zinc');
use constant NB_STRIP => 3; my $strip_vspacing = ($self->get('-height') - 2 * V_MARGIN) / NB_STRIP;
my $step = $self->get('-height') / NB_STRIP; my $strip_width = $self->get('-width') - H_MARGIN;
my $strip_height = $strip_vspacing;
my $nb_strips = keys %{$self->{strips}}; 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}, my $strip = Paparazzi::Strip->new( -zinc => $zinc, -parent_grp => $self->{sp_main_group},
-origin => $p, -width => $w, -height => $h, -origin => $p, -width => $w, -height => $h,
-aircraft => $aircraft); -aircraft => $aircraft);
my $ac_id = $aircraft->get('-ac_id'); my $ac_id = $aircraft->get('-ac_id');
$zinc->bind($strip->{'frame'},'<ButtonPress-1>',[\&OnStripPressed,$self, $ac_id]); $zinc->bind($strip->{'frame'},'<ButtonPress-1>',[\&OnStripPressed,$self, $ac_id]);
$self->{strips}->{$ac_id} = $strip; $self->{strips}->{$ac_id} = $strip;
if ($nb_strips == 0) {
OnStripPressed($zinc, $self, $ac_id);
}
} }
sub OnStripPressed { sub OnStripPressed {
+5 -3
View File
@@ -41,6 +41,8 @@ my $options =
render => 1, render => 1,
vertical => 0, vertical => 0,
tracelevel => 1, tracelevel => 1,
width => 250,
height => 750,
}; };
sub populate { sub populate {
@@ -81,17 +83,17 @@ sub on_new_aircraft {
sub build_gui { sub build_gui {
my ($self) = @_; my ($self) = @_;
$self->{mw} = MainWindow->new(); $self->{mw} = MainWindow->new();
my $size = 250; my $size = $options->{width};
my $top_frame = $self->{mw}->Frame()->pack(-side => 'top', -fill => 'both'); my $top_frame = $self->{mw}->Frame()->pack(-side => 'top', -fill => 'both');
my ($stp_p, $stp_w, $stp_h) = ([0, 0], $size, $size); my ($stp_p, $stp_w, $stp_h) = ([0, 0], $size, $size);
my ($pfd_p, $pfd_w, $pfd_h) = ([$stp_w, 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 ($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}) { if ($options->{vertical}) {
($pfd_p, $pfd_w, $pfd_h) = ([0, $stp_h] , $size, $size); ($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); ($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 , my $zinc = $top_frame->Zinc(-width => $z_w ,
+1 -1
View File
@@ -61,7 +61,7 @@ ignutm.opt : latlong.cmx ignutm.ml
utm_of.opt : latlong.cmx utm_of.ml utm_of.opt : latlong.cmx utm_of.ml
$(OCAMLOPT) -o $@ $^ $(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) # GTKCFLAGS := $(shell gtk-config --cflags)
%.o : %.c %.o : %.c
+2
View File
@@ -34,6 +34,8 @@ sub populate {
$self->configspec( $self->configspec(
-ac_id => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef], -ac_id => [S_NEEDINIT, S_PASSIVE, S_RDONLY, S_OVRWRT, S_NOPRPG, undef],
-callsign => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, ""], -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], 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], airframe => [S_NOINIT, S_PASSIVE, S_RDWR, S_OVRWRT, S_NOPRPG, undef],
+1 -1
View File
@@ -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.longitude = Double_val(lon);
msg.latitude = Double_val(lat); msg.latitude = Double_val(lat);
msg.altitude = Double_val(z) + 20; msg.altitude = Double_val(z) + 50;
msg.agl = 0.; msg.agl = 0.;
msg.phi = Double_val(phi); msg.phi = Double_val(phi);
msg.theta = Double_val(theta); msg.theta = Double_val(theta);
+25 -3
View File
@@ -25,9 +25,10 @@ sub populate {
sub completeinit { sub completeinit {
my ($self) = @_; my ($self) = @_;
$self->SUPER::completeinit(); $self->SUPER::completeinit();
my $cfg_file = $self->get('-config_file'); # my $cfg_file = $self->get('-config_file');
my $variables = $self->get('-variables'); # my $variables = $self->get('-variables');
$self->read_cfg($cfg_file); # $self->read_cfg($cfg_file);
$self->check_config();
} }
sub prepare_args { sub prepare_args {
@@ -89,6 +90,7 @@ sub toggle_program {
sub toggle_program_in_session { sub toggle_program_in_session {
my ($self, $session_name, $pgm_idx) = @_; my ($self, $session_name, $pgm_idx) = @_;
$self->check_config();
my $session = $self->get('-sessions')->{$session_name}; my $session = $self->get('-sessions')->{$session_name};
my $session_program = $session->{pgms}->[$pgm_idx]; my $session_program = $session->{pgms}->[$pgm_idx];
# print "processing program in session context\n".Dumper($session); # print "processing program in session context\n".Dumper($session);
@@ -114,6 +116,7 @@ sub toggle_program_in_session {
sub start_session { sub start_session {
my ($self, $session_name) = @_; my ($self, $session_name) = @_;
$self->check_config();
# print "starting session $session_name\n"; # print "starting session $session_name\n";
my $sessions = $self->get('-sessions'); my $sessions = $self->get('-sessions');
my $session = $sessions->{$session_name}; my $session = $sessions->{$session_name};
@@ -140,6 +143,25 @@ sub get_session_program_status {
return (defined $session_program->{pid}); 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 { sub xml_parse_args {
my ($args) = @_; my ($args) = @_;
my @args_a; my @args_a;