#!/hermes/bin/loadint pinky -f ##################################################################### # # Script : Demo High Voltage Monitor 2 # # Description : This script monitors the current high voltage # values provided by the demo server in a # timegraph manner. # # Comments : Just a demo. # # Date : ? # # Updates : 05/05/95 wrote this header //MAF # # Author : Klaus Ackerstaff (ack@hermes.desy.de) # Marc-Andre Funk (maf@hermes.desy.de) # # Remarks : - # # # (C) Hermes Collaboration ##################################################################### #===================================================================# # open a dad-connection to the server and book the # dataflow "hvValues". #===================================================================# dadInit dadConnect mon hvValues grabobj hvValue mon.hvValue #===================================================================# # Define the global variables we'll use #===================================================================# set tcl_precision 17 set channels 5 set ntimes 20 set chandef { {cross green} {plus magenta} {circle blue}\ {square red} {diamond yellow}} #===================================================================# # This is the main frame #===================================================================# frame .main #===================================================================# # make a timegraph widget at the top window side #===================================================================# frame .main.graph -bd 5 -relief sunken set graph .main.graph.graph blt_graph $graph tgraph_ini $graph $ntimes $channels for {set i 0} {$i < $channels} {incr i 1} { $graph element configure dat$i \ -symbol [lindex [lindex $chandef $i] 0] \ -fg [lindex [lindex $chandef $i] 1] \ -label "Channel #[expr $i + 1]" } $graph configure -width 500 -height 250 $graph yaxis configure -loose 1 $graph yaxis configure -min 500 $graph yaxis configure -title "HV \[V\]" $graph xaxis configure -title "time" -command "xtime %H:%M:%S" pack $graph pack .main.graph -side top #===================================================================# # Build some buttons on the rightmost side #===================================================================# set buttons .main.butts frame $buttons -bd 5 -relief groove button $buttons.config -text config \ -command [list ConfigureGraph [winfo name .] $graph] pack $buttons.config -side left -fill x -expand 1 button $buttons.print -text "save ps" -command { $graph postscript bar.ps \ -pagewidth 6.5i -pageheight 9i -landscape true } pack $buttons.print -side left -fill x -expand 1 button $buttons.exit -text "Exit" -command exit pack $buttons.exit -side left -fill x -expand 1 pack $buttons -side left -expand 1 -fill x #===================================================================# # Show all #===================================================================# pack .main -side top -fill x -expand 1 #===================================================================# # procedure called by PinK file handler # Message gets a table from the server (60 sec waiting time in case # the net is slow). It then gets the new fields and writes the values # to the timegraph #===================================================================# proc HVupdate { con } { global graph $con.hvValue clear catch "$con Message 60000" err if { $err !="" } exit set imax [$con.hvValue rows] for {set i 1} {$i <= $imax} {incr i 1} { $con.hvValue fetch ID $i set value [$con.hvValue getfield Value] set ltime [$con.hvValue getfield iTimeStart] tgraph $graph [expr $i-1] $ltime $value } return 0; } #===================================================================# # create a dad file handler and execute the procedure "HVupdate" # define above whenever there is something new on this connection. #===================================================================# mon CreateFH HVupdate mon BookDo #========================== End of file ============================#