summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/ivymon78
1 files changed, 61 insertions, 17 deletions
diff --git a/src/ivymon b/src/ivymon
index d145f93..5fcab1f 100755
--- a/src/ivymon
+++ b/src/ivymon
@@ -11,6 +11,7 @@ use Tk::ErrorDialog;
use Tk::Dialog;
use Tk::ProgressBar;
use Sys::Hostname;
+use Time::HiRes qw(gettimeofday);
use Ivy;
use Carp;
use strict;
@@ -18,7 +19,7 @@ use Getopt::Long;
use Tk::CmdLine;
use vars qw/$VERSION $opt_help $opt_b $opt_bus $opt_history @opt_bind @opt_send $opt_size
$opt_undersize $opt_out $opt_loadingmode $opt_replayrepeat $opt_replaystartregexp
- $opt_replaystopregexp/;
+ $opt_replaystopregexp $opt_replaytimegranularity/;
# **** VERSION ***
$VERSION = '1.8';
@@ -103,6 +104,8 @@ my @effectivebind;
my $replay_speed = 1;
my $replay_runnable = 1;
my $replay_running = 0;
+my $replay_time_granularity = 1;
+my $replay_time_decimalplaces = 0;
my $replay_timer;
my $replay_tpl;
my $replay_text;
@@ -117,7 +120,7 @@ my $replay_bg = 'gray75';
my $replay_fg = 'black';
my $replay_bg_orig;
my $replay_fg_orig;
-my $replay_hour = &replayTime();;
+my $replay_hour;
#----------------------------------------------------------------------------------
# command line options management
#----------------------------------------------------------------------------------
@@ -128,12 +131,14 @@ Tk::CmdLine::SetArguments();
if (not GetOptions('-help', '-history=s', '-b=s', '-bus=s', '-bind=s@',
'-send=s@', '-size=s', '-undersize', '-loadingmode=s',
'-replayrepeat', '-replaystartregexp=s',
+ '-replaytimegranularity=s',
'-replaystopregexp=s', '-out=s') or $opt_help) {
print "Usage: ivymon [-b[us] bus] [-help] [-history length]\n";
print " [-size size] [-undersize]\n";
print " [-bind regexp1] ... [-bind regexpN] \n";
print " [-send message1] ... [-send messageN] \n";
print " [-loadingmode mode] [-replayrepeat]\n";
+ print " [-replaytimegranularity float>0]\n";
print " [-replaystartregexp regexp] [-replaystopregexp regexp]\n";
print " [-out outputfile] [standard X11 options...]\n";
print " [inputfile]\n";
@@ -150,6 +155,8 @@ if (not GetOptions('-help', '-history=s', '-b=s', '-bus=s', '-bind=s@',
print " -loadingmode <display|replay|replay-pause>\n";
print " Loading mode of input files\n";
print " ('replay-pause' by default)\n";
+ print " -replaytimegranularity Time granularity (in second) for replaying\n";
+ print " messages (1 by default)\n";
print " NOTE: The following options are usable if at least one input file is\n";
print " given and if -loadingmode is set to 'replay'\n";
print " -replayrepeat If set, repeat infinitely the replay sequence\n";
@@ -174,7 +181,16 @@ if ($ivy_port) {
} else {
$title = "Ivymon v$VERSION (default port)";
}
-
+$replay_time_granularity = $opt_replaytimegranularity if $opt_replaytimegranularity > 0;
+if ($replay_time_granularity >= 1) {
+ $replay_time_decimalplaces = 0;
+} else {
+ $replay_time_decimalplaces = $replay_time_granularity;
+ $replay_time_decimalplaces =~ s/^\+?\d*\.//;
+ $replay_time_decimalplaces = length($replay_time_decimalplaces);
+}
+$replay_hour = &replayTime();
+
push(@effectivebind, @opt_bind);
@effectivebind = ('(.*)') unless @effectivebind > 0;
push(@bind_def, @opt_bind);
@@ -896,7 +912,7 @@ sub addIvyBinding {
$message = shift;
}
$messagesNumber++;
- my $time = time();
+ my $time = gettimeofday();
if ($stopFlag) {
&bufferizeMessages($sender, $message, $time);
} else {
@@ -1565,7 +1581,7 @@ sub sendMsg {
my $entry = shift;
$messagesNumber++;
&beforeUpdatingMessages;
- &updateMessages($appname, $entry, scalar time());
+ &updateMessages($appname, $entry, scalar gettimeofday());
&afterUpdatingMessages;
$ivy->sendMsgs($entry);
@@ -2106,6 +2122,12 @@ sub loadfileForReplay {
&wheelmousebindings($replay_text);
# build speed control buttons
my $ctrl_fm1 = $ctrl_fm->Frame()->pack(-side => 'left', -padx => 10);
+ $ctrl_fm1->Checkbutton(-text => "x0.1", -indicatoron => 0,
+ -height => 2,
+ -width => 4,
+ -onvalue => 0.1,
+ -variable => \$replay_speed,
+ -selectcolor => 'white')->pack(-side => 'left');
$ctrl_fm1->Checkbutton(-text => "x0.5", -indicatoron => 0,
-height => 2,
-width => 4,
@@ -2130,16 +2152,18 @@ sub loadfileForReplay {
-onvalue => 5,
-variable => \$replay_speed,
-selectcolor => 'white')->pack(-side => 'left');
- $ctrl_fm1->Checkbutton(-text => "x9", -indicatoron => 0,
+ $ctrl_fm1->Checkbutton(-text => "x10", -indicatoron => 0,
-height => 2,
-width => 4,
- -onvalue => 9,
- -variable => \$replay_speed,
- -selectcolor => 'white')->pack(-side => 'left');
+ -onvalue => 10,
+ -variable => \$replay_speed,
+ -selectcolor => 'white')->pack(-side => 'left');
# build hour label
my $ctrl_fm2 = $ctrl_fm->Frame()->pack(-side => 'left', -padx => 10);
my $hour_lab = $ctrl_fm2->Label(-borderwidth => 1, -relief => 'ridge',
- -height => 2, -width => 9,
+ -height => 2,
+ -width => ($replay_time_decimalplaces > 0) ?
+ 10 + $replay_time_decimalplaces : 9,
-textvariable => \$replay_hour,
)->pack(-side => 'left');
@@ -2187,7 +2211,11 @@ sub loadfileForReplay {
chomp;
next if /^applications=/ or /^messages_number=/ or /^\s*$/ or /^(marker\d+)$/;
($sender, $time, $message) = split(/\s+/, $_, 3);
- $time = int($time);
+ if ($replay_time_granularity >= 1) {
+ $time = int($time);
+ } else {
+ $time = sprintf("%.".$replay_time_decimalplaces."f", $time);
+ }
if (defined $replay_max_time) {
$replay_max_time = $time if $time > $replay_max_time;
} else {
@@ -2364,6 +2392,8 @@ sub replayStart {
return if $replay_running and not $loopflag;
#print "abort 2 replayStart\n" if $loopflag and not $replay_running ;
return if $loopflag and not $replay_running;
+ $replay_timer = $mw->after(1000*$replay_time_granularity/$replay_speed,
+ [\&replayStart, 1]) unless $replay_stepbystep;
$replay_runnable = 0;
$replay_running = 1;
if ($replay_time > $replay_max_time) {
@@ -2395,17 +2425,19 @@ sub replayStart {
my $i = $t->tagRanges($replay_time);
$t->see($i) if defined $i;
}
- $replay_time++;
+ $replay_time += $replay_time_granularity;
+ $replay_time = sprintf("%.".$replay_time_decimalplaces."f", $replay_time) if
+ $replay_time_decimalplaces > 0;
# step by step mode
if ($replay_stepbystep) {
while (not defined $replay_msg{$replay_time}) {
- $replay_time++;
+ $replay_time += $replay_time_granularity;
+ $replay_time = sprintf("%.".$replay_time_decimalplaces."f", $replay_time) if
+ $replay_time_decimalplaces > 0;
last if $replay_time > $replay_max_time;
}
$replay_running = 0;
$replay_runnable = 1;
- } else {
- $replay_timer = $mw->after(1000/$replay_speed, [\&replayStart, 1]);
}
} # end replayStart
@@ -2423,7 +2455,7 @@ sub replayClose {
$ivy->bindRegexp($opt_replaystartregexp);
$ivy->bindRegexp($opt_replaystopregexp);
&replayStop();
- $replay_text->after(200, sub {$replay_tpl->destroy});
+ $replay_text->after(400, sub {$replay_tpl->destroy});
$replay_speed = 1;
$replay_repeat = $opt_replayrepeat;
$replay_stepbystep = undef;
@@ -2436,7 +2468,15 @@ sub replayTime {
my $time = shift;
if (defined $time) {
my ($s, $m, $h) = localtime($time);
- return sprintf("%02d:%02d:%02d", $h, $m, $s);
+ if ($replay_time_decimalplaces > 0) {
+ my $dec =
+ substr($time, -$replay_time_decimalplaces, $replay_time_decimalplaces);
+ return sprintf("%02d:%02d:%02d.%s", $h, $m, $s, $dec);
+ } else {
+ return sprintf("%02d:%02d:%02d", $h, $m, $s);
+ }
+ } elsif ($replay_time_decimalplaces > 0) {
+ return "--:--:--."."-" x $replay_time_decimalplaces;
} else {
return "--:--:--";
}
@@ -2686,6 +2726,10 @@ Specify how to manage the messages loaded at launching. If set to 'display', the
If set, the replay sequence will be repetitive.
+=item B<-replaytimegranularity> float > 0
+
+Specify the time granularity in second for replaying messages. Set to 1 by default.
+
=item B<-replaystartregexp> regexp
Specify the ivy regular expression to match in order to start the replay sequence. Default is '^ClockStart'. You can do manually the same using the B<Play> button of the Replay window.