From db80d30cc203ea89e94e28c34b29bc6c9a5a0252 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Wed, 27 Apr 2011 11:11:00 +1000 Subject: [PATCH] Revert code so that the "driving" status is set by the tcl setpoint procedure. The "inTolerance" script only resets the "driving" flag after the setpoint has been sent, ie after "writestatus" transitions to the sent state. The "checktol" script now compares the sensor reading against the setpoint "target" value instead of the setpoint reading from the lakeshore, this should allow the drive command to work properly if ramping has been enabled on the lakeshore r3115 | ffr | 2011-04-27 11:11:00 +1000 (Wed, 27 Apr 2011) | 3 lines --- .../temperature/sct_lakeshore_336.tcl | 16 +++++++++------- .../temperature/sct_lakeshore_340.tcl | 16 +++++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_336.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_336.tcl index 2b1f3665..12b94151 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_336.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_336.tcl @@ -710,7 +710,8 @@ proc inTolerance {CtrlLoopIdx} { set cmpIdString [string compare -length 13 $data "LSCI,MODEL336"] } if {$cmpIdString == 0 } { - if [ hgetpropval $tc_root/sensor/setpoint$CtrlLoopIdx setpoint_pending ] { + set wrStatus [ hgetpropval $tc_root/sensor/setpoint$CtrlLoopIdx writestatus ] + if {$wrStatus == "start"} { continue } # set nodename $tc_root/control/config_Loop_$CtrlLoopIdx @@ -903,12 +904,11 @@ proc setPoint {tc_root nextState cmd whichCtrlLoop} { # Called by drive adapter # puts "setPoint(): driving set to 1" set nodename $tc_root/sensor/setpoint$whichCtrlLoop + hsetprop $nodename driving 1 } #puts "setPoint(wrStatus=$wrStatus): sct send $cmd$par" sct send "$cmd$par" - sct setpoint_pending 0 } message ]} { - hsetprop $nodename driving 0 return -code error "in setPoint: $message. Last write command: $::scobj::ls336::ls336_lastWriteCmd" } return $nextState @@ -1087,7 +1087,12 @@ proc checktol {tc_root currtime timecheck iLoop iSensor} { set sensorValue $tc_root/sensor/sensorValue$iSensor set temp [hval $sensorValue] set isetp $tc_root/sensor/setpoint$iLoop - set setpt [hval $isetp] + if [hpropexists $isetp "target"] { + set setpt [hgetpropval $isetp "target"] + } else { + hset $tc_root/emon/isInTolerance_Lp$iLoop "inTolerance" + return 1 + } set tol [hval $tc_root/control/tolerance1] if {$iLoop == 2 } { set tol [hval $tc_root/control/tolerance2] @@ -1179,10 +1184,8 @@ proc check {tc_root whichCtrlLoop} { } } } message ]} { - sct driving 0 return -code error "in check(): $message. Last write command: $::scobj::ls336::ls336_lastWriteCmd" } - sct setpoint_pending 1 return OK } @@ -1734,7 +1737,6 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p hsetprop $nodeName checklimits ${ns}::check $scobj_hpath $idx hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath hsetprop $nodeName halt ${ns}::halt $scobj_hpath $idx - hsetprop $nodeName setpoint_pending 0 } } message ]} { return -code error "in createNode $message" diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl index 4db6084a..a5440afa 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl @@ -710,7 +710,8 @@ proc inTolerance {CtrlLoopIdx} { set cmpIdString [string compare -length 13 $data "LSCI,MODEL336"] } if {$cmpIdString == 0 } { - if [ hgetpropval $tc_root/sensor/setpoint$CtrlLoopIdx setpoint_pending ] { + set wrStatus [ hgetpropval $tc_root/sensor/setpoint$CtrlLoopIdx writestatus ] + if {$wrStatus == "start"} { continue } # set nodename $tc_root/control/config_Loop_$CtrlLoopIdx @@ -903,12 +904,11 @@ proc setPoint {tc_root nextState cmd whichCtrlLoop} { # Called by drive adapter # puts "setPoint(): driving set to 1" set nodename $tc_root/sensor/setpoint$whichCtrlLoop + hsetprop $nodename driving 1 } #puts "setPoint(wrStatus=$wrStatus): sct send $cmd$par" sct send "$cmd$par" - sct setpoint_pending 0 } message ]} { - hsetprop $nodename driving 0 return -code error "in setPoint: $message. Last write command: $::scobj::ls340::ls340_lastWriteCmd" } return $nextState @@ -1087,7 +1087,12 @@ proc checktol {tc_root currtime timecheck iLoop iSensor} { set sensorValue $tc_root/sensor/sensorValue$iSensor set temp [hval $sensorValue] set isetp $tc_root/sensor/setpoint$iLoop - set setpt [hval $isetp] + if [hpropexists $isetp "target"] { + set setpt [hgetpropval $isetp "target"] + } else { + hset $tc_root/emon/isInTolerance_Lp$iLoop "inTolerance" + return 1 + } set tol [hval $tc_root/control/tolerance1] if {$iLoop == 2 } { set tol [hval $tc_root/control/tolerance2] @@ -1179,10 +1184,8 @@ proc check {tc_root whichCtrlLoop} { } } } message ]} { - sct driving 0 return -code error "in check(): $message. Last write command: $::scobj::ls340::ls340_lastWriteCmd" } - sct setpoint_pending 1 return OK } @@ -1734,7 +1737,6 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p hsetprop $nodeName checklimits ${ns}::check $scobj_hpath $idx hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath hsetprop $nodeName halt ${ns}::halt $scobj_hpath $idx - hsetprop $nodeName setpoint_pending 0 } } message ]} { return -code error "in createNode $message"