#!/usr/local/bin/wish8.4
#
package require BLT
package require Tktable
package require msgcat
#
#
set app_path  [ file dirname [info script ] ]
#
set ::appName 		TkTopNetFlows
set ::appVersion	0.4
#
# loading libraries
#
foreach i [ list "TkTopNetFlows_lib.tcl"  ]  {
    uplevel #0  " [list  source [file join  /usr local lib $appName-$appVersion  $i] ] "
#    uplevel #0  " [list  source [file join    $i] ] "
}
#
#=============!!! Configuration section BEGIN !!!================
#
#
option add *Barchart.Postscript.Decorations false
option add *Barchart.Postscript.Landscape   true
#
#
# Load config file(s) and replace default configuration
#
foreach x $argv {
    source $x
}
#=============!!! Configuration section END !!!================
#
if { [info commands DestroyMain ]=="" } {
    proc DestroyMain {} { destroy . }
}
#
wm withdraw .
Logo
topNetFlows 
#
bind .topNF <Destroy>   	+DestroyMain
bind .topNF <F10>		+DestroyMain
bind .topNF <Control-x>		+DestroyMain
set ::myName 		[ file rootname [ file tail [ info script ] ] ]
if { [string match $::myName "TkTopNetFlowsHist" ] } { 
    set ::topNetFlows::mode "history" 
} else {
    bind .topNF <F5> {}
}

if { $::topNetFlows::server=="" || $::topNetFlows::port=="" } { 
    AskForServer .topNF
} else {
    set params  [join [ AskServer "GET PARAMS" ] ]
    if { $params !=  "" } {
        set ::topNetFlows::server_version  [ lindex $params 0 ]
        set ::topNetFlows::step         [ lindex $params 1 ]
        set ::topNetFlows::t_wind_size  [lindex $params 2 ]
    }
    MapYGrid
    .topNF.graph configure -barwidth $::topNetFlows::step
    if { $::topNetFlows::view_name == "" }  {
	AskForView .topNF
    } else {
	if { [string match $::topNetFlows::mode "history" ] } {
	    wm title .topNF [join [list "HISTORY" [ AskServer "DESCRIBE VIEW \"$::topNetFlows::view_name\"" ] ] ]
	    after 10 loadHistory
	} else {
	    wm title .topNF [join [ AskServer "DESCRIBE VIEW \"$::topNetFlows::view_name\"" ] ]
	    after 10 loadUpdate
	}
    }
}
#
