Rename and move the Rheometer drivers for Kookaburra
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
# Generated driver for antonparr_MCR500
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::antonparr_MCR500 {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::antonparr_MCR500::debug_log {tc_root debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
set fd [open "../log/antonparr_MCR500_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::antonparr_MCR500::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::antonparr_MCR500::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::antonparr_MCR500::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::antonparr_MCR500::mkDriver { speed_name torque_name tol settle } {
|
||||
::scobj::antonparr_MCR500::sics_log 9 "::scobj::antonparr_MCR500::mkDriver ${speed_name} ${torque_name} ${tol} ${settle}"
|
||||
set ns "[namespace current]"
|
||||
set catch_status [ catch {
|
||||
|
||||
# mkDriver hook code starts
|
||||
if [::utility::obj_exists $speed_name] {
|
||||
add_rheo $speed_name $tol $settle
|
||||
}
|
||||
if [::utility::obj_exists $torque_name] {
|
||||
add_rheo $torque_name $tol $settle
|
||||
}
|
||||
# mkDriver hook code ends
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::antonparr_MCR500 {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
}
|
||||
|
||||
proc add_antonparr_MCR500 {speed_name torque_name tol settle} {
|
||||
set catch_status [ catch {
|
||||
::scobj::antonparr_MCR500::sics_log 9 "add_antonparr_MCR500 ${speed_name} ${torque_name} ${tol} ${settle}"
|
||||
::scobj::antonparr_MCR500::sics_log 1 "::scobj::antonparr_MCR500::mkDriver ${speed_name} ${torque_name} ${tol} ${settle}"
|
||||
::scobj::antonparr_MCR500::mkDriver ${speed_name} ${torque_name} ${tol} ${settle}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_antonparr_MCR500.tcl"
|
||||
::scobj::antonparr_MCR500::sics_log 9 "file evaluation of sct_antonparr_MCR500.tcl"
|
||||
|
||||
proc ::scobj::antonparr_MCR500::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::antonparr_MCR500"
|
||||
dict for {k u} $::config_dict {
|
||||
if { [dict exists $u "implementation"] } {
|
||||
if { ![dict exists $u "enabled"] } {
|
||||
continue
|
||||
}
|
||||
set enabled [string tolower [dict get $u "enabled"]]
|
||||
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
|
||||
continue
|
||||
}
|
||||
set implementation [dict get $u "implementation"]
|
||||
if { !([dict exists $::config_dict $implementation]) } {
|
||||
continue
|
||||
}
|
||||
set v [dict get $::config_dict $implementation]
|
||||
if { !([dict exists $v "driver"]) } {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "antonparr_MCR500"] } {
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
foreach arg {speed_name torque_name tol settle} {
|
||||
if {[dict exists $u $arg]} {
|
||||
lappend arg_list "[dict get $u $arg]"
|
||||
} elseif {[dict exists $v $arg]} {
|
||||
lappend arg_list "[dict get $v $arg]"
|
||||
} else {
|
||||
${ns}::sics_log 9 "Missing configuration value $arg"
|
||||
lappend missing_list $arg
|
||||
}
|
||||
}
|
||||
if { [llength $missing_list] > 0 } {
|
||||
error "Rheometer is missing configuration values $missing_list"
|
||||
}
|
||||
add_antonparr_MCR500 {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::antonparr_MCR500::read_config
|
||||
} else {
|
||||
::scobj::antonparr_MCR500::sics_log 5 "No config dict"
|
||||
}
|
||||
104
site_ansto/instrument/config/environment/sct_rheometer.tcl
Normal file
104
site_ansto/instrument/config/environment/sct_rheometer.tcl
Normal file
@@ -0,0 +1,104 @@
|
||||
## 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 tol settle} {
|
||||
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
|
||||
hsetprop /sics/$rhControl callBack "rhCallBack /sics/$rhControl"
|
||||
}
|
||||
Reference in New Issue
Block a user