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
|
# issue a command with a value in the target property of the variable
|
||||||
proc setPoint {tc_root nextState cmd} {
|
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]"
|
set par "[sct target]"
|
||||||
sct send "s $par"
|
sct send "s $par\r\n?"
|
||||||
|
debug_log "setPoint: write \"s $par\""
|
||||||
sct driving 1
|
sct driving 1
|
||||||
sct time_check [clock seconds]
|
sct time_check [clock seconds]
|
||||||
debug_log "setPoint: write $cmd$par"
|
|
||||||
if {$par != [sct oldval]} {
|
if {$par != [sct oldval]} {
|
||||||
sct oldval $par
|
sct oldval $par
|
||||||
sct update [sct target]
|
sct update [sct target]
|
||||||
@@ -36,7 +36,7 @@ namespace eval ::scobj::green_magnet {
|
|||||||
hdelprop [sct] geterror
|
hdelprop [sct] geterror
|
||||||
}
|
}
|
||||||
debug_log "getValue $cmd sct=[sct] root=$tc_root nextState=$nextState"
|
debug_log "getValue $cmd sct=[sct] root=$tc_root nextState=$nextState"
|
||||||
sct send "?"
|
sct send "$cmd"
|
||||||
return $nextState
|
return $nextState
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +71,7 @@ namespace eval ::scobj::green_magnet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc noResponse {} {
|
proc noResponse {} {
|
||||||
|
debug_log "noResponse"
|
||||||
return idle
|
return idle
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,13 +96,17 @@ namespace eval ::scobj::green_magnet {
|
|||||||
set hifield [expr {[hval $tc_root/setpoint] + [hval $tc_root/tolerance]}]
|
set hifield [expr {[hval $tc_root/setpoint] + [hval $tc_root/tolerance]}]
|
||||||
debug_log "checktol: field = $field, lofield = $lofield, hifield = $hifield"
|
debug_log "checktol: field = $field, lofield = $lofield, hifield = $hifield"
|
||||||
if { $field < $lofield || $field > $hifield} {
|
if { $field < $lofield || $field > $hifield} {
|
||||||
|
if {[hval $tc_root/emon/isintol] != 0} {
|
||||||
hset $tc_root/emon/isintol 0
|
hset $tc_root/emon/isintol 0
|
||||||
|
}
|
||||||
set rslt 0
|
set rslt 0
|
||||||
} else {
|
} else {
|
||||||
set timeout [hval $tc_root/tolerance/settletime]
|
set timeout [hval $tc_root/tolerance/settletime]
|
||||||
if { ($currtime - $timecheck) > $timeout } {
|
if { ($currtime - $timecheck) > $timeout } {
|
||||||
|
if {[hval $tc_root/emon/isintol] != 1} {
|
||||||
hset $tc_root/emon/isintol 1
|
hset $tc_root/emon/isintol 1
|
||||||
}
|
}
|
||||||
|
}
|
||||||
set rslt 1
|
set rslt 1
|
||||||
}
|
}
|
||||||
debug_log "checktol: result = $rslt"
|
debug_log "checktol: result = $rslt"
|
||||||
@@ -115,10 +120,16 @@ namespace eval ::scobj::green_magnet {
|
|||||||
# only call this when writestatus!="start"
|
# only call this when writestatus!="start"
|
||||||
proc drivestatus {tc_root} {
|
proc drivestatus {tc_root} {
|
||||||
if {[sct driving]} {
|
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]]
|
set intol [checktol $tc_root [clock seconds] [sct time_check]]
|
||||||
if {$intol == 0} {
|
if {$intol == 0} {
|
||||||
sct time_check [clock seconds]
|
sct time_check [clock seconds]
|
||||||
} else {
|
}
|
||||||
|
if {[hval $tc_root/emon/isintol] == 1} {
|
||||||
sct driving 0
|
sct driving 0
|
||||||
}
|
}
|
||||||
return busy
|
return busy
|
||||||
@@ -231,7 +242,9 @@ namespace eval ::scobj::green_magnet {
|
|||||||
|
|
||||||
set deviceCommand {\
|
set deviceCommand {\
|
||||||
{} setpoint 0 1 1 float user {} {} {} {setPoint} {}\
|
{} 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
|
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}} {
|
proc add_green_magnet {name IP port {_tol 5.0}} {
|
||||||
set fd [open "/tmp/green_magnet.log" a]
|
set fd [open "/tmp/green_magnet.log" a]
|
||||||
if {[SplitReply [magnetic_simulation]]=="false"} {
|
if {[SplitReply [magnetic_simulation]]=="false"} {
|
||||||
puts $fd "makesctcontroller green_magnet std ${IP}:$port"
|
puts $fd "makesctcontroller green_magnet std ${IP}:$port \"\r\n\""
|
||||||
makesctcontroller green_magnet std ${IP}:$port
|
makesctcontroller green_magnet std ${IP}:$port "\r\n"
|
||||||
}
|
}
|
||||||
puts $fd "mk_sct_green_magnet green_magnet environment $name $_tol"
|
puts $fd "mk_sct_green_magnet green_magnet environment $name $_tol"
|
||||||
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