Add voltage, status and "end-of-driving"
r3731 | dcl | 2012-09-03 09:03:12 +1000 (Mon, 03 Sep 2012) | 1 line
This commit is contained in:
@@ -15,12 +15,12 @@ namespace eval ::scobj::green_magnet {
|
||||
|
||||
# issue a command with a value in the target property of the variable
|
||||
proc setPoint {tc_root nextState cmd} {
|
||||
debug_log "setPoint: cmd=$cmd sct=[sct] $tc_root"
|
||||
debug_log "setPoint: nextState=$nextState, cmd=$cmd, sct=[sct] $tc_root"
|
||||
set par "[sct target]"
|
||||
sct send "s $par"
|
||||
sct send "s $par\r\n?"
|
||||
debug_log "setPoint: write \"s $par\""
|
||||
sct driving 1
|
||||
sct time_check [clock seconds]
|
||||
debug_log "setPoint: write $cmd$par"
|
||||
if {$par != [sct oldval]} {
|
||||
sct oldval $par
|
||||
sct update [sct target]
|
||||
@@ -36,7 +36,7 @@ namespace eval ::scobj::green_magnet {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
debug_log "getValue $cmd sct=[sct] root=$tc_root nextState=$nextState"
|
||||
sct send "?"
|
||||
sct send "$cmd"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace eval ::scobj::green_magnet {
|
||||
}
|
||||
|
||||
proc noResponse {} {
|
||||
debug_log "noResponse"
|
||||
return idle
|
||||
}
|
||||
|
||||
@@ -95,12 +96,16 @@ namespace eval ::scobj::green_magnet {
|
||||
set hifield [expr {[hval $tc_root/setpoint] + [hval $tc_root/tolerance]}]
|
||||
debug_log "checktol: field = $field, lofield = $lofield, hifield = $hifield"
|
||||
if { $field < $lofield || $field > $hifield} {
|
||||
hset $tc_root/emon/isintol 0
|
||||
if {[hval $tc_root/emon/isintol] != 0} {
|
||||
hset $tc_root/emon/isintol 0
|
||||
}
|
||||
set rslt 0
|
||||
} else {
|
||||
set timeout [hval $tc_root/tolerance/settletime]
|
||||
if { ($currtime - $timecheck) > $timeout } {
|
||||
hset $tc_root/emon/isintol 1
|
||||
if {[hval $tc_root/emon/isintol] != 1} {
|
||||
hset $tc_root/emon/isintol 1
|
||||
}
|
||||
}
|
||||
set rslt 1
|
||||
}
|
||||
@@ -115,10 +120,16 @@ namespace eval ::scobj::green_magnet {
|
||||
# only call this when writestatus!="start"
|
||||
proc drivestatus {tc_root} {
|
||||
if {[sct driving]} {
|
||||
if {[hval $tc_root/drive_state] == "HALT"} {
|
||||
hset $tc_root/drive_state ""
|
||||
hsetprop $tc_root/setpoint driving 0
|
||||
return idle
|
||||
}
|
||||
set intol [checktol $tc_root [clock seconds] [sct time_check]]
|
||||
if {$intol == 0} {
|
||||
sct time_check [clock seconds]
|
||||
} else {
|
||||
}
|
||||
if {[hval $tc_root/emon/isintol] == 1} {
|
||||
sct driving 0
|
||||
}
|
||||
return busy
|
||||
@@ -231,7 +242,9 @@ namespace eval ::scobj::green_magnet {
|
||||
|
||||
set deviceCommand {\
|
||||
{} setpoint 0 1 1 float user {} {} {} {setPoint} {}\
|
||||
sensor value 1 0 0 float internal {} {rdValue} {} {} {}\
|
||||
sensor value 1 0 0 float internal {?} {rdValue} {} {} {}\
|
||||
{} status 1 0 0 text internal {t} {rdValue} {} {} {}\
|
||||
{} voltage 1 0 0 text internal {v} {rdValue} {} {} {}\
|
||||
}
|
||||
|
||||
hfactory $scobj_hpath/sensor plain spy none
|
||||
@@ -308,8 +321,8 @@ namespace eval ::scobj::green_magnet {
|
||||
proc add_green_magnet {name IP port {_tol 5.0}} {
|
||||
set fd [open "/tmp/green_magnet.log" a]
|
||||
if {[SplitReply [magnetic_simulation]]=="false"} {
|
||||
puts $fd "makesctcontroller green_magnet std ${IP}:$port"
|
||||
makesctcontroller green_magnet std ${IP}:$port
|
||||
puts $fd "makesctcontroller green_magnet std ${IP}:$port \"\r\n\""
|
||||
makesctcontroller green_magnet std ${IP}:$port "\r\n"
|
||||
}
|
||||
puts $fd "mk_sct_green_magnet green_magnet environment $name $_tol"
|
||||
mk_sct_green_magnet green_magnet environment $name $_tol
|
||||
|
||||
Reference in New Issue
Block a user