WIP update
r3104 | dcl | 2011-04-18 14:42:07 +1000 (Mon, 18 Apr 2011) | 1 line
This commit is contained in:
@@ -98,12 +98,15 @@ debug_log "rdTemp [sct] [sct result]"
|
|||||||
debug_log "scan [string range $data 3 6] %4x data"
|
debug_log "scan [string range $data 3 6] %4x data"
|
||||||
set rslt [scan [string range $data 3 6] %4x data]
|
set rslt [scan [string range $data 3 6] %4x data]
|
||||||
# ANSTO special temp
|
# ANSTO special temp
|
||||||
set data [expr {0.1 * $data}]
|
set data [format "%.1f" [expr {0.1 * $data}]]
|
||||||
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
|
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
|
||||||
if {$data != [sct oldval]} {
|
if {"$data" ne "[sct oldval]"} {
|
||||||
|
debug_log "$data != [sct oldval] => [expr {"$data" != "[sct oldval]"}]"
|
||||||
|
debug_log "$data == [sct oldval] => [expr {"$data" == "[sct oldval]"}]"
|
||||||
sct oldval $data
|
sct oldval $data
|
||||||
sct update $data
|
sct update $data
|
||||||
sct utime readtime
|
sct utime readtime
|
||||||
|
debug_log "update result data=$data, oldval=[sct oldval]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -198,6 +201,7 @@ debug_log "rdPower [sct] [sct result]"
|
|||||||
} else {
|
} else {
|
||||||
debug_log "scan [string range $data 3 4] %4x data"
|
debug_log "scan [string range $data 3 4] %4x data"
|
||||||
set rslt [scan [string range $data 3 4] %4x data]
|
set rslt [scan [string range $data 3 4] %4x data]
|
||||||
|
set data [expr {$data - 0x80}]
|
||||||
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
|
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
|
||||||
if {$data != [sct oldval]} {
|
if {$data != [sct oldval]} {
|
||||||
sct oldval $data
|
sct oldval $data
|
||||||
@@ -242,8 +246,11 @@ debug_log "rdVisc [sct] [sct result]"
|
|||||||
} else {
|
} else {
|
||||||
debug_log "scan [string range $data 3 8] %6x data"
|
debug_log "scan [string range $data 3 8] %6x data"
|
||||||
set rslt [scan [string range $data 3 8] %6x data]
|
set rslt [scan [string range $data 3 8] %6x data]
|
||||||
|
if {$data > 0x7FFFFF} {
|
||||||
|
set data [expr {$data - 0x1000000}]
|
||||||
|
}
|
||||||
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
|
debug_log "scan result rslt=$rslt, data=$data, oldval=[sct oldval]"
|
||||||
if {$data != [sct oldval]} {
|
if {"$data" ne "[sct oldval]"} {
|
||||||
sct oldval $data
|
sct oldval $data
|
||||||
sct update $data
|
sct update $data
|
||||||
sct utime readtime
|
sct utime readtime
|
||||||
@@ -254,42 +261,32 @@ debug_log "rdVisc [sct] [sct result]"
|
|||||||
return idle
|
return idle
|
||||||
}
|
}
|
||||||
|
|
||||||
proc getState {tc_root nextState cmd} {
|
#
|
||||||
|
# Send a command for the state/substate
|
||||||
|
#
|
||||||
|
proc getState {tc_root nextState} {
|
||||||
|
debug_log "getState $tc_root $nextState sct=[sct] state=[sct my_state] substate=[sct my_substate]"
|
||||||
if { [hpropexists [sct] geterror] } {
|
if { [hpropexists [sct] geterror] } {
|
||||||
hdelprop [sct] geterror
|
hdelprop [sct] geterror
|
||||||
}
|
}
|
||||||
debug_log "getState $tc_root $nextState $cmd sct=[sct]"
|
|
||||||
if {[ catch {
|
if {[ catch {
|
||||||
set my_state [SplitReply [hgetprop $tc_root/device_state state]]
|
set my_state [sct my_state]
|
||||||
set my_substate [SplitReply [hgetprop $tc_root/device_state substate]]
|
set my_substate [sct my_substate]
|
||||||
if {$my_state == "STATE_LT"} {
|
if {$my_state == "STATE_INIT"} {
|
||||||
set my_cmd "LT..."
|
|
||||||
} elseif {$my_state == "STATE_RT"} {
|
|
||||||
set my_cmd "RTF"
|
|
||||||
} elseif {$my_state == "STATE_RD"} {
|
|
||||||
set my_cmd "RD..."
|
|
||||||
} elseif {$my_state == "STATE_LOAD"} {
|
|
||||||
set my_cmd "RTC"
|
|
||||||
} elseif {$my_state == "STATE_LOADED"} {
|
|
||||||
set my_cmd "RTC"
|
|
||||||
} elseif {$my_state == "STATE_LOADING"} {
|
|
||||||
set table [split " " [SplitReply [hgetprop $tc_root/device_state profile_table]]]
|
|
||||||
set tablen [llength $table]
|
|
||||||
if {$my_substate < 0 || $my_substate >= $tablen} {
|
|
||||||
# TODO ERROR handling
|
|
||||||
}
|
|
||||||
set my_cmd [lindex $table $my_substate]
|
|
||||||
} elseif {$my_state == "STATE_INIT"} {
|
|
||||||
if {$my_substate == 0} {
|
if {$my_substate == 0} {
|
||||||
set my_cmd "SEC04"
|
set my_cmd "SEC04"
|
||||||
} elseif {$my_substate == 1} {
|
} elseif {$my_substate == 1} {
|
||||||
set my_cmd "RSV"
|
set my_cmd "RSV"
|
||||||
} elseif {$my_substate == 2} {
|
} elseif {$my_substate == 2} {
|
||||||
set my_cmd "STT..."
|
set my_cmd "STT00FA"
|
||||||
}
|
}
|
||||||
|
} elseif {$my_state == "STATE_TEST"} {
|
||||||
|
set my_cmd "RD[sct last]"
|
||||||
|
} elseif {$my_state == "STATE_IDLE"} {
|
||||||
|
set my_cmd "RD000000"
|
||||||
} else {
|
} else {
|
||||||
hsetprop $tc_root/device_state state "STATE_INIT"
|
sct my_state "STATE_INIT"
|
||||||
hsetprop $tc_root/device_state substate "0"
|
sct my_substate "0"
|
||||||
set my_cmd "SEC04"
|
set my_cmd "SEC04"
|
||||||
}
|
}
|
||||||
sct send "$my_cmd"
|
sct send "$my_cmd"
|
||||||
@@ -302,101 +299,125 @@ debug_log "rdVisc [sct] [sct result]"
|
|||||||
##
|
##
|
||||||
# @brief Reads the current newport state and error messages.
|
# @brief Reads the current newport state and error messages.
|
||||||
proc rdState {tc_root} {
|
proc rdState {tc_root} {
|
||||||
debug_log "rdState [sct] [sct result]"
|
debug_log "rdState [sct] [sct result]"
|
||||||
|
set nextState "idle"
|
||||||
set data [sct result]
|
set data [sct result]
|
||||||
set my_driving [SplitReply [hgetprop $tc_root/setpoint driving]]
|
if {[string first "ASCERR:" $data] >=0} {
|
||||||
debug_log "rdState $tc_root: driving=$my_driving, result=$data"
|
sct geterror $data
|
||||||
if {[ catch {
|
} elseif {[ catch {
|
||||||
set my_state [SplitReply [hgetprop $tc_root/device_state my_state]]
|
set my_state [sct my_state]
|
||||||
if {$my_state == "STATE_LT"} {
|
set my_substate [sct my_substate]
|
||||||
set parts [split [sct result] " "]
|
if {$my_state == "STATE_INIT"} {
|
||||||
if {[llength $parts] == 2 && [lindex $parts end] == "LT00" && [string range [lindex $parts 0] 0 1] == "TL"} {
|
if {"$my_substate" == "0"} {
|
||||||
set index [string range [lindex $parts 0] 2 3]
|
sct my_substate 1
|
||||||
|
} elseif {"$my_substate" == "1"} {
|
||||||
|
set parts [split [sct result] " "]
|
||||||
|
sct my_substate 2
|
||||||
|
} elseif {"$my_substate" == "2"} {
|
||||||
|
sct my_state "STATE_IDLE"
|
||||||
|
sct my_substate 0
|
||||||
} else {
|
} else {
|
||||||
debug_log "Load Table error: [sct result]"
|
sct my_substate 0
|
||||||
}
|
}
|
||||||
} elseif {$my_state == "STATE_RT"} {
|
} elseif {$my_state == "STATE_IDLE"} {
|
||||||
set parts [split [sct result] " "]
|
set parts [split [sct result] " "]
|
||||||
if {[llength $parts] >= 2 && [lindex $parts end] == "RT00"} {
|
if {[llength $parts] == 2} {
|
||||||
set parts [lreplace $parts end end]
|
set data [lindex $parts 0]
|
||||||
# TODO process the data
|
set stts [lindex $parts 1]
|
||||||
} else {
|
if {"$stts" == "RD00"} {
|
||||||
debug_log "Read Table error: [sct result]"
|
debug_log "scan $data DR%6x%4x%6x%2x%4x%2x the_t the_c the_v the_e the_s the_r"
|
||||||
}
|
set rslt [scan $data "DR%6x%4x%6x%2x%4x%2x" the_t the_c the_v the_e the_s the_r]
|
||||||
} elseif {$my_state == "STATE_RD"} {
|
debug_log "scan result rslt=$rslt, the_t=$the_t , the_c=$the_c , the_v=$the_v , the_e=$the_e , the_s=$the_s , the_r=$the_r"
|
||||||
set parts [split [sct result] " "]
|
if {$rslt == 6} {
|
||||||
if {[llength $parts] >= 2 && [lindex $parts end] == "RD00"} {
|
# TODO handle test start
|
||||||
set parts [lreplace $parts end end]
|
if {$the_r != 0} {
|
||||||
debug_log "scan [lindex $parts 0] DR%6x%4x%6x%2x%4x%2x the_t the_c the_v the_e the_s the_r"
|
sct test_time [clock seconds]
|
||||||
set rslt [scan [lindex $parts 0] "DR%6x%4x%6x%2x%4x%2x" the_t the_c the_v the_e the_s the_r]
|
set file_name [hval $tc_root/profile]
|
||||||
debug_log "scan result rslt=$rslt, the_t=$the_t , the_c=$the_c , the_v=$the_v , the_e=$the_e , the_s=$the_s , the_r=$the_r"
|
debug_log "file: $file_name"
|
||||||
if {$rslt == 6} {
|
set file_name [file tail [file rootname $file_name]]
|
||||||
# TODO process the data and increment through to list?
|
debug_log "file: $file_name"
|
||||||
|
set file_name "[file normalize "../log/${file_name}_[clock format [sct test_time] -format "%Y%m%d%H%M%S"]"]"
|
||||||
|
debug_log "file: ${file_name}"
|
||||||
|
sct datafile "${file_name}"
|
||||||
|
set f [open "[sct datafile].txt" "w"]
|
||||||
|
puts $f "SRY[clock format [sct test_time] -format "%d%m%Y"]"
|
||||||
|
puts $f "SRO[clock format [sct test_time] -format "%H%M%S"]"
|
||||||
|
close $f
|
||||||
|
set f [open "[sct datafile].csv" "w"]
|
||||||
|
puts $f "Time,Temp,Visc,Heat,Speed"
|
||||||
|
close $f
|
||||||
|
sct my_state "STATE_TEST"
|
||||||
|
sct last "000000"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug_log "Read Data format error: [sct result]"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_log "Read Data format error: [sct result]"
|
debug_log "Read Data status error: [sct result]"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_log "Read Data error: [sct result]"
|
debug_log "Read Data response error: [sct result]"
|
||||||
}
|
}
|
||||||
} elseif {$my_state == "STATE_INIT"} {
|
} elseif {"$my_state" == "STATE_TEST"} {
|
||||||
set parts [split [sct result] " "]
|
set parts [split [sct result] " "]
|
||||||
if {[llength $parts] == 2 && [lindex $parts end] == "RD00"} {
|
if {[llength $parts] == 2} {
|
||||||
set parts [lreplace $parts end end]
|
set data [lindex $parts 0]
|
||||||
debug_log "scan [lindex $parts 0] DR%6x%4x%6x%2x%4x%2x the_t the_c the_v the_e the_s the_r"
|
set stts [lindex $parts 1]
|
||||||
set rslt [scan [lindex $parts 0] "DR%6x%4x%6x%2x%4x%2x" the_t the_c the_v the_e the_s the_r]
|
if {"$stts" == "RD00"} {
|
||||||
debug_log "scan result rslt=$rslt, the_t=$the_t , the_c=$the_c , the_v=$the_v , the_e=$the_e , the_s=$the_s , the_r=$the_r"
|
debug_log "scan $data DR%6x%4x%6x%2x%4x%2x the_t the_c the_v the_e the_s the_r"
|
||||||
if {$rslt == 6} {
|
set rslt [scan $data "DR%6x%4x%6x%2x%4x%2x" the_t the_c the_v the_e the_s the_r]
|
||||||
# TODO handle the data, test start, test end
|
debug_log "scan result rslt=$rslt, the_t=$the_t , the_c=$the_c , the_v=$the_v , the_e=$the_e , the_s=$the_s , the_r=$the_r"
|
||||||
sct print "[lindex $parts 0]"
|
if {$rslt == 6} {
|
||||||
|
# process the data and increment through list
|
||||||
|
if {"[string range $data 2 7]" ne "[sct last]"} {
|
||||||
|
sct last [string range $data 2 7]
|
||||||
|
# write last data
|
||||||
|
set f [open "[sct datafile].txt" "a"]
|
||||||
|
puts $f "$data"
|
||||||
|
close $f
|
||||||
|
set f [open "[sct datafile].csv" "a"]
|
||||||
|
set my_time [expr {[sct test_time] + int($the_t / 45.0)}]
|
||||||
|
set my_temp [expr {0.1 * $the_c}]
|
||||||
|
if {$the_v > 0x7FFFFF} {
|
||||||
|
set my_visc [expr {$the_v - 0x1000000}]
|
||||||
|
} else {
|
||||||
|
set my_visc [expr {$the_v}]
|
||||||
|
}
|
||||||
|
set my_heat [expr {$the_e - 0x80}]
|
||||||
|
set my_speed [expr {$the_s}]
|
||||||
|
puts $f "[clock format $my_time -format "%Y-%m-%d %H:%M:%S"],$my_temp,$my_visc,$my_heat,$my_speed"
|
||||||
|
close $f
|
||||||
|
set nextState "idle"
|
||||||
|
}
|
||||||
|
if {$the_r == 0} {
|
||||||
|
sct my_state "STATE_IDLE"
|
||||||
|
sct my_substate 0
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
debug_log "Read Data format error: [sct result]"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_log "Read Data format error: [sct result]"
|
debug_log "Read Data status error: [sct result]"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug_log "Read Data error: [sct result]"
|
debug_log "Read Data response error: [sct result]"
|
||||||
}
|
}
|
||||||
} elseif {$my_state == "STATE_LOAD"} {
|
|
||||||
# TODO
|
|
||||||
hsetprop $tc_root/device_state state "STATE_LOADING"
|
|
||||||
hsetprop $tc_root/device_state substate "0"
|
|
||||||
return read
|
|
||||||
} elseif {$my_state == "STATE_LOADING"} {
|
|
||||||
# TODO
|
|
||||||
set my_substate [SplitReply [hgetprop $tc_root/device_state substate]]
|
|
||||||
set table [split " " [SplitReply [hgetprop $tc_root/device_state profile_table]]]
|
|
||||||
set tablen [llength $table]
|
|
||||||
if {$my_substate < 0 || $my_substate >= $tablen} {
|
|
||||||
# TODO ERROR handling
|
|
||||||
} elseif {$my_substate == $tablen} {
|
|
||||||
hsetprop $tc_root/device_state state "STATE_LOADED"
|
|
||||||
hsetprop $tc_root/device_state substate "0"
|
|
||||||
} else {
|
|
||||||
hsetprop $tc_root/device_state substate [expr {[SplitReply [hgetprop $tc_root/device_state substate]] + 1}]
|
|
||||||
}
|
|
||||||
return read
|
|
||||||
} elseif {$my_state == "STATE_LOADED"} {
|
|
||||||
# TODO
|
|
||||||
hsetprop $tc_root/device_state state "STATE_LOADING"
|
|
||||||
hsetprop $tc_root/device_state substate "0"
|
|
||||||
return read
|
|
||||||
} else {
|
} else {
|
||||||
hsetprop $tc_root/device_state state "STATE_IDLE"
|
sct my_state "STATE_IDLE"
|
||||||
hsetprop $tc_root/device_state substate "0"
|
sct my_substate "0"
|
||||||
return idle
|
set nextState "idle"
|
||||||
}
|
}
|
||||||
} catch_message ]} {
|
} catch_message ]} {
|
||||||
debug_log "getState error: $catch_message"
|
debug_log "getState error: $catch_message"
|
||||||
}
|
}
|
||||||
|
|
||||||
set data [SplitReply [hgetprop $tc_root/setpoint driving]]
|
if {[sct my_state] != [sct oldval]} {
|
||||||
debug_log "rdState $tc_root: result=$data"
|
sct oldval [sct my_state]
|
||||||
if {[string first "ASCERR:" $data] >=0} {
|
sct update [sct my_state]
|
||||||
sct geterror $data
|
|
||||||
} elseif {$data != [sct oldval]} {
|
|
||||||
sct oldval $data
|
|
||||||
sct update $data
|
|
||||||
sct utime readtime
|
sct utime readtime
|
||||||
}
|
}
|
||||||
return idle
|
return $nextState
|
||||||
}
|
}
|
||||||
|
|
||||||
proc getHP {tc_root nextState cmd} {
|
proc getHP {tc_root nextState cmd} {
|
||||||
@@ -437,41 +458,37 @@ debug_log "setPoint $cmd $par"
|
|||||||
proc setProf {tc_root nextState cmd} {
|
proc setProf {tc_root nextState cmd} {
|
||||||
debug_log "setProf $tc_root [sct] [sct target]"
|
debug_log "setProf $tc_root [sct] [sct target]"
|
||||||
sct print "setProf $tc_root [sct] [sct target]"
|
sct print "setProf $tc_root [sct] [sct target]"
|
||||||
sct print "Value: [hval [sct]]"
|
|
||||||
sct print "Props: [hlistprop [sct]]"
|
|
||||||
set my_index [sct index]
|
set my_index [sct index]
|
||||||
if { [hpropexists [sct] geterror] } {
|
if { [hpropexists [sct] geterror] } {
|
||||||
hdelprop [sct] geterror
|
hdelprop [sct] geterror
|
||||||
}
|
}
|
||||||
if {$my_index < 0} {
|
if {$my_index < 0} {
|
||||||
if {"[sct target]" != "[hval [sct]]"} {
|
set lines [list]
|
||||||
set lines [list]
|
if {[file exists "[sct target]"] && [file readable "[sct target]"]} {
|
||||||
if {[file exists "[sct target]"] && [file readable "[sct target]"]} {
|
sct print "opening [file normalize "[sct target]"]"
|
||||||
sct print "opening [file normalize "[sct target]"]"
|
set f [open "[sct target]"]
|
||||||
set f [open "[sct target]"]
|
while {1} {
|
||||||
while {1} {
|
set line [gets $f]
|
||||||
set line [gets $f]
|
if {[eof $f]} {
|
||||||
if {[eof $f]} {
|
close $f
|
||||||
close $f
|
break
|
||||||
break
|
|
||||||
}
|
|
||||||
if {[string range $line 0 1] != "LT"} {
|
|
||||||
sct geterror "Profile error: $line"
|
|
||||||
sct print "Profile error: $line"
|
|
||||||
close $f
|
|
||||||
return idle
|
|
||||||
}
|
|
||||||
lappend lines $line
|
|
||||||
}
|
}
|
||||||
sct profile "[join $lines " "]"
|
if {[string range $line 0 1] != "LT"} {
|
||||||
sct oldval [sct target]
|
sct geterror "Profile error: $line"
|
||||||
sct update [sct target]
|
sct print "Profile error: $line"
|
||||||
sct utime readtime
|
close $f
|
||||||
} else {
|
return idle
|
||||||
sct geterror "file [sct target] is [file normalize "[sct target]"], exists: [file exists "[sct target]"], readable: [file readable "[sct target]"]"
|
}
|
||||||
sct print "file [sct target] is [file normalize "[sct target]"], exists: [file exists "[sct target]"], readable: [file readable "[sct target]"]"
|
lappend lines $line
|
||||||
return idle
|
|
||||||
}
|
}
|
||||||
|
sct profile "[join $lines " "]"
|
||||||
|
sct oldval [sct target]
|
||||||
|
sct update [sct target]
|
||||||
|
sct utime readtime
|
||||||
|
} else {
|
||||||
|
sct geterror "file [sct target] is [file normalize "[sct target]"], exists: [file exists "[sct target]"], readable: [file readable "[sct target]"]"
|
||||||
|
sct print "file [sct target] is [file normalize "[sct target]"], exists: [file exists "[sct target]"], readable: [file readable "[sct target]"]"
|
||||||
|
return idle
|
||||||
}
|
}
|
||||||
sct send "RTC"
|
sct send "RTC"
|
||||||
} else {
|
} else {
|
||||||
@@ -503,10 +520,98 @@ debug_log "setPoint $cmd $par"
|
|||||||
sct index $my_index
|
sct index $my_index
|
||||||
if {$my_index > [llength $my_list]} {
|
if {$my_index > [llength $my_list]} {
|
||||||
sct index -1
|
sct index -1
|
||||||
|
return "idle"
|
||||||
|
}
|
||||||
|
return "write"
|
||||||
|
}
|
||||||
|
|
||||||
|
proc setTest {tc_root nextState cmd} {
|
||||||
|
debug_log "setTest $tc_root [sct] [sct target]"
|
||||||
|
sct print "setTest $tc_root [sct] [sct target]"
|
||||||
|
set data [sct target]
|
||||||
|
if {$data != 0} {
|
||||||
|
sct update 0
|
||||||
|
sct send "SEC01"
|
||||||
|
sct print "sct send \"SEC01\""
|
||||||
|
} else {
|
||||||
|
sct update 0
|
||||||
|
sct utime readtime
|
||||||
|
sct send "RD000000"
|
||||||
|
#sct print "sct send \"RD000000\""
|
||||||
|
sct last "000000"
|
||||||
|
}
|
||||||
|
return $nextState
|
||||||
|
}
|
||||||
|
|
||||||
|
proc ackTest {tc_root} {
|
||||||
|
debug_log "ackTest $tc_root [sct] [sct target]"
|
||||||
|
set data [sct result]
|
||||||
|
set ts [string range $data 2 7]
|
||||||
|
if {[sct target] != 0} {
|
||||||
return idle
|
return idle
|
||||||
}
|
}
|
||||||
set my_item [lindex $my_list $my_index]
|
if {$ts == [sct last]} {
|
||||||
return write
|
return idle
|
||||||
|
} else {
|
||||||
|
sct print "[lindex [split "$data" " "] 0]"
|
||||||
|
sct last $ts
|
||||||
|
sct send "RD$ts"
|
||||||
|
#sct print "sct send \"RD$ts\""
|
||||||
|
return ackTest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
proc rdTest {tc_root} {
|
||||||
|
debug_log "rdTest [sct] [sct result]"
|
||||||
|
set data [sct result]
|
||||||
|
switch -glob -- $data {
|
||||||
|
"ASCERR:*" {
|
||||||
|
sct geterror $data
|
||||||
|
}
|
||||||
|
default {
|
||||||
|
if { [hpropexists [sct] geterror] } {
|
||||||
|
hdelprop [sct] geterror
|
||||||
|
}
|
||||||
|
set flist [split $data " "]
|
||||||
|
if {[llength $flist] != 2} {
|
||||||
|
sct geterror "Field error: expected two fields, received $data"
|
||||||
|
return idle
|
||||||
|
}
|
||||||
|
set data [lindex $flist 0]
|
||||||
|
set stts [lindex $flist 1]
|
||||||
|
if {[string length $stts] != 4} {
|
||||||
|
sct geterror "Length error: expected RDxx but received $data"
|
||||||
|
} elseif {[string range $stts 0 1] != "RD"} {
|
||||||
|
sct geterror "Unexpected status: expected RDxx but received $stts"
|
||||||
|
} elseif {![string is xdigit [string range $stts 2 3]]} {
|
||||||
|
sct geterror "Hexadecimal error: expected RDxx but received $data"
|
||||||
|
} elseif {[string length $data] != 26} {
|
||||||
|
sct geterror "Length error: expected DRttttttccccvvvvvveessssrr but received $data"
|
||||||
|
} elseif {[string range $data 0 1] != "DR"} {
|
||||||
|
sct geterror "Unexpected response: expected DRttttttccccvvvvvveessssrr but received $data"
|
||||||
|
} elseif {![string is xdigit [string range $data 24 25]]} {
|
||||||
|
sct geterror "Hexadecimal error: expected DRttttttccccvvvvvveessssrr but received $data"
|
||||||
|
} else {
|
||||||
|
debug_log "scan $data DR%6x%4x%6x%2x%4x%2x the_t the_c the_v the_e the_s the_r"
|
||||||
|
set rslt [scan $data "DR%6x%4x%6x%2x%4x%2x" the_t the_c the_v the_e the_s the_r]
|
||||||
|
debug_log "scan result rslt=$rslt, the_t=$the_t , the_c=$the_c , the_v=$the_v , the_e=$the_e , the_s=$the_s , the_r=$the_r"
|
||||||
|
if {$rslt == 6} {
|
||||||
|
# TODO handle test start
|
||||||
|
if {$the_r != 0} {
|
||||||
|
set data 1
|
||||||
|
} else {
|
||||||
|
set data 0
|
||||||
|
}
|
||||||
|
if {$data != [sct oldval]} {
|
||||||
|
sct oldval $data
|
||||||
|
sct update $data
|
||||||
|
sct utime readtime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return idle
|
||||||
}
|
}
|
||||||
|
|
||||||
proc chkWrite {tc_root} {
|
proc chkWrite {tc_root} {
|
||||||
@@ -691,7 +796,8 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
|
|||||||
{} speed 1 1 0 float user {RSR} {rdSpeed} {0} {setSpeed.chkWrite} {}\
|
{} speed 1 1 0 float user {RSR} {rdSpeed} {0} {setSpeed.chkWrite} {}\
|
||||||
{} power 1 0 0 float internal {RSC} {rdPower} {0} {} {}\
|
{} power 1 0 0 float internal {RSC} {rdPower} {0} {} {}\
|
||||||
{} viscosity 1 0 0 float internal {RSI} {rdVisc} {0} {} {}\
|
{} viscosity 1 0 0 float internal {RSI} {rdVisc} {0} {} {}\
|
||||||
{} profile 0 1 0 text user {RTF} {rdProf} {0} {setProf.ackProf} {}\
|
{} profile 0 1 0 text user {} {} {0} {setProf.ackProf} {}\
|
||||||
|
{} test 1 1 0 text user {RD000000} {rdTest} {0} {setTest.ackTest} {}\
|
||||||
}
|
}
|
||||||
|
|
||||||
hfactory $scobj_hpath/sensor plain spy none
|
hfactory $scobj_hpath/sensor plain spy none
|
||||||
@@ -721,11 +827,11 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
|
|||||||
hsetprop $scobj_hpath/status values busy,idle
|
hsetprop $scobj_hpath/status values busy,idle
|
||||||
|
|
||||||
hfactory $scobj_hpath/device_state plain spy text
|
hfactory $scobj_hpath/device_state plain spy text
|
||||||
hsetprop $scobj_hpath/device_state read ${ns}::getState $scobj_hpath rdState "NOT USED"
|
hsetprop $scobj_hpath/device_state read ${ns}::getState $scobj_hpath rdState
|
||||||
hsetprop $scobj_hpath/device_state rdState ${ns}::rdState $scobj_hpath
|
hsetprop $scobj_hpath/device_state rdState ${ns}::rdState $scobj_hpath
|
||||||
hsetprop $scobj_hpath/device_state oldval UNKNOWN
|
hsetprop $scobj_hpath/device_state oldval UNKNOWN
|
||||||
hsetprop $scobj_hpath/device_state state "STATE_INIT"
|
hsetprop $scobj_hpath/device_state my_state "STATE_INIT"
|
||||||
hsetprop $scobj_hpath/device_state substate "0"
|
hsetprop $scobj_hpath/device_state my_substate "0"
|
||||||
hsetprop $scobj_hpath/device_state profile_table ""
|
hsetprop $scobj_hpath/device_state profile_table ""
|
||||||
|
|
||||||
hfactory $scobj_hpath/remote_ctrl plain spy text
|
hfactory $scobj_hpath/remote_ctrl plain spy text
|
||||||
@@ -754,6 +860,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
|
|||||||
hsetprop $scobj_hpath/profile index -1
|
hsetprop $scobj_hpath/profile index -1
|
||||||
|
|
||||||
if {[SplitReply [environment_simulation]]=="false"} {
|
if {[SplitReply [environment_simulation]]=="false"} {
|
||||||
|
debug_log "Registering node $scobj_hpath/device_state for poll at 1 seconds"
|
||||||
$sct_controller poll $scobj_hpath/device_state 1 halt read
|
$sct_controller poll $scobj_hpath/device_state 1 halt read
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user