Quartzdyne Q-Link Pressure and Temperature Sensor
r2914 | dcl | 2010-05-10 10:05:41 +1000 (Mon, 10 May 2010) | 2 lines
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
# Define procs in ::scobj::xxx namespace
|
||||
# MakeSICSObj $obj SCT_<class>
|
||||
# The MakeSICSObj cmd adds a /sics/$obj node. NOTE the /sics node is not browsable.
|
||||
|
||||
|
||||
namespace eval ::scobj::qlink {
|
||||
# Temperature controllers must have at least the following nodes
|
||||
# /tempcont/setpoint
|
||||
# /tempcont/sensor/value
|
||||
proc debug_log {args} {
|
||||
set fd [open "/tmp/qlink.log" a]
|
||||
puts $fd $args
|
||||
close $fd
|
||||
}
|
||||
|
||||
proc getValue {nextState cmd} {
|
||||
sct send "#01$cmd"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
proc rdValue {tc_root} {
|
||||
set data [sct result]
|
||||
if [ catch {
|
||||
debug_log "rdValue $tc_root [sct] result=$data"
|
||||
} message ] {
|
||||
debug_log "rdValue $tc_root failure"
|
||||
}
|
||||
switch -glob -- $data {
|
||||
"ASCERR:*" {
|
||||
sct geterror $data
|
||||
}
|
||||
default {
|
||||
if {$data != [sct oldval]} {
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
debug_log "rdValue new data for $tc_root [sct] $my_model result=$data"
|
||||
}
|
||||
}
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
proc noResponse {} {
|
||||
return idle
|
||||
}
|
||||
proc wrtValue {wcmd args} {
|
||||
}
|
||||
|
||||
proc mk_sct_qlink {sct_controller klass tempobj tol} {
|
||||
if [ catch {
|
||||
set ns ::scobj::qlink
|
||||
|
||||
MakeSICSObj $tempobj SCT_OBJECT
|
||||
sicslist setatt $tempobj klass $klass
|
||||
sicslist setatt $tempobj long_name $tempobj
|
||||
|
||||
set scobj_hpath /sics/$tempobj
|
||||
hfactory $scobj_hpath/pressure plain spy none
|
||||
hfactory $scobj_hpath/pressure/value plain internal float
|
||||
hsetprop $scobj_hpath/pressure/value read ${ns}::getValue rdValue "D1"
|
||||
hsetprop $scobj_hpath/pressure/value rdValue ${ns}::rdValue $scobj_hpath
|
||||
hsetprop $scobj_hpath/pressure/value oldval UNKNOWN
|
||||
hsetprop $scobj_hpath/pressure/value units "BAR"
|
||||
|
||||
hfactory $scobj_hpath/temperature plain spy none
|
||||
hfactory $scobj_hpath/temperature/value plain internal float
|
||||
hsetprop $scobj_hpath/temperature/value read ${ns}::getValue rdValue "D2"
|
||||
hsetprop $scobj_hpath/temperature/value rdValue ${ns}::rdValue $scobj_hpath
|
||||
hsetprop $scobj_hpath/temperature/value oldval UNKNOWN
|
||||
hsetprop $scobj_hpath/temperature/value units "K"
|
||||
|
||||
hfactory $scobj_hpath/itc500_lasterror plain user text
|
||||
hset $scobj_hpath/itc500_lasterror ""
|
||||
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
$sct_controller poll $scobj_hpath/pressure/value
|
||||
$sct_controller poll $scobj_hpath/temperature/value
|
||||
}
|
||||
|
||||
::scobj::hinitprops $tempobj
|
||||
hsetprop $scobj_hpath klass NXenvironment
|
||||
::scobj::set_required_props $scobj_hpath
|
||||
hsetprop $scobj_hpath type part
|
||||
foreach snsr {pressure temperature} {
|
||||
foreach {rootpath hpath klass priv} "
|
||||
$scobj_hpath $snsr NXsensor spy
|
||||
$scobj_hpath $snsr/value sensor user
|
||||
" {
|
||||
hsetprop $rootpath/$hpath klass $klass
|
||||
hsetprop $rootpath/$hpath privilege $priv
|
||||
hsetprop $rootpath/$hpath control true
|
||||
hsetprop $rootpath/$hpath data true
|
||||
hsetprop $rootpath/$hpath nxsave true
|
||||
}
|
||||
hsetprop $scobj_hpath/$snsr type part
|
||||
hsetprop $scobj_hpath/$snsr/value nxalias tc1_${snsr}_value
|
||||
hsetprop $scobj_hpath/$snsr/value mutable true
|
||||
hsetprop $scobj_hpath/$snsr/value sdsinfo ::nexus::scobj::sdsinfo
|
||||
}
|
||||
hsetprop $scobj_hpath privilege spy
|
||||
} message ] {
|
||||
return -code error $message
|
||||
}
|
||||
}
|
||||
namespace export mk_sct_qlink
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Create a Quartzdyne Q-Link controller
|
||||
#
|
||||
# @param name, the name of the temperature controller (eg tc1)
|
||||
# @param IP, the IP address of the device, this can be a hostname, (eg ca1-kowari)
|
||||
# @param port, the IP protocol port number of the device
|
||||
# @param _tol (optional), this is the initial tolerance setting
|
||||
proc add_qlink {name IP port {_tol 5.0}} {
|
||||
set fd [open "/tmp/qlink.log" a]
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
puts $fd "makesctcontroller sct_qlink std ${IP}:$port"
|
||||
makesctcontroller sct_qlink std ${IP}:$port
|
||||
}
|
||||
puts $fd "mk_sct_qlink sct_qlink environment $name $_tol"
|
||||
mk_sct_qlink sct_qlink environment $name $_tol
|
||||
close $fd
|
||||
}
|
||||
|
||||
puts stdout "file evaluation of sct_qlink.tcl"
|
||||
set fd [open "/tmp/qlink.log" w]
|
||||
puts $fd "file evaluation of sct_qlink.tcl"
|
||||
close $fd
|
||||
|
||||
namespace import ::scobj::qlink::*
|
||||
|
||||
#add_qlink qlink 137.157.201.213 502 5
|
||||
add_qlink qlink localhost 30508 5
|
||||
Reference in New Issue
Block a user