#!/hermes/bin/loadint pinky -f ##################################################################### # # Script : Demo High Voltage Control # # Description : This script sends messages via the Demo server # to the hv ('hardware') client and reports # messages it's receiving from there. # # 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 ##################################################################### #===================================================================# # Here our global variables are defined #===================================================================# global cmd message #===================================================================# # open a dad-connection to the server and book the dataflow "scCmds". # create a PinK object for the table scCommand #===================================================================# dadInit dadConnect con scCmds grabobj scCommand con.scCommand #===================================================================# # This is how to send a command to the control client: #===================================================================# proc HVSendCmd {} { global cmd con.scCommand clear con.scCommand setfield ID NEXT con.scCommand setfield cSender HVCNTRL con.scCommand setfield cReceiver HVSET con.scCommand setfield cCommand "$cmd" con.scCommand insrow con WUpdate con.scCommand con.scCommand clear } #===================================================================# # Organize the main frame #===================================================================# frame .main -bd 5 #===================================================================# # and now an entry along with its binding, putting a number in it # and hit sends the command and then releases the # cursor focus. The global variable command is set. #===================================================================# set command .main.command frame $command label $command.label -text "Command:" -anchor center \ -width 20 -height 1 -relief groove pack $command.label -side left -fill both -expand 1 entry $command.cmd -relief sunken -width 64 -textvariable cmd bind $command.cmd {focus none; HVSendCmd} pack $command.cmd -side left -fill both -expand 1 pack $command -fill x -expand 1 #===================================================================# # add a label to display the answer and other messages #===================================================================# set answer .main.answer frame $answer label $answer.label -text "Answer:" -anchor center \ -width 20 -height 1 -relief groove pack $answer.label -side left -fill both -expand 1 label $answer.answ -height 1 -relief sunken -width 64\ -textvariable message -anchor w pack $answer.answ -side left -fill both -expand 1 pack $answer -fill x -expand 1 #===================================================================# # Now create some buttons with commands #===================================================================# set butts .main.buts frame $butts -bd 5 -relief groove button $butts.send -text "Send" -command HVSendCmd pack $butts.send -side left -fill both -expand 1 button $butts.exit -text "Exit" -command exit pack $butts.exit -side left -fill both -expand 1 pack $butts -fill x -expand 1 #===================================================================# # Show all this #===================================================================# pack .main -fill x -expand 1 #===================================================================# # This is the procedure called by PinK file handler # Message gets a table from the server (60 sec waiting time in case # the net is slow) and puts the content into the answer label. #===================================================================# proc HVctrl { con } { global message catch "$con Message 60000" err if { $err !="" } exit $con.scCommand getrow 1 set message [$con.scCommand getfield cCommand] $con.scCommand clear } #===================================================================# # Specify the booking condition and enable the file handler for the # connection, i.e. the PinK procedure "HVctrl" will be executed # whenever some new info is coming on the connection # Finally book the next update. #===================================================================# con BookIf con.scCommand "cReceiver = 'HVCNTRL'" con CreateFH HVctrl con BookDoNow #========================== End of file ============================#