add HDB nodes

r3770 | jgn | 2012-10-18 14:54:11 +1100 (Thu, 18 Oct 2012) | 1 line
This commit is contained in:
Jing Chen
2012-10-18 14:54:11 +11:00
committed by Douglas Clowes
parent 12c6a9c0a8
commit 39a3e0ab19

View File

@@ -11,13 +11,14 @@
# object in TCL. # object in TCL.
# #
# @author: Jing Chen, ANSTO, 2012-08-22 # @author: Jing Chen, ANSTO, 2012-08-22
# @brief: driver for Lakeshore 218 Temperature Controller (in TCL) # @brief: SICS driver for Lakeshore 218 Temperature Controller (in TCL)
# #
# ----------------------------------------------------------------------------*/ # ----------------------------------------------------------------------------*/
# Default temperature controller parameters # Default temperature controller parameters
namespace eval ::scobj::ls218 { namespace eval ::scobj::ls218 {
}
############# Reading polled nodes ################################### ############# Reading polled nodes ###################################
@@ -31,7 +32,7 @@ namespace eval ::scobj::ls218 {
# @param idx indicates which control loop or which input channel # @param idx indicates which control loop or which input channel
# the command belongs to # the command belongs to
# @return nextState The next function to call after this one (typically 'rdValue') # @return nextState The next function to call after this one (typically 'rdValue')
proc getValue {idx nextState cmd chID} { proc ::scobj::ls218::getValue {idx cmd chID nextState} {
if {[ catch { if {[ catch {
if {$chID == 1} { if {$chID == 1} {
set comm "$cmd $idx" set comm "$cmd $idx"
@@ -46,10 +47,11 @@ proc getValue {idx nextState cmd chID} {
} else { } else {
return -code error "in getValue: error input Ch ID" return -code error "in getValue: error input Ch ID"
} }
sct send "$cmd\r\n" sct send "$comm\r\n"
} message ]} { } message ]} {
return -code error "in getValue: $message" return -code error "in getValue: $message"
} }
after 1000
return $nextState return $nextState
} }
@@ -58,15 +60,11 @@ proc getValue {idx nextState cmd chID} {
# rdValue is the default nextState for getValue() and setValue() # rdValue is the default nextState for getValue() and setValue()
# @param idx indicates which control loop or which input channel the command belongs to # @param idx indicates which control loop or which input channel the command belongs to
# @return idle Always returns system state idle - command sequence completed. # @return idle Always returns system state idle - command sequence completed.
proc rdValue {nodeName varName idx} { proc ::scobj::ls218::rdValue {nodeName varName idx} {
if {[ catch { if {[ catch {
set replyData [string trimright [sct result] " \r\n"] set replyData [string trimright [sct result] " \r\n"]
set fields [split $replyData ,] set fields [split $replyData ,]
if {$replyData != [sct oldval]} { set curValue $replyData
sct oldval $replyData
sct update $replyData
sct utime readtime
}
switch -exact $varName { switch -exact $varName {
"alarm" { if {[lindex $fields 0] == 0} { "alarm" { if {[lindex $fields 0] == 0} {
@@ -84,7 +82,7 @@ proc rdValue {nodeName varName idx} {
hset $nodeName/highValue [lindex $fields 2] hset $nodeName/highValue [lindex $fields 2]
hset $nodeName/lowValue [lindex $fields 3] hset $nodeName/lowValue [lindex $fields 3]
hset $nodeName/deadband [lindex $fields 4] hset $nodeName/deadband [lindex $fields 4]
hset $nodeName/latchEnbale [lindex $fields 5] hset $nodeName/latchEnable [lindex $fields 5]
} }
"aStatus" { if {[lindex $fields 0] == 0} { "aStatus" { if {[lindex $fields 0] == 0} {
hset $nodeName/highStatus Unactivated hset $nodeName/highStatus Unactivated
@@ -97,7 +95,9 @@ proc rdValue {nodeName varName idx} {
hset $nodeName/lowStatus Activated hset $nodeName/lowStatus Activated
} }
} }
"Celsius" { hset $nodeName [lindex $fields 0] } "Celsius" { hset $nodeName [lindex $fields 0]
set curValue [lindex $fields 0]
}
"CurveHd" { hset $nodeName/curve [lindex $fields 0] "CurveHd" { hset $nodeName/curve [lindex $fields 0]
hset $nodeName/name [lindex $fields 1] hset $nodeName/name [lindex $fields 1]
hset $nodeName/SN [lindex $fields 2] hset $nodeName/SN [lindex $fields 2]
@@ -114,7 +114,7 @@ proc rdValue {nodeName varName idx} {
default {hset $nodeName/coefficient UNKNOW} default {hset $nodeName/coefficient UNKNOW}
} }
} }
"CurveID" { hset ind [lindex $fields 0] "CurveID" { set ind [lindex $fields 0]
if {$ind == 0} { if {$ind == 0} {
hset $nodeName none hset $nodeName none
} elseif { 1 <= $ind <= 5} { } elseif { 1 <= $ind <= 5} {
@@ -126,7 +126,7 @@ proc rdValue {nodeName varName idx} {
} else { } else {
} }
} }
"control" { hset ind [lindex $fields 0] "control" { set ind [lindex $fields 0]
if {$ind == 0} { if {$ind == 0} {
hset $nodeName off hset $nodeName off
} elseif {$ind == 1} { } elseif {$ind == 1} {
@@ -144,7 +144,9 @@ proc rdValue {nodeName varName idx} {
default { hset $nodeName UNKNOW} default { hset $nodeName UNKNOW}
} }
} }
"Kelvin" { hset $nodeName $fields } "Kelvin" { hset $nodeName $fields
set curValue $fields
}
"Linear" { hset $nodeName/varM [lindex $fields 0] "Linear" { hset $nodeName/varM [lindex $fields 0]
hset $nodeName/varB [lindex $fields 2] hset $nodeName/varB [lindex $fields 2]
switch -exact [lindex $fields 1] { switch -exact [lindex $fields 1] {
@@ -154,7 +156,9 @@ proc rdValue {nodeName varName idx} {
default { hset $nodeName/xSource UNKNOW} default { hset $nodeName/xSource UNKNOW}
} }
} }
"LinearEquData" { hset $nodeName $fields } "LinearEquData" { hset $nodeName $fields
set curValue $fields
}
"mnmxSource" { switch -exact [lindex $fields 0] { "mnmxSource" { switch -exact [lindex $fields 0] {
1 { hset $nodeName Kelvin} 1 { hset $nodeName Kelvin}
2 { hset $nodeName Celsius} 2 { hset $nodeName Celsius}
@@ -171,21 +175,27 @@ proc rdValue {nodeName varName idx} {
# 5 32 temp overrange # 5 32 temp overrange
# 6 64 units under range # 6 64 units under range
# 7 128 untis over range # 7 128 untis over range
set i [expr {$fields >> 4}] set field [string trimleft $fields 0]
set bitValue [expr {$i & 0x01}] set i [format %x $field]
set i [expr 0x$i >> 4]
set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $nodeName "temp underrange, " } if {$bitValue == 1} { append $nodeName "temp underrange, " }
set i [expr {$i >> 1}] set i [expr 0x$i >> 1]
set bitValue [expr {$i & 0x01}] set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $nodeName "temp overrange, " } if {$bitValue == 1} { append $nodeName "temp overrange, " }
set i [expr {$i >> 1}] set i [expr 0x$i >> 1]
set bitValue [expr {$i & 0x01}] set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $nodeName "units under range, " } if {$bitValue == 1} { append $nodeName "units under range, " }
set i [expr {$i >> 1}] set i [expr 0x$i >> 1]
set bitValue [expr {$i & 0x01}] set bitValue [expr 0x$i & 0x01]
if {$bitValue == 1} { append $nodeName "untis over range" } if {$bitValue == 1} { append $nodeName "untis over range" }
} }
"SensorUnitValue" { hset $nodeName $fields } "SensorUnitValue" { hset $nodeName $fields
"data" { hset $nodeName $fields } set curValue $fields
}
"data" { hset $nodeName $fields
set curValue $fields
}
"aOutput" { switch -exact [lindex $fields 0] { "aOutput" { switch -exact [lindex $fields 0] {
0 { hset $nodeName/bipolarEnable "positive only" } 0 { hset $nodeName/bipolarEnable "positive only" }
1 { hset $nodeName/bipolarEnable "bipolar" } 1 { hset $nodeName/bipolarEnable "bipolar" }
@@ -235,6 +245,11 @@ proc rdValue {nodeName varName idx} {
} }
default { return -code error "in rdValue: wrong input parameter"} default { return -code error "in rdValue: wrong input parameter"}
} }
if {$curValue != [sct oldval]} {
sct oldval $curValue
sct update $curValue
sct utime readtime
}
} message ]} { } message ]} {
return -code error "in rdValue: $message " return -code error "in rdValue: $message "
} }
@@ -268,14 +283,14 @@ proc rdValue {nodeName varName idx} {
# @param nxalias attribute for HDB tree # @param nxalias attribute for HDB tree
# @return OK # @return OK
proc createNode {scobj_hpath idx sct_controller cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc \ proc createNode {scobj_hpath idx sct_controller cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc} {
hdbEnable klass control data priv type nxsave mutable nxalias} {
# It is a command that is supported by the device # It is a command that is supported by the device
if {[ catch { if {[ catch {
set ns ::scobj::ls218 set ns ::scobj::ls218
if {$idx > 0} { if {$idx > 0} {
set basePath $scobj_hpath/ch$idx set channel ch$idx
set basePath $scobj_hpath/$channel
} else { } else {
set basePath $scobj_hpath set basePath $scobj_hpath
} }
@@ -295,42 +310,39 @@ proc createNode {scobj_hpath idx sct_controller cmdGroup varName readable pollEn
default {hset $nodeName UNKNOWN} default {hset $nodeName UNKNOWN}
} }
switch -exact $dataType {
"none" { hset $nodeName UNKNOW }
"int" { hset $nodeName 0 }
"float" { hset $nodeName 0 }
"text" { hset $nodeName UNKNOW}
default { hset $nodeName UNKNOWN }
}
if {$readable == 1} { if {$readable == 1} {
hsetprop $nodeName read ${ns}::getValue $idx $rdFunc $rdCmd $chID hsetprop $nodeName read ${ns}::getValue $idx $rdCmd $chID rdFuncState
hsetprop $nodeName $rdFunc ${ns}::$rdFunc $nodeName $varName $idx hsetprop $nodeName rdFuncState ${ns}::rdValue $nodeName $varName $idx
hsetprop $nodeName oldval UNKNOW hsetprop $nodeName oldval UNKNOW
} }
if {$pollEnabled == 1} { if {$pollEnabled == 1} {
if {[SplitReply [environment_simulation]]=="false"} {
# puts "enabling polling for $nodeName" # puts "enabling polling for $nodeName"
$sct_controller poll $nodeName $sct_controller poll $nodeName
} }
# add hdb nodes
if {$hdbEnable == 1} {
hsetprop $nodeName nxalias $nxalias
hsetprop $nodeName klass $klass
hsetprop $nodeName privilege $priv
hsetprop $nodeName control $control
hsetprop $nodeName data $data
hsetprop $nodeName nxsave $nxsave
hsetprop $nodeName mutable $mutable
hsetprop $nodeName sdsinfo ::nexus::scobj::sdsinfo
} }
} message ]} { } message ]} {
return -code error "in createNode $message" return -code error "in createNode $message"
} }
return OK return OK
} }
# create parent HDB nods
proc createParentHDBNode {hPath klass priv type control data} {
if {[ catch {
hsetprop $hPath klass $klass
hsetprop $hPath privilege $priv
hsetprop $hPath type $type
hsetprop $hPath control $control
hsetprop $hPath data $data
} message ]} {
return -code error "in createParentHDBNode $message"
}
return OK
}
## ##
# @brief mkLS218() creates a scriptcontext object for a Lakeshore 218 temperature controller # @brief mkLS218() creates a scriptcontext object for a Lakeshore 218 temperature controller
# @param sct_controller name of the ls218 scriptcontext object (typically sct_ls218_tc1 or tc2) # @param sct_controller name of the ls218 scriptcontext object (typically sct_ls218_tc1 or tc2)
@@ -338,7 +350,7 @@ proc createNode {scobj_hpath idx sct_controller cmdGroup varName readable pollEn
# @param tempobj short name for the temperature controller scriptcontext object (typ. tc1 or tc2) # @param tempobj short name for the temperature controller scriptcontext object (typ. tc1 or tc2)
# @param tol temperature tolerance in Kelvin (typ. 1) # @param tol temperature tolerance in Kelvin (typ. 1)
# @return nothing (well, the sct object) # @return nothing (well, the sct object)
proc mkLS218 {argList} { proc ::scobj::ls218::mkLS218 {argList} {
if {[ catch { if {[ catch {
foreach {k v} $argList { foreach {k v} $argList {
set KEY [string toupper $k] set KEY [string toupper $k]
@@ -346,60 +358,36 @@ proc mkLS218 {argList} {
} }
MakeSICSObj $pa(NAME) SCT_OBJECT MakeSICSObj $pa(NAME) SCT_OBJECT
sicslist setatt $pa(NAME) klass $pa(KLASS) sicslist setatt $pa(NAME) klass environment
sicslist setatt $pa(NAME) long_name $pa(NAME) sicslist setatt $pa(NAME) long_name $pa(NAME)
set scobj_hpath /sics/$pa(NAME) set scobj_hpath /sics/$pa(NAME)
makesctcontroller sct_$pa(NAME) std $pa(IP):$pa(PORT) makesctcontroller sct_$pa(NAME) std $pa(IP):$pa(PORT)
::scobj::set_required_props $scobj_hpath # create parent nodes for input, output, and relay
foreach chanType {input output relay} {
foreach {nodesToplevel permission dataType init klass control data priv type} { switch -exact $chanType {
{} spy none none environment true true spy part "input" {set chanList $pa(INPUTCHAN)}
"output" {set chanList $pa(OUTPUTCHAN)}
input spy none none environment true true spy NXsensor "relay" {set chanList $pa(RELAYCHAN)}
input/ch1 spy none none environment true true spy NXsensor
input/ch2 spy none none environment true true spy NXsensor
input/ch3 spy none none environment true true spy NXsensor
input/ch4 spy none none environment true true spy NXsensor
input/ch5 spy none none environment true true spy NXsensor
input/ch6 spy none none environment true true spy NXsensor
input/ch7 spy none none environment true true spy NXsensor
input/ch8 spy none none environment true true spy NXsensor
output spy none UNKNOW environment true true spy NXsensor
output/ch1 spy none UNKNOW environment true true spy NXsensor
output/ch2 spy none UNKNOW environment true true spy NXsensor
relay spy none UNKNOW environment false true spy NXsensor
relay/ch1 spy none UNKNOW environment false true spy NXsensor
relay/ch2 spy none UNKNOW environment false true spy NXsensor
relay/ch3 spy none UNKNOW environment false true spy NXsensor
relay/ch4 spy none UNKNOW environment false true spy NXsensor
relay/ch5 spy none UNKNOW environment false true spy NXsensor
relay/ch6 spy none UNKNOW environment false true spy NXsensor
relay/ch7 spy none UNKNOW environment false true spy NXsensor
relay/ch8 spy none UNKNOW environment false true spy NXsensor
other spy none UNKNOW environment false true spy NXsensor
} {
if {$nodesToplevel != ""} {
set hPath $scobj_hpath/$nodesToplevel
hfactory $hPath plain $permission $dataType
hset $hPath $init
} else {
set hPath $scobj_hpath
} }
if {[string length $chanList] > 0} {
if {$control == "true"} { set hPath $scobj_hpath/$chanType
hsetprop $hPath klass $klass hfactory $hPath plain user none
hsetprop $hPath privilege $priv hset $hPath UNKNOWN
hsetprop $hPath type $type foreach idx $chanList {
hsetprop $hPath control $control set hPath $scobj_hpath/$chanType/ch$idx
hsetprop $hPath data $data hfactory $hPath plain user none
hset $hPath UNKNOWN
} }
} }
}
# create parent node for other
set hPath $scobj_hpath/other
hfactory $hPath plain user none
hset $hPath UNKNOWN
# Create state machines for the following device commands (non-polled entries are place-holders # Create state machines for the following device commands (non-polled entries are place-holders
# for manually maintained nodes, like the selector for the input that provides the sample temperature # for manually maintained nodes, like the selector for the input that provides the sample temperature
@@ -433,99 +421,154 @@ proc mkLS218 {argList} {
########################################################################################################### ###########################################################################################################
set inputNodes { set inputNodes {
{} alarm 1 1 none user {ALARM?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} alarm 1 1 none user {ALARM?} 1 {rdValue}
alarm offOn 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} alarm offOn 0 0 text user {} 0 {}
alarm source 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} alarm source 0 0 text user {} 0 {}
alarm highValue 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} alarm highValue 0 0 float user {} 0 {}
alarm lowValue 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} alarm lowValue 0 0 float user {} 0 {}
alarm deadband 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} alarm deadband 0 0 float user {} 0 {}
alarm latchEnable 0 0 int user {} 0 {} 0 {} {} {} {} {} {} {} {} alarm latchEnable 0 0 int user {} 0 {}
{} aStatus 1 1 none user {ALARMST?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} aStatus 1 1 none user {ALARMST?} 1 {rdValue}
aStatus highStatus 1 1 text user {} 0 {} 0 {} {} {} {} {} {} {} {} aStatus highStatus 0 0 text user {} 0 {}
aStatus lowStatus 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} aStatus lowStatus 0 0 text user {} 0 {}
{} Celsius 1 1 float user {CRDG?} 1 {rdValue} 1 NXsensor true true true true {} {} reading-Celsius {} Celsius 1 1 float user {CRDG?} 1 {rdValue}
{} CurveHd 1 1 none user {CRVHDR?} 0 {rdValue} 0 {} {} {} {} {} {} {} {} {} CurveHd 1 1 none user {CRVHDR?} 0 {rdValue}
CurveHd curve 0 0 int user {} 0 {} 0 {} {} {} {} {} {} {} {} CurveHd curve 0 0 text user {} 0 {}
CurveHd name 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} CurveHd name 0 0 text user {} 0 {}
CurveHd SN 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} CurveHd SN 0 0 text user {} 0 {}
CurveHd format 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} CurveHd format 0 0 text user {} 0 {}
CurveHd limitValue 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} CurveHd limitValue 0 0 float user {} 0 {}
CurveHd coefficient 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} CurveHd coefficient 0 0 text user {} 0 {}
{} CurveID 1 1 text user {INCRV?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} CurveID 1 1 text user {INCRV?} 1 {rdValue}
{} control 1 1 text user {INPUT?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} control 1 1 text user {INPUT?} 1 {rdValue}
{} inputType 1 1 text user {INTYPE?} G {rdValue} 0 {} {} {} {} {} {} {} {} {} inputType 1 1 text user {INTYPE?} G {rdValue}
{} Kelvin 1 1 float user {KRDG?} 1 {rdValue} 1 NXsensor true true true true true true reading-Kelvin {} Kelvin 1 1 float user {KRDG?} 1 {rdValue}
{} Linear 1 1 none user {LINEAR?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} Linear 1 1 none user {LINEAR?} 1 {rdValue}
Linear varM 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} Linear varM 0 0 float user {} 0 {}
Linear xSource 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} Linear xSource 0 0 text user {} 0 {}
Linear varB 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} Linear varB 0 0 float user {} 0 {}
{} LinearEquData 1 1 float user {LRDG?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} LinearEquData 1 1 float user {LRDG?} 1 {rdValue}
{} mnmxSource 1 1 text user {MNMX?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} mnmxSource 1 1 text user {MNMX?} 1 {rdValue}
{} mnmxValue 1 1 text user {MNMXRDG?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} mnmxValue 1 1 text user {MNMXRDG?} 1 {rdValue}
{} status 1 1 text user {RDGST?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} status 1 1 text user {RDGST?} 1 {rdValue}
{} SensorUnitValue 1 1 float user {SRDG?} 1 {rdValue} 1 NXsensor true true true true true true reading-SensorUnitValue {} SensorUnitValue 1 1 float user {SRDG?} 1 {rdValue}
} }
set outputNodes { set outputNodes {
{} data 1 1 float user {AOUT?} 1 {rdValue} 1 NXsensor true true true true true true reading-output {} data 1 1 float user {AOUT?} 1 {rdValue}
{} aOutput 1 1 none user {ANALOG?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} aOutput 1 1 none user {ANALOG?} 1 {rdValue}
aOutput bipolarEnable 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput bipolarEnable 0 0 text user {} 0 {}
aOutput monitorMode 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput monitorMode 0 0 text user {} 0 {}
aOutput inputChID 0 0 int user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput inputChID 0 0 int user {} 0 {}
aOutput source 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput source 0 0 text user {} 0 {}
aOutput highValue 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput highValue 0 0 float user {} 0 {}
aOutput lowValue 0 0 float user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput lowValue 0 0 float user {} 0 {}
aOutput manualValue 0 0 int user {} 0 {} 0 {} {} {} {} {} {} {} {} aOutput manualValue 0 0 int user {} 0 {}
} }
set relayNodes { set relayNodes {
{} relay 1 1 none user {RELAY?} 1 {rdValue} 0 {} {} {} {} {} {} {} {} {} relay 1 1 none user {RELAY?} 1 {rdValue}
relay mode 1 1 text user {} 0 {} 0 {} {} {} {} {} {} {} {} relay mode 0 0 text user {} 0 {}
relay input 0 0 int user {} 0 {} 0 {} {} {} {} {} {} {} {} relay input 0 0 int user {} 0 {}
relay alarmType 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} relay alarmType 0 0 text user {} 0 {}
} }
set otherNodes { set otherNodes {
{} IDN 1 1 none user {*IDN?} 0 {rdValue} 0 {} {} {} {} {} {} {} {} {} IDN 1 1 none user {*IDN?} 0 {rdValue}
IDN manufacturer 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} IDN manufacturer 0 0 text user {} 0 {}
IDN model 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} IDN model 0 0 text user {} 0 {}
IDN serialNumber 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} IDN serialNumber 0 0 text user {} 0 {}
IDN firmwareDate 0 0 text user {} 0 {} 0 {} {} {} {} {} {} {} {} IDN firmwareDate 0 0 text user {} 0 {}
{} logStatus 1 1 text user {LOG?} 0 {rdValue} 0 {} {} {} {} {} {} {} {} {} logStatus 1 1 text user {LOG?} 0 {rdValue}
} }
# create sub-tree for all 8 input channels # create sub-tree for all 8 input channels
for {set idx 1} {$idx<=8} {incr idx} { foreach idx $pa(INPUTCHAN) {
foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc hdbEnable klass control data priv type nxsave mutable nxalias}\ foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc} $inputNodes {
$inputNodes { createNode $scobj_hpath/input $idx sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID $rdFunc
createNode $scobj_hpath/input $idx sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID \
$rdFunc $hdbEnable $klass $control $data $priv $type $nxsave $mutable $nxalias
} }
} }
# create sub-tree for all 2 output channels # create sub-tree for all 2 output channels
for {set idx 1} {$idx<=2} {incr idx} { foreach idx $pa(OUTPUTCHAN) {
foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc hdbEnable klass control data priv type nxsave mutable nxalias}\ foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc} $outputNodes {
$outputNodes { createNode $scobj_hpath/output $idx sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID $rdFunc
createNode $scobj_hpath/output $idx sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID \
$rdFunc $hdbEnable $klass $control $data $priv $type $nxsave $mutable $nxalias
} }
} }
# create sub-tree for all 8 relay channels # create sub-tree for all 8 relay channels
for {set idx 1} {$idx<=8} {incr idx} { foreach idx $pa(RELAYCHAN) {
foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc hdbEnable klass control data priv type nxsave mutable nxalias}\ foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc} $relayNodes {
$relayNodes { createNode $scobj_hpath/relay $idx sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID $rdFunc
createNode $scobj_hpath/relay $idx sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID \
$rdFunc $hdbEnable $klass $control $data $priv $type $nxsave $mutable $nxalias
} }
} }
# create "other" sub-tree # create "other" sub-tree
foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc hdbEnable klass control data priv type nxsave mutable nxalias}\ foreach {cmdGroup varName readable pollEnabled dataType permission rdCmd chID rdFunc} $otherNodes {
$otherNodes { createNode $scobj_hpath/other 0 sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID $rdFunc
createNode $scobj_hpath/other 0 sct_$pa(NAME) $cmdGroup $varName $readable $pollEnabled $dataType $permission $rdCmd $chID \ }
$rdFunc $hdbEnable $klass $control $data $priv $type $nxsave $mutable $nxalias
# create HDB tree
::scobj::set_required_props $scobj_hpath
foreach {hPath klass control data priv type} {
ls218 environment true true spy part
input NXsensor true true user NXsensor
output NXsensor true true user NXsensor
} {
switch -exact $hPath {
"ls218" { set curPath /sics/$hPath
createParentHDBNode $curPath $klass $priv $type $control $data
}
default { switch -exact $hPath {
"input" {set chanList $pa(INPUTCHAN)}
"output" {set chanList $pa(OUTPUTCHAN)}
}
if {[string length $chanList] > 0} {
set curPath /sics/ls218/$hPath
createParentHDBNode $curPath $klass $priv $type $control $data
foreach idx $chanList {
set curPath /sics/ls218/$hPath/ch$idx
createParentHDBNode $curPath $klass $priv $type $control $data
}
}
}
}
}
if {[string length $pa(INPUTCHAN)] > 0} {
foreach idx $pa(INPUTCHAN) {
foreach {item klass control data nxsave mutable priv alias} {
Celsius sensor true true true true user Celsius
Kelvin sensor true true true true user Kelvin
SensorUnitValue sensor true true true true user SensorUnitValue
} {
set hpath /sics/ls218/input/ch$idx/$item
hsetprop $hpath nxalias ls218-input-ch$idx-$alias
hsetprop $hpath klass $klass
hsetprop $hpath privilege $priv
hsetprop $hpath control $control
hsetprop $hpath data $data
hsetprop $hpath nxsave $nxsave
hsetprop $hpath mutable $mutable
hsetprop $hpath sdsinfo ::nexus::scobj::sdsinfo
}
}
}
if {[string length $pa(OUTPUTCHAN)] > 0} {
foreach idx $pa(OUTPUTCHAN) {
set hpath /sics/ls218/output/ch$idx/data
hsetprop $hpath nxalias ls218-output-ch$idx-data
hsetprop $hpath klass sensor
hsetprop $hpath privilege user
hsetprop $hpath control true
hsetprop $hpath data true
hsetprop $hpath nxsave true
hsetprop $hpath mutable true
hsetprop $hpath sdsinfo ::nexus::scobj::sdsinfo
}
} }
::scobj::hinitprops $pa(NAME) ::scobj::hinitprops $pa(NAME)
@@ -535,8 +578,6 @@ proc mkLS218 {argList} {
} }
} }
namespace export ls218
}
# end of namespace ::scobj::ls218 # end of namespace ::scobj::ls218
# Main process call # Main process call
@@ -548,12 +589,13 @@ proc mkLS218 {argList} {
# @return nothing (well, the sct object) # @return nothing (well, the sct object)
#::scobj::ls218::mkLS218 { #::scobj::ls218::mkLS218 {
# name "ls218" # name ls218
# IP 137.157.202.219 # IP 137.157.202.219
# PORT 4001 # PORT 4002
# tuning 1 # tuning 1
# interval 5 # interval 5
# klass environment # inputChan {1 2 3 4 5 6 7 8}
# outputChan {1 2}
# relayChan {1 2 3 4 5 6 7 8}
#} #}
namespace import ::scobj::ls218::*