Pull over sct_antonparr_MCR500.tcl from RELEASE-3_1

This commit is contained in:
Douglas Clowes
2015-03-05 13:56:44 +11:00
parent f269a17ef3
commit 6f8e7b5429

View File

@ -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"
}