Implement "settle_time" in generated drivers

This commit is contained in:
Douglas Clowes
2014-03-19 13:44:04 +11:00
parent 0581b2b8e1
commit 8964750835
3 changed files with 34 additions and 2 deletions

View File

@ -74,6 +74,7 @@ driver hiden_xcs = {
property pid_ivalue = 0.1 property pid_ivalue = 0.1
property pid_dvalue = 0.0 property pid_dvalue = 0.0
property pid_imax = 30 property pid_imax = 30
property settle_time = 5.250
} }
var gas_factor = { value = 1.0; } var gas_factor = { value = 1.0; }
control = false control = false

View File

@ -77,10 +77,25 @@ proc ::scobj::hiden_xcs::checkstatus {tc_root} {
if {[sct driving]} { if {[sct driving]} {
set sp "[sct target]" set sp "[sct target]"
set pv "[hval ${tc_root}/[sct driveable]]" set pv "[hval ${tc_root}/[sct driveable]]"
if { ${pv} > ${sp} - [sct tolerance] && ${pv} < ${sp} + [sct tolerance] } { if { abs(${pv} - ${sp}) <= [sct tolerance] } {
if { [hpropexists [sct] settle_time] } {
if { [hpropexists [sct] settle_time_start] } {
if { [sct utime] - [sct settle_time_start] >= [sct settle_time]} {
sct driving 0
return "idle"
}
return "busy"
} else {
sct utime settle_time_start
return "busy"
}
}
sct driving 0 sct driving 0
return "idle" return "idle"
} }
if { [hpropexists [sct] settle_time_start] } {
hdelprop [sct] settle_time_start
}
return "busy" return "busy"
} else { } else {
return "idle" return "idle"
@ -819,6 +834,7 @@ proc ::scobj::hiden_xcs::mk_sct_hiden_xcs { sct_controller name tol } {
hsetprop ${scobj_hpath}/humidity pid_ivalue "0.1" hsetprop ${scobj_hpath}/humidity pid_ivalue "0.1"
hsetprop ${scobj_hpath}/humidity pid_pvalue "0.2" hsetprop ${scobj_hpath}/humidity pid_pvalue "0.2"
hsetprop ${scobj_hpath}/humidity sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/humidity sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/humidity settle_time "5.25"
hsetprop ${scobj_hpath}/humidity type "drivable" hsetprop ${scobj_hpath}/humidity type "drivable"
hsetprop ${scobj_hpath}/humidity nxalias "${name}_humidity" hsetprop ${scobj_hpath}/humidity nxalias "${name}_humidity"

View File

@ -967,10 +967,25 @@ def put_checkstatus_function(MyDriver, func):
txt += [' if {[sct driving]} {'] txt += [' if {[sct driving]} {']
txt += [' set sp "[sct target]"'] txt += [' set sp "[sct target]"']
txt += [' set pv "[hval ${tc_root}/[sct driveable]]"'] txt += [' set pv "[hval ${tc_root}/[sct driveable]]"']
txt += [' if { ${pv} > ${sp} - [sct tolerance] && ${pv} < ${sp} + [sct tolerance] } {'] txt += [' if { abs(${pv} - ${sp}) <= [sct tolerance] } {']
txt += [' if { [hpropexists [sct] settle_time] } {']
txt += [' if { [hpropexists [sct] settle_time_start] } {']
txt += [' if { [sct utime] - [sct settle_time_start] >= [sct settle_time]} {']
txt += [' sct driving 0']
txt += [' return "idle"']
txt += [' }']
txt += [' return "busy"']
txt += [' } else {']
txt += [' sct utime settle_time_start']
txt += [' return "busy"']
txt += [' }']
txt += [' }']
txt += [' sct driving 0'] txt += [' sct driving 0']
txt += [' return "idle"'] txt += [' return "idle"']
txt += [' }'] txt += [' }']
txt += [' if { [hpropexists [sct] settle_time_start] } {']
txt += [' hdelprop [sct] settle_time_start']
txt += [' }']
txt += [' return "busy"'] txt += [' return "busy"']
txt += [' } else {'] txt += [' } else {']
txt += [' return "idle"'] txt += [' return "idle"']