diff options
author | etienne | 2007-06-26 14:52:29 +0000 |
---|---|---|
committer | etienne | 2007-06-26 14:52:29 +0000 |
commit | e33bed4bab96614e7b8c13d2931537359d90afa6 (patch) | |
tree | 24f1c07040ddfee16cf708bf015692ba2fa397d9 /src/ivyreplay | |
parent | 9593495329be3713c99d7e1a9aa40131e10448aa (diff) | |
download | ivymon-e33bed4bab96614e7b8c13d2931537359d90afa6.zip ivymon-e33bed4bab96614e7b8c13d2931537359d90afa6.tar.gz ivymon-e33bed4bab96614e7b8c13d2931537359d90afa6.tar.bz2 ivymon-e33bed4bab96614e7b8c13d2931537359d90afa6.tar.xz |
Suppression des options -size et -undersize. L'option X11 -geometry
redevient utilisable.
Ajout de -light qui supprime l'affichage des messages ivy.
Possibilite d'ajouter des retards dans le fichier d'entree sous la
forme delay=float
Diffstat (limited to 'src/ivyreplay')
-rwxr-xr-x | src/ivyreplay | 252 |
1 files changed, 111 insertions, 141 deletions
diff --git a/src/ivyreplay b/src/ivyreplay index 5aa1009..cc6f905 100755 --- a/src/ivyreplay +++ b/src/ivyreplay @@ -19,15 +19,13 @@ use strict; use Getopt::Long; use Tk::CmdLine; use vars qw/$opt_help $opt_b $opt_bus - $opt_size $opt_undersize $opt_autostart - $opt_repeat $opt_startregexp + $opt_light $opt_autostart + $opt_repeat $opt_startregexp $opt_stopregexp $opt_timegranularity $opt_debug/; +our $VERSION = '1.22'; + # geometry -my $minW = 1024; -my $minH = 768; -my $smallsized = 0; -my $coef = 1; my $ivy_port; # undef:=> default value is treated by ivy-perl my $appname = 'IvyReplay'; @@ -64,7 +62,6 @@ my $replay_fg = 'black'; my $replay_bg_orig; my $replay_fg_orig; my $replay_hour; - $opt_startregexp = '^ClockStart\$'; $opt_stopregexp = '^ClockStop\$'; @@ -75,13 +72,15 @@ $opt_stopregexp = '^ClockStop\$'; Tk::CmdLine::SetArguments(-font => '7x14'); Tk::CmdLine::SetArguments(); -if (not GetOptions('-help', '-b=s', '-bus=s', '-size=s', '-undersize', +if (not GetOptions('-help', '-b=s', '-bus=s', '-light', '-repeat', '-startregexp=s', '-debug', '-timegranularity=s', '-autostart', '-stopregexp=s') or $opt_help) { print "\n"; + print "IvyReplay version $VERSION\n"; + print "\n"; print "Usage: ivyreplay [-b[us] bus] [-help]\n"; - print " [-size size] [-undersize] [-autostart]\n"; + print " [-autostart] [-light]\n"; print " [-repeat] [-timegranularity float>0]\n"; print " [-startregexp regexp] [-stopregexp regexp]\n"; print " [standard X11 options...]\n"; @@ -89,9 +88,9 @@ if (not GetOptions('-help', '-b=s', '-bus=s', '-size=s', '-undersize', print "\n"; print "Options :\n"; print " -b <[addr]:port> Ivy bus (\$IVYBUS by default)\n"; - print " -size <VGA|SVGA|XGA|SXGA|UXGA> Size of the main window\n"; - print " -undersize If set, slightly reduces the main window\n"; + print " -light If set, does not display messages\n"; print " -autostart If set, messages are replayed as soon as the\n"; + print " input file is loaded\n"; print " -repeat If set, repeat infinitely the replay sequence\n"; print " -timegranularity Time granularity (in second) for replaying\n"; print " messages (1 by default)\n"; @@ -104,8 +103,7 @@ if (not GetOptions('-help', '-b=s', '-bus=s', '-size=s', '-undersize', exit ; } - -croak "Error : an input file is expected\n" unless @ARGV > 0; +my ($minW, $minH) = (defined $opt_light) ? (800, 50) : (800, 100); $replay_repeat = $opt_repeat; if ($opt_bus) { @@ -138,52 +136,6 @@ if ($replay_time_granularity >= 1) { $replay_hour = &replayTime(); -#=================================== -# -# Size options - -if($opt_size eq "UXGA" || $opt_size eq "1600") { - $minW = 1600; - $minH = 1200; - $smallsized = 0; - $coef = 1.2; - Tk::CmdLine::SetArguments(-font => '10x20'); - Tk::CmdLine::SetArguments(); -} elsif ($opt_size eq "SXGA" || $opt_size eq "1280") { - $minW = 1280; - $minH = 1024; - $smallsized = 0; - $coef = 1.1; - Tk::CmdLine::SetArguments(-font => '8x13'); - Tk::CmdLine::SetArguments(); -} elsif ($opt_size eq "XGA" || $opt_size eq "1024") { - $minW = 1024; - $minH = 768; - $smallsized = 1; - $coef = 1; - Tk::CmdLine::SetArguments(-font => '7x14'); - Tk::CmdLine::SetArguments(); -} elsif ($opt_size eq "SVGA" || $opt_size eq "800") { - $minW = 800; - $minH = 600; - $smallsized = 1; - $coef = 0.64; - Tk::CmdLine::SetArguments(-font => '6x10'); - Tk::CmdLine::SetArguments(); -} elsif ($opt_size eq "VGA" || $opt_size eq "640"){ - $minW = 640; - $minH = 480; - $smallsized = 1; - $coef = 0.48; - Tk::CmdLine::SetArguments(-font => '5x7'); - Tk::CmdLine::SetArguments(); -} - -if ($opt_undersize) { - $minW -= 10; - $minH -= 30; -} - #================================================================================= # # H M I @@ -191,10 +143,10 @@ if ($opt_undersize) { #================================================================================= my $mw = MainWindow->new(); -# Set default min size -$mw->geometry($minW."x".$minH); $mw->title($title); +$mw->minsize($minW, $minH); + #---------------------------------------------------------------------------------- # Progress bar #---------------------------------------------------------------------------------- @@ -246,7 +198,9 @@ $ivy->start; # load input files my $file = $ARGV[0]; -if (not open(IN, $file)) { +if (not $file) { + $mw->Tk::Error("Error : an input file is expected"); +} elsif (not open(IN, $file)) { $mw->Tk::Error("Can't open file '$file' ($!)"); } else { &showProgressbar(); @@ -285,7 +239,7 @@ sub stepsnumber { while(<IN>) { chomp; next if (/^applications=/ or /^(marker\d+)$/ or /^(messages_number=)/ - or /^\#/); + or /^\#/ or /^delay=/); my ($sender, $message) = split(/\s+/, $_, 2); if ($message =~ /^(\d[\d\.]+\d)\s+.*/) { $timefound = 1; @@ -303,20 +257,22 @@ sub build { %replay_msg = (); $replay_time = undef; - # build replay window my $ctrl_fm = $mw->Frame()->pack(-side => 'bottom', -pady => 5); - $replay_text = $mw->Scrolled('Text', - -scrollbars => 'e', - -spacing1 => 2, - -spacing2 => 0, - -spacing3 => 2, - )->pack(-fill => 'both', - -expand => 1, - -side => 'bottom'); - # colors - $replay_bg_orig = $replay_text->cget(-background); - $replay_fg_orig = $replay_text->cget(-foreground); - &wheelmousebindings($replay_text); + unless ($opt_light) { + # build replay window + $replay_text = $mw->Scrolled('Text', + -scrollbars => 'e', + -spacing1 => 2, + -spacing2 => 0, + -spacing3 => 2, + )->pack(-fill => 'both', + -expand => 1, + -side => 'bottom'); + # colors + $replay_bg_orig = $replay_text->cget(-background); + $replay_fg_orig = $replay_text->cget(-foreground); + &wheelmousebindings($replay_text); + } # build speed control buttons my $realspeedrate = 1; my $ctrl_fm1 = $ctrl_fm->Frame()->pack(-side => 'left', -padx => 10); @@ -411,72 +367,84 @@ sub build { -height => 1)->pack(-side => 'left', -padx => 10, -fill => 'y', -expand => 1); $mw->update; - $mw->minsize($mw->width, 100); } # end build sub loadfileForReplay { + + my $step = shift; + my $line = 0; - my $step = shift; - my $line = 0; - - # display messsages to replay - my ($sender, $time, $message); - while(<IN>) { + # display messsages to replay + my ($sender, $time, $message); + my $delay = 0; + while(<IN>) { chomp; next if /^\#/ or /^applications=/ or /^messages_number=/ or /^\s*$/ or /^(marker\d+)$/; - ($sender, $time, $message) = split(/\s+/, $_, 3); + if (/^delay=(\d.*)/) { + if ($1 < 0) { + carp "delay (=$1) must be >=0\n"; + } else { + $delay += $1; + } + #print "delay=$delay\n"; + next; + } + ($sender, $time, $message) = split(/\s+/, $_, 3); + $time += $delay; if ($replay_time_granularity >= 1) { - $time = int($time); + $time = int($time); } else { - $time = sprintf("%.".$replay_time_decimalplaces."f", $time); + $time = sprintf("%.".$replay_time_decimalplaces."f", $time); } if (defined $replay_max_time) { - $replay_max_time = $time if $time > $replay_max_time; + $replay_max_time = $time if $time > $replay_max_time; } else { - $replay_max_time = $time; + $replay_max_time = $time; } if (defined $replay_min_time) { - $replay_min_time = $time if $time < $replay_min_time; + $replay_min_time = $time if $time < $replay_min_time; } else { - $replay_min_time = $time; + $replay_min_time = $time; } $line++; $message =~ s/^\"//; $message =~ s/\"$//; push(@{$replay_msg{$time}}, $message); - $replay_text->insert('end', &replayTime($time)." ".$message."\n", $time); - # when user click on a message the begin time changes. - $replay_text->tagBind($time, '<1>', [sub { - my $ti = $_[1]; - my $replay_was_running; - if ($replay_running) { - $replay_was_running = 1; - &replayStop; - } - $replay_text->tagConfigure($replay_last_time, - -foreground => $replay_fg_orig, - -background => $replay_bg_orig) - if defined $replay_last_time; - $replay_text->tagConfigure($ti, - -foreground => $replay_fg, - -background => $replay_bg); - $replay_last_time = $ti; - $replay_hour = &replayTime($ti); - $replay_time = $ti; - ®ulationReset(); - &replayStart if $replay_was_running; - }, $time]); + if ($replay_text) { + $replay_text->insert('end', &replayTime($time)." ".$message."\n", $time); + # when user click on a message the begin time changes. + $replay_text->tagBind($time, '<1>', [sub { + my $ti = $_[1]; + my $replay_was_running; + if ($replay_running) { + $replay_was_running = 1; + &replayStop; + } + $replay_text->tagConfigure($replay_last_time, + -foreground => $replay_fg_orig, + -background => $replay_bg_orig) + if defined $replay_last_time; + $replay_text->tagConfigure($ti, + -foreground => $replay_fg, + -background => $replay_bg); + $replay_last_time = $ti; + $replay_hour = &replayTime($ti); + $replay_time = $ti; + ®ulationReset(); + &replayStart if $replay_was_running; + }, $time]); + } &setProgressbar($line, $step); - } - $mw->raise; - $replay_time = $replay_min_time; - $replay_text->configure(-state => 'disabled'); - # ivy bindings - $ivy->bindRegexp($opt_startregexp, [\&replayStart]) if $opt_startregexp; - $ivy->bindRegexp($opt_stopregexp, [\&replayStop]) if $opt_stopregexp; + } + $replay_text->configure(-state => 'disabled') if $replay_text; + $mw->raise; + $replay_time = $replay_min_time; + # ivy bindings + $ivy->bindRegexp($opt_startregexp, [\&replayStart]) if $opt_startregexp; + $ivy->bindRegexp($opt_stopregexp, [\&replayStop]) if $opt_stopregexp; } # end loadfileForReplay @@ -530,7 +498,7 @@ sub replayStart { $t->tagConfigure($replay_last_time, -foreground => $replay_fg_orig, -background => $replay_bg_orig) - if defined $replay_last_time; + if $t and defined $replay_last_time; $replay_running = 0; $replay_runnable = 1; return; @@ -544,14 +512,14 @@ sub replayStart { $t->tagConfigure($replay_last_time, -foreground => $replay_fg_orig, -background => $replay_bg_orig) - if defined $replay_last_time; + if $t and defined $replay_last_time; $t->tagConfigure($replay_time, -foreground => $replay_fg, - -background => $replay_bg); + -background => $replay_bg) if $t; } $replay_last_time = $replay_time; - my ($i) = $t->tagRanges($replay_time); - $t->see($i) if defined $i; + my ($i) = $t->tagRanges($replay_time) if $t; + $t->see($i) if defined $i and $t; } $replay_time += $replay_time_granularity; $replay_time = sprintf("%.".$replay_time_decimalplaces."f", $replay_time) if @@ -610,21 +578,26 @@ sub replayStop { $replay_running = 0; $replay_runnable = 1; - $replay_text->afterCancel($replay_timer) if defined $replay_timer; + $replay_text->afterCancel($replay_timer) if $replay_text + and defined $replay_timer; ®ulationReset(); } # end replayStop sub replayClose { - $ivy->bindRegexp($opt_startregexp); - $ivy->bindRegexp($opt_stopregexp); - &replayStop(); - $replay_text->after(400, sub {$mw->destroy}); - $replay_speed = 1; - $replay_repeat = $opt_repeat; - $replay_stepbystep = undef; - $replay_hour = '--:--:--'; + $ivy->bindRegexp($opt_startregexp); + $ivy->bindRegexp($opt_stopregexp); + &replayStop(); + if ($replay_text) { + $replay_text->after(400, sub {$mw->destroy}); + } else { + $mw->destroy; + } + $replay_speed = 1; + $replay_repeat = $opt_repeat; + $replay_stepbystep = undef; + $replay_hour = '--:--:--'; } # end replayClose @@ -693,8 +666,7 @@ ivyreplay - a graphical application for replaying Ivy messages =head1 SYNOPSIS -B<ivyreplay> [B<-b> ivybus] [B<-help>] - [B<-size> window size] [B<-undersize>] +B<ivyreplay> [B<-b> ivybus] [B<-help>] [B<-light>] [B<-autostart>] [B<-repeat>] [B<-timegranularity> float>0] [B<-startregexp> regexp] @@ -719,15 +691,13 @@ Set the bus domain and port number to be used. Use $IVYBUS variable if defined. Get some help +=item B<-autostart> -=item B<-size> window size - -Set the size of the IvyMon window. Can be VGA or 640, SVGA or 800, XGA or 1024, SXGA or 1280, UXGA or 1600. Default is XGA (1024x768). - -=item B<-undersize> +If set, messages are replayed as soon as the input file is loaded. -Slightly reduce the IvyMon window to fit it in screen with borders of the window manager. Option not set by default. +=item B<-light> +If set, messages are not displayed. =item B<-repeat> |