summaryrefslogtreecommitdiff
path: root/src/ivymon
diff options
context:
space:
mode:
Diffstat (limited to 'src/ivymon')
-rwxr-xr-xsrc/ivymon248
1 files changed, 210 insertions, 38 deletions
diff --git a/src/ivymon b/src/ivymon
index 7eef0a9..de0865f 100755
--- a/src/ivymon
+++ b/src/ivymon
@@ -20,7 +20,7 @@ my $minW = 1050;
my $minH = 768;
my $ivy_port; # undef:=> default value is treated by ivy-perl
-my $history = 100000;
+my $history = 200000;
my $casesensitiveflag = 1;
my $regexpflag = 0;
# misc
@@ -59,6 +59,9 @@ my $fmtduration = '00:00';
my $messagesNumber = 0;
my $messagesLastNumber = 0;
my $messagesSpeed = 0;
+my $recordedNumber = 0;
+my $deletedNumber = 0;
+my $bufNumber = 0;
my $bindingsFlag = 0;
my $stopFlag = 0;
@@ -66,10 +69,12 @@ my $noMessageYet = 1;
my $jump_cnt = 0;
my $noUpdateFlag = 0;
+my $loadedFileFlag = 0;
+my $loadingFlag = 0;
my $appname = 'IvyMon';
$appname =~ s/ /_/g;
-
+
# Rejeu messages array
my @send_def =
('ClockStop',
@@ -173,7 +178,7 @@ my @bind_def = ('(.*)',
'(^GetDuplicate .*)',
'(^Duplicate .*)',
'(^GetDataBaseInfos .*)',
- '(^DataBaseInfo .*)',
+ '(^DataBaseInfos .*)',
'(^GetFlightsWithStrip .*)',
'(^FlightsWithStrip .*)',
'(^SetStripTime .*)',
@@ -346,8 +351,41 @@ my $top2_fm = $top_fm->Frame()->pack(-side => 'top',
);
my $messagesLabel =
$top2_fm->Label(-text => "Messages :")->pack(-side => 'left');
+
my $messagesCounterValue =
- $top2_fm->Label(-textvariable => \$messagesNumber)->pack(-side => 'right');
+ $top2_fm->Label(-textvariable => \$recordedNumber,
+ -width => 8,
+ -anchor => 'w')->pack(-side => 'right');
+
+my $messagesCounterLabel =
+ $top2_fm->Label(-text => "Recorded :",
+ -width => 15,
+ -anchor => 'e')->pack(-side => 'right');
+
+my $messagesBufdValue =
+ $top2_fm->Label(-textvariable => \$bufNumber,
+ -width => 8,
+ -anchor => 'w')->pack(-side => 'right');
+
+my $messagesBufLabel =
+ $top2_fm->Label(-text => "Bufferized :",
+ -width => 17,
+ -anchor => 'e')->pack(-side => 'right');
+
+my $messagesDeletedValue =
+ $top2_fm->Label(-textvariable => \$deletedNumber,
+ -width => 8,
+ -anchor => 'w')->pack(-side => 'right');
+
+my $messagesDeletedLabel =
+ $top2_fm->Label(-text => "Skipped :",
+ -width => 14,
+ -anchor => 'e')->pack(-side => 'right');
+
+my $messagesMaxLabel =
+ $top2_fm->Label(-text => "Recordable : $history",
+ -width => 25)->pack(-side => 'right');
+
my $messagesText =
$top_fm->Scrolled(Text,
@@ -391,10 +429,10 @@ for my $marker (qw(marker0 marker1 marker2 marker3 marker4)) {
$messagesCounterValue->repeat(1000, sub {
$messagesSpeed = $messagesNumber - $messagesLastNumber;
$messagesLastNumber = $messagesNumber;
- # if update mechanism is off, we force it here
+ # if update mechanism is off, we flush data here
if ($noUpdateFlag) {
- $messagesCounterValue->update;
$messagesText->see('end');
+ $messagesCounterValue->update;
}
# if too many messages, update mechanism is unset
if ($messagesSpeed > 50) {
@@ -404,7 +442,7 @@ $messagesCounterValue->repeat(1000, sub {
# (each time a message is received, update is forced in Text window)
} else {
$noUpdateFlag = 0;
- }
+ }
});
#----------------------------------------------------------------------------------
@@ -634,7 +672,22 @@ for my $msg (sort(@send_def)) {
#----------------------------------------------------------------------------------
# Balloon help messages
#----------------------------------------------------------------------------------
-
+$balloonhelp->attach($messagesMaxLabel, -balloonmsg =>
+ "Maximum number of recordable messages\n".
+ "(=history size value)"
+ );
+$balloonhelp->attach($messagesDeletedLabel, -balloonmsg =>
+ "Counter for received messages which are\n".
+ "skipped when history size is reached."
+ );
+$balloonhelp->attach($messagesBufLabel, -balloonmsg =>
+ "Counter for received messages which are bufferized\n".
+ "when [Scroll Lock] button is active. They will be\n".
+ "displayed when user will restore scroll mode."
+ );
+$balloonhelp->attach($messagesCounterLabel, -balloonmsg =>
+ "Counter for received and displayed messages."
+ );
$balloonhelp->attach($bindingsEntry, -balloonmsg =>
"This input field is used to enter new bindings or\n".
"edit default one from list above. In both case, hit\n".
@@ -752,7 +805,6 @@ MainLoop;
sub addIvyBinding {
my $binding = shift;
#print "in addIvyBinding $binding\n";
- return if $stopFlag;
$ivy->bindRegexp($binding, [sub {
$messagesNumber++;
if ($stopFlag) {
@@ -911,6 +963,7 @@ sub addmarker {
sub bufferizeMessages {
my ($sender, $message) = @_;
+ $bufNumber++;
# if scrolling is locked, don't force display, just put message in buffer
push(@messagesbuffer, [$sender, $message]);
splice(@messagesbuffer, 0, 1) if @messagesbuffer > $history;
@@ -923,37 +976,51 @@ sub beforeUpdatingMessages {
} # end beforeUpdatingMessages
-
sub updateMessages {
my ($sender, $message) = @_;
- $noMessageYet = 0;
chomp($message);
$message = '"' . $message . '"' ;
- # is scrolling is available, format and then display message
- my $text = "$sender $message\n";
- # look at history : compare widget text lines number with history size
- my ($linesNb) = split(/\./, $messagesText->index('end'));
- $linesNb--;
- if ($linesNb > $history) {
- my $dl = $linesNb - $history;
- $messagesText->delete('1.0', "1.0 + $dl lines");
+ # If scrolling is available, format and then display message.
+ # Unless file has been loaded, look at history : compare widget text lines
+ # number with history size
+ if ($loadedFileFlag) {
+ &loadMessage($sender, $message);
$messagesText->update unless $noUpdateFlag;
- }
- # to comment...
- my $index1 = $messagesText->index('end');
- $index1 = "$index1 - 1 lines";
- my $senderlen = length($sender);
- my $index2 = "$index1 + $senderlen chars";
+ } else {
+ my ($linesNb) = split(/\./, $messagesText->index('end'));
+ $linesNb--;
+ #print "linesNb=$linesNb\n";
+ if ($linesNb > $history) {
+ $deletedNumber += 1;
+ if ($deletedNumber == 1) {
+ $messagesDeletedLabel->configure(-foreground => 'red');
+ $messagesDeletedValue->configure(-foreground => 'red');
+ }
+ } else {
+ &loadMessage($sender, $message);
+ $messagesText->update unless $noUpdateFlag;
+ }
+ }
+
+} # end updateMessages
+
+sub loadMessage {
+ my ($sender, $message) = @_;
+ $recordedNumber++;
+ $noMessageYet = 0;
+ my $text = "$sender $message\n";
+ my $index1 = $messagesText->index('end')." - 1 lines";
+ my $index2 = "$index1 + ".length($sender)." chars";
$messagesText->insert('end', $text);
$messagesText->tagAdd('sender', $index1, $index2);
- my $msglen = length($message);
- $index1 = "$index2 + 1 chars";
- $index2 = "$index1 + $msglen chars";
- $messagesText->tagAdd($sender, $index1, $index2);
- $messagesText->update unless $noUpdateFlag;
+ my $index3 = "$index2 + 1 chars";
+ my $index4 = "$index3 + ".length($message)." chars";
+ $messagesText->tagAdd($sender, $index3, $index4);
+
+
+} # end loadmessages
-} # end updateMessages
sub afterUpdatingMessages {
$messagesText->see('end');
@@ -1292,7 +1359,7 @@ sub searchOnTheFly {
my $string = $searchEntry->get;
my $strlen;
return unless $string;
- print "string=$string\n";
+ #print "string=$string\n";
my $index0;
if ($searchString) {
if ($string ne $searchString) {
@@ -1450,15 +1517,32 @@ sub start {
if ($messagesText->index('insert') !~ /\.0$/) {
$messagesText->insert('insert', "\n");
}
+
+ # disable other buttons
+ my $jumpstate = $jumpButton->cget(-state);
+ $loadButton->configure(-state => 'disabled');
+ $saveButton->configure(-state => 'disabled');
+ $jumpButton->configure(-state => 'disabled');
+ $clearButton->configure(-state => 'disabled');
$startButton->configure(-state => 'disabled');
+ $stopButton->configure(-state => 'disabled');
+ $mw->update;
+
$noUpdateFlag = 1;
&beforeUpdatingMessages;
for my $msg (@messagesbuffer) {
&updateMessages($msg->[0], $msg->[1]);
+ $bufNumber--;
}
&afterUpdatingMessages;
$noUpdateFlag = 0;
$stopFlag = 0;
+
+ # restore other buttons state
+ $loadButton->configure(-state => 'normal');
+ $saveButton->configure(-state => 'normal');
+ $jumpButton->configure(-state => $jumpstate);
+ $clearButton->configure(-state => 'normal');
$stopButton->configure(-state => 'normal');
} # end start
@@ -1481,11 +1565,36 @@ sub loadfile {
['All Files', '*']],
);
return unless $file;
+
+
# open file
unless (open(IN, "$file")) {
$mw->Tk::Error("$!\n");
return;
}
+ # set load flags...
+ $loadedFileFlag = 1;
+ $loadingFlag = 1;
+ $balloonhelp->attach($messagesMaxLabel, -balloonmsg =>
+ "No history limit when file is loaded");
+ $balloonhelp->attach($messagesDeletedLabel, -balloonmsg =>
+ "Messages deletion is deactivated when file is loaded");
+
+ $messagesDeletedLabel->configure(-foreground => 'gray60');
+ $messagesDeletedValue->configure(-foreground => 'gray60');
+ $messagesMaxLabel->configure(-foreground => 'gray60');
+ # disable other buttons
+ my $jumpstate = $jumpButton->cget(-state);
+ my $startstate = $startButton->cget(-state);
+ my $stopstate = $stopButton->cget(-state);
+ $loadButton->configure(-state => 'disabled');
+ $saveButton->configure(-state => 'disabled');
+ $jumpButton->configure(-state => 'disabled');
+ $clearButton->configure(-state => 'disabled');
+ $startButton->configure(-state => 'disabled');
+ $stopButton->configure(-state => 'disabled');
+ $mw->update;
+
my %client;
my $step = 0;
my $line = 0;
@@ -1513,17 +1622,27 @@ sub loadfile {
}
$messagesNumber++;
$line++;
- $message =~ s/^\"(.*)\"$/$1/;
- &updateMessages($sender, $message);
+ #$message =~ s/^\"(.*)\"$/$1/;
+ &loadMessage($sender, $message);
#print "sender=$sender message=$message step=$step line=$line\n";
$progressbar->value($line);
$progressbar->update if ($step == 0 or $line % $step == 0);
}
}
+ $progressbar->value(0);
&afterUpdatingMessages;
$noUpdateFlag = 0;
close(IN);
- $progressbar->value(0);
+
+ # restore other buttons state
+ $loadButton->configure(-state => 'normal');
+ $saveButton->configure(-state => 'normal');
+ $jumpButton->configure(-state => $jumpstate);
+ $clearButton->configure(-state => 'normal');
+ $startButton->configure(-state => $startstate);
+ $stopButton->configure(-state => $stopstate);
+ $loadingFlag = 0;
+
} # end loadfile
@@ -1538,10 +1657,34 @@ sub savefile {
['All Files', '*']],
);
return unless $file;
+
+ # disable other buttons
+ my $jumpstate = $jumpButton->cget(-state);
+ my $startstate = $startButton->cget(-state);
+ my $stopstate = $stopButton->cget(-state);
+ $loadButton->configure(-state => 'disabled');
+ $saveButton->configure(-state => 'disabled');
+ $jumpButton->configure(-state => 'disabled');
+ $clearButton->configure(-state => 'disabled');
+ $startButton->configure(-state => 'disabled');
+ $stopButton->configure(-state => 'disabled');
+ $mw->update;
+
+ my $restorestate = sub {
+ # restore other buttons state
+ $loadButton->configure(-state => 'normal');
+ $saveButton->configure(-state => 'normal');
+ $jumpButton->configure(-state => $jumpstate);
+ $clearButton->configure(-state => 'normal');
+ $startButton->configure(-state => $startstate);
+ $stopButton->configure(-state => $stopstate);
+ };
+
my $status = 0;
# open file
unless (open(OUT, ">$file")) {
$mw->Tk::Error("$!\n");
+ &$restorestate;
return;
}
# save connected applications name
@@ -1549,6 +1692,7 @@ sub savefile {
unless (print OUT "applications=", join(',', @clients),"\n") {
$mw->Tk::Error("$!\n");
close(OUT);
+ &$restorestate;
return;
}
@@ -1585,7 +1729,9 @@ sub savefile {
}
close(OUT);
$progressbar->value(0);
-
+
+ &$restorestate;
+
} # end savefile
sub clear {
@@ -1599,11 +1745,37 @@ sub clear {
return;
}
}
+
+ # disable other buttons
+ my $jumpstate = $jumpButton->cget(-state);
+ my $startstate = $startButton->cget(-state);
+ my $stopstate = $stopButton->cget(-state);
+ $loadButton->configure(-state => 'disabled');
+ $saveButton->configure(-state => 'disabled');
+ $jumpButton->configure(-state => 'disabled');
+ $clearButton->configure(-state => 'disabled');
+ $startButton->configure(-state => 'disabled');
+ $stopButton->configure(-state => 'disabled');
+ $mw->update;
+
$messagesText->configure(-state => 'normal');
$messagesNumber = 0;
- $messagesText->delete('0.0', 'end');
+ $recordedNumber = 0;
+ #$messagesText->delete('1.0', 'end');
+ while ($messagesText->compare($messagesText->index('end'), ">", "2.0")) {
+ $messagesText->delete('1.0', '1000.0');
+ my $index = $messagesText->index('end');
+ }
$messagesText->configure(-state => 'disabled');
+ # restore other buttons state
+ $loadButton->configure(-state => 'normal');
+ $saveButton->configure(-state => 'normal');
+ $jumpButton->configure(-state => $jumpstate);
+ $clearButton->configure(-state => 'normal');
+ $startButton->configure(-state => $startstate);
+ $stopButton->configure(-state => $stopstate);
+
} # end clear
@@ -1768,7 +1940,7 @@ Gets some help
=item B<-history> size
-Sets the history size of messages window (default: 10000)
+Sets the history size of messages window (default: 200000). If ivymon receives more messages, they won't be displayed neither stored.
=item B<-bind> regular_expression