update initialisation and add code to use controller limit function

r3058 | dcl | 2011-02-16 16:31:01 +1100 (Wed, 16 Feb 2011) | 1 line
This commit is contained in:
Douglas Clowes
2011-02-16 16:31:01 +11:00
parent 18a57956b1
commit 84d02dec64

View File

@@ -147,7 +147,7 @@ debug_log "setValue $dev:16:$cmd $par"
if {[hval $tc_root/device_control/power] >= 0} {
set power [hval $tc_root/device_control/power]
} else {
hset $tc_root/device_control/power [hval $tc_root/sensor/value]
hset $tc_root/device_control/power 20.0
set power [hval $tc_root/device_control/power]
debug_log "initialised $tc_root/device_control/power to $power"
}
@@ -235,14 +235,16 @@ debug_log "setValue $dev:16:$cmd $par"
debug_log "rdState $tc_root: driving=$my_driving"
set val [hval $tc_root/setpoint]
debug_log "rdState $tc_root: setpoint=$val"
if {[hpropexists $tc_root/setpoint target]} {
set tgt [SplitReply [hgetprop $tc_root/setpoint target]]
debug_log "rdState $tc_root: target=$tgt"
} else {
hsetprop $tc_root/setpoint target $val
set tgt [SplitReply [hgetprop $tc_root/setpoint target]]
if {![hpropexists $tc_root/setpoint target]} {
set tgt 20.0
hset $tc_root/setpoint $tgt
debug_log "rdState $tc_root: initialised target to: target=$tgt"
}
set tgt [SplitReply [hgetprop $tc_root/setpoint target]]
debug_log "rdState $tc_root: target=$tgt"
if {![hpropexists $tc_root/limit_hi target]} {
hset $tc_root/limit_hi 25.0
}
if {$my_driving > 0} {
set temp [hval $tc_root/samplesensor]
set tol [hval $tc_root/tolerance]
@@ -292,12 +294,19 @@ debug_log "setValue $dev:16:$cmd $par"
sct utime readtime
}
if {![hpropexists $tc_root/setpoint target]} {
hsetprop $tc_root/setpoint target $data
hsetprop $tc_root/setpoint target 20.0
debug_log "getSS initialised $tc_root/setpoint target to: target=$data"
hset $tc_root/device_control/target $data
hset $tc_root/device_control/target 20.0
debug_log "getSS initialised $tc_root/device_control/target to $data"
}
debug_log "getSS $tc_root $nextState $cmd [sct] = $data ($d1 $d2 $d3 $d4)"
for {set i 1} {$i <= 4} {incr i} {
debug_log "getSS Loop $i limit test: [hval $tc_root/Loop$i/limit_state] == 51 && [hval $tc_root/Loop$i/sensor2] < [hval $tc_root/Loop$i/limit_hi]"
if {[hval $tc_root/Loop$i/limit_state] == 51 && [hval $tc_root/Loop$i/sensor2] < ([hval $tc_root/Loop$i/limit_hi] - 2.0)} {
debug_log "getSS Loop $i limit reset)"
hset $tc_root/Loop$i/limit_clear 0
}
}
return idle
}
@@ -369,6 +378,32 @@ debug_log "setValue $dev:16:$cmd $par"
return idle
}
# Get the High Limit Point
proc getLimHi {tc_root nextState cmd} {
set d1 [hval $tc_root/Loop1/limit_hi]
set d2 [hval $tc_root/Loop2/limit_hi]
set d3 [hval $tc_root/Loop3/limit_hi]
set d4 [hval $tc_root/Loop4/limit_hi]
set data [expr {($d1 + $d2 + $d3 + $d4) / 4.0}]
if {$data != [sct oldval]} {
sct oldval $data
sct update $data
sct utime readtime
}
debug_log "getLimHi $tc_root $nextState $cmd [sct] = $data ($d1 $d2 $d3 $d4)"
return idle
}
# Set the High Limit Point
proc setLimHi {tc_root nextState cmd} {
debug_log "setLimHi $tc_root $nextState $cmd [sct]=[sct target] [hget [sct]]"
hset $tc_root/Loop1/limit_hi [sct target]
hset $tc_root/Loop2/limit_hi [sct target]
hset $tc_root/Loop3/limit_hi [sct target]
hset $tc_root/Loop4/limit_hi [sct target]
return idle
}
# Set the All Set Points
proc setAll {tc_root nextState cmd} {
debug_log "setAll $tc_root $nextState $cmd [sct]=[sct target] [hget [sct]]"
@@ -500,6 +535,8 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
set func_name "$rdFunc"
} elseif {$rdFunc == "getSS"} {
set func_name "$rdFunc"
} elseif {$rdFunc == "getLimHi"} {
set func_name "$rdFunc"
} elseif {$rdFunc == "rdFloat"} {
set func_name "getFloat"
} elseif {$rdFunc == "rdTemp"} {
@@ -572,21 +609,34 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
sensor value 1 0 0 float internal {0} {getPV} {0} {} {}\
{} power 1 0 0 float internal {0} {getHP} {0} {} {}\
{} samplesensor 1 0 0 float internal {0} {getSS} {0} {} {}\
{} limit_hi 1 1 0 float user {0} {getLimHi} {0} {setLimHi} {}\
Loop1 setpoint 1 1 0 float user {2160} {rdTemp} {2160} {setTemp} {}\
Loop1 sensor 1 0 0 float internal {1940} {rdTemp} {1940} {} {}\
Loop1 sensor2 1 0 0 float internal { 562} {rdTemp} { 562} {} {}\
Loop1 sensor2 1 0 0 float internal {562} {rdTemp} {562} {} {}\
Loop1 limit_hi 1 1 0 float user {686} {rdTemp} {686} {setTemp} {}\
Loop1 limit_state 1 0 0 int internal {690} {rdValue} {690} {} {}\
Loop1 limit_clear 0 1 0 int user {680} {} {680} {setValue} {}\
Loop1 power 1 0 0 float internal {1900} {rdFloat} {1900} {} {}\
Loop2 setpoint 1 1 0 float user {5160} {rdTemp} {5160} {setTemp} {}\
Loop2 sensor 1 0 0 float internal {4940} {rdTemp} {4940} {} {}\
Loop2 sensor2 1 0 0 float internal {3562} {rdTemp} {3562} {} {}\
Loop2 limit_hi 1 1 0 float user {3686} {rdTemp} {3686} {setTemp} {}\
Loop2 limit_state 1 0 0 int internal {3690} {rdValue} {3690} {} {}\
Loop2 limit_clear 0 1 0 int user {3680} {} {3680} {setValue} {}\
Loop2 power 1 0 0 float internal {4900} {rdFloat} {4900} {} {}\
Loop3 setpoint 1 1 0 float user {8160} {rdTemp} {8160} {setTemp} {}\
Loop3 sensor 1 0 0 float internal {7940} {rdTemp} {7940} {} {}\
Loop3 sensor2 1 0 0 float internal {6562} {rdTemp} {6562} {} {}\
Loop3 limit_hi 1 1 0 float user {6686} {rdTemp} {6686} {setTemp} {}\
Loop3 limit_state 1 0 0 int internal {6690} {rdValue} {6690} {} {}\
Loop3 limit_clear 0 1 0 int user {6680} {} {6680} {setValue} {}\
Loop3 power 1 0 0 float internal {7900} {rdFloat} {7900} {} {}\
Loop4 setpoint 1 1 0 float user {11160} {rdTemp} {11160} {setTemp} {}\
Loop4 sensor 1 0 0 float internal {10940} {rdTemp} {10940} {} {}\
Loop4 sensor2 1 0 0 float internal {9562} {rdTemp} {9562} {} {}\
Loop4 limit_hi 1 1 0 float user {9686} {rdTemp} {9686} {setTemp} {}\
Loop4 limit_state 1 0 0 int internal {9690} {rdValue} {9690} {} {}\
Loop4 limit_clear 0 1 0 int user {9680} {} {9680} {setValue} {}\
Loop4 power 1 0 0 float internal {10900} {rdFloat} {10900} {} {}\
}
@@ -630,17 +680,17 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable\
hfactory $scobj_hpath/device_control plain spy none
hfactory $scobj_hpath/device_control/target plain user float
hset $scobj_hpath/device_control/target -1.0
hset $scobj_hpath/device_control/target 20.0
hfactory $scobj_hpath/device_control/power plain user float
hset $scobj_hpath/device_control/power -1.0
hset $scobj_hpath/device_control/power 0.0
hfactory $scobj_hpath/device_control/previous_error plain user float
hset $scobj_hpath/device_control/previous_error 0.0
hfactory $scobj_hpath/device_control/was_time plain internal int
hset $scobj_hpath/device_control/was_time [clock seconds]
hfactory $scobj_hpath/device_control/Kc plain user float
hset $scobj_hpath/device_control/Kc [expr 1.0]
hset $scobj_hpath/device_control/Kc [expr 6.0]
hfactory $scobj_hpath/device_control/Ti plain user float
hset $scobj_hpath/device_control/Ti [expr 600.0]
hset $scobj_hpath/device_control/Ti [expr 250.0]
hfactory $scobj_hpath/device_control/Auto plain user int
hset $scobj_hpath/device_control/Auto 1
@@ -724,9 +774,9 @@ proc add_watlow_st {name IP port dev_id {_tol 5.0}} {
close $fd
}
puts stdout "file evaluation of sct_watlow_st.tcl"
puts stdout "file evaluation of sct_watlow_st4.tcl"
set fd [open "/tmp/watlow_st.log" w]
puts $fd "file evaluation of sct_watlow_st.tcl"
puts $fd "file evaluation of sct_watlow_st4.tcl"
close $fd
namespace import ::scobj::watlow_st::*