West 6100 driver
This commit is contained in:
@ -0,0 +1,581 @@
|
||||
# Generated driver for west_6100
|
||||
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
|
||||
#
|
||||
|
||||
namespace eval ::scobj::west_6100 {
|
||||
set debug_threshold 5
|
||||
}
|
||||
|
||||
proc ::scobj::west_6100::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/west_6100_[basename ${tc_root}].log" "a"]
|
||||
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
|
||||
puts ${fd} "${line}"
|
||||
close ${fd}
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
proc ::scobj::west_6100::sics_log {debug_level debug_string} {
|
||||
set catch_status [ catch {
|
||||
set debug_threshold ${::scobj::west_6100::debug_threshold}
|
||||
if {${debug_level} >= ${debug_threshold}} {
|
||||
sicslog "::scobj::west_6100::${debug_string}"
|
||||
}
|
||||
} catch_message ]
|
||||
}
|
||||
|
||||
# check function for hset change
|
||||
proc ::scobj::west_6100::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::west_6100::getDecimal {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "getDecimal tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getDecimal hook code starts
|
||||
set cmd "1:3:${cmd_str}:1:U16"
|
||||
# getDecimal hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "getDecimal 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::west_6100::getInteger {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "getInteger tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set cmd "${cmd_str}"
|
||||
# getInteger hook code starts
|
||||
set cmd "1:3:${cmd_str}:1:U16"
|
||||
# getInteger hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
debug_log ${tc_root} 1 "getInteger 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::west_6100::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::west_6100::rdDecimal {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "rdDecimal 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]"
|
||||
}
|
||||
# rdDecimal hook code starts
|
||||
set data [expr {0.10 * ${data}}]
|
||||
# rdDecimal hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
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::west_6100::rdInteger {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "rdInteger 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]"
|
||||
}
|
||||
# rdInteger 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::west_6100::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}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::west_6100::wrDecimal {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "wrDecimal 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}"
|
||||
# wrDecimal hook code starts
|
||||
set par [expr {round(10.0 * [sct target])}]
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
# wrDecimal hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "wrDecimal 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 write a parameter value on a device
|
||||
proc ::scobj::west_6100::wrInteger {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "wrInteger 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}"
|
||||
# wrInteger hook code starts
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
# wrInteger hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "wrInteger 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::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_id } {
|
||||
::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
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}/alarm1 plain user float
|
||||
hsetprop ${scobj_hpath}/alarm1 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {13}
|
||||
hsetprop ${scobj_hpath}/alarm1 rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm1 write ${ns}::wrDecimal ${scobj_hpath} noResponse {13}
|
||||
hsetprop ${scobj_hpath}/alarm1 noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm1 check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm1 control true
|
||||
hsetprop ${scobj_hpath}/alarm1 data true
|
||||
hsetprop ${scobj_hpath}/alarm1 mutable true
|
||||
hsetprop ${scobj_hpath}/alarm1 nxsave true
|
||||
hsetprop ${scobj_hpath}/alarm1 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/alarm1 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/alarm1 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/alarm1 type "part"
|
||||
hsetprop ${scobj_hpath}/alarm1 nxalias "${name}_alarm1"
|
||||
|
||||
hfactory ${scobj_hpath}/alarm2 plain user float
|
||||
hsetprop ${scobj_hpath}/alarm2 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {14}
|
||||
hsetprop ${scobj_hpath}/alarm2 rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm2 write ${ns}::wrDecimal ${scobj_hpath} noResponse {14}
|
||||
hsetprop ${scobj_hpath}/alarm2 noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm2 check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/alarm2 control true
|
||||
hsetprop ${scobj_hpath}/alarm2 data true
|
||||
hsetprop ${scobj_hpath}/alarm2 mutable true
|
||||
hsetprop ${scobj_hpath}/alarm2 nxsave true
|
||||
hsetprop ${scobj_hpath}/alarm2 oldval 0.0
|
||||
hsetprop ${scobj_hpath}/alarm2 klass "parameter"
|
||||
hsetprop ${scobj_hpath}/alarm2 sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/alarm2 type "part"
|
||||
hsetprop ${scobj_hpath}/alarm2 nxalias "${name}_alarm2"
|
||||
|
||||
hfactory ${scobj_hpath}/power plain user int
|
||||
hsetprop ${scobj_hpath}/power read ${ns}::getInteger ${scobj_hpath} rdInteger {3}
|
||||
hsetprop ${scobj_hpath}/power rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/power control true
|
||||
hsetprop ${scobj_hpath}/power data true
|
||||
hsetprop ${scobj_hpath}/power mutable true
|
||||
hsetprop ${scobj_hpath}/power nxsave true
|
||||
hsetprop ${scobj_hpath}/power oldval 0
|
||||
hsetprop ${scobj_hpath}/power klass "parameter"
|
||||
hsetprop ${scobj_hpath}/power sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/power type "part"
|
||||
hsetprop ${scobj_hpath}/power nxalias "${name}_power"
|
||||
|
||||
hfactory ${scobj_hpath}/powermax plain user int
|
||||
hsetprop ${scobj_hpath}/powermax read ${ns}::getInteger ${scobj_hpath} rdInteger {20}
|
||||
hsetprop ${scobj_hpath}/powermax rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/powermax write ${ns}::wrInteger ${scobj_hpath} noResponse {20}
|
||||
hsetprop ${scobj_hpath}/powermax noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/powermax check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/powermax control true
|
||||
hsetprop ${scobj_hpath}/powermax data true
|
||||
hsetprop ${scobj_hpath}/powermax mutable true
|
||||
hsetprop ${scobj_hpath}/powermax nxsave true
|
||||
hsetprop ${scobj_hpath}/powermax oldval 0
|
||||
hsetprop ${scobj_hpath}/powermax klass "parameter"
|
||||
hsetprop ${scobj_hpath}/powermax sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/powermax type "part"
|
||||
hsetprop ${scobj_hpath}/powermax nxalias "${name}_powermax"
|
||||
|
||||
hfactory ${scobj_hpath}/ramprate plain user float
|
||||
hsetprop ${scobj_hpath}/ramprate read ${ns}::getDecimal ${scobj_hpath} rdDecimal {24}
|
||||
hsetprop ${scobj_hpath}/ramprate rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/ramprate write ${ns}::wrDecimal ${scobj_hpath} noResponse {24}
|
||||
hsetprop ${scobj_hpath}/ramprate noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/ramprate check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/ramprate control true
|
||||
hsetprop ${scobj_hpath}/ramprate data true
|
||||
hsetprop ${scobj_hpath}/ramprate mutable true
|
||||
hsetprop ${scobj_hpath}/ramprate nxsave true
|
||||
hsetprop ${scobj_hpath}/ramprate oldval 0.0
|
||||
hsetprop ${scobj_hpath}/ramprate klass "parameter"
|
||||
hsetprop ${scobj_hpath}/ramprate sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/ramprate type "part"
|
||||
hsetprop ${scobj_hpath}/ramprate nxalias "${name}_ramprate"
|
||||
|
||||
hfactory ${scobj_hpath}/sensor plain user float
|
||||
hsetprop ${scobj_hpath}/sensor read ${ns}::getDecimal ${scobj_hpath} rdDecimal {1}
|
||||
hsetprop ${scobj_hpath}/sensor rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/sensor control true
|
||||
hsetprop ${scobj_hpath}/sensor data true
|
||||
hsetprop ${scobj_hpath}/sensor mutable true
|
||||
hsetprop ${scobj_hpath}/sensor nxsave true
|
||||
hsetprop ${scobj_hpath}/sensor oldval 0.0
|
||||
hsetprop ${scobj_hpath}/sensor klass "parameter"
|
||||
hsetprop ${scobj_hpath}/sensor sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/sensor type "part"
|
||||
hsetprop ${scobj_hpath}/sensor nxalias "${name}_sensor"
|
||||
|
||||
hfactory ${scobj_hpath}/setpoint plain user float
|
||||
hsetprop ${scobj_hpath}/setpoint read ${ns}::getDecimal ${scobj_hpath} rdDecimal {2}
|
||||
hsetprop ${scobj_hpath}/setpoint rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/setpoint write ${ns}::wrDecimal ${scobj_hpath} noResponse {2}
|
||||
hsetprop ${scobj_hpath}/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/setpoint check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/setpoint control true
|
||||
hsetprop ${scobj_hpath}/setpoint data true
|
||||
hsetprop ${scobj_hpath}/setpoint mutable true
|
||||
hsetprop ${scobj_hpath}/setpoint nxsave true
|
||||
hsetprop ${scobj_hpath}/setpoint oldval 0.0
|
||||
hsetprop ${scobj_hpath}/setpoint klass "parameter"
|
||||
hsetprop ${scobj_hpath}/setpoint sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/setpoint type "part"
|
||||
hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint"
|
||||
|
||||
hfactory ${scobj_hpath}/w_sp plain user float
|
||||
hsetprop ${scobj_hpath}/w_sp read ${ns}::getDecimal ${scobj_hpath} rdDecimal {21}
|
||||
hsetprop ${scobj_hpath}/w_sp rdDecimal ${ns}::rdDecimal ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/w_sp write ${ns}::wrDecimal ${scobj_hpath} noResponse {21}
|
||||
hsetprop ${scobj_hpath}/w_sp noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/w_sp check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/w_sp control true
|
||||
hsetprop ${scobj_hpath}/w_sp data true
|
||||
hsetprop ${scobj_hpath}/w_sp mutable true
|
||||
hsetprop ${scobj_hpath}/w_sp nxsave true
|
||||
hsetprop ${scobj_hpath}/w_sp oldval 0.0
|
||||
hsetprop ${scobj_hpath}/w_sp klass "parameter"
|
||||
hsetprop ${scobj_hpath}/w_sp sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/w_sp type "part"
|
||||
hsetprop ${scobj_hpath}/w_sp nxalias "${name}_w_sp"
|
||||
|
||||
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}/alarm1 1
|
||||
${sct_controller} poll ${scobj_hpath}/alarm2 1
|
||||
${sct_controller} poll ${scobj_hpath}/power 1
|
||||
${sct_controller} poll ${scobj_hpath}/powermax 1
|
||||
${sct_controller} poll ${scobj_hpath}/ramprate 1
|
||||
${sct_controller} poll ${scobj_hpath}/sensor 1
|
||||
${sct_controller} poll ${scobj_hpath}/setpoint 1
|
||||
${sct_controller} poll ${scobj_hpath}/w_sp 1
|
||||
${sct_controller} write ${scobj_hpath}/alarm1
|
||||
${sct_controller} write ${scobj_hpath}/alarm2
|
||||
${sct_controller} write ${scobj_hpath}/powermax
|
||||
${sct_controller} write ${scobj_hpath}/ramprate
|
||||
${sct_controller} write ${scobj_hpath}/setpoint
|
||||
${sct_controller} write ${scobj_hpath}/w_sp
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100"
|
||||
}
|
||||
|
||||
hfactory ${scobj_hpath}/aux plain spy none
|
||||
hsetprop ${scobj_hpath}/aux data "false"
|
||||
hsetprop ${scobj_hpath}/aux klass "@none"
|
||||
hsetprop ${scobj_hpath}/aux type "part"
|
||||
|
||||
hfactory ${scobj_hpath}/aux/decimal plain user int
|
||||
hsetprop ${scobj_hpath}/aux/decimal read ${ns}::getInteger ${scobj_hpath} rdInteger {18}
|
||||
hsetprop ${scobj_hpath}/aux/decimal rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/aux/decimal control false
|
||||
hsetprop ${scobj_hpath}/aux/decimal data false
|
||||
hsetprop ${scobj_hpath}/aux/decimal mutable false
|
||||
hsetprop ${scobj_hpath}/aux/decimal nxsave false
|
||||
hsetprop ${scobj_hpath}/aux/decimal oldval 0
|
||||
hsetprop ${scobj_hpath}/aux/decimal sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/aux/decimal type "part"
|
||||
hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal"
|
||||
|
||||
hfactory ${scobj_hpath}/aux/instatus plain user int
|
||||
hsetprop ${scobj_hpath}/aux/instatus read ${ns}::getInteger ${scobj_hpath} rdInteger {133}
|
||||
hsetprop ${scobj_hpath}/aux/instatus rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/aux/instatus control false
|
||||
hsetprop ${scobj_hpath}/aux/instatus data false
|
||||
hsetprop ${scobj_hpath}/aux/instatus mutable false
|
||||
hsetprop ${scobj_hpath}/aux/instatus nxsave false
|
||||
hsetprop ${scobj_hpath}/aux/instatus oldval 0
|
||||
hsetprop ${scobj_hpath}/aux/instatus sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/aux/instatus type "part"
|
||||
hsetprop ${scobj_hpath}/aux/instatus nxalias "${name}_aux_instatus"
|
||||
|
||||
hfactory ${scobj_hpath}/aux/model plain user int
|
||||
hsetprop ${scobj_hpath}/aux/model read ${ns}::getInteger ${scobj_hpath} rdInteger {122}
|
||||
hsetprop ${scobj_hpath}/aux/model rdInteger ${ns}::rdInteger ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/aux/model control false
|
||||
hsetprop ${scobj_hpath}/aux/model data false
|
||||
hsetprop ${scobj_hpath}/aux/model mutable false
|
||||
hsetprop ${scobj_hpath}/aux/model nxsave false
|
||||
hsetprop ${scobj_hpath}/aux/model oldval 0
|
||||
hsetprop ${scobj_hpath}/aux/model sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/aux/model type "part"
|
||||
hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model"
|
||||
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/aux/decimal 2
|
||||
${sct_controller} poll ${scobj_hpath}/aux/instatus 2
|
||||
${sct_controller} poll ${scobj_hpath}/aux/model 2
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100"
|
||||
}
|
||||
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::west_6100 {
|
||||
namespace export debug_threshold
|
||||
namespace export debug_log
|
||||
namespace export sics_log
|
||||
namespace export mkDriver
|
||||
}
|
||||
|
||||
proc add_west_6100 {name ip_address tcp_port dev_id} {
|
||||
set catch_status [ catch {
|
||||
::scobj::west_6100::sics_log 9 "add_west_6100 ${name} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
if {[string equal -nocase "aqadapter" "${ip_address}"]} {
|
||||
::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"
|
||||
makesctcontroller sct_${name} aqadapter ${tcp_port}
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}"
|
||||
makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}
|
||||
}
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 9 "[environment_simulation] => No sctcontroller for west_6100"
|
||||
}
|
||||
::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}"
|
||||
::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
clientput "file evaluation of sct_west_6100.tcl"
|
||||
::scobj::west_6100::sics_log 9 "file evaluation of sct_west_6100.tcl"
|
||||
|
||||
proc ::scobj::west_6100::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::west_6100"
|
||||
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"] "west_6100"] } {
|
||||
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"]"
|
||||
}
|
||||
}
|
||||
set arg_list [list]
|
||||
set missing_list [list]
|
||||
foreach arg {dev_id} {
|
||||
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_west_6100 ${name} ${ip_address} ${tcp_port} {*}$arg_list
|
||||
} else {
|
||||
add_west_6100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
if { [info exists ::config_dict] } {
|
||||
::scobj::west_6100::read_config
|
||||
} else {
|
||||
::scobj::west_6100::sics_log 5 "No config dict"
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
|
||||
driver west_6100 = {
|
||||
protocol = modbus_ap
|
||||
class = environment
|
||||
simulation_group = environment_simulation
|
||||
add_args = 'dev_id'
|
||||
make_args = 'dev_id'
|
||||
Group = {
|
||||
priv = user; data = true; control = true; mutable = true;
|
||||
type = float;
|
||||
readable = 1;
|
||||
fetch_function = getDecimal;
|
||||
read_function = rdDecimal;
|
||||
write_function = wrDecimal;
|
||||
var sensor = { read_command = "1"; }
|
||||
var setpoint = { read_command = "2"; write_command = "2"; writeable = 1; }
|
||||
var w_sp = { read_command = "21"; write_command = "21"; writeable = 1; }
|
||||
var ramprate = { read_command = "24"; write_command = "24"; writeable = 1; }
|
||||
var alarm1 = { read_command = "13"; write_command = "13"; writeable = 1; }
|
||||
var alarm2 = { read_command = "14"; write_command = "14"; writeable = 1; }
|
||||
type = int;
|
||||
fetch_function = getInteger;
|
||||
read_function = rdInteger;
|
||||
write_function = wrInteger;
|
||||
var power = { read_command = "3";}
|
||||
var powermax = { read_command = "20"; write_command = "20"; writeable = 1; }
|
||||
}
|
||||
group aux = {
|
||||
data = false;
|
||||
control = false;
|
||||
mutable = false;
|
||||
readable = 2;
|
||||
nxsave = false;
|
||||
fetch_function = getInteger;
|
||||
read_function = rdInteger;
|
||||
var model = { type = int; read_command = "122"; }
|
||||
var decimal = { type = int; read_command = "18"; }
|
||||
var instatus = { type = int; read_command = "133"; }
|
||||
}
|
||||
code fetch_function getInteger = {
|
||||
@TCL
|
||||
set cmd "1:3:${cmd_str}:1:U16"
|
||||
@END
|
||||
}
|
||||
code read_function rdInteger = {
|
||||
@TCL
|
||||
@END
|
||||
}
|
||||
code write_function wrInteger = {
|
||||
@TCL
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
@END
|
||||
}
|
||||
# Decimal Adjusted fields
|
||||
code fetch_function getDecimal = {
|
||||
@TCL
|
||||
set cmd "1:3:${cmd_str}:1:U16"
|
||||
@END
|
||||
}
|
||||
code read_function rdDecimal = {
|
||||
@TCL
|
||||
set data [expr {0.10 * ${data}}]
|
||||
@END
|
||||
}
|
||||
code write_function wrDecimal = {
|
||||
@TCL
|
||||
set par [expr {round(10.0 * [sct target])}]
|
||||
set cmd "1:16:${cmd_str}:1:U16:${par}"
|
||||
@END
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user