Separate out the PID related code into pid_function blocks
This commit is contained in:
@ -188,10 +188,14 @@ driver hiden_xcs = {
|
|||||||
@ }
|
@ }
|
||||||
@ if { [hpropexists [sct] target] } {
|
@ if { [hpropexists [sct] target] } {
|
||||||
@ set pid [pid_humidity ${tc_root} [sct target] ${data}]
|
@ set pid [pid_humidity ${tc_root} [sct target] ${data}]
|
||||||
|
}
|
||||||
|
code pid_function pid_humidity = {
|
||||||
@ set path [pathname [sct]]
|
@ set path [pathname [sct]]
|
||||||
|
@ set sign 1
|
||||||
@ foreach node [list analog/sp1 analog/sp2] {
|
@ foreach node [list analog/sp1 analog/sp2] {
|
||||||
@ set pid [expr -${pid}]
|
@ set sign [expr -${sign}]
|
||||||
@ hsetprop ${path}/${node} bias_humidity ${pid}
|
@ set signed_pid [expr ${sign} * ${pid}]
|
||||||
|
@ hsetprop ${path}/${node} bias_humidity ${signed_pid}
|
||||||
@ if { [hpropexists ${path}/${node} target] } {
|
@ if { [hpropexists ${path}/${node} target] } {
|
||||||
@ hset ${path}/${node} [hgetpropval ${path}/${node} target]
|
@ hset ${path}/${node} [hgetpropval ${path}/${node} target]
|
||||||
@ } else {
|
@ } else {
|
||||||
@ -214,6 +218,11 @@ driver hiden_xcs = {
|
|||||||
@ sct targets ${targets}
|
@ sct targets ${targets}
|
||||||
@ if { [hpropexists [sct] target] } {
|
@ if { [hpropexists [sct] target] } {
|
||||||
@ set pid [pid_flow ${tc_root} [sct target] ${data}]
|
@ set pid [pid_flow ${tc_root} [sct target] ${data}]
|
||||||
|
@# cut this function short
|
||||||
|
@ return ${nextState}
|
||||||
|
}
|
||||||
|
code pid_function pid_flow = {
|
||||||
|
@ set path [pathname [sct]]
|
||||||
@ foreach node [list analog/sp1 analog/sp2] {
|
@ foreach node [list analog/sp1 analog/sp2] {
|
||||||
@ hsetprop ${path}/${node} bias_flow ${pid}
|
@ hsetprop ${path}/${node} bias_flow ${pid}
|
||||||
@ if { [hpropexists ${path}/${node} target] } {
|
@ if { [hpropexists ${path}/${node} target] } {
|
||||||
@ -223,7 +232,6 @@ driver hiden_xcs = {
|
|||||||
@ }
|
@ }
|
||||||
@ }
|
@ }
|
||||||
@ }
|
@ }
|
||||||
@ return ${nextState}
|
|
||||||
}
|
}
|
||||||
code write_function write_digital = {
|
code write_function write_digital = {
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user