Update the Stanford SR630 SCT file for ten channels
This commit is contained in:
@ -0,0 +1,473 @@
|
||||
# Generated driver for stanford_sr630
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::stanford_sr630 {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::stanford_sr630::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/stanford_sr630_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::stanford_sr630::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::stanford_sr630::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::stanford_sr630::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
# check function for hset change
|
||||
proc ::scobj::stanford_sr630::checkrange {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
|
||||
set setpoint [sct target]
|
||||
if { [hpropexists [sct] lowerlimit] } {
|
||||
set lolimit [sct lowerlimit]
|
||||
} else {
|
||||
# lowerlimit not set, use target
|
||||
set lolimit [sct target]
|
||||
}
|
||||
if { [hpropexists [sct] upperlimit] } {
|
||||
set hilimit [sct upperlimit]
|
||||
} else {
|
||||
# upperlimit not set, use target
|
||||
set hilimit [sct target]
|
||||
}
|
||||
# checkrange hook code goes here
|
||||
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
|
||||
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
|
||||
}
|
||||
return OK
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "fetch_id tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# fetch_id hook code starts
|
||||
if {[hval [sct]] == "UNKNOWN"} {
|
||||
set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]"
|
||||
} else {
|
||||
set cmd "*IDN?;DATE?;TIME?"
|
||||
}
|
||||
# fetch_id hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "fetch_id sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to request the read of a parameter on a device
|
||||
proc ::scobj::stanford_sr630::getSensor {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "getSensor tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getSensor hook code starts
|
||||
set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}"
|
||||
# getSensor hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "getSensor sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to check the write parameter on a device
|
||||
proc ::scobj::stanford_sr630::noResponse {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
|
||||
# noResponse hook code goes here
|
||||
return "idle"
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::stanford_sr630::readSensor {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "readSensor tc_root=${tc_root} sct=[sct] result=[sct result]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set data [sct result]
|
||||
set nextState "idle"
|
||||
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "${data}"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# readSensor hook code goes here
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::stanford_sr630::read_id {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "read_id tc_root=${tc_root} sct=[sct] result=[sct result]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set data [sct result]
|
||||
set nextState "idle"
|
||||
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "${data}"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# read_id hook code goes here
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::stanford_sr630::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set cmd "${cmd_str}${par}"
|
||||
# setValue hook code goes here
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "setValue sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port } {
|
||||
::scobj::stanford_sr630::sics_log 9 "::scobj::stanford_sr630::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"
|
||||
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}
|
||||
|
||||
hfactory ${scobj_hpath}/id plain user text
|
||||
hsetprop ${scobj_hpath}/id read ${ns}::fetch_id ${scobj_hpath} read_id {@}
|
||||
hsetprop ${scobj_hpath}/id read_id ${ns}::read_id ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/id control true
|
||||
hsetprop ${scobj_hpath}/id data true
|
||||
hsetprop ${scobj_hpath}/id mutable true
|
||||
hsetprop ${scobj_hpath}/id nxsave true
|
||||
hsetprop ${scobj_hpath}/id oldval UNKNOWN
|
||||
hset ${scobj_hpath}/id UNKNOWN
|
||||
hsetprop ${scobj_hpath}/id klass "parameter"
|
||||
hsetprop ${scobj_hpath}/id sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/id type "part"
|
||||
hsetprop ${scobj_hpath}/id nxalias "${name}_id"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_01 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_01 read ${ns}::getSensor ${scobj_hpath} readSensor {1}
|
||||
hsetprop ${scobj_hpath}/sensor_01 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_01 control true
|
||||
hsetprop ${scobj_hpath}/sensor_01 data true
|
||||
hsetprop ${scobj_hpath}/sensor_01 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_01 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_01 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_01 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_01 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_01 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_01 nxalias "${name}_sensor_01"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_02 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_02 read ${ns}::getSensor ${scobj_hpath} readSensor {2}
|
||||
hsetprop ${scobj_hpath}/sensor_02 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_02 control true
|
||||
hsetprop ${scobj_hpath}/sensor_02 data true
|
||||
hsetprop ${scobj_hpath}/sensor_02 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_02 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_02 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_02 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_02 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_02 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_02 nxalias "${name}_sensor_02"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_03 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_03 read ${ns}::getSensor ${scobj_hpath} readSensor {3}
|
||||
hsetprop ${scobj_hpath}/sensor_03 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_03 control true
|
||||
hsetprop ${scobj_hpath}/sensor_03 data true
|
||||
hsetprop ${scobj_hpath}/sensor_03 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_03 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_03 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_03 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_03 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_03 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_03 nxalias "${name}_sensor_03"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_04 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_04 read ${ns}::getSensor ${scobj_hpath} readSensor {4}
|
||||
hsetprop ${scobj_hpath}/sensor_04 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_04 control true
|
||||
hsetprop ${scobj_hpath}/sensor_04 data true
|
||||
hsetprop ${scobj_hpath}/sensor_04 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_04 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_04 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_04 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_04 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_04 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_04 nxalias "${name}_sensor_04"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_05 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_05 read ${ns}::getSensor ${scobj_hpath} readSensor {5}
|
||||
hsetprop ${scobj_hpath}/sensor_05 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_05 control true
|
||||
hsetprop ${scobj_hpath}/sensor_05 data true
|
||||
hsetprop ${scobj_hpath}/sensor_05 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_05 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_05 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_05 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_05 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_05 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_05 nxalias "${name}_sensor_05"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_06 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_06 read ${ns}::getSensor ${scobj_hpath} readSensor {6}
|
||||
hsetprop ${scobj_hpath}/sensor_06 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_06 control true
|
||||
hsetprop ${scobj_hpath}/sensor_06 data true
|
||||
hsetprop ${scobj_hpath}/sensor_06 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_06 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_06 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_06 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_06 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_06 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_06 nxalias "${name}_sensor_06"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_07 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_07 read ${ns}::getSensor ${scobj_hpath} readSensor {7}
|
||||
hsetprop ${scobj_hpath}/sensor_07 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_07 control true
|
||||
hsetprop ${scobj_hpath}/sensor_07 data true
|
||||
hsetprop ${scobj_hpath}/sensor_07 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_07 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_07 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_07 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_07 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_07 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_07 nxalias "${name}_sensor_07"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_08 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_08 read ${ns}::getSensor ${scobj_hpath} readSensor {8}
|
||||
hsetprop ${scobj_hpath}/sensor_08 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_08 control true
|
||||
hsetprop ${scobj_hpath}/sensor_08 data true
|
||||
hsetprop ${scobj_hpath}/sensor_08 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_08 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_08 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_08 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_08 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_08 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_09 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_09 read ${ns}::getSensor ${scobj_hpath} readSensor {9}
|
||||
hsetprop ${scobj_hpath}/sensor_09 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_09 control true
|
||||
hsetprop ${scobj_hpath}/sensor_09 data true
|
||||
hsetprop ${scobj_hpath}/sensor_09 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_09 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_09 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_09 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_09 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_09 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_09 nxalias "${name}_sensor_09"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor_10 plain user float
|
||||
hsetprop ${scobj_hpath}/sensor_10 read ${ns}::getSensor ${scobj_hpath} readSensor {10}
|
||||
hsetprop ${scobj_hpath}/sensor_10 readSensor ${ns}::readSensor ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor_10 control true
|
||||
hsetprop ${scobj_hpath}/sensor_10 data true
|
||||
hsetprop ${scobj_hpath}/sensor_10 mutable true
|
||||
hsetprop ${scobj_hpath}/sensor_10 nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor_10 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor_10 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor_10 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor_10 type "part"
|
||||
hsetprop ${scobj_hpath}/sensor_10 nxalias "${name}_sensor_10"
|
||||
|
||||
hsetprop ${scobj_hpath} data "true"
|
||||
hsetprop ${scobj_hpath} klass "@none"
|
||||
hsetprop ${scobj_hpath} type "part"
|
||||
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/id 10
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_01 1
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_02 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_03 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_04 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_05 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_06 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_07 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_08 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_09 60
|
||||
${sct_controller} poll ${scobj_hpath}/sensor_10 60
|
||||
} else {
|
||||
::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No poll/write for stanford_sr630"
|
||||
}
|
||||
hsetprop ${scobj_hpath} klass environment
|
||||
hsetprop ${scobj_hpath} data true
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
# mkDriver hook code goes here
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
namespace eval ::scobj::stanford_sr630 {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
}
|
||||
|
||||
proc add_stanford_sr630 {name ip_address tcp_port} {
|
||||
set catch_status [ catch {
|
||||
::scobj::stanford_sr630::sics_log 9 "add_stanford_sr630 ${name} ${ip_address} ${tcp_port}"
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
||||
::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
||||
} else {
|
||||
::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}"
|
||||
makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
|
||||
}
|
||||
} else {
|
||||
::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for stanford_sr630"
|
||||
}
|
||||
::scobj::stanford_sr630::sics_log 1 "::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"
|
||||
::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_stanford_sr630.tcl"
|
||||
::scobj::stanford_sr630::sics_log 9 "file evaluation of sct_stanford_sr630.tcl"
|
||||
|
||||
proc ::scobj::stanford_sr630::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::stanford_sr630"
|
||||
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"] "stanford_sr630"] } {
|
||||
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_address [dict get $v ip]
|
||||
set tcp_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_address [dict get $v ip]
|
||||
set tcp_port [dict get $v port]
|
||||
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port}
|
||||
if { [dict exists $v "timeout"] } {
|
||||
${asyncqueue} timeout "[dict get $v "timeout"]"
|
||||
}
|
||||
}
|
||||
if { [string equal -nocase ${asyncqueue} "sct"] } {
|
||||
add_stanford_sr630 ${name} ${ip_address} ${tcp_port}
|
||||
} else {
|
||||
add_stanford_sr630 ${name} "aqadapter" ${asyncqueue}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::stanford_sr630::read_config
|
||||
} else {
|
||||
::scobj::stanford_sr630::sics_log 5 "No config dict"
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
# Stanford Research Systems SR630 Thermocouple Monitor
|
||||
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent
|
||||
# vim: ts=8 sts=2 sw=2 expandtab nocindent autoindent smartindent
|
||||
driver stanford_sr630 = {
|
||||
vendor=StanfordResearchSystems; device=SR630;
|
||||
protocol=std;
|
||||
class=environment;
|
||||
vendor = StanfordResearchSystems; device=SR630;
|
||||
protocol = std;
|
||||
class = environment;
|
||||
simulation_group = environment_simulation;
|
||||
|
||||
group = {
|
||||
@ -11,22 +11,33 @@ driver stanford_sr630 = {
|
||||
var id = {
|
||||
readable = 10;
|
||||
type = text;
|
||||
fetch_function = fetch_id;
|
||||
read_function = read_id;
|
||||
read_command = "";
|
||||
read_command = "@";
|
||||
value = "UNKNOWN";
|
||||
}
|
||||
var senor_01 = {
|
||||
readable = 10;
|
||||
type = float;
|
||||
read_function = readSensor;
|
||||
read_command = "1";
|
||||
}
|
||||
var senor_02 = {
|
||||
readable = 10;
|
||||
type = float;
|
||||
fetch_function = getSensor;
|
||||
read_function = readSensor;
|
||||
read_command = "2";
|
||||
type = float;
|
||||
fetch_function = getSensor;
|
||||
read_function = readSensor;
|
||||
var sensor_01 = { readable = 1; read_command = "1"; }
|
||||
var sensor_02 = { readable = 60; read_command = "2"; }
|
||||
var sensor_03 = { readable = 60; read_command = "3"; }
|
||||
var sensor_04 = { readable = 60; read_command = "4"; }
|
||||
var sensor_05 = { readable = 60; read_command = "5"; }
|
||||
var sensor_06 = { readable = 60; read_command = "6"; }
|
||||
var sensor_07 = { readable = 60; read_command = "7"; }
|
||||
var sensor_08 = { readable = 60; read_command = "8"; }
|
||||
var sensor_09 = { readable = 60; read_command = "9"; }
|
||||
var sensor_10 = { readable = 60; read_command = "10"; }
|
||||
}
|
||||
code fetch_id = {
|
||||
@TCL
|
||||
if {[hval [sct]] == "UNKNOWN"} {
|
||||
set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]"
|
||||
} else {
|
||||
set cmd "*IDN?;DATE?;TIME?"
|
||||
}
|
||||
@END
|
||||
}
|
||||
code read_id = {
|
||||
@TCL
|
||||
@ -34,6 +45,7 @@ driver stanford_sr630 = {
|
||||
}
|
||||
code getSensor = {
|
||||
@TCL
|
||||
set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}"
|
||||
@END
|
||||
}
|
||||
code readSensor = {
|
||||
|
Reference in New Issue
Block a user