#!/usr/bin/wish ##!/net/fs7/home/adaq/halog/src/bin/jwish ##!/cs/op/bin/iwish ##!/net/fs1/apps/tcl7.6/bin/wish # 2/11/98 (saw) Fixed the year 1998 problem global ttime names channels bind all {} wm geometry . +1+1 set Indname [pid] set Report "" proc Goodbye {} { global Indname catch {exec rm /net/fs7/home/adaq/halog/tmp${Indname}1.gif } catch {exec rm /net/fs7/home/adaq/halog/tmp${Indname}2.gif } exit } proc Keeptime {} { global Realtime Date set Realtime [exec date +%R] set Date [exec date +%m-%d-%y] after 60000 Keeptime } Keeptime wm protocol . WM_DELETE_WINDOW { Goodbye } frame .titlebar label .titlebar.top -relief groove -text "Hall A Log" -font -adobe-helvetica-bold-o-normal--20-140-100-100-p-98-iso8859-1 -fg Black -bg yellow pack .titlebar .titlebar.top -fill x frame .topinfo label .topinfo.datetitle -text "Date " -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black entry .topinfo.date -state disabled -width 10 -relief sunken -textvariable Date -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg Blue -fg Yellow label .topinfo.usertitle -text " User " -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black entry .topinfo.user -width 12 -relief sunken -textvariable User -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg cyan -fg Black #label .topinfo.catertitle -text " Cater # " -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black #entry .topinfo.cater -width 6 -relief sunken -textvariable Cater -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg cyan -fg Black label .topinfo.followuptitle -text " Follows up Entry # " -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black entry .topinfo.followup -width 6 -relief sunken -textvariable Followup -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg cyan -fg Black label .topinfo.timetitle -text " Time " -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black entry .topinfo.time -state disabled -width 5 -relief sunken -textvariable Realtime -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg Blue -fg Yellow pack .topinfo #pack .topinfo.datetitle .topinfo.date .topinfo.timetitle .topinfo.time .topinfo.usertitle .topinfo.user .topinfo.catertitle .topinfo.cater -side left -padx 2m -pady 2m pack .topinfo.datetitle .topinfo.date .topinfo.timetitle .topinfo.time .topinfo.usertitle .topinfo.user .topinfo.followuptitle .topinfo.followup -side left -padx 2m -pady 2m set Date [exec date +%m-%d-%y] bind .topinfo.date { set Date [exec date +%%m-%%d-%%y] } bind .topinfo.date { CHECKDATE focus .topinfo.time } bind .topinfo.date { CHECKDATE focus .topinfo.time } bind .topinfo.date { focus .topinfo.date } bind .topinfo.date { CHECKDATE } set Usertemp [ string toupper [string range $env(LOGNAME) 0 0] ] set User "$Usertemp[string range $env(LOGNAME) 1 end]" if {$env(LOGNAME) == "volmer"} { set User "Volmer" } if {$env(LOGNAME) == "mack"} { set User "Mack" } if {$env(LOGNAME) == "saw"} { set User "Wood" } bind .topinfo.user { set User $env(LOGNAME) } #bind .topinfo.user { # focus .topinfo.cater # } #bind .topinfo.user { # focus .topinfo.cater # } bind .topinfo.user { focus .topinfo.follwup } bind .topinfo.user { focus .topinfo.followup } bind .topinfo.user { focus .topinfo.user } #bind .topinfo.cater { # # focus .repo.report # # } #bind .topinfo.cater { # # # focus .repo.report # # } #bind .topinfo.cater { # focus .topinfo.cater # } #bind .topinfo.cater { # # } bind .topinfo.followup { focus .repo.report } bind .topinfo.followup { focus .repo.report } bind .topinfo.followup { focus .topinfo.followup } bind .topinfo.followup { } bind .topinfo.time { set Realtime [exec date +%%R] } bind .topinfo.time { set Realtime [CHECKTIME $Realtime] focus .topinfo.user } bind .topinfo.time { set Realtime [CHECKTIME $Realtime] focus .topinfo.user } bind .topinfo.time { focus .topinfo.time } bind .topinfo.time { set Realtime [CHECKTIME $Realtime] } label .reporttitle -text Description -justify center -relief flat -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black pack .reporttitle frame .repo text .repo.report -width 70 -relief sunken -height 5 -wrap word -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg cyan -fg Black -yscrollcommand ".repo.reportscroll set" scrollbar .repo.reportscroll -command ".repo.report yview" pack .repo -expand true -fill y pack .repo.report .repo.reportscroll -side left -expand true -fill y bind .repo.report { focus .topinfo.date } bind .repo.report { } bind .repo.report { READREPORT if {[winfo exists .spell] == 0} { CHECKSPELL} } bind .repo.report { focus .repo.report } bind .repo.report { focus .repo.report READREPORT } frame .keys label .keys.keylabel -text "Keywords for Hall A Log Entry" -relief flat -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black entry .keys.keyword -width 24 -relief sunken -textvariable Keyword -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg cyan -fg Black label .keys.feedbacklabel -text "Message Center" -relief flat -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -fg Black entry .keys.feedback -width 18 -relief raised -textvariable Feedback -font -adobe-times-medium-r-normal--24-240-75-75-p-125-iso8859-1 -bg Blue -fg Yellow set Feedback "Welcome to halog!" pack .keys pack .keys.keylabel .keys.keyword .keys.feedbacklabel .keys.feedback -side left -padx 2m -pady 2m bind .keys.keyword { focus .keys.keyword } frame .buttons button .buttons.help -text "Help" -command HELPME button .buttons.scan -text "ScanIt!" -command { exec >@stdout /net/fs7/home/adaq/halog/src/scandir/ScanIt & } button .buttons.entry -text "Make Entry" -command { set Notcomplete 0 set error [catch MAKEENTRY] if {$Notcomplete == 0 } { CLEANFORM if {$error == 0 } { set Feedback "Entry Complete" } } } button .buttons.clear -text "Clear Entry" -command CLEANFORM set album 0 set Pic1 0 set Pic2 0 button .buttons.picture -text "Grab Screen" -command { if {$album == 0 } { frame .album frame .albumbuttons button .albumbuttons.grab1 -text "Grab 1st Picture" -command { TAKEPHOTO 1 set Pic1 1} checkbutton .albumbuttons.pic1 -text "Enter Picture 1" -variable Pic1 -command { if {$Pic1 == 0} { .album.can delete image1 } } button .albumbuttons.grab2 -text "Grab 2nd Picture" -command { TAKEPHOTO 2 set Pic2 1 } checkbutton .albumbuttons.pic2 -text "Enter Picture 2" -variable Pic2 -command { if {$Pic2 == 0} { .album.can delete image2 } } pack .album -before .buttons pack .albumbuttons -before .buttons canvas .album.can -width 22c -height 10c pack .album.can pack .albumbuttons.grab1 .albumbuttons.pic1 .albumbuttons.grab2 .albumbuttons.pic2 -side left -padx 1m -pady 2m set album 1 pack forget .buttons.picture } TAKEPHOTO 1 set Pic1 1 } button .buttons.exit -text "Quit" -command { set exitvar 0 if { [string length $Report] > 1 } { toplevel .exit wm title .exit { Are you Sure } set exitvar 1 label .exit.top -text "DO YOU WANT TO QUIT WITHOUT" -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 label .exit.middle -text "MAKING THE CURRENT ENTRY?" -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 button .exit.yes -text yes -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -command { Goodbye } button .exit.no -text no -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -command { destroy .exit } button .exit.maybe -text maybe -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 -command { destroy .exit.maybe label .exit.answer -text "C'mon, make a choice." -font -adobe-helvetica-bold-o-normal--14-100-100-100-p-78-iso8859-1 pack .exit.answer } pack .exit.top .exit.middle .exit.yes .exit.no .exit.maybe -fill x wm geometry .exit +1000+0 } if {$exitvar == 0} { Goodbye } } set Elog 1 menubutton .buttons.elogonly -text "Change Form" -relief groove -menu .buttons.elogonly.menu menu .buttons.elogonly.menu .buttons.elogonly.menu add command -label "Your Form here" -command { set Elog 0 } pack .buttons #pack .buttons.entry .buttons.elogonly .buttons.clear .buttons.picture .buttons.alarms .buttons.help .buttons.exit -side left -padx 1m -pady 2m pack .buttons.entry .buttons.elogonly .buttons.clear .buttons.picture .buttons.scan .buttons.help .buttons.exit -side left -padx 1m -pady 2m ######################################################################### # # # This procedure checks the time for proper format - Thanks Shannon # # # ######################################################################### proc CHECKTIME {Wtime} { global Feedback set Wtime [string trim $Wtime] if {$Wtime == ""} { return $Wtime } if { [string length $Wtime] > 5 } { bell set Wtime "" set Feedback "Use HH:MM" return $Wtime } if { [string length $Wtime] == 1} { set Wtime "000$Wtime" } if { [string length $Wtime] == 2} { set Wtime "00$Wtime" } if { [string length $Wtime] == 3} { set Wtime "0$Wtime" } if { [string length $Wtime] == 4 & [string first : $Wtime] != 1} \ { set Wtime "[string range $Wtime 0 1]:[string range $Wtime 2 3]"} if { [string length $Wtime] == 4 & [string first : $Wtime] == 1} \ { set Wtime "0$Wtime"} if { [string length $Wtime] == 5 & [string first : $Wtime] != 2} { set Wtime "" bell set Feedback "Use HH:MM" return $Wtime } if { [string first : $Wtime] != [string last : $Wtime]} { set Wtime "" bell set Feedback "Use HH:MM" return $Wtime } set PartTime [string range $Wtime 0 1] if {[string range $PartTime 0 0] == 0 } { set PartTime [string range $PartTime 1 1] } if { [catch { set Error [expr $PartTime+1] } ] != 0} { set Wtime "" bell set Feedback "Use HH:MM" return $Wtime } set PartTime [string range $Wtime 3 4] if {[string range $PartTime 0 0] == 0 } { set PartTime [string range $PartTime 1 1] } if { [ catch { set Error [expr $PartTime+1] } ] != 0} { set Wtime "" bell set Feedback "Use HH:MM" return $Wtime } set PartTime [string range $Wtime 0 1] if { $PartTime > 23 ^ $PartTime < 0 } { set Wtime "" set Feedback "Use HH:MM" bell return $Wtime } set PartTime [string range $Wtime 3 4] if { $PartTime > 59 ^ $PartTime < 0 } { bell set Wtime "" set Feedback "Use HH:MM" } return $Wtime } ######################################################################### # # # This procedure checks the date for proper format # # # ######################################################################### proc CHECKDATE {} { global Date Feedback if {$Date == ""} { return } regsub -all {\\} $Date "-" Date regsub -all "/" $Date "-" Date if {[string first - $Date] == 1} { set Date "$Date" } if { [string match "??-??-??" $Date]== 0 && $Date != ""} { bell set Feedback "Use mm-dd-yy" set Date "" focus .topinfo.date return } set PartDate [string range $Date 0 1] if {[string range $PartDate 0 0] == 0 } { set PartDate [string range $PartDate 1 1] } if { [ catch { set Error [expr $PartDate+1] } ] != 0} { bell set Feedback "Use mm-dd-yy" set Date "" return } set PartDate [string range $Date 3 4] if {[string range $PartDate 0 0] == 0 } { set PartDate [string range $PartDate 1 1] } if { [ catch { set Error [expr $PartDate+1] } ] != 0} { bell set Feedback "Use mm-dd-yy" set Date "" return } set PartDate [string range $Date 6 7] if {[string range $PartDate 0 0] == 0 } { set PartDate [string range $PartDate 1 1] } if { [ catch { set Error [expr $PartDate+1] } ] != 0} { bell set Feedback "Use mm-dd-yy" set Date "" return } set PartDate [string range $Date 0 1] if { $PartDate > 12 ^ $PartDate < 0 } { bell set Feedback "Use mm-dd-yy" set Date "" return } set PartDate [string range $Date 3 4] if { $PartDate > 31 ^ $PartDate < 0 } { bell set Feedback "Use mm-dd-yy" set Date "" return } set PartDate [string range $Date 6 7] # if { $PartDate > 97 ^ $PartDate < 96 } { # bell # set Feedback "Use mm-dd-yy" # set Date "" # } } ######################################################################### # # # This procedure checks Spelling in the Text box in the Report block # # # ######################################################################### proc CHECKSPELL {} { global Report regsub -all \n [exec echo $Report | spell ] " " Spellresults #puts $Spellresults toplevel .spell #wm title {SpellCheck} frame .spell.main wm geometry .spell +1000+500 button .spell.quit -text Quit -command {destroy .spell} scrollbar .spell.scroll -command ".spell.text yview" listbox .spell.text -height 7 -width 20 -relief raised -bd 2 -fg yellow -bg blue -yscrollcommand ".spell.scroll set" pack .spell.scroll -in .spell.main -side right -fill y pack .spell.text -in .spell.main -side left pack .spell.quit -side bottom -fill x pack .spell.main -side top set lngth [llength $Spellresults] set i 0 while {$i <= $lngth} { .spell.text insert end [lindex $Spellresults $i] incr i } } ######################################################################### # # # This procedure changes what is in the text box to the variable Report # # # ######################################################################### proc READREPORT {} { global Report Uneditedreport set Uneditedreport "[.repo.report get 1.0 end]" regsub -all \n $Uneditedreport " " Report # set spellresults [exec echo $Report | spell ] } ######################################################################### # # # This procedure Checks entries for completeness upon Submission # # # ######################################################################### proc MAKEENTRY {} { global Date User Realtime Uptime Restoretime System Location Device Report Cater Followup EntryString Feedback Elog Keyword Notcomplete Indname set Date [string trim $Date] if {$Date == ""} { focus .topinfo.date bell set Feedback "Enter a Date" set Notcomplete 1 return } set User [string trim $User] if {$User == ""} { focus .topinfo.user bell set Feedback "Enter User Name" set Notcomplete 1 return } set Realtime [string trim $Realtime] if {$Realtime == ""} { bell if {$Elog == 0 } { focus .entry.Realtime set Feedback "Enter Initial Realtime" } else { focus .topinfo.time set Feedback "Enter Time" } set Notcomplete 1 return } set Report [string trim $Report] if {$Report == "" || [string length $Report] < 1 } { focus .repo.report bell set Feedback "Enter a Report" set Notcomplete 1 return } set Keyword [string trim $Keyword] if {$Keyword == "" || [string length $Keyword] < 1 } { focus .keys.keyword bell set Feedback "Enter some Keywords" set Notcomplete 1 return } MAKEHTML } ######################################################################### # # # This procedure makes an ELOG entry from the information given # # # ######################################################################### proc MAKEHTML {} { global Date User Realtime Uptime Restoretime System Location Device Report Cater Followup Uneditedreport Keyword Feedback Elog Pic1 Pic2 Indname set Sec [exec date +%S] set Filename "/net/fs7/home/adaq/public_html/halog/log/tmp_html/[string range $Date 6 7][string range $Date 0 1][string range $Date 3 4][string range $Realtime 0 1][string range $Realtime 3 4]$Sec.html" set Giffile1 "[string range $Date 6 7][string range $Date 0 1][string range $Date 3 4][string range $Realtime 0 1][string range $Realtime 3 4]$Sec.1.gif" set Giffile2 "[string range $Date 6 7][string range $Date 0 1][string range $Date 3 4][string range $Realtime 0 1][string range $Realtime 3 4]$Sec.2.gif" set Giffiletemp1 "/net/fs7/home/adaq/public_html/halog/log/tmp_html/[string range $Date 6 7][string range $Date 0 1][string range $Date 3 4][string range $Realtime 0 1][string range $Realtime 3 4]$Sec.1.gif" set Giffiletemp2 "/net/fs7/home/adaq/public_html/halog/log/tmp_html/[string range $Date 6 7][string range $Date 0 1][string range $Date 3 4][string range $Realtime 0 1][string range $Realtime 3 4]$Sec.2.gif" set Alognum [exec /net/fs7/home/adaq/halog/src/halognumber] set f [open $Filename w] puts $f "
" puts $f "" puts $f "

User name $User

" puts $f "

Log entry time $Realtime:$Sec on [exec date +%B] [exec date +%e,%Y]

" puts $f "

Entry number $Alognum

" if {$Followup != "" } { puts $f "" } puts $f "keyword=$Keyword
" puts $f "
" # Put in extra carriage returns. regsub -all \n $Uneditedreport "
\n" output puts $f $output puts $f "
" if {$Pic1 == 1} { puts $f "
" puts $f "FIGURE 1
" puts $f "" exec mv /net/fs7/home/adaq/halog/tmp/${Indname}1.gif $Giffiletemp1 } if {$Pic2 == 1} { puts $f "
" if {$Pic1 == 1} { puts $f "FIGURE 2
" } else { puts $f "FIGURE 1
" } puts $f "" exec mv /net/fs7/home/adaq/halog/tmp/${Indname}2.gif $Giffiletemp2 } close $f set Pic1 0 set Pic2 0 } ######################################################################### # # # This procedure takes Photos for the elog # # # ######################################################################### proc TAKEPHOTO {number} { global User gallery1s gallery2s Indname wm iconify . catch {exec >@stdout /net/fs7/home/adaq/halog/src/xwpick/xwpick -format gif /net/fs7/home/adaq/halog/tmp/$Indname$number.gif} exec chmod 666 /net/fs7/home/adaq/halog/tmp/$Indname$number.gif image create photo gallery$number gallery$number read /net/fs7/home/adaq/halog/tmp/$Indname$number.gif set height [image height gallery$number] set width [image width gallery$number] set xnumber [expr $width/400 + 1] if {$height > 400} { set ynumber [expr $height/400 + 1] } else { set ynumber 1 } image create photo gallery{$number}s gallery{$number}s copy gallery$number -subsample $xnumber $ynumber if {$number == 1} { .album.can create image 0 0 -image gallery{$number}s -anchor nw -tags image1 } if {$number == 2} { .album.can create image 400 0 -image gallery{$number}s -anchor nw -tags image2 } wm deiconify . } ######################################################################### # # # This procedure makes the Help window. # # # ######################################################################### proc HELPME {} { toplevel .help wm title .help { HELP File for DTLite } frame .help.mainhelp button .help.quit -text Quit -command {destroy .help} scrollbar .help.scroll -command ".help.text yview" listbox .help.text -height 20 -width 75 -relief raised -bd 2 -fg blue -bg white -yscrollcommand ".help.scroll set" pack .help.scroll -in .help.mainhelp -side right -fill y pack .help.text -in .help.mainhelp -side left pack .help.quit -side bottom -fill x pack .help.mainhelp -side top set F [open /net/fs7/home/adaq/halog/src/help.dtlite] while { [gets $F line] >= 0} { .help.text insert end $line } close $F } proc CLEANFORM {} { global Date User Realtime Uptime Restoretime System Location Device Cater Followup Keyword Feedback Indname global Pic1 Pic2 album Report set Realtime [exec date +%R] set Uptime "" set Restoretime "" set System "" set Location "" set Device "" set Cater "" set Followup "" set Keyword "" set Feedback "Welcome to DTLite" catch {exec rm /net/fs7/home/adaq/halog/tmp${Indname}1.gif } catch {exec rm /net/fs7/home/adaq/halog/tmp${Indname}2.gif } .repo.report delete 1.0 end set Report "" set Pic1 0 set Pic2 0 if {$album == 1} { set album 0 destroy .album destroy .albumbuttons pack .buttons.picture -before .buttons.help -side left -padx 1m -pady 2m } }