SR630 reduce to 8 channels and 600 second polls, change driver name

This commit is contained in:
Douglas Clowes
2014-09-04 09:26:03 +10:00
parent 8af9116667
commit 24c8792467
2 changed files with 63 additions and 101 deletions

View File

@@ -1,16 +1,16 @@
# Generated driver for stanford_sr630 # Generated driver for srs_sr630
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent # vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
# #
namespace eval ::scobj::stanford_sr630 { namespace eval ::scobj::srs_sr630 {
set debug_threshold 5 set debug_threshold 5
} }
proc ::scobj::stanford_sr630::debug_log {tc_root debug_level debug_string} { proc ::scobj::srs_sr630::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch { set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold] set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} { if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/stanford_sr630_[basename ${tc_root}].log" "a"] set fd [open "../log/srs_sr630_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}" set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}" puts ${fd} "${line}"
close ${fd} close ${fd}
@@ -18,17 +18,17 @@ proc ::scobj::stanford_sr630::debug_log {tc_root debug_level debug_string} {
} catch_message ] } catch_message ]
} }
proc ::scobj::stanford_sr630::sics_log {debug_level debug_string} { proc ::scobj::srs_sr630::sics_log {debug_level debug_string} {
set catch_status [ catch { set catch_status [ catch {
set debug_threshold ${::scobj::stanford_sr630::debug_threshold} set debug_threshold ${::scobj::srs_sr630::debug_threshold}
if {${debug_level} >= ${debug_threshold}} { if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::stanford_sr630::${debug_string}" sicslog "::scobj::srs_sr630::${debug_string}"
} }
} catch_message ] } catch_message ]
} }
# check function for hset change # check function for hset change
proc ::scobj::stanford_sr630::checkrange {tc_root} { proc ::scobj::srs_sr630::checkrange {tc_root} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]" debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target] set setpoint [sct target]
@@ -54,7 +54,7 @@ proc ::scobj::stanford_sr630::checkrange {tc_root} {
} }
# function to request the read of a parameter on a device # function to request the read of a parameter on a device
proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} { proc ::scobj::srs_sr630::fetch_id {tc_root nextState cmd_str} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "fetch_id tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" debug_log ${tc_root} 1 "fetch_id tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } { if { [hpropexists [sct] geterror] } {
@@ -65,7 +65,7 @@ proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} {
if {[hval [sct]] == "UNKNOWN"} { if {[hval [sct]] == "UNKNOWN"} {
set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]" set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]"
} else { } else {
set cmd "*IDN?;DATE?;TIME?" set cmd "*IDN?"
} }
# fetch_id hook code ends # fetch_id hook code ends
if { [hpropexists [sct] geterror] } { if { [hpropexists [sct] geterror] } {
@@ -82,7 +82,7 @@ proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} {
} }
# function to request the read of a parameter on a device # function to request the read of a parameter on a device
proc ::scobj::stanford_sr630::getSensor {tc_root nextState cmd_str} { proc ::scobj::srs_sr630::getSensor {tc_root nextState cmd_str} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "getSensor tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" debug_log ${tc_root} 1 "getSensor tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } { if { [hpropexists [sct] geterror] } {
@@ -106,7 +106,7 @@ proc ::scobj::stanford_sr630::getSensor {tc_root nextState cmd_str} {
} }
# function to check the write parameter on a device # function to check the write parameter on a device
proc ::scobj::stanford_sr630::noResponse {tc_root} { proc ::scobj::srs_sr630::noResponse {tc_root} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]" debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# noResponse hook code goes here # noResponse hook code goes here
@@ -116,7 +116,7 @@ proc ::scobj::stanford_sr630::noResponse {tc_root} {
} }
# function to parse the read of a parameter on a device # function to parse the read of a parameter on a device
proc ::scobj::stanford_sr630::readSensor {tc_root} { proc ::scobj::srs_sr630::readSensor {tc_root} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "readSensor tc_root=${tc_root} sct=[sct] result=[sct result]" debug_log ${tc_root} 1 "readSensor tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } { if { [hpropexists [sct] geterror] } {
@@ -142,7 +142,7 @@ proc ::scobj::stanford_sr630::readSensor {tc_root} {
} }
# function to parse the read of a parameter on a device # function to parse the read of a parameter on a device
proc ::scobj::stanford_sr630::read_id {tc_root} { proc ::scobj::srs_sr630::read_id {tc_root} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "read_id tc_root=${tc_root} sct=[sct] result=[sct result]" debug_log ${tc_root} 1 "read_id tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } { if { [hpropexists [sct] geterror] } {
@@ -168,7 +168,7 @@ proc ::scobj::stanford_sr630::read_id {tc_root} {
} }
# function to write a parameter value on a device # function to write a parameter value on a device
proc ::scobj::stanford_sr630::setValue {tc_root nextState cmd_str} { proc ::scobj::srs_sr630::setValue {tc_root nextState cmd_str} {
set catch_status [ catch { set catch_status [ catch {
debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } { if { [hpropexists [sct] geterror] } {
@@ -191,8 +191,8 @@ proc ::scobj::stanford_sr630::setValue {tc_root nextState cmd_str} {
handle_exception ${catch_status} ${catch_message} handle_exception ${catch_status} ${catch_message}
} }
proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port } { proc ::scobj::srs_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}" ::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"
set ns "[namespace current]" set ns "[namespace current]"
set catch_status [ catch { set catch_status [ catch {
@@ -321,50 +321,22 @@ proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port
hsetprop ${scobj_hpath}/sensor_08 type "part" hsetprop ${scobj_hpath}/sensor_08 type "part"
hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08" 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} data "true"
hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} klass "@none"
hsetprop ${scobj_hpath} type "part" hsetprop ${scobj_hpath} type "part"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
${sct_controller} poll ${scobj_hpath}/id 10 ${sct_controller} poll ${scobj_hpath}/id 5
${sct_controller} poll ${scobj_hpath}/sensor_01 1 ${sct_controller} poll ${scobj_hpath}/sensor_01 60
${sct_controller} poll ${scobj_hpath}/sensor_02 60 ${sct_controller} poll ${scobj_hpath}/sensor_02 5
${sct_controller} poll ${scobj_hpath}/sensor_03 60 ${sct_controller} poll ${scobj_hpath}/sensor_03 5
${sct_controller} poll ${scobj_hpath}/sensor_04 60 ${sct_controller} poll ${scobj_hpath}/sensor_04 5
${sct_controller} poll ${scobj_hpath}/sensor_05 60 ${sct_controller} poll ${scobj_hpath}/sensor_05 5
${sct_controller} poll ${scobj_hpath}/sensor_06 60 ${sct_controller} poll ${scobj_hpath}/sensor_06 5
${sct_controller} poll ${scobj_hpath}/sensor_07 60 ${sct_controller} poll ${scobj_hpath}/sensor_07 5
${sct_controller} poll ${scobj_hpath}/sensor_08 60 ${sct_controller} poll ${scobj_hpath}/sensor_08 5
${sct_controller} poll ${scobj_hpath}/sensor_09 60
${sct_controller} poll ${scobj_hpath}/sensor_10 60
} else { } else {
::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No poll/write for stanford_sr630" ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No poll/write for srs_sr630"
} }
hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} data true
@@ -374,39 +346,39 @@ proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port
handle_exception ${catch_status} ${catch_message} handle_exception ${catch_status} ${catch_message}
} }
namespace eval ::scobj::stanford_sr630 { namespace eval ::scobj::srs_sr630 {
namespace export debug_threshold namespace export debug_threshold
namespace export debug_log namespace export debug_log
namespace export sics_log namespace export sics_log
namespace export mkDriver namespace export mkDriver
} }
proc add_stanford_sr630 {name ip_address tcp_port} { proc add_srs_sr630 {name ip_address tcp_port} {
set catch_status [ catch { set catch_status [ catch {
::scobj::stanford_sr630::sics_log 9 "add_stanford_sr630 ${name} ${ip_address} ${tcp_port}" ::scobj::srs_sr630::sics_log 9 "add_srs_sr630 ${name} ${ip_address} ${tcp_port}"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
if {[string equal -nocase "aqadapter" "${ip_address}"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} {
::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
makesctcontroller sct_${name} aqadapter ${tcp_port} makesctcontroller sct_${name} aqadapter ${tcp_port}
} else { } else {
::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}"
makesctcontroller sct_${name} std ${ip_address}:${tcp_port} makesctcontroller sct_${name} std ${ip_address}:${tcp_port}
} }
} else { } else {
::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for stanford_sr630" ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for srs_sr630"
} }
::scobj::stanford_sr630::sics_log 1 "::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" ::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"
::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}
} catch_message ] } catch_message ]
handle_exception ${catch_status} ${catch_message} handle_exception ${catch_status} ${catch_message}
} }
clientput "file evaluation of sct_stanford_sr630.tcl" clientput "file evaluation of sct_srs_sr630.tcl"
::scobj::stanford_sr630::sics_log 9 "file evaluation of sct_stanford_sr630.tcl" ::scobj::srs_sr630::sics_log 9 "file evaluation of sct_srs_sr630.tcl"
proc ::scobj::stanford_sr630::read_config {} { proc ::scobj::srs_sr630::read_config {} {
set catch_status [ catch { set catch_status [ catch {
set ns "::scobj::stanford_sr630" set ns "::scobj::srs_sr630"
dict for {k u} $::config_dict { dict for {k u} $::config_dict {
if { [dict exists $u "implementation"] } { if { [dict exists $u "implementation"] } {
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
@@ -425,7 +397,7 @@ proc ::scobj::stanford_sr630::read_config {} {
if { !([dict exists $v "driver"]) } { if { !([dict exists $v "driver"]) } {
continue continue
} }
if { [string equal -nocase [dict get $v "driver"] "stanford_sr630"] } { if { [string equal -nocase [dict get $v "driver"] "srs_sr630"] } {
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
set asyncqueue "null" set asyncqueue "null"
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
@@ -455,9 +427,9 @@ proc ::scobj::stanford_sr630::read_config {} {
} }
} }
if { [string equal -nocase ${asyncqueue} "sct"] } { if { [string equal -nocase ${asyncqueue} "sct"] } {
add_stanford_sr630 ${name} ${ip_address} ${tcp_port} add_srs_sr630 ${name} ${ip_address} ${tcp_port}
} else { } else {
add_stanford_sr630 ${name} "aqadapter" ${asyncqueue} add_srs_sr630 ${name} "aqadapter" ${asyncqueue}
} }
} }
} }
@@ -467,7 +439,7 @@ proc ::scobj::stanford_sr630::read_config {} {
} }
if { [info exists ::config_dict] } { if { [info exists ::config_dict] } {
::scobj::stanford_sr630::read_config ::scobj::srs_sr630::read_config
} else { } else {
::scobj::stanford_sr630::sics_log 5 "No config dict" ::scobj::srs_sr630::sics_log 5 "No config dict"
} }

View File

@@ -1,6 +1,6 @@
# Stanford Research Systems SR630 Thermocouple Monitor # Stanford Research Systems SR630 Thermocouple Monitor
# vim: ts=8 sts=2 sw=2 expandtab nocindent autoindent smartindent # vim: ts=8 sts=2 sw=2 expandtab nocindent autoindent smartindent
driver stanford_sr630 = { driver srs_sr630 = {
vendor = StanfordResearchSystems; device=SR630; vendor = StanfordResearchSystems; device=SR630;
protocol = std; protocol = std;
class = environment; class = environment;
@@ -9,7 +9,7 @@ driver stanford_sr630 = {
group = { group = {
priv = user; priv = user;
var id = { var id = {
readable = 10; readable = 600;
type = text; type = text;
fetch_function = fetch_id; fetch_function = fetch_id;
read_function = read_id; read_function = read_id;
@@ -19,37 +19,27 @@ driver stanford_sr630 = {
type = float; type = float;
fetch_function = getSensor; fetch_function = getSensor;
read_function = readSensor; read_function = readSensor;
var sensor_01 = { readable = 1; read_command = "1"; } var sensor_01 = { readable = 60; read_command = "1"; }
var sensor_02 = { readable = 60; read_command = "2"; } var sensor_02 = { readable = 600; read_command = "2"; }
var sensor_03 = { readable = 60; read_command = "3"; } var sensor_03 = { readable = 600; read_command = "3"; }
var sensor_04 = { readable = 60; read_command = "4"; } var sensor_04 = { readable = 600; read_command = "4"; }
var sensor_05 = { readable = 60; read_command = "5"; } var sensor_05 = { readable = 600; read_command = "5"; }
var sensor_06 = { readable = 60; read_command = "6"; } var sensor_06 = { readable = 600; read_command = "6"; }
var sensor_07 = { readable = 60; read_command = "7"; } var sensor_07 = { readable = 600; read_command = "7"; }
var sensor_08 = { readable = 60; read_command = "8"; } var sensor_08 = { readable = 600; read_command = "8"; }
var sensor_09 = { readable = 60; read_command = "9"; }
var sensor_10 = { readable = 60; read_command = "10"; }
} }
code fetch_id = { code fetch_id = {%%
@TCL
if {[hval [sct]] == "UNKNOWN"} { if {[hval [sct]] == "UNKNOWN"} {
set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]" set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]"
} else { } else {
set cmd "*IDN?;DATE?;TIME?" set cmd "*IDN?"
} }
@END %%}
} code read_id = {%%
code read_id = { %%}
@TCL code getSensor = {%%
@END
}
code getSensor = {
@TCL
set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}" set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}"
@END %%}
} code readSensor = {%%
code readSensor = { %%}
@TCL
@END
}
} }