summaryrefslogtreecommitdiff
path: root/src/ivyreplay
diff options
context:
space:
mode:
Diffstat (limited to 'src/ivyreplay')
-rwxr-xr-xsrc/ivyreplay99
1 files changed, 69 insertions, 30 deletions
diff --git a/src/ivyreplay b/src/ivyreplay
index b4d9adb..3670726 100755
--- a/src/ivyreplay
+++ b/src/ivyreplay
@@ -18,13 +18,11 @@ use Carp;
use strict;
use Getopt::Long;
use Tk::CmdLine;
-use vars qw/$opt_help $opt_b $opt_bus
+use vars qw/$opt_help $opt_b $opt_bus
$opt_light $opt_autostart
$opt_repeat $opt_startregexp $opt_padding
$opt_stopregexp $opt_timegranularity $opt_debug/;
-our $VERSION = '1.25';
-
# geometry
my $ivy_port; # undef:=> default value is treated by ivy-perl
@@ -73,13 +71,11 @@ my $padding = 2;
Tk::CmdLine::SetArguments(-font => '-Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-1');
Tk::CmdLine::SetArguments();
-if (not GetOptions('-help', '-b=s', '-bus=s', '-light',
+if (not GetOptions('-help', '-b=s', '-bus=s', '-light',
'-repeat', '-startregexp=s', '-debug', '-timegranularity=s',
'-autostart', '-stopregexp=s', '-padding=s') or $opt_help) {
print "\n";
- print "IvyReplay version $VERSION\n";
- print "\n";
print "Usage: ivyreplay [-b[us] bus] [-help]\n";
print " [-autostart] [-light] [-padding int>0]\n";
print " [-repeat] [-timegranularity float>0]\n";
@@ -89,12 +85,12 @@ if (not GetOptions('-help', '-b=s', '-bus=s', '-light',
print "\n";
print "Options :\n";
print " -b <[addr]:port> Ivy bus (\$IVYBUS by default)\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 " -light If set, does not display messages\n";
print " -padding Additionnal space in px above and below text lines\n";
print " (2 by default)\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";
print " -startregexp <regexp> Regexp to match for starting replay\n";
@@ -106,7 +102,7 @@ if (not GetOptions('-help', '-b=s', '-bus=s', '-light',
exit ;
}
-my ($minW, $minH) = (defined $opt_light) ? (850, 50) : (850, 200);
+my ($minW, $minH) = (defined $opt_light) ? (850, 50) : (850, 400);
$replay_repeat = $opt_repeat;
if ($opt_bus) {
@@ -114,7 +110,7 @@ if ($opt_bus) {
} elsif ($opt_b) {
$ivy_port = $opt_b;
}
-my $title = "Ivyreplay v$VERSION ";
+my $title = "Ivyreplay ";
$title .= ($ivy_port) ? "($ivy_port)" : "(default port)";
$replay_time_granularity = $opt_timegranularity if $opt_timegranularity > 0;
@@ -192,31 +188,36 @@ $ivy->start;
my @files = @ARGV;
my $steps = 0;
-if (@files == 0) {
- $mw->Tk::Error("Error : an input file is expected");
+if (scalar(@files) == 0) {
+ die "Error : an input file is expected";
} else {
&showProgressbar("Loading file...");
my $file = $files[0];
+ my ($lines, $timeflag);
if (not open(IN, $file)) {
$mw->Tk::Error("Can't open file '$file' ($!)");
} else {
- my ($lines, $timefound) = &stepsnumber;
+ ($lines, $timeflag) = &linesnumber;
$title .= " - $lines messages";
$mw->title($title);
$steps = int($lines/10);
$progressbar->configure(-to => $steps*10);
- if ($timefound) {
- &loadfileForReplay();
+ if ($timeflag >= 0) {
+ &loadfileForReplay($timeflag);
&hideProgressbar();
} else {
+ &hideProgressbar();
$mw->Tk::Error("No time information in file '$file'. ".
"Can't be replayed.");
}
- }
- close(IN);
+ }
+ close(IN);
unless ($opt_light) {
&showProgressbar("Displaying msgs...");
- &displayMessages();
+ if ($timeflag >= 0) {
+ &displayMessages;
+ $replay_stepbystep = 1 if $timeflag == 0;
+ }
&hideProgressbar();
}
&replayStart() if $opt_autostart;
@@ -235,10 +236,9 @@ MainLoop;
# Functions related to input/output files
#----------------------------------------------------------------------------------
-sub stepsnumber {
+sub linesnumber {
- my $step = 0;
- my $timefound;
+ my $timeflag; # 0=no_time, 1=time_ok, -1=bad_time
my $lc = 0;
# get lines number and test if exists time field
@@ -247,16 +247,22 @@ sub stepsnumber {
next if (/^applications=/ or /^(marker\d+)$/ or /^(messages_number=)/
or /^\#/ or /^delay=/ or /^comment=/ or /^\s*$/);
my ($sender, $message) = split(/\s+/, $_, 2);
- if ($message =~ /^(\d[\d\.]+\d)\s+.*/) {
- $timefound = 1;
+ if (not defined $timeflag) {
+ # print "message=[$message]\n";
+ if ($message =~ /^--\s+/) {
+ $timeflag = 0;
+ } elsif ($message =~ /^\d+(\.\d+)?\s+/) {
+ $timeflag = 1;
+ } else {
+ $timeflag = -1;
+ }
}
$lc++;
}
- $step = $lc;
seek(IN, 0, 0);
- return ($step, $timefound);
+ return ($lc, $timeflag);
-} # end stepsnumber
+} # end linesnumber
sub build {
@@ -378,6 +384,7 @@ sub build {
sub loadfileForReplay {
+ my $time_flag = shift;
# display messsages to replay
my ($sender, $time, $message);
my $delay = 0;
@@ -397,6 +404,7 @@ sub loadfileForReplay {
}
$line++;
($sender, $time, $message) = split(/\s+/, $_, 3);
+ $time = $line unless $time_flag;
$time += $delay;
if ($replay_time_granularity >= 1) {
$time = int($time);
@@ -468,7 +476,8 @@ sub displayMessages {
}
$replay_text->configure(-state => 'disabled') if $replay_text;
-}
+} # end displayMessages
+
sub showProgressbar {
@@ -627,7 +636,12 @@ sub replayTime {
my $time = shift;
if (defined $time) {
- my ($s, $m, $h) = localtime($time);
+ my ($s, $m, $h);
+ if ($time < 86400) {
+ ($s, $m, $h) = gmtime($time);
+ } else {
+ ($s, $m, $h) = localtime($time);
+ }
if ($replay_time_decimalplaces > 0) {
my $dec =
substr($time, -$replay_time_decimalplaces, $replay_time_decimalplaces);
@@ -698,7 +712,7 @@ B<ivyreplay> [B<-b> ivybus] [B<-help>] [B<-light>]
=head1 DESCRIPTION
-IvyReplay is dedicated to replay Ivy messages. Input file must have been generated with ivymon v1.6 or later (it must contain time information).
+IvyReplay is dedicated to replay Ivy messages. Input file must have been generated with ivymon v1.6 or later (it must contain time information).
=head1 OPTIONS
@@ -745,8 +759,33 @@ Specify the ivy regular expression to match in order to stop the replay sequence
ivyreplay -b 10.192.36.255:3456 -repeat -startregexp '^ReplayOn' -stopregexp '^ReplayOff' /my/dir/log.ivy
+=head1 INPUT FILE EXAMPLES
+
+Each line must contain sender name, time or -- and ivy message.
+
+=head2 File generated by ivymon
+
+ ivylaunch2 1492604147.63163 "ivylaunch2 READY"
+ ivycontrolpanel2 1492604147.68041 "ivycontrolpanel2 READY"
+ Rejeu 1492604147.68194 "rejeu CONNECTED"
+ TWINKLE2013:default:default:default 1492604149.1944 "TWINKLE2013:default:default:default READY"
+ Rejeu 1492604149.20423 "Range TWINKLE2013_12386 FirstTime=10:43:00 LastTime=13:20:16 Visible=N/A"
+ TWINKLE2013:default:default:default 1492604149.20839 "GetRange MsgName=TWINKLE2013_12386 Flight=ALL"
+ ivycontrolpanel2 1492604158.51925 "ClockStart"
+ Rejeu 1492604159.52008 "ClockEvent Time=10:43:01 Rate=1.0 Bs=0"
+ Rejeu 1492604159.53595 "EndTransmissionEvent Time=10:43:01"
+
+=head2 File created from scratch (for step-by-step usage, no time information)
+
+ none -- CreatePPilotEvent acc=default wp=default role=default EventId= Flight=154 Label=Event Time=11:02:00
+ none -- TrackDiedEvent Flight=154
+ none -- CreatePPilotEvent acc=default wp=default role=default EventId=001 Flight=154 Label=Event Time=11:02:00
+ none -- CreatePPilotEvent acc=default wp=default role=default EventId=001 Flight=154 Label=Conflit! Time=11:02:00
+ none -- UpdatePPilotEventTime acc=default wp=default role=default EventId=001 Time=11:02:40
+ none -- UpdatePPilotEventTime acc=default wp=default role=default EventId= Time=11:02:40
+ none -- DeletePPilotEvent acc=default wp=default role=default EventId=
-=head1 AUTHORS
+=head1 AUTHOR
Daniel Etienne <etienne@cena.fr>