lost connection to previous cntlmonAPI
Parameters
Usage
Comments:
Transition to this state0 depends on client confirmation
or it could be forced due to lost of connection
level : user, exit and lostconnect
logfile is closed in handleExit
proc cmonClient::state0 { { level user } { msg "" } } {
if { [ llength $::cmonClient::sid ] > 0 } {
;## no change if same site and connected
set flag 1
;## user wants to change sites but same site
if { [ regexp {user} $level ] } {
if { ! [ string compare $::cmonClient::oldsite $::cmonClient::var(site) ] } {
return $::cmonClient::state
}
}
;## user wants to change site or exit
switch -- $level {
user -
exit { set choice [ showWarning "Do you really want to disconnect\n\
from LDAS cntlmon API at $::cmonClient::oldsite?" okcancel ]
if { $choice } {
set ::cmonClient::var(site) $::cmonClient::oldsite
set flag 0
} elseif { [ string match exit $level ] } {
foreach pid $::cmonClient::childPids {
catch { exec kill -9 $pid }
}
cmonClient::setDisconnected 1
exitCleanup
clientExit
}
}
lostconnect {
set msg "Lost connection to LDAS cntlmon API at $::cmonClient::oldsite.\n\
Please retry connection later."
set choice [ showWarning $msg ok ]
set flag 1
set ::cmonClient::var(site) $::cmonClient::NOSERVER
}
readerror {
catch { close $::cmonClient::sid } err
set flag 1
set errmsg "$msg, disconnected"
set choice [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message $errmsg -icon error -title Error -justify left -font $::MSGFONT ]
}
}
if { $flag } {
cmonClient::setDisconnected 1
}
} else {
set ::cmonClient::state 0
}
if { ! $::cmonClient::state } {
cmonClient::enableSites
}
return $::cmonClient::state
}
§ § §
cmonClient::state01
Description
transitions to state 0, the initial state.
and then to state1 if conditions permit (user confirmed)
a site must be chosen here
Parameters
Usage
Comments:
proc cmonClient::state01 { { site "" } } {
;## the following transitions by disconnecting from one site and
;## connecting to the next after the user's consent.
if { [ catch {
set seqpt "state0"
set state [ state0 ]
if { ! $state } {
set seqpt "state1"
set ::cmonClient::var(site) $site
state1
}
} err ] } {
#puts "error: $seqpt $err"
cmonClient::state0 lostconnect
}
}
§ § §
cmonClient::setConnected
Description
set the connected light after login & passwd are accepted
Parameters
Usage
Comments:
proc cmonClient::setConnected {} {
foreach { host port } $::siteport($::cmonClient::var(site)) { break }
$::cmonClient::connectw configure -text \
[ format %-40.40s "$::cmonClient::client@$host" ] -bg green
set ::cmonClient::state 1
$::cmonClient::updatesitew configure -state disabled
set globusButton [ set ::cmonClient::globusToggle ]
$globusButton configure -state disabled
$::cmonClient::serverw configure -text "cntlmonAPI $::cmonClient::serverVersion"
;## label each package for reset but dont do it until page is raised
eval $::cmonClient::pageUpdate
cmonClient::sendNoOp
}
§ § §
cmonClient::setDisconnected
Description
set things that are for disconnection
Parameters
Usage
Comments:
proc cmonClient::setDisconnected { { reset 0 } } {
set ::cmonClient::state 0
set site $::cmonClient::var(site)
if { ! [ string match $::cmonClient::NOSERVER $site ] } {
catch { unset ::beowulfNodes($site) }
}
set ::cmonClient::var(site) $::cmonClient::NOSERVER
catch { close $::cmonClient::sid } err
set globusButton [ set ::cmonClient::globusToggle ]
$globusButton configure -state normal
set ::cmonClient::sid {}
set ::cmonClient::client new
set ::cmonClient::state 0
$::cmonClient::connectw configure -text $::cmonClient::notConnected -bg orange
;## trigger trace
set ::beowulfNodes($::cmonClient::NOSERVER) \
[ set ::beowulfNodes($::cmonClient::NOSERVER) ]
;## remove some server vars
$::cmonClient::updatesitew configure -state normal
$::cmonClient::serverw configure -text "cntlmonAPI ??"
set ::cmonClient::serverKey nokey
eval $::cmonClient::pageUpdate
;## disable ping for globus
catch { after cancel $::cmonClient::NoOpId }
catch { unset ::cmonClient::NoOpId }
}
§ § §
cmonClient::retryConnect
Description
retry connection
Parameters
Usage
Comments:
proc cmonClient::retryConnect { site { delay 50000 } { retry 0 } } {
if { $::cmonClient::state == 1 } {
# cmonClient::enableSites
return
}
if { [ catch {
set ::cmonClient::noPass 0
cmonClient::disableSites $site
cmonClient::state1
catch { unset ::cmonClient::reconnectId }
if { $::cmonClient::state != 1 } {
incr retry 1
if { $retry < $::RECONNECT_TIMES } {
set ::cmonClient::reconnectId \
[ after $delay cmonClient::retryConnect $delay $retry ]
}
}
} err ] } {
cmonClient::state0 lostconnect
}
cmonClient::enableSites
}
§ § §
cmonClient::disableSites
Description
retry connection
Parameters
Usage
Comments:
proc cmonClient::disableSites { site } {
set sitemenu $::cmonClient::sitemenu
for { set i 0 } { $i < [ llength $::cmonClient::sites ] } { incr i 1 } {
$sitemenu entryconfigure $i -state disabled
}
set ::cmonClient::var(site) $site
}
§ § §
cmonClient::enableSites
Description
retry connection
Parameters
Usage
Comments:
proc cmonClient::enableSites {} {
set sitemenu $::cmonClient::sitemenu
for { set i 0 } { $i < [ llength $::cmonClient::sites ] } { incr i 1 } {
$sitemenu entryconfigure $i -state normal
}
}
§ § §
cmonClient::maintainSites
Description
transitions to state 0, the initial state.
and then to state1 if conditions permit (user confirmed)
a site must be chosen here
Parameters
Usage
Comments:
proc cmonClient::maintainSites {} {
if { $::cmonClient::state != 0 } {
set msg "Please disconnect from $::cmonClient::var(site) first"
set choice [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message $msg -icon error -title Error -justify left -font $::MSGFONT ]
return
}
if { [ winfo exist $::cmonClient::whostName ] } {
return
}
if { [ catch {
catch { unset ::cmonClient::sitedialog }
set dlg [Dialog $::cmonClient::whostName -parent . -modal local \
-separator 1 -title "cntlmon API server site: " \
-side bottom -default 0 -cancel 3 ]
set badd [$dlg add -name 0 -command "cmonClient::addSite $dlg" -text add -state disabled ]
set bupdate [$dlg add -name 1 -command "cmonClient::updateSite $dlg" -text update -state disabled ]
set bdel [ $dlg add -name 2 -command "cmonClient::deleteSite $dlg" -text delete -state disabled ]
$dlg add -name cancel -command "destroy $dlg"
set dlgframe [$dlg getframe]
set f1 [ frame $dlg.fsite ]
set lab [ label $f1.lbl -text " Site domain:" -width 20 -justify right ]
set othersite [ComboBox $f1.site -width 5 \
-textvariable ::cmonClient::sitedialog\(othersite\) \
-values [ concat other $::cmonClient::sites ] \
-helptext "Your site's domain name e.g. ldas-dev" \
-editable no \
-modifycmd "cmonClient::displaySite $dlg $f1.site $badd $bupdate $bdel" ]
pack $lab -side left -anchor e
pack $othersite -side right -fill x -expand 1
pack $f1 -side top -fill x -expand 1
set ::cmonClient::sitedialog(othersite) [ lindex $::cmonClient::sites 0 ]
set ::cmonClient::sitedialog(otheraddr) ""
set otheraddr [LabelEntry $dlg.addr -label "Site address: " -labelwidth 20 -labelanchor e \
-textvariable ::cmonClient::sitedialog(otheraddr) -editable 1 -width 20 -labeljustify right \
-helptext "Your site's full address e.g. ldas-dev.ligo.caltech.edu or 131.215.115.248" ]
set ::cmonClient::sitedialog(otherport) ""
set otherport [LabelEntry $dlg.port -label "cntlmon API port: " -labelwidth 20 -labelanchor e \
-textvariable ::cmonClient::sitedialog(otherport) -editable 1 -width 10 -labeljustify right \
-helptext "The port number of the cntlmonAPI for this site, e.g. 10000" ]
set ::cmonClient::sitedialog(otherport) 10000
set ::cmonClient::sitedialog(otherdbnames) ""
set otherdbnames [LabelEntry $dlg.dbnames -label "Site databases: " -labelwidth 20 -labelanchor e \
-textvariable ::cmonClient::sitedialog(otherdbnames) -editable 1 -width 20 -labeljustify right \
-helptext "(Optional) databases at your site, e.g. cit_test cit_1" ]
$othersite bind <Return> "focus $otheraddr"
$otheraddr bind <Return> "focus $otherport"
$otherport bind <Return> "focus $otherdbnames"
$otherdbnames bind <Return> "focus $otheraddr"
pack $othersite $otheraddr $otherport $otherdbnames -side top -fill x -expand 1
$dlg draw
# destroy $dlg
} err ] } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message $err -icon error ]
catch { destroy $dlg }
}
}
§ § §
cmonClient::displaySite
Description
display site info
Parameters
Usage
Comments:
proc cmonClient::displaySite { dialog sitew badd bupdate bdel } {
setCombo $sitew
set ::cmonClient::sitedialog(otherdbnames) ""
set ::cmonClient::sitedialog(otheraddr) ""
set ::cmonClient::sitedialog(otherdbnames) ""
if { ! [ regexp {^(no-server|other)$} $::cmonClient::sitedialog(othersite) ] } {
foreach { host port } $::siteport($::cmonClient::sitedialog(othersite)) { break }
set ::cmonClient::sitedialog(otheraddr) $host
set ::cmonClient::sitedialog(otherport) $port
catch { set ::cmonClient::sitedialog(otherdbnames) $::dbnames($::cmonClient::sitedialog(othersite)) }
}
if { [ string match other $::cmonClient::sitedialog(othersite) ] } {
$sitew configure -editable yes
$badd configure -state normal
$bupdate configure -state disabled
$bdel configure -state disabled
} else {
$sitew configure -editable no
$badd configure -state disabled
$bupdate configure -state normal
$bdel configure -state normal
}
}
§ § §
cmonClient::addSite
Description
add a new server site
Parameters
Usage
Comments:
proc cmonClient::addSite { dialog } {
set text ""
set siteindex [ lsearch -exact $::cmonClient::sites $::cmonClient::sitedialog(othersite) ]
if { $siteindex > -1 } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message "$::cmonClient::sitedialog(othersite) already exists." \
-icon error -justify left -font $::MSGFONT ]
return
}
if { [ string equal other $::cmonClient::sitedialog(othersite) ] } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message "Other cannot be used for site name" \
-icon error -justify left -font $::MSGFONT ]
return
}
if { ! [ string length $::cmonClient::sitedialog(otheraddr) ] } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message "Please enter a site address or IP address" \
-icon error -justify left -font $::MSGFONT ]
return
}
if { ! [ string length $::cmonClient::sitedialog(otherport) ] } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message "Please enter your cntlmon API server port" \
-icon error -justify left -font $::MSGFONT ]
return
}
if { ! [ regexp {^\d+} $::cmonClient::sitedialog(otherport) ] } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message "cntlmon API server port must be numeric" \
-icon error -justify left -font $::MSGFONT ]
return
}
if { [ string length $::cmonClient::sitedialog(otherdbnames) ] } {
foreach db $::cmonClient::sitedialog(otherdbnames) {
if { [ string length $db ] > 8 } {
set ack [ MessageDlg .cmonClientDlg -type ok -aspect 120 \
-message "Database name $db exceeds 8 characters" \
-icon error -justify left -font $::MSGFONT ]
return
}
}
array set ::dbnames [ list $::cmonClient::sitedialog(othersite) \
$::cmonClient::sitedialog(otherdbnames) ]
append text "array set ::dbnames \[ list $::cmonClient::sitedialog(othersite) \
$::cmonClient::sitedialog(otherdbnames) \]\n"
} else {
array set ::dbnames [ list $::cmonClient::sitedialog(othersite) { none } ]
append text "array set ::dbnames \[ list $::cmonClient::sitedialog(othersite) \{ none \} \]\n"
}
array set ::LDASmachines [ list $::cmonClient::sitedialog(othersite) \
{ gateway dataserver metaserver datacon controlmon beowulf } ]
append text "array set ::LDASmachines \[ list $::cmonClient::sitedialog(othersite) \
\{ gateway dataserver metaserver datacon controlmon beowulf \} \]\n"
array set ::siteport [ list $::cmonClient::sitedialog(othersite) \
[ list $::cmonClient::sitedialog(otheraddr) $::cmonClient::sitedialog(otherport) ] ]
append text "array set ::siteport \[ list $::cmonClient::sitedialog(othersite) \
\[ list $::cmonClient::sitedialog(otheraddr) $::cmonClient::sitedialog(otherport) \] \]\n"
if { $siteindex < 0 } {
set ::cmonClient::sites [ linsert $::cmonClient::sites end-1 $::cmonClient::sitedialog(othersite) ]
}
set fd [ open $::statefile a+ ]
set text [ string trim $text \n ]
puts $fd $text
close $fd
destroy $dialog
set ack [ MessageDlg .cmonClientDlg -type ok \
-message "$::cmonClient::sitedialog(othersite) added to server sites and saved in $::statefile." -icon info ]
;## add site to options menu
cmonClient::createSiteOptions
#set ::cmonClient::var(site) $::cmonClient::sitedialog(othersite)
catch { unset ::cmonClient::sitedialog }
}
§ § §
cmonClient::createSiteOptions
Description
create the options menu when sites are new or
other sites have been added.
Usage
Comments:
The sites are sorted when recreated.
proc cmonClient::createSiteOptions { { sitew "" } } {
if { [ string length $sitew ] } {
set ::cmonClient::sitew $sitew
}
catch { destroy $::cmonClient::sitew }
set sites [ lsort -ascii [ array names ::siteport ] ]
set ::cmonClient::sites [ concat no-server $sites ]
set sitemenu [ eval tk_optionMenu $::cmonClient::sitew \
::cmonClient::var(site) $::cmonClient::sites ]
for { set i 0 } { $i < [ llength $::cmonClient::sites ] } { incr i 1 } {
set site [ lindex $::cmonClient::sites $i ]
if { [ string match $::cmonClient::NOSERVER $site ] } {
$sitemenu entryconfigure $i -command cmonClient::state0
} else {
$sitemenu entryconfigure $i -command "cmonClient::state01 $site"
}
}
set ::cmonClient::sitemenu $sitemenu
catch { destroy $::cmonClient::connectw }
set parent [ winfo parent $::cmonClient::sitew ]
label $parent.connects -text $::cmonClient::notConnected -relief ridge -bg orange \
-borderwidth 2
set ::cmonClient::connectw $parent.connects
pack $::cmonClient::sitew $parent.connects -side left -fill y -padx 1 -anchor w
set ::cmonClient::var(site) $::cmonClient::NOSERVER
}
§ § §
cmonClient::createUserOptions
Description
create the options menu when sites are new or
other sites have been added.
Usage
Comments:
The sites are sorted when recreated.
proc cmonClient::createUserOptions { parent } {
if { [ catch {
set but1 [ checkbutton $parent.info -text "show info" -anchor w \
-variable ::POPUP_SHOW_INFO \
-font $::LISTFONT -onvalue 1 -offvalue 0 -relief sunken -borderwidth 2 ]
if { ! [ info exist ::POPUP_SHOW_INFO ] } {
set ::POPUP_SHOW_INFO 1
}
set but2 [ checkbutton $parent.warn -text "show warnings" -anchor w \
-variable ::POPUP_SHOW_WARN \
-font $::LISTFONT -onvalue 1 -offvalue 0 -relief sunken -borderwidth 2 ]
if { ! [ info exist ::POPUP_SHOW_INFO ] } {
set ::POPUP_SHOW_WARN 1
}
set but3 [ checkbutton $parent.printqueue -text "print queue" -anchor w \
-variable ::POPUP_PRINT_QUEUE -onvalue 1 -offvalue 0 -borderwidth 2 \
-font $::LISTFONT -command blt_graph::showPrintQueue -relief sunken ]
set ::POPUP_PRINT_QUEUE 0
pack $but1 $but2 $but3 -side left -padx 2
} err ] } {
return -code error $err
}
}
§ § §
cmonClient::updateSite
Description
removes a site .e.g. which has been added by other
Usage
Comments:
proc cmonClient::updateSite { dialog } {
set text ""
set site $::cmonClient::sitedialog(othersite)
array set ::siteport [ list $::cmonClient::sitedialog(othersite) \
[ list $::cmonClient::sitedialog(otheraddr) $::cmonClient::sitedialog(otherport) ] ]
append text "array set ::siteport \[ list $::cmonClient::sitedialog(othersite) \
\[ list $::cmonClient::sitedialog(otheraddr) $::cmonClient::sitedialog(otherport) \] \]\n"
set pattern "(siteport|dbnames).+$site "
if { [ string length $::cmonClient::sitedialog(otherdbnames) ] } {
array set ::dbnames [ list $::cmonClient::sitedialog(othersite) \
$::cmonClient::sitedialog(otherdbnames) ]
append text "array set ::dbnames \[ list $::cmonClient::sitedialog(othersite) \
\[ list $::cmonClient::sitedialog(otherdbnames) \] \]\n"
} else {
array set ::dbnames [ list $::cmonClient::sitedialog(othersite) none ]
append text "array set ::dbnames \[ list $::cmonClient::sitedialog(othersite) \{ none \} \]\n"
}
set text [ string trim $text \n ]
set newtext ""
if { [ file exist $::statefile ] } {
set fd [ open $::statefile r ]
set data [ read -nonewline $fd ]
close $fd
set data [ split $data \n ]
set site $::cmonClient::sitedialog(othersite)
foreach line $data {
if { ! [ regexp $pattern $line ] } {
append newtext $line\n
}
}
append newtext $text
set newtext [ string trim $newtext \n ]
set fd [ open $::statefile w ]
;## open for writing
puts $fd $newtext
close $fd
}
destroy $dialog
set ack [ MessageDlg .cmonClientDlg -type ok \
-message "Updated information for site $::cmonClient::sitedialog(othersite) and\n\
saved in $::statefile" -icon info ]
catch { unset ::cmonClient::sitedialog }
}
§ § §
cmonClient::deleteSite
Description
removes a site .e.g. which has been added by other
Usage
Comments:
proc cmonClient::deleteSite { dialog } {
if { ! [ string match no-server $::cmonClient::sitedialog(othersite) ] } {
set ack [ MessageDlg .cmonClientDlg -type okcancel -aspect 120 \
-message "Do you really want to delete $::cmonClient::sitedialog(othersite) " \
-icon question -justify left -font $::MSGFONT ]
if { [ string match cancel $ack ] } {
return
}
}
set site $::cmonClient::sitedialog(othersite)
set siteindex [ lsearch -exact $::cmonClient::sites $::cmonClient::sitedialog(othersite) ]
set ::cmonClient::sites [ lreplace $::cmonClient::sites $siteindex $siteindex ]
unset ::siteport($site)
catch { unset ::dbnames($site) }
unset ::LDASmachines($site)
set pattern "$::cmonClient::sitedialog(othersite) "
destroy $dialog
set newtext ""
if { [ file exist $::statefile ] } {
set fd [ open $::statefile r ]
set data [ read -nonewline $fd ]
set data [ split $data \n ]
set newtext ""
foreach line $data {
if { ! [ regexp $pattern $line ] } {
append newtext $line\n
}
}
set newtext [ string trim $newtext \n ]
set fd [ open $::statefile w ]
;## open for writing
puts $fd $newtext
close $fd
}
cmonClient::createSiteOptions
set ack [ MessageDlg .cmonClientDlg -type ok \
-message "$::cmonClient::sitedialog(othersite) deleted" -icon info ]
catch { unset ::cmonClient::sitedialog }
}
§ § §
##*******************************************************
Name: cmonClient::helpTips
Description:
Parameters:
Usage:
Comments:
proc cmonClient::help {} {
set msg "Please visit LDAS home page, link 'using ControlmonAPI Client' for details"
catch { set ack [ MessageDlg .filtertips -title Tips -type ok -aspect 300 \
-message $msg -icon info -justify left -font $::MSGFONT ] }
}
§ § §
##*******************************************************
Name: cmonClient::useGlobusToggle
Description:
Parameters:
Usage:
Comments:
proc cmonClient::useGlobusToggle { button } {
if { $::POPUP_SHOW_INFO } {
set msg "To change this option again when connected to a server, you would need to disconnect, \
select this option and reconnect your cmonClient to the server. If you get an error with Globus, \
you will need to use cmonClient 1.8.0 for servers that are still on raw GSI sockets."
set icon info
set image [ Bitmap::get info ]
set dname .cmonClientGlobusToggle
if { ![ winfo exist $dname ] } {
set dlg [ Dialog .cmonClientGlobusToggle -parent . -modal none \
-separator 1 -title $icon \
-side bottom -anchor s -default 0 -image $image ]
$dlg add -name ok -anchor s -command [ list destroy $dlg ]
set dlgframe [ $dlg getframe ]
message $dlgframe.msg -aspect 300 -text $msg \
-justify left -font $::MSGFONT
pack $dlgframe.msg -side top -anchor w
$dlg draw
after 15000 [ list destroy $dlg ]
}
}
if { [ catch {
;## EXPIRE USER NAME AND PASSWORD IF ANY
foreach var [ list cntllogin cntlpasswd ] {
if { [ info exist ::$var ] } {
unset ::$var
}
}
if { $::USE_GLOBUS } {
cmonGlobusChannel::init
}
} err ] } {
catch { set ack [ MessageDlg .errorDialog[clock seconds ] -title Tips -type ok -aspect 300 \
-message $err -icon error -justify left -font $::MSGFONT ] }
}
}
§ § §
##*******************************************************
Name: cmonClient::helpTips
Description:
Parameters:
Usage:
Comments:
does not work if cntlmonAPI no longer use tcl socket for operator port
proc cmonClient::pingServer {} {
if { $::cmonClient::state != 1 } {
after $::PINGDELAY cmonClient::pingServer
return
}
if { [ catch {
foreach { host port } $::siteport($::cmonClient::var(site)) { break }
set sid [ socket $host $port ]
close $sid
} err ] } {
set msg "[myName]: $err"
if { [ info exist ::logfd ] } {
catch { puts $::logfd $msg ; flush $::logfd }
} else {
puts $msg
}
catch { close $sid }
cmonClient::state0 lostconnect
}
after $::PINGDELAY cmonClient::pingServer
}
§ § §
##*******************************************************
Name: cmonClient::init
Description:
set up vars if they dont exist
Parameters:
Usage:
Comments:
proc cmonClient::init {} {
;## set up xterm
set ::XTERM [ auto_execok xterm ]
if { ! [ string length $::XTERM ] } {
if { [ string match $::tcl_platform(os) SunOS ] } {
set ::XTERM /usr/openwin/bin/xterm
} else {
set ::XTERM /usr/X11R6/bin/xterm
}
}
if { ! [ file exist $::XTERM ] } {
set ack [ tk_messageBox -type ok -default ok \
-message "Please define xterm path in cmonClient resource" ]
}
if { ! [ info exist ::SERVER_DELAY ] } {
set ::SERVER_DELAY 3600000
}
if { ! [ info exist ::PINGDELAY ] } {
set ::PINGDELAY 900000
}
;## max time out for passwd is set to 30 min
if { ! [ info exist ::LOCKTIMEOUT] } {
set ::LOCKTIMEOUT 30
}
;## update password widget every 1 min
if { ! [ info exist ::LOCK_INTERVAL ] } {
set ::LOCK_INTERVAL 60000
} else {
set ::LOCK_INTERVAL [ expr $::LOCK_INTERVAL * 60000 ]
}
if { ! [ info exist ::PRINTCMD ] } {
set ::PRINTCMD lpr
}
if { ! [ info exist ::SERVICE_NAME ] } {
set ::SERVICE_NAME ldas
}
}
§ § §
Name: cmonClient::saveState
Description:
save state info
Usage:
Comments:
proc cmonClient::saveState {} {
if { [ file exist $::statefile ] } {
set fd [ open $::statefile r ]
set data [ read -nonewline $fd ]
close $fd
foreach var [ list POPUP_SHOW_INFO POPUP_SHOW_WARN RSC_LAST_DIFF_VERSION ] {
if { ! [ info exist ::$var ] } {
continue
}
set rc [ regsub -- "set ::$var \\S+" $data "set ::$var [ set ::$var ]" x ]
if { !$rc } {
append data "\nset ::$var [ set ::$var ]"
} else {
set data $x
}
}
set fd [ open ${::statefile}.tmp w ]
puts $fd [ string trim $data \n ]
close $fd
file rename -force ${::statefile}.tmp $::statefile
}
}
§ § §
Name: cmonClient::NoOpReply
Description:
save state info
Usage:
Comments:
NoOp callback
proc cmonClient::NoOpReply { page rc clientCmd html } {
set name cmonClient
set clientCmd [ split $clientCmd : ]
set client [ lindex $clientCmd 0 ]
set cmdId [ lindex $clientCmd 1 ]
set afterid [ lindex $clientCmd 2 ]
# puts "in NoOpReply, rc=$rc, page=$page, client=$client,cmdId=$cmdId, afterid=$afterid"
# set ::cmonClient::client $client
;## turn ping off if server does not support it
if { [ string match "*invalid command*cntlmon::NoOp*" $html ] } {
catch { after cancel $::cmonClient::NoOpId }
set ::cmonClient::NoOpId stop
return
}
;## turn ping off also if error
if { ! [ string match "*NoOp*" $html ] } {
set ack [ tk_messageBox -type ok -default ok \
-message $html \
-icon info ]
catch { after cancel $::cmonClient::NoOpId }
set ::cmonClient::NoOpId stop
}
}
§ § §
Name: cmonClient::sendNoOp
Description:
save state info
Usage:
Comments:
send no op only if there is outstanding request
silent if there are errors as the server could be disconnected
proc cmonClient::sendNoOp {} {
if { $::cmonClient::state } {
if { $::USE_GLOBUS } {
set cmdId new
set client $::cmonClient::client
set repeat 0
set freq 0
set page cmonClient
if { [ catch {
set cmd "cmonClient::NoOpReply $page\n$repeat\n$freq\n\$client:$cmdId\ncntlmon::NoOp"
sendCmd $cmd
} err ] } {
#set ack [ tk_messageBox -type ok -default ok \
#-message "sendNoOp error: $err" \
#-icon error ]
set ::cmonClient::NoOpId stop
}
;## if server does not support this dont send it
if { [ info exist ::cmonClient::NoOpId ] } {
if { [ string equal stop $::cmonClient::NoOpId ] } {
unset ::cmonClient::NoOpId
return
}
}
set ::cmonClient::NoOpId [ after 5000 cmonClient::sendNoOp ]
} else