Update "Decimal" processing for 4100/6100

This commit is contained in:
Douglas Clowes
2014-09-10 14:22:50 +10:00
parent 99fae91ff9
commit 0867f5a315
2 changed files with 22 additions and 5 deletions

View File

@@ -126,7 +126,10 @@ proc ::scobj::west_6100::rdDecimal {tc_root} {
error "[sct geterror]"
}
# rdDecimal hook code starts
set data [expr {0.10 * ${data}}]
set decimal [hval ${tc_root}/aux/decimal]
if { ${decimal} > 0 } {
set data [expr {pow(10, -${decimal}) * ${data}}]
}
# rdDecimal hook code ends
if { [hpropexists [sct] geterror] } {
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
@@ -203,7 +206,12 @@ proc ::scobj::west_6100::wrDecimal {tc_root nextState cmd_str} {
set par [sct target]
set cmd "${cmd_str}${par}"
# wrDecimal hook code starts
set par [expr {round(10.0 * [sct target])}]
set decimal [hval ${tc_root}/aux/decimal]
set par [sct target]
if { ${decimal} > 0 } {
set par [expr {pow(10, ${decimal}) * ${par}}]
}
set par [expr {round(${par})}]
set cmd "1:16:${cmd_str}:1:U16:${par}"
# wrDecimal hook code ends
if { [hpropexists [sct] geterror] } {
@@ -424,6 +432,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_
hsetprop ${scobj_hpath}/aux/decimal mutable false
hsetprop ${scobj_hpath}/aux/decimal nxsave false
hsetprop ${scobj_hpath}/aux/decimal oldval 0
hset ${scobj_hpath}/aux/decimal 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"