## RHEOMETER CONTROL proc rhCallBack {rootPath} { set catch_status [ catch { # if rhReading >= trigger then start histmem and pop trigger and time if {[hval $rootPath/runexp] == -1} { return idle } set trigList [hval $rootPath/triggerList] if {$trigList == "EMPTY"} { hset $rootPath/runexp -1 return idle } set acqTime [hval $rootPath/acqTime] if {$acqTime == "EMPTY"} { broadcast "You must set acquisition time" hset $rootPath/runexp -1 return idle } if {[SplitReply [file_status]] == "UNKNOWN"} { broadcast "Data will be saved in a standard HISTOGRAM_XY file" broadcast "You can override this default by running the 'newfile' command first" newfile HISTOGRAM_XY } set rhReading [hval $rootPath] set tol [hval $rootPath/tol] set trigLevel [lindex $trigList 0] if {[hval $rootPath/runexp] == 1} { set CBID [ SplitReply [scriptcallback connect hmm COUNTEND "rheometer_savehmmdata $rootPath"] ] hsetprop $rootPath cbid $CBID hset $rootPath/runexp 0 sct utime timecheck } if {[expr abs($rhReading - $trigLevel)] > $tol } { sct utime timecheck return idle } sct utime rhCBtime set currtime [sct rhCBtime] set timecheck [sct timecheck] set timeout [hval $rootPath/settletime] # broadcast currtime = $currtime, timecheck = $timecheck, timeout = $timeout, delta = [expr $currtime - $timecheck], rhReading = $rhReading, trigLevel = $trigLevel, tol = $tol, deltaSeed = [expr abs($rhReading - $trigLevel)] if {[expr $currtime - $timecheck] > $timeout} { set listLen [llength $trigList] if {$listLen > 1} { # Pop trigger hset $rootPath/triggerList [lrange $trigList 1 end] } else { hset $rootPath/triggerList "EMPTY" hset $rootPath/acqTime "EMPTY" hset $rootPath/runexp -1 } if { $acqTime != "EMPTY" && [llength $acqTime] > 1} { hset $rootPath/acqTime [lrange $acqTime 1 end] } histmem pause broadcast [info level 0] [hval $rootPath] trigger a [lindex $acqTime 0] second acquisition, sicstime [sicstime] histmem mode time histmem preset [lindex $acqTime 0] histmem start } return idle } message ] handle_exception $catch_status $message } ## # @brief Pop trigger and acquisition time proc rheometer_savehmmdata {rootPath} { set si [hval $rootPath/saveIndex] broadcast [info level 0]: save data index = $si, sicstime [sicstime] save $si if {[hval $rootPath/runexp] == -1} { hset $rootPath/saveIndex 0 newfile clear set CBID [hgetpropval $rootPath cbid] if {$CBID != 0} { scriptcallback remove hmm $CBID hsetprop $rootPath cbid 0 } } else { incr si hset $rootPath/saveIndex $si } } publish rheometer_savehmmdata user proc add_rheo {rhControl IP tol settle {PORT 4001}} { MakeProtek $rhControl $IP $PORT 1.0 0.0 0.5 "rhCallBack /sics/$rhControl" hfactory /sics/$rhControl/saveIndex plain user int hset /sics/$rhControl/saveIndex 0 hfactory /sics/$rhControl/triggerList plain user text hset /sics/$rhControl/triggerList "EMPTY" hfactory /sics/$rhControl/acqTime plain user text hset /sics/$rhControl/acqTime "EMPTY" hfactory /sics/$rhControl/runexp plain user float hset /sics/$rhControl/runexp -1 hfactory /sics/$rhControl/tol plain user float hset /sics/$rhControl/tol $tol hfactory /sics/$rhControl/settletime plain user float hset /sics/$rhControl/settletime $settle hsetprop /sics/$rhControl timecheck 0 }