Modified some more old drivers to use config_dict as in gen_sct.py

TODO
environment/sct_keithley_2700.tcl
environment/sct_protek_common.tcl
This commit is contained in:
Ferdi Franceschini
2014-07-01 20:12:42 +10:00
parent d9255be951
commit 5ee2634d30
7 changed files with 562 additions and 113 deletions

View File

@@ -1341,14 +1341,14 @@ namespace export mk_sct_bruker_BEC1
##
# @brief add_bruker_BEC1() adds a scriptcontext object for a Bruker BEC1 power supply (1T magnet)
# @brief add_bruker_bec1() adds a scriptcontext object for a Bruker BEC1 power supply (1T magnet)
# and makes it available to SICServer
# @param name short name for the temperature controller scriptcontext object (typ. ma1 or ma2)
# @param IP IP address of the device (e.g. IP of moxabox that hooks up to the BEC1)
# @param port port number on the moxabox (typ. 4001, 4002, 4003, or 4004)
# @param tol magnetic field strength tolerance in Tesla (default 0.1T)
# @return nothing (well, the sct object)
proc add_bruker_BEC1 {name IP port {_tol 0.1} {CID 1} {CTYPE B} } {
proc add_bruker_bec1 {name IP port {_tol 0.1} {CID 1} {CTYPE B} } {
# Don't create a magnet controller for the script validator, this may cause the
# the BEC1 to lock up.
# NOTE: This is placed outside the catch block because "return" raises an exception
@@ -1363,27 +1363,91 @@ proc add_bruker_BEC1 {name IP port {_tol 0.1} {CID 1} {CTYPE B} } {
mk_sct_bruker_BEC1 sct_bruker_BEC1_$name environment $name $_tol $CID $CTYPE
makesctemon $name /sics/$name/emon/mon_mode /sics/$name/emon/is_in_tolerance /sics/$name/emon/errhandler
} message ]
handle_exception $catch_status $message "In subroutine add_bruker_BEC1()."
handle_exception $catch_status $message "In subroutine add_bruker_bec1()."
}
if {[ catch {
if { [ info exists ::config_dict ] } {
dict for {secname secinfo} $::config_dict {
if { [dict exists $secinfo "driver"] && ([dict get $secinfo "driver"] == "bruker_bec1") } {
if { [ dict get $::secinfo enabled ] } {
set name [dict get $::secinfo name]
set IP [dict get $::secinfo ip]
set PORT [dict get $::secinfo port]
set tol [dict get $::secinfo tol]
set cid [dict get $::secinfo id]
set ctype [dict get $::secinfo type]
add_bruker_BEC1 $name $IP $PORT $tol $cid $ctype
namespace eval ::scobj::bruker_bec1 {
set debug_threshold 5
}
proc ::scobj::bruker_bec1::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::bruker_bec1::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::bruker_bec1::${debug_string}"
}
} catch_message ]
}
clientput "file evaluation of sct_bruker_bec1.tcl"
::scobj::bruker_bec1::sics_log 9 "file evaluation of sct_bruker_bec1.tcl"
proc ::scobj::bruker_bec1::read_config {} {
set catch_status [ catch {
set ns "::scobj::bruker_bec1"
dict for {k v} $::config_dict {
if { [dict exists $v "implementation"] } {
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
continue
}
set name [dict get $v name]
set enabled [string tolower [dict get $v "enabled"]]
set implementation [dict get $v "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"] "bruker_bec1"] } {
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
set asyncqueue ${name}_queue
set IP [dict get $v ip]
set PORT [dict get $v port]
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {tol id type} {
if {[dict exists $v $arg]} {
lappend arg_list "[dict get $v $arg]"
} else {
${ns}::sics_log 9 "Missing configuration value $arg"
error "Missing configuration value $arg"
}
}
add_bruker_bec1 ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
}
} message ]} {
clientput "ERROR: $message"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::bruker_bec1::read_config
} else {
::scobj::bruker_bec1::sics_log 5 "No config dict"
}
namespace import ::scobj::bruker_BEC1::*