From e4183f5211e7ed165d20868e16ca1d98c69d6a34 Mon Sep 17 00:00:00 2001 From: etienne Date: Thu, 8 Aug 2002 13:50:26 +0000 Subject: * Bug fix : les messages emis par ivymon apparaissaient trop tardivement dans la liste des messages (d'ou des requetes apres les reponses...) * Bug fix : dans le champ Bindings, la selection englobe le ')' final. * Mettre a jour la liste des bindings et des messages a emettre en fonction des applications presentes sur le bus. * Bug : dans le champ Messages to send, quand le message ne possede pas de '=' le premier mot du message est selectionné. * Pouvoir mettre en evidence des messages d'une application qui n'est plus presente sur le bus. * Meilleure gestion des scrollbars. --- src/ivymon | 259 +++++++++++++++++++++++++++++-------------------------------- 1 file changed, 121 insertions(+), 138 deletions(-) diff --git a/src/ivymon b/src/ivymon index c1711c6..90b5435 100755 --- a/src/ivymon +++ b/src/ivymon @@ -14,7 +14,7 @@ use Carp; use strict 'vars'; use Getopt::Long; use Tk::CmdLine; -use vars qw/$opt_help $opt_b $opt_history @opt_bind @opt_send $opt_msgsfile/; +use vars qw/$opt_help $opt_b $opt_history @opt_bind @opt_send/; # geometry my $minW = 1050; @@ -81,113 +81,17 @@ my $appname = 'IvyMon'; $appname =~ s/ /_/g; # Rejeu messages array -my @send_def = - ('ClockStop', - 'ClockStart', - 'ClockBackward', - 'ClockForward', - 'SetClock Time=', - 'SetClock Rate=', - 'GetClockDatas', - 'GetRadarRefresh', - 'GetTrajectory MsgName= Flight= From=', - 'GetPln MsgName= Flight= From=', - 'GetSectorsInfos MsgName= Flight=', - 'GetPosition MsgName= Flight= Time=', - 'GetOldPositions MsgName= Flight= Nb= ', - 'GetStrip MsgName= Flight= Sector=', - 'GetRange MsgName= Flight=', - 'GetDuplicate MsgName= Flight=', - 'GetTrack MsgName= Flight=', - 'GetDataBaseInfos MsgName= Cond=', - 'GetFlightsWithStrip MsgName= Sector=', - 'GetSidStarNames MsgName=', - 'GetStandardTrajectory MsgName= Type= Name=', - 'GetGroupsOfSectors MsgName=', - 'SetGroupsOfSectors List=', - 'SetStripTime Flight= Sector= Time=', - 'SetSectorIn Flight= Sector= Time=', - 'SetSectorOut Flight= Sector= Time=', - 'SetSectorsInfos Flight= List=', - 'SetCallSign Flight= CallSign=', - 'SetMiniPln Flight= Ssr= Dep= Arr=', - 'SetTfl Flight= Sector= Tfl=', - 'SetBeforeTrack Flight= List=', - 'SetAfterTrack Flight= List=', - 'TranslateTime Flight= Shift=', - 'TranslateFl Flight= Delta=', - 'AircraftDirect Flight= Beacon=', - 'AircraftHeading Flight= To=', - 'AircraftTurn Flight= Angle=', - 'AircraftLevel Flight= Fl=', - 'AircraftSpeed Flight= Speed=', - 'AircraftIntercept Flight= Beacon= Axis=', - 'AircraftSetTrack Flight= Slice=', - 'SetUserEventList Flight= EventName= List=', - 'MergeUserEventList Flight= EventName= List=', - 'GetUserEventList Flight= Name=', - 'GetUserEventNames MsgName= Flight=', - 'CancelLastOrder Flight=', - 'Discard Flight=', - 'Enable Flight=', - 'Dump Flight=', - 'StripsOnOff Print=yes', - 'StripsOnOff Print=no', - 'TagStrip Flight= Sector=', - 'PrintTaggedStrips', - 'Debug Flight=', - 'FileRead Type=rejeu Name=', - 'FileRead Type=simu Name=', - 'FileWrite Type=rejeu Name=', - 'FileWrite Type=simu Name=', - 'FileWrite Type=dump Name=', - 'ClockEvent Time= Rate= Bs=', - 'RadarEndEvent', - 'TrackMovedEvent Flight= CallSign= Ssr= Sector= Layers= Y= Vx= Vy= Afl= '. - 'Rate= Heading= GroundSpeed= Tendency= Time=', - 'TrackDiedEvent Flight=', - 'SectorEvent Flight= SectorOut= SectorIn= Time=', - 'BeaconEvent Flight= Beacon= Fl= Mode= Time=', - 'LayerEvent Flight= Layer= Mode=', - 'StripEvent Flight= Time= CallSign= AircraftType= Ssr= Speed= Rfl= Sector= '. - 'ExitSector= Frequency= Efl= Tfl= List=', - 'PlnEvent Flight= Time= CallSign= AircraftType= Ssr= Speed= Rfl= Dep= Arr= List=', - 'StcaAlertEvent Flight= Mode= MinValidLevel= MaxValidLevel= OtherFlight= Time=', - 'MsawAlertEvent Flight= Type= Time=', - 'UserEvent Flight= Name= Value=', - 'RadarRefresh Period=', - 'Trajectory XXX Slice=', - 'Trajectory XXX EndSlice', - 'Pln XXX Flight= Time= CallSign= AircraftType= Ssr= Speed= Rfl= Dep= Arr= List=', - 'SectorsInfos XXX Flight=123 List=', - 'Position XXX Flight= CallSign= Ssr= Sector= Layers= X= Y= Vx= Vy= Afl= '. - 'Rate= Heading= GroundSpeed= Tendency= Time=', - 'OldPositions XXX Flight= Nb= List=', - 'Strip XXX Flight= Time= CallSign= AircraftType= Ssr= Speed= Rfl= Dep= '. - 'Arr= Sector= ExitSector= Frequency= Efl= Tfl= List=', - 'Range XXX FirstTime= LastTime= Visible=', - 'Duplicate XXX NewFlight=', - 'Track XXX Slice=', - 'Track XXX EndSlice', - 'DataBaseInfos XXX Nb= List=', - 'FlightsWithStrip XXX Sector= List=', - 'SidStarNames XXX sid= star=', - 'StandardTrajectory XXX Slice=', - 'StandardTrajectory XXX EndSlice', - 'GroupsOfSectors XXX List=', - 'FileReadEvent Type=REJEU Name= StartTime= EndTime=', - 'FileReadEvent Type=SIMU Name= StartTime= EndTime=', - 'TrajectoryUpdateEvent Flight=', - ); +my @send_def; # Rejeu available (not effective) bindings array -my @bind_def = (@send_def); -for (@bind_def) { - s/\=\s+/\=\.\* /g; - s/\=\s*$/=\.\*/g; - s/^(.*)$/\(^$1\)/; - -} +my @bind_def; + +#for (@bind_def) { + # s/\=\s+/\=\.\* /g; + # s/\=\s*$/=\.\*/g; + # s/^(.*)$/\(^$1\)/; +# +#} # Effective bindings array my @effectivebind; @@ -201,11 +105,10 @@ Tk::CmdLine::SetArguments(-font => '7x14'); Tk::CmdLine::SetArguments(); if (not GetOptions('-help', '-history=s', '-b=s', '-bind=s@', - '-send=s@', '-msgsfile=s') or $opt_help) { + '-send=s@') or $opt_help) { print "Usage: ivymon [-b bus] [-help] [-history length]\n"; print " [-bind regexp1] ... [-bind regexpN] \n"; print " [-send message1] ... [-send messageN] \n"; -# print " [-msgsfile file]\n"; print " [standard X11 options...]\n"; print "\n"; print "Options :\n"; @@ -214,7 +117,6 @@ if (not GetOptions('-help', '-history=s', '-b=s', '-bind=s@', "(default $history messages)\n"; print " -bind Ivy binding regular expression\n"; print " -send Ivy message to send\n"; -# print " -msgsfile Ivy messages file\n"; print "\n"; exit ; @@ -443,7 +345,7 @@ $bindingsEntry->focus; my $bindingsList = $bindings_fm->Scrolled(Listbox, - -scrollbars => 'e', + -scrollbars => 'osoe', -height => 4, -width => 30)->pack(-fill => 'y', -side => 'top', @@ -455,7 +357,7 @@ $bindingsEntry->bind('' => [\&findExprInList, $bindingsList]); my $effectivebindingsList = $bindings_fm->Scrolled(Listbox, - -scrollbars => 'e', + -scrollbars => 'osoe', -height => 4, -width => 30)->pack(-fill => 'y', -side => 'bottom', @@ -470,7 +372,7 @@ $effectivebindingsList->bind('', [\&removeBinding]); #---------------------------------------------------------------------------------- my $clientsListbox = $clients_fm->Scrolled(Listbox, - -scrollbars => 's')->pack(-fill => 'both', + -scrollbars => 'osoe')->pack(-fill => 'both', -expand => 1, -side => 'top'); $clientsListbox->bind('<1>', [\&selectClient]); @@ -512,7 +414,7 @@ my $clockbackCheckbutton = -sticky => 'nsew'); my $sendList = $send_fm->Scrolled(Listbox, - -scrollbars => 'e', + -scrollbars => 'osoe', -width => 40)->pack(-fill => 'y', -anchor => 'w', -side => 'bottom', @@ -671,6 +573,21 @@ for my $msg (sort(@send_def)) { #---------------------------------------------------------------------------------- # Balloon help messages #---------------------------------------------------------------------------------- + +my $completionText = + "Provides completion functionality : type part \n". + "of a word and hit the [Tab] key to activate \n". + "completion. "; + +my $historyText = + "Provides history functionality : use [Up] and \n". + "[Down] keys to navigate in inputs history. "; + +my $insertionText = + "Also makes values entries easier : when you hit \n". + "the [Tab] key, the insertion cursor move to the \n". + "next rvalue field, and select it if defined. "; + $balloonhelp->attach($messagesMaxLabel, -balloonmsg => "Maximum number of recordable messages\n". "(=history size value) " @@ -691,13 +608,9 @@ $balloonhelp->attach($bindingsEntry, -balloonmsg => "This input field is used to enter new bindings or\n". "edit default one from list above. In both case, \n". "hit [Enter] to apply. \n". - "Provides completion and history functionalities :\n". - "type part of a word and hit the [Tab] key to \n". - "activate completion, use [Up] and [Down] keys to \n". - "access previous inputs. \n". - "Also makes values entries easier : when you hit \n". - "the [Tab] key, the insertion cursor move to the \n". - "next rvalue field. " + $historyText."\n". + $completionText."\n". + $insertionText ); $balloonhelp->attach($bindingsList, -balloonmsg => "Available bindings list. Select an item for edition or\n". @@ -716,13 +629,9 @@ $balloonhelp->attach($sendEntry, -balloonmsg => "This input field is used to enter new messages or\n". "edit default one from list above. In both case, \n". "hit [Enter] to send it. \n". - "Provides completion and history functionalities :\n". - "type part of a word and hit the [Tab] key to \n". - "activate completion, use [Up] and [Down] keys to \n". - "access previous inputs. \n". - "Also makes values entries easier : when you hit \n". - "the [Tab] key, the insertion cursor move to the \n". - "next rvalue field. " + $historyText."\n". + $completionText."\n". + $insertionText ); $balloonhelp->attach($sendList, -balloonmsg => "Available messages list. Select an item for edition\n". @@ -736,11 +645,11 @@ $balloonhelp->attach($messagesText, -balloonmsg => "marker, just double-click on it. " ); $balloonhelp->attach($searchEntry, -balloonmsg => - "This input field is used to search expressions in\n". - "messages list. Hit [Return] key to search forward\n". - "and [Shift-Return] key to search backward. \n". - "Provides history functionality : use [Up] and \n". - "[Down] keys to access previous inputs. " + "This input field is used to search expressions in \n". + "messages list. Hit [Return] or [Control-s] key to \n". + "search forward and [Shift-Return] or [Control-r] \n". + "key to search backward. \n". + $historyText ); $balloonhelp->attach($stopButton, -balloonmsg => "Stop scrolling in Messages area." @@ -836,6 +745,7 @@ sub checkClientsStatus { &addClient($appname, $host_or_regexp); } elsif ($status eq 'subscribing') { $clientsBindings{$appname}->{$host_or_regexp}++; + &newBinding($host_or_regexp); } elsif ($status eq 'unsubscribing') { $clientsBindings{$appname}->{$host_or_regexp}--; } else { @@ -871,7 +781,7 @@ sub manageClient { my $host = shift; my $i = 0; for ($clientsListbox->get(0, 'end')) { - if ($_ =~ /^$client/) { + if ($_ =~ /^$client/ or $_ =~ /-- $client/) { $clientsListbox->delete($i); last; } @@ -881,7 +791,9 @@ sub manageClient { for (values(%{$connectedClients{$client}})) { $num += $_; } - if ($num == 1) { + if ($num == 0) { + $clientsListbox->insert('end', "-- $client died"); + } elsif ($num == 1) { $clientsListbox->insert($i, "$client on $host"); } elsif ($num > 1) { my $msg = "$client "; @@ -906,8 +818,9 @@ sub selectClient { if $selectedClient; my $selindex = $clientsListbox->curselection; my $client = $clientsListbox->get($selindex); + $client =~ s/^-- //; $client =~ s/\(\d+\)$//; - $client =~ s/ on .*//; + $client =~ s/\s.*//; if ($selectedClient eq $client) { $selectedClient = undef; $clientsListbox->selectionClear($selindex); @@ -941,9 +854,14 @@ sub showClientBindings { )->pack(-side => 'top', -fill => 'both', -expand => 1); + $t->tagConfigure('0', -background => '#d4d4d4'); + $t->tagConfigure('1', -background => '#e5e5e5'); + my $i = 0; for my $regexp (sort keys(%{$clientsBindings{$client}})) { - $t->insert('end', $regexp."\n") + + $t->insert('end', $regexp."\n", $i % 2) if $clientsBindings{$client}->{$regexp} > 0; + $i++; } $tpl->Button(-text => 'Close', -command => [sub {$tpl->destroy; @@ -1194,6 +1112,72 @@ sub addBindingInList { } # end addBindingInList +sub newBinding2 { + my $regexp = shift; + return if $regexp eq '(.*)'; + # skip ^ and $ characters in regexp + $regexp =~ s/^\^//; + $regexp =~ s/\$$//; + my $msg = $regexp; + $msg =~ s/=\(.*\)\s/= /g; + #$msg =~ s/\(.*\)//g; + # skip parenthesis in regexp + $regexp =~ s/\(//g; + $regexp =~ s/\)//g; + $regexp = "^(".$regexp.")"; + &addBindingInList($regexp); + &addMsgToSend(undef, $msg); + +} # end newBinding + + +sub newBinding { + my $regexp = shift; + return if $regexp eq '(.*)'; + # skip ^ and $ characters in regexp + $regexp =~ s/^\^//; + $regexp =~ s/\$$//; + my $msg = $regexp; + + $msg =~ s/=\(\W.*\)\s/= /g; + $msg =~ s/\(\W.*\)//g; + my @expr; + my $msgsnum = 1; + while ($msg =~ /\((.*?\|.*?)\)/g) { + push(@expr, $1); + $msgsnum *= split(/\|/, $1); + } + my @msgs; + for (my $i=0; $i < $msgsnum; $i++) { + push(@msgs, $msg); + } + # skip parenthesis in regexp + $regexp =~ s/\(//g; + $regexp =~ s/\)//g; + $regexp = "^(".$regexp.")"; + &addBindingInList($regexp); + if ($msgsnum > 1) { + for my $expr (@expr) { + my (@field) = split(/\|/, $expr); + my $j = 0; + for (my $i=0; $i < @msgs; $i++) { + my $qmexpr = quotemeta($expr); + $msgs[$i] =~ s/\($qmexpr\)/$field[$j]/; + $j++; + $j = 0 if $j == @field; + } + } + for (@msgs) { + &addMsgToSend(undef, $_); + } + } else { + &addMsgToSend(undef, $msg); + } + +} # end newBinding + + + sub selectBinding { $bindingsEntry->focus; my $selindex = $bindingsList->curselection; @@ -1983,6 +1967,7 @@ sub findRvalue { if ($index < 0) { $index = index($expr, '='); } + return if $index < 0; my $rvalue = substr($expr, $index+1); $entry->selectionClear; if ($rvalue =~ /(^\S+)/) { @@ -1992,7 +1977,6 @@ sub findRvalue { $entry->selectionFrom($index+1); $entry->selectionTo($index +1 + length($rvalue)); } - return if $index < 0; $entry->icursor($index+1); $entry->xview($index-15); @@ -2092,4 +2076,3 @@ ivymon -b 10.192.36.255:3456 -history 20000 -bind 'PLN:(.*) SectorActivation sec =head1 AUTHORS Daniel Etienne - -- cgit v1.1