Regen SCT drivers
This commit is contained in:
@@ -92,7 +92,11 @@ proc ::scobj::knauer_pump::fetch_from_glp {tc_root nextState cmd_str} {
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/glp real_data]
|
||||
set dlist [split ${data} ","]
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
if { [llength ${dlist}] > ${index} } {
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
} else {
|
||||
sct result ""
|
||||
}
|
||||
set cmd "@@NOSEND@@"
|
||||
# fetch_from_glp hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
@@ -120,7 +124,11 @@ proc ::scobj::knauer_pump::fetch_from_status {tc_root nextState cmd_str} {
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
if { [llength ${dlist}] > ${index} } {
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
} else {
|
||||
sct result ""
|
||||
}
|
||||
set cmd "@@NOSEND@@"
|
||||
# fetch_from_status hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
@@ -374,9 +382,12 @@ proc ::scobj::knauer_pump::read_glp {tc_root} {
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# read_glp hook code starts
|
||||
set dlist [split [lindex [split ${data} ":"] 1] ","]
|
||||
sct real_data "[join [lrange ${dlist} 0 end] ,]"
|
||||
set data "Hidden in real_data property"
|
||||
if { [string equal -nocase -length 6 ${data} "ERROR:"] } {
|
||||
} else {
|
||||
set dlist [split [lindex [split ${data} ":"] 1] ","]
|
||||
sct real_data "[join [lrange ${dlist} 0 end] ,]"
|
||||
set data "Hidden in real_data property"
|
||||
}
|
||||
# read_glp hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
@@ -427,6 +438,77 @@ proc ::scobj::knauer_pump::read_status {tc_root} {
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to parse the read of a parameter on a device
|
||||
proc ::scobj::knauer_pump::remote_read {tc_root} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "remote_read tc_root=${tc_root} sct=[sct] result=[sct result]"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set data [sct result]
|
||||
set nextState "idle"
|
||||
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
|
||||
# the protocol driver has reported an error
|
||||
sct geterror "${data}"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# remote_read hook code starts
|
||||
if { [string equal -length 7 ${data} "REMOTE:"] } {
|
||||
set data [lindex [split ${data} :] 1]
|
||||
} else {
|
||||
sct geterror "bad response"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
# remote_read hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::knauer_pump::remote_write {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "remote_write tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
set par [sct target]
|
||||
set cmd "${cmd_str}${par}"
|
||||
# remote_write hook code starts
|
||||
if { ${par} == 0 } {
|
||||
set cmd "LOCAL"
|
||||
} else {
|
||||
set cmd "REMOTE"
|
||||
}
|
||||
# remote_write hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
error "[sct geterror]"
|
||||
}
|
||||
if { [hpropexists [sct] driving] } {
|
||||
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
|
||||
sct driving 1
|
||||
}
|
||||
}
|
||||
debug_log ${tc_root} 1 "remote_write sct send ${cmd}"
|
||||
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
|
||||
sct send "${cmd}"
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
}
|
||||
|
||||
# function to write a parameter value on a device
|
||||
proc ::scobj::knauer_pump::setValue {tc_root nextState cmd_str} {
|
||||
set catch_status [ catch {
|
||||
@@ -549,6 +631,7 @@ proc ::scobj::knauer_pump::volume_checkpumping {tc_root nextState cmd_str} {
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,]
|
||||
set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2"
|
||||
set nextState noResponse
|
||||
sct driving 0
|
||||
sct pumping 0
|
||||
}
|
||||
}
|
||||
@@ -621,10 +704,10 @@ proc ::scobj::knauer_pump::volume_fetch {tc_root nextState cmd_str} {
|
||||
sct raw_volume ${pump_volume}
|
||||
if { [hpropexists [sct] base_volume] } {
|
||||
set pump_volume [expr {${pump_volume} - [sct base_volume]}]
|
||||
} else {
|
||||
} elseif { [hpropexists [sct] raw_volume] } {
|
||||
sct base_volume [sct raw_volume]
|
||||
}
|
||||
sct result ${pump_volume}
|
||||
sct result [format "%.2f" ${pump_volume}]
|
||||
set cmd "@@NOSEND@@"
|
||||
# volume_fetch hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
@@ -673,6 +756,13 @@ proc ::scobj::knauer_pump::volume_write {tc_root nextState cmd_str} {
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,]
|
||||
set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,3"
|
||||
sct pumping 1
|
||||
set data ${par}
|
||||
if { ${data} != [sct oldval] } {
|
||||
debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]"
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
# volume_write hook code ends
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
|
||||
@@ -717,6 +807,7 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
|
||||
hsetprop ${scobj_hpath}/dummy/glp mutable true
|
||||
hsetprop ${scobj_hpath}/dummy/glp nxsave false
|
||||
hsetprop ${scobj_hpath}/dummy/glp oldval UNKNOWN
|
||||
hsetprop ${scobj_hpath}/dummy/glp real_data " "
|
||||
hsetprop ${scobj_hpath}/dummy/glp sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/dummy/glp type "part"
|
||||
hsetprop ${scobj_hpath}/dummy/glp nxalias "${name}_dummy_glp"
|
||||
@@ -1077,6 +1168,22 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
|
||||
hsetprop ${scobj_hpath}/pump/ratio_sp units "percent"
|
||||
hsetprop ${scobj_hpath}/pump/ratio_sp nxalias "${name}_pump_ratio_sp"
|
||||
|
||||
hfactory ${scobj_hpath}/pump/remote plain user int
|
||||
hsetprop ${scobj_hpath}/pump/remote read ${ns}::getValue ${scobj_hpath} remote_read {REMOTE?}
|
||||
hsetprop ${scobj_hpath}/pump/remote remote_read ${ns}::remote_read ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/pump/remote write ${ns}::remote_write ${scobj_hpath} noResponse {}
|
||||
hsetprop ${scobj_hpath}/pump/remote noResponse ${ns}::noResponse ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/pump/remote check ${ns}::checkrange ${scobj_hpath}
|
||||
hsetprop ${scobj_hpath}/pump/remote control true
|
||||
hsetprop ${scobj_hpath}/pump/remote data true
|
||||
hsetprop ${scobj_hpath}/pump/remote mutable true
|
||||
hsetprop ${scobj_hpath}/pump/remote nxsave true
|
||||
hsetprop ${scobj_hpath}/pump/remote oldval 0
|
||||
hsetprop ${scobj_hpath}/pump/remote klass "parameter"
|
||||
hsetprop ${scobj_hpath}/pump/remote sdsinfo "::nexus::scobj::sdsinfo"
|
||||
hsetprop ${scobj_hpath}/pump/remote type "part"
|
||||
hsetprop ${scobj_hpath}/pump/remote nxalias "${name}_pump_remote"
|
||||
|
||||
hfactory ${scobj_hpath}/pump/state plain user text
|
||||
hsetprop ${scobj_hpath}/pump/state read ${ns}::state_fetch ${scobj_hpath} rdValue { }
|
||||
hsetprop ${scobj_hpath}/pump/state rdValue ${ns}::rdValue ${scobj_hpath}
|
||||
@@ -1145,12 +1252,14 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio
|
||||
if {[string equal -nocase "${simulation_flag}" "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/pump/flow_pv 1
|
||||
${sct_controller} poll ${scobj_hpath}/pump/ratio_pv 1
|
||||
${sct_controller} poll ${scobj_hpath}/pump/remote 1
|
||||
${sct_controller} poll ${scobj_hpath}/pump/state 1
|
||||
${sct_controller} poll ${scobj_hpath}/pump/status 1
|
||||
${sct_controller} poll ${scobj_hpath}/pump/volume_pv 1
|
||||
${sct_controller} poll ${scobj_hpath}/pump/volume_sp 1
|
||||
${sct_controller} write ${scobj_hpath}/pump/flow_sp
|
||||
${sct_controller} write ${scobj_hpath}/pump/ratio_sp
|
||||
${sct_controller} write ${scobj_hpath}/pump/remote
|
||||
${sct_controller} write ${scobj_hpath}/pump/volume_sp
|
||||
} else {
|
||||
::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump"
|
||||
|
||||
Reference in New Issue
Block a user