Added sct wrapper to load legacy sct_oxford_labview.tcl driver.

This commit is contained in:
Ferdi Franceschini
2014-08-08 09:19:11 +10:00
parent bd4dfdee79
commit 944902c9d4
11 changed files with 209 additions and 118 deletions

View File

@ -0,0 +1,16 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver oxford12tlv = {
protocol = std
class = environment
simulation_group = environment_simulation
add_args = 'id datype interval'
make_args = 'id datype interval'
code mkDriver = {%%
::scobj::magnetic::mkMagnetic [subst {
NAME $name
SCTCONTROLLER $sct_controller
TUNING 1
INTERVAL $interval
}]
%%}
}

View File

@ -0,0 +1,167 @@
# Generated driver for oxford12tlv
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::oxford12tlv {
set debug_threshold 5
}
proc ::scobj::oxford12tlv::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/oxford12tlv_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::oxford12tlv::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::oxford12tlv::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::oxford12tlv::${debug_string}"
}
} catch_message ]
}
proc ::scobj::oxford12tlv::mkDriver { sct_controller name id datype interval } {
::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::mkDriver ${sct_controller} ${name} ${id} ${datype} ${interval}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass environment
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} data true
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code starts
::scobj::magnetic::mkMagnetic [subst {
NAME $name
SCTCONTROLLER $sct_controller
TUNING 1
INTERVAL $interval
}]
# mkDriver hook code ends
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::oxford12tlv {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_oxford12tlv {name IP port id datype interval} {
set catch_status [ catch {
::scobj::oxford12tlv::sics_log 9 "add_oxford12tlv ${name} ${IP} ${port} ${id} ${datype} ${interval}"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
} else {
::scobj::oxford12tlv::sics_log 9 "[environment_simulation] => No sctcontroller for oxford12tlv"
}
::scobj::oxford12tlv::sics_log 1 "::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${id} ${datype} ${interval}"
::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${id} ${datype} ${interval}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
clientput "file evaluation of sct_oxford12tlv.tcl"
::scobj::oxford12tlv::sics_log 9 "file evaluation of sct_oxford12tlv.tcl"
proc ::scobj::oxford12tlv::read_config {} {
set catch_status [ catch {
set ns "::scobj::oxford12tlv"
dict for {k u} $::config_dict {
if { [dict exists $u "implementation"] } {
if { !([dict exists $u "name"] && [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 name [dict get $u name]
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"] "oxford12tlv"] } {
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"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
}
} 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]
set missing_list [list]
foreach arg {id datype interval} {
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 "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
add_oxford12tlv ${name} ${IP} ${PORT} {*}$arg_list
} else {
add_oxford12tlv ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::oxford12tlv::read_config
} else {
::scobj::oxford12tlv::sics_log 5 "No config dict"
}

View File

@ -239,7 +239,6 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
set pa($KEY) $v set pa($KEY) $v
} }
MakeSICSObj $pa(NAME) SCT_OBJECT
sicslist setatt $pa(NAME) klass environment sicslist setatt $pa(NAME) klass environment
sicslist setatt $pa(NAME) long_name $pa(NAME) sicslist setatt $pa(NAME) long_name $pa(NAME)
@ -342,7 +341,7 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
# hset /sics/$fPath/end_temperature_s3 [hval /sics/$fPath/Temp_s3] # hset /sics/$fPath/end_temperature_s3 [hval /sics/$fPath/Temp_s3]
# } # }
makesctcontroller sct_magnetic std $pa(IP):$pa(PORT) set ::scobj::magnetic::sct_name $pa(SCTCONTROLLER)
hsetprop $hPath/field read ::scobj::magnetic::rqFieldFunc hsetprop $hPath/field read ::scobj::magnetic::rqFieldFunc
hsetprop $hPath/field rdFieldState ::scobj::magnetic::rdFieldStateFunc $hPath hsetprop $hPath/field rdFieldState ::scobj::magnetic::rdFieldStateFunc $hPath
@ -357,10 +356,10 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
hsetprop $hPath/DilutTempReading rdTempState ::scobj::magnetic::rdTempStateFunc $hPath "Dilut" hsetprop $hPath/DilutTempReading rdTempState ::scobj::magnetic::rdTempStateFunc $hPath "Dilut"
if {[SplitReply [environment_simulation]]=="false"} { if {[SplitReply [environment_simulation]]=="false"} {
sct_magnetic poll $hPath/field $pa(INTERVAL) $pa(SCTCONTROLLER) poll $hPath/field $pa(INTERVAL)
sct_magnetic poll $hPath/Temp $pa(INTERVAL) $pa(SCTCONTROLLER) poll $hPath/Temp $pa(INTERVAL)
sct_magnetic poll $hPath/HelioxTempReading $pa(INTERVAL) $pa(SCTCONTROLLER) poll $hPath/HelioxTempReading $pa(INTERVAL)
sct_magnetic poll $hPath/DilutTempReading $pa(INTERVAL) $pa(SCTCONTROLLER) poll $hPath/DilutTempReading $pa(INTERVAL)
} }
hsetprop $hPath tuning $pa(TUNING) hsetprop $hPath tuning $pa(TUNING)
@ -381,11 +380,11 @@ proc ::scobj::magnetic::mkMagnetic {argList} {
hsetprop $hPath/set_magneticField checkReply ::scobj::magnetic::checkReplyFunc $hPath hsetprop $hPath/set_magneticField checkReply ::scobj::magnetic::checkReplyFunc $hPath
if {[SplitReply [environment_simulation]]=="false"} { if {[SplitReply [environment_simulation]]=="false"} {
sct_magnetic write $hPath/set_rate $pa(SCTCONTROLLER) write $hPath/set_rate
sct_magnetic write $hPath/set_magneticField $pa(SCTCONTROLLER) write $hPath/set_magneticField
sct_magnetic write $hPath/set_DiluxTemp $pa(SCTCONTROLLER) write $hPath/set_DiluxTemp
sct_magnetic write $hPath/set_HelioxTemp $pa(SCTCONTROLLER) write $hPath/set_HelioxTemp
sct_magnetic write $hPath/set_HeaterSwitch $pa(SCTCONTROLLER) write $hPath/set_HeaterSwitch
} }
} }
} }
@ -406,10 +405,10 @@ proc OxfordSetField {{setPoint ""} {mode ""} args} {
if {$mode == ""} { if {$mode == ""} {
set comm "setF $setPoint\r\n" set comm "setF $setPoint\r\n"
sct_magnetic send $comm $::scobj::magnetic::sct_name send $comm
} elseif {$mode == "P"} { } elseif {$mode == "P"} {
set comm "setF $setPoint Pers\r\n" set comm "setF $setPoint Pers\r\n"
sct_magnetic send $comm $::scobj::magnetic::sct_name send $comm
} else { } else {
broadcast "Wrong parameters being provided, check!" broadcast "Wrong parameters being provided, check!"
return return
@ -436,7 +435,7 @@ proc OxfordSetRate {{setRate ""} args} {
hset /sample/$NAME/fieldSetRate $setRate hset /sample/$NAME/fieldSetRate $setRate
set comm "setR $setRate\r\n" set comm "setR $setRate\r\n"
sct_magnetic send $comm $::scobj::magnetic::sct_name send $comm
} }
} }
@ -449,7 +448,7 @@ proc OxfordSetHTemp {{temp ""} args} {
#hset /sample/$NAME/HelioxTempSetPoint $temp #hset /sample/$NAME/HelioxTempSetPoint $temp
set comm "setHelioxTemp $temp\r\n" set comm "setHelioxTemp $temp\r\n"
sct_magnetic send $comm $::scobj::magnetic::sct_name send $comm
#set num 0 #set num 0
#while { $num <= 40 && [expr abs([hval /sample/$NAME/HelioxTempSetPoint] - [hval /sample/$NAME/HelioxTempReading]) ] >= 0.001 } { #while { $num <= 40 && [expr abs([hval /sample/$NAME/HelioxTempSetPoint] - [hval /sample/$NAME/HelioxTempReading]) ] >= 0.001 } {
@ -470,7 +469,7 @@ proc OxfordSetDTemp {{temp ""} args} {
hset /sample/$NAME/DilutTempSetPoint $temp hset /sample/$NAME/DilutTempSetPoint $temp
set comm "setDilutTemp $temp\r\n" set comm "setDilutTemp $temp\r\n"
sct_magnetic send $comm $::scobj::magnetic::sct_name send $comm
} }
} }
@ -485,7 +484,7 @@ proc OxfordSetHS {mode} {
} }
set comm "setHS [string toupper $mode]\r\n" set comm "setHS [string toupper $mode]\r\n"
sct_magnetic send $comm $::scobj::magnetic::sct_name send $comm
broadcast "Wait 60 seconds for the operation to complete before reset the mode" broadcast "Wait 60 seconds for the operation to complete before reset the mode"
} }
@ -494,101 +493,3 @@ publish OxfordSetRate user
publish OxfordSetHTemp user publish OxfordSetHTemp user
publish OxfordSetDTemp user publish OxfordSetDTemp user
publish OxfordSetHS user publish OxfordSetHS user
proc add_oxford_labview { name IP PORT {interval 5} } {
::scobj::magnetic::mkMagnetic [subst {
name $name
IP $IP
PORT $PORT
tuning 1
interval $interval
}]
}
namespace eval ::scobj::oxford_labview {
set debug_threshold 5
}
proc ::scobj::oxford_labview::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::oxford_labview::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::oxford_labview::${debug_string}"
}
} catch_message ]
}
clientput "file evaluation of sct_oxford_labview.tcl"
::scobj::oxford_labview::sics_log 9 "file evaluation of sct_oxford_labview.tcl"
proc ::scobj::oxford_labview::read_config {} {
set catch_status [ catch {
set ns "::scobj::oxford_labview"
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"] "oxford_labview"] } {
set driver [dict get $v driver]
${ns}::sics_log 9 "Found ${name}: $driver"
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
${ns}::sics_log 9 "${name}:${driver}: MakeAsyncProtocol ${asyncprotocol}"
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]
${ns}::sics_log 9 "${name}:${driver}: MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}"
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
# foreach arg {interval} {
# 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"
# }
# }
${ns}::sics_log 9 "add_oxford_labview ${name} aqadapter ${asyncqueue} {*}$arg_list"
add_oxford_labview ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::oxford_labview::read_config
} else {
::scobj::oxford_labview::sics_log 5 "No config dict"
}

View File

@ -103,6 +103,7 @@ implementation = normal_sample_stage
name = sample_stage name = sample_stage
optype = motion_axis optype = motion_axis
[12tmagnet_oxford] [12tmagnet_oxford]
asyncqueue = sct
desc = "12 Tesla Oxford Magnet" desc = "12 Tesla Oxford Magnet"
driver = "oxford_labview" driver = "oxford_labview"
imptype = magnetic_field imptype = magnetic_field

View File

@ -53,6 +53,7 @@ fileeval $cfPath(environment)/temperature/sct_qlink.tcl
fileeval $cfPath(environment)/temperature/west400.tcl fileeval $cfPath(environment)/temperature/west400.tcl
fileeval $cfPath(environment)/temperature/sct_west4100.tcl fileeval $cfPath(environment)/temperature/sct_west4100.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl
fileeval $cfPath(environment)/he3/sct_he3.tcl fileeval $cfPath(environment)/he3/sct_he3.tcl
fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl
fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl

View File

@ -30,6 +30,7 @@ fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl
fileeval $cfPath(environment)/sct_keithley_2700.tcl fileeval $cfPath(environment)/sct_keithley_2700.tcl
fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl
fileeval $cfPath(environment)/sct_keithley_2700.tcl fileeval $cfPath(environment)/sct_keithley_2700.tcl
fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl
fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl

View File

@ -100,6 +100,7 @@ implementation = normal_sample_stage
name = sample_stage name = sample_stage
optype = motion_axis optype = motion_axis
[12tmagnet_oxford] [12tmagnet_oxford]
asyncqueue = sct
desc = "12 Tesla Oxford Magnet" desc = "12 Tesla Oxford Magnet"
driver = "oxford_labview" driver = "oxford_labview"
imptype = magnetic_field imptype = magnetic_field

View File

@ -56,6 +56,7 @@ fileeval $cfPath(environment)/temperature/sct_qlink.tcl
fileeval $cfPath(environment)/temperature/west400.tcl fileeval $cfPath(environment)/temperature/west400.tcl
fileeval $cfPath(environment)/temperature/sct_west4100.tcl fileeval $cfPath(environment)/temperature/sct_west4100.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl
fileeval $cfPath(environment)/he3/sct_he3.tcl fileeval $cfPath(environment)/he3/sct_he3.tcl
fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl
fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl

View File

@ -89,9 +89,11 @@ implementation = normal_sample_stage
name = sample_stage name = sample_stage
optype = motion_axis optype = motion_axis
[12tmagnet_oxford] [12tmagnet_oxford]
asyncqueue = sct
desc = "12 Tesla Oxford Magnet" desc = "12 Tesla Oxford Magnet"
driver = "oxford_labview" driver = "oxford12tlv"
imptype = magnetic_field imptype = magnetic_field
interval = 5
ip = 10.157.205.3 ip = 10.157.205.3
port = 55001 port = 55001

View File

@ -29,9 +29,8 @@ fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl
fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl
fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl
fileeval $cfPath(environment)/sct_protek_common.tcl fileeval $cfPath(environment)/sct_protek_common.tcl
fileeval $cfPath(environment)/temperature/sct_oxford_itc.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford_ips.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl
fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl
fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl
fileeval $cfPath(nexus)/nxscripts.tcl fileeval $cfPath(nexus)/nxscripts.tcl
fileeval $cfPath(scan)/scan.tcl fileeval $cfPath(scan)/scan.tcl

View File

@ -156,6 +156,7 @@ desc = "Load the ten position sample changer configuration"
imptype = motion_axis imptype = motion_axis
[12tmagnet_oxford] [12tmagnet_oxford]
asyncqueue = sct
desc = "12 Tesla Oxford Magnet" desc = "12 Tesla Oxford Magnet"
driver = "oxford_labview" driver = "oxford_labview"
imptype = magnetic_field imptype = magnetic_field