#--------------------------------------------------------- # This is a new asynchronous driver for the Pfeiffer # Vacuum measurement device. This driver has been redone # in order to better integrate it into the Hipadaba tree # at FOCUS. # # The pfeiffer device is somewhat shitty in that it cannot # be switched on all the time. What is implemented now is # this: the looser has to switch the thing on via the state # field. After that values are read any 2 minutes. After 20 # minutes the thing switches itself off again. # # Then there is a funny protocol. A normal command is easy: # Host: command # Pfeiffer: or # It gets involved when a parameter is requested. Then it looks # like this: # Host: command # Pfeiffer: or # Host: # Pfeiffer: something,value # # The script chains: # pfiffstate - pfiffstatereply # pfiffreadsensor - pfiffenq - pfiffreply # # copyright: see file COPYRIGHT # # Mark Koennecke, March 2009 #--------------------------------------------------------- MakeSICSObj pfiff Vacuum #makesctcontroller pfiffsct pfeiffer localhost:8080 makesctcontroller pfiffsct pfeiffer $ts:3009 #pfiffsct debug -1 set pfiffpar [list Antitrumpet Be-filter Flightpath Sample-Chamber] #----------------------------------------------------- proc pfiffstate {} { set val [sct target] if {[string compare $val on] == 0} { sct send "SEN ,2,2,2,2,0,0" sct utime devon } else { sct send "SEN ,1,1,1,1,0,0" } return pfiffstatereply } #---------------------------------------------------- proc pfiffstatereply {} { sct update [sct target] return idle } #------------------------------------------------------ # This tests for the state being off # This also tests if the device has been on for more # then 20 minutes. If so it is switched off #------------------------------------------------------ proc pfiffreadsensor {num} { set test [hval /sics/pfiff/state] if {[string compare $test off] == 0} { sct update "sensor off" return idle } set time [hgetpropval /sics/pfiff/state devon] if {[clock seconds] > $time + 20*60} { hset /sics/pfiff/state off return idle } if {$num < 5} { sct send [format "PR%1.1d" $num] return pfiffenq } else { return idle } } #------------------------------------------------------- proc pfiffenq {} { sct send "" return pfiffreply } #------------------------------------------------------- proc pfiffreply {} { set reply [sct result] if {[string first ERR $reply] >= 0 || [string first ASCER $reply] >= 0} { sct geterror $reply return idle } set l [split $reply ,] sct update [lindex $l 1] hdelprop [sct] geterror return idle } #-------------------------------------------------------- proc pfiffidle {} { return idle } #--------------------------------------------------------- set count 1 foreach p $pfiffpar { hfactory /sics/pfiff/$p plain internal text hsetprop /sics/pfiff/$p read "pfiffreadsensor $count" hsetprop /sics/pfiff/$p pfiffenq pfiffenq hsetprop /sics/pfiff/$p pfiffreply pfiffreply pfiffsct poll /sics/pfiff/$p 120 incr count } hfactory /sics/pfiff/state plain spy text hupdate /sics/pfiff/state off hsetprop /sics/pfiff/state values on,off hsetprop /sics/pfiff/state write pfiffstate hsetprop /sics/pfiff/state pfiffstatereply pfiffstatereply pfiffsct write /sics/pfiff/state #------------------------------------------------------ proc pfiffread {num} { global pfiffpar set par [lindex $pfiffpar [expr $num -1]] return [hval /sics/pfiff/$par] } #-------------------------------------------------------- proc vac {} { global pfiffpar set test [hval /sics/pfiff/state] if {[string first off $test] >= 0} { hset /sics/pfiff/state on foreach p $pfiffpar { pfiffsct queue /sics/pfiff/$p progress read } return "Switched Pfeiffer on, try to read again in a couple of seconds" } append result "Antitrumpet : " [pfiffread 1] "\n" append result "Berylium filter : " [pfiffread 2] "\n" append result "Flightpath : " [pfiffread 3] "\n" append result "Sample chamber : " [pfiffread 4] "\n" return $result } Publish vac User