Trigger acquisition when within tolerance of the next step for the required settletime.
Also made generic so you can create a temperature control for example instead of a speed based control. r3218 | ffr | 2011-06-20 10:02:04 +1000 (Mon, 20 Jun 2011) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
d1bc6cda97
commit
7a92bfb4dd
@@ -1,52 +1,67 @@
|
||||
## RHEOMETER CONTROL
|
||||
|
||||
proc rhCallBack {rootPath} {
|
||||
# if rhSpeed >= 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/acqTime "EMPTY"
|
||||
hset $rootPath/runexp 0
|
||||
return idle
|
||||
}
|
||||
set acqTime [hval /sics/rhSpeed/acqTime]
|
||||
if {$acqTime == "EMPTY"} {
|
||||
broadcast "You must set acquisition time"
|
||||
return idle
|
||||
}
|
||||
set rhSpeed [hval $rootPath]
|
||||
set trigLevel [lindex $trigList 0]
|
||||
if {$rhSpeed >= $trigLevel } {
|
||||
set listLen [llength $trigList]
|
||||
if {$listLen > 1} {
|
||||
# If the rhSpeed has jumped over a number of trigger values then skip over those elements in the list
|
||||
for {set tlIndex 1} {$tlIndex < $listLen} {incr tlIndex} {
|
||||
set trigLevel [lindex $trigList $tlIndex]
|
||||
if {$rhSpeed < $trigLevel } {
|
||||
break
|
||||
}
|
||||
}
|
||||
set catch_status [ catch {
|
||||
# if rhReading >= trigger then start histmem and pop trigger and time
|
||||
if {[hval $rootPath/runexp] == -1} {
|
||||
return idle
|
||||
}
|
||||
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
|
||||
if {$listLen > 1} {
|
||||
# Pop trigger
|
||||
hset $rootPath/triggerList [lrange $trigList $tlIndex end]
|
||||
} else {
|
||||
hset $rootPath/triggerList "EMPTY"
|
||||
hset $rootPath/acqTime "EMPTY"
|
||||
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 { $acqTime != "EMPTY" && [llength $acqTime] > 1} {
|
||||
hset $rootPath/acqTime [lrange $acqTime 1 end]
|
||||
if {[expr abs($rhReading - $trigLevel)] > $tol } {
|
||||
sct utime timecheck
|
||||
return idle
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
|
||||
##
|
||||
@@ -55,9 +70,14 @@ 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] == 0} {
|
||||
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
|
||||
@@ -66,16 +86,19 @@ proc rheometer_savehmmdata {rootPath} {
|
||||
publish rheometer_savehmmdata user
|
||||
|
||||
|
||||
proc add_rheo {IP} {
|
||||
MakeProtek rhTorque $IP 4002
|
||||
MakeProtek rhSpeed $IP 4001 1.0 0.0 0.5 "rhCallBack /sics/rhSpeed"
|
||||
hfactory /sics/rhSpeed/saveIndex plain user int
|
||||
hset /sics/rhSpeed/saveIndex 0
|
||||
hfactory /sics/rhSpeed/triggerList plain user text
|
||||
hset /sics/rhSpeed/triggerList "EMPTY"
|
||||
hfactory /sics/rhSpeed/acqTime plain user text
|
||||
hset /sics/rhSpeed/acqTime "EMPTY"
|
||||
hfactory /sics/rhSpeed/runexp plain user float
|
||||
hset /sics/rhSpeed/runexp 0
|
||||
scriptcallback connect hmm COUNTEND "rheometer_savehmmdata /sics/rhSpeed"
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user