Reasonably working Knauer pump driver
This commit is contained in:
@ -39,21 +39,20 @@ driver knauer_pump = {
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = volume_fetch;
|
||||
#checkrange_function = volume_reject;
|
||||
property 'units' = 'mL';
|
||||
}
|
||||
var setp = {
|
||||
type = float;
|
||||
writeable = 1;
|
||||
write_command = ' ';
|
||||
write_function = pump_write;
|
||||
write_function = volume_write;
|
||||
driveable = pump/volume/pval;
|
||||
checkstatus_function = pump_checkstatus;
|
||||
halt_function = pump_halt;
|
||||
checkstatus_function = volume_checkstatus;
|
||||
halt_function = volume_halt;
|
||||
lowerlimit = 0; upperlimit = 100; tolerance = 0.01;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = pump_fetch;
|
||||
fetch_function = volume_fsm;
|
||||
property 'units' = 'mL';
|
||||
property this_state = 0;
|
||||
}
|
||||
@ -81,84 +80,12 @@ driver knauer_pump = {
|
||||
type = float;
|
||||
value = 1.0;
|
||||
writeable = 1; write_command = ' '; write_function = flow_write;
|
||||
lowerlimit = 0; upperlimit = 10;
|
||||
lowerlimit = 0; upperlimit = 9.999;
|
||||
property 'units' = 'mL/min';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
group grp_stuff = {
|
||||
readable = 600;
|
||||
type = text;
|
||||
data = false; control = false; nxsave = false;
|
||||
var an_out = { read_command = 'AN_OUT?'; }
|
||||
var boardinfo = { read_command = 'BOARDINFO?'; }
|
||||
var config = { read_command = 'CONFIG?'; }
|
||||
var cprofinfo = { read_command = 'CPROFINFO?'; }
|
||||
var dout = { read_command = 'DOUT?'; }
|
||||
var error = { read_command = 'ERROR?'; }
|
||||
var errors = { read_command = 'ERRORS?'; }
|
||||
var flushpmp = { read_command = 'FLUSHPMP?'; }
|
||||
var head = { read_command = 'HEAD?'; }
|
||||
var head_par = { read_command = 'HEAD_PAR?'; }
|
||||
var identify = { read_command = 'IDENTIFY?'; }
|
||||
var lpg = { read_command = 'LPG?'; }
|
||||
var oem = { read_command = 'OEM?'; }
|
||||
var opt = { read_command = 'OPT?'; }
|
||||
var plim = { read_command = 'PLIM?'; }
|
||||
var pressure = { read_command = 'PRESSURE?'; }
|
||||
var prfastacq = { read_command = 'PRFASTACQ?'; }
|
||||
var purge = { read_command = 'PURGE?'; }
|
||||
var remote = { read_command = 'REMOTE?'; }
|
||||
var rfid = { read_command = 'RFID?'; }
|
||||
var service = { read_command = 'SERVICE?'; }
|
||||
var sysinfo = { read_command = 'SYSINFO?'; }
|
||||
var 'units' = { read_command = 'UNITS?'; }
|
||||
var valves = { read_command = 'VALVES?'; }
|
||||
}
|
||||
group grp_glp = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
fetch_function = fetch_from_glp;
|
||||
var board_time = { read_command = '0'; }
|
||||
var motor_time = { read_command = '1'; }
|
||||
var head_count = { read_command = '3'; }
|
||||
var head_time = { read_command = '4'; }
|
||||
var head_volm = { read_command = '5'; }
|
||||
var head_voln = { read_command = '6'; }
|
||||
var head_pwrhi = { read_command = '7'; }
|
||||
var head_pwrlo = { read_command = '8'; }
|
||||
var pump_revs = { read_command = '9'; }
|
||||
var pump_volm = { read_command = '10'; }
|
||||
var pump_voln = { read_command = '11'; }
|
||||
var pump_pwrhi = { read_command = '12'; }
|
||||
var pump_pwrlo = { read_command = '13'; }
|
||||
}
|
||||
group grp_status = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
fetch_function = fetch_from_status;
|
||||
var state = { read_command = '1'; }
|
||||
var cur_error = { read_command = '2'; }
|
||||
var cur_run_time = { read_command = '3'; }
|
||||
var flow_rate = { read_command = '4'; }
|
||||
var lpg_0 = { read_command = '5'; }
|
||||
var lpg_1 = { read_command = '6'; }
|
||||
var lpg_2 = { read_command = '7'; }
|
||||
var lpg_3 = { read_command = '8'; }
|
||||
var evt_0 = { read_command = '9'; }
|
||||
var evt_1 = { read_command = '10'; }
|
||||
var evt_2 = { read_command = '11'; }
|
||||
var evt_3 = { read_command = '12'; }
|
||||
var evt_4 = { read_command = '13'; }
|
||||
var evt_5 = { read_command = '14'; }
|
||||
var evt_6 = { read_command = '15'; }
|
||||
var evt_7 = { read_command = '16'; }
|
||||
var cur_pres = { read_command = '17'; }
|
||||
var start_in = { read_command = '18'; }
|
||||
var error_in = { read_command = '19'; }
|
||||
}
|
||||
|
||||
#
|
||||
# Ensure the pump starts up in REMOTE mode
|
||||
#
|
||||
@ -177,18 +104,6 @@ driver knauer_pump = {
|
||||
}
|
||||
%%}
|
||||
|
||||
code fetch_from_glp = {%%
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/glp real_data]
|
||||
set dlist [split ${data} ","]
|
||||
if { [llength ${dlist}] > ${index} } {
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
} else {
|
||||
sct result ""
|
||||
}
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
|
||||
#
|
||||
# These functions handle the real_data returned by the pump for the STATUS? command
|
||||
#
|
||||
@ -198,18 +113,6 @@ driver knauer_pump = {
|
||||
set data "Hidden in real_data property"
|
||||
%%}
|
||||
|
||||
code fetch_from_status = {%%
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
set dlist [split ${data} ","]
|
||||
if { [llength ${dlist}] > ${index} } {
|
||||
sct result [lindex ${dlist} ${index}]
|
||||
} else {
|
||||
sct result ""
|
||||
}
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
|
||||
#
|
||||
# Decode the status from the real_data to PUMPING if it is pumping else IDLE
|
||||
#
|
||||
@ -250,6 +153,7 @@ driver knauer_pump = {
|
||||
"SYS_ST_HOLD" \
|
||||
"SYS_ST_PURGE" \
|
||||
"SYS_ST_STANDBY" \
|
||||
"SYS_ST_SEVEN" \
|
||||
"SYS_ST_FAILED" \
|
||||
"SYS_ST_RUNATEND" \
|
||||
]
|
||||
@ -357,8 +261,7 @@ driver knauer_pump = {
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
|
||||
##########
|
||||
code pump_write = {%%
|
||||
code volume_write = {%%
|
||||
hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume]
|
||||
hset ${tc_root}/[sct driveable] 0.0
|
||||
set cmd "REMOTE"
|
||||
@ -373,7 +276,7 @@ driver knauer_pump = {
|
||||
}
|
||||
%%}
|
||||
|
||||
code pump_fetch = {%%
|
||||
code volume_fsm = {%%
|
||||
if { [sct this_state] > 0 } {
|
||||
set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow/setp])}]
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio/setp] /] ,]
|
||||
@ -396,6 +299,12 @@ driver knauer_pump = {
|
||||
} elseif { [sct this_state] == 5 } {
|
||||
set cmd "START:1,0"
|
||||
sct this_state 0
|
||||
} elseif { [sct this_state] == 91 } {
|
||||
set cmd "STOP:1,0"
|
||||
sct this_state 92
|
||||
} elseif { [sct this_state] == 92 } {
|
||||
set cmd "STOP:0,0"
|
||||
sct this_state 0
|
||||
} else {
|
||||
sct this_state 0
|
||||
set cmd "@@NOSEND@@"
|
||||
@ -405,15 +314,13 @@ driver knauer_pump = {
|
||||
set cmd "@@NOSEND@@"
|
||||
set nextState idle
|
||||
if { [hpropexists [sct] pumping] && [sct pumping] } {
|
||||
if { [hpropexists [sct] driving] && [sct driving] } {
|
||||
pump_checkstatus "${tc_root}"
|
||||
}
|
||||
set new_value [hval ${tc_root}/pump/status]
|
||||
set old_value [sct oldval]
|
||||
if {${new_value} != ${old_value}} {
|
||||
sct oldval ${new_value}
|
||||
if {${old_value} == "PUMPING" && ${new_value} == "IDLE"} {
|
||||
set cmd "STOP"
|
||||
set cmd "STOP:0,0"
|
||||
sct this_state 91
|
||||
set nextState noResponse
|
||||
sct result ""
|
||||
sct driving 0
|
||||
@ -424,59 +331,11 @@ driver knauer_pump = {
|
||||
}
|
||||
%%}
|
||||
|
||||
code pump_halt = {%%
|
||||
set flow_tgt 0
|
||||
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,]
|
||||
set cmd "STOP"
|
||||
sct send ${cmd}
|
||||
%%}
|
||||
##########
|
||||
code volume_write = {%%
|
||||
hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume]
|
||||
hset ${tc_root}/[sct driveable] 0.0
|
||||
set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow_sp])}]
|
||||
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
|
||||
}
|
||||
%%}
|
||||
|
||||
code volume_checkpumping = {%%
|
||||
set cmd "@@NOSEND@@"
|
||||
set nextState idle
|
||||
if { [hpropexists [sct] pumping] && [sct pumping] } {
|
||||
if { [hpropexists [sct] driving] && [sct driving] } {
|
||||
volume_checkstatus "${tc_root}"
|
||||
}
|
||||
set sp "[sct target]"
|
||||
set pv "[hval ${tc_root}/[sct driveable]]"
|
||||
if { (${sp} - ${pv}) <= [sct tolerance] } {
|
||||
set flow_tgt 0
|
||||
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 result ""
|
||||
sct driving 0
|
||||
sct pumping 0
|
||||
}
|
||||
}
|
||||
%%}
|
||||
|
||||
code volume_halt = {%%
|
||||
set flow_tgt 0
|
||||
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 cmd "STOP:0,0"
|
||||
sct this_state 91
|
||||
debug_log ${tc_root} 1 "volume_halt sct send ${cmd}"
|
||||
sct send ${cmd}
|
||||
%%}
|
||||
|
||||
code volume_reject = {%%
|
||||
sct geterror "cannot use hset on [sct]"
|
||||
error "[sct geterror]"
|
||||
%%}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user