Reworking the Knauer

This commit is contained in:
Douglas Clowes
2014-10-03 14:59:56 +10:00
parent a51ce71999
commit 5ba5af5db8
2 changed files with 1036 additions and 1132 deletions

View File

@@ -10,7 +10,7 @@ driver knauer_pump = {
# #
group dummy = { group dummy = {
type = text; readable = 1; data = false; control = false; nxsave = false; type = text; readable = 1; data = false; control = false; nxsave = false;
var status = { read_command = 'STATUS?'; read_function = read_status; } var status = { read_command = 'STATUS?'; read_function = read_status; property real_data = ' '; }
var glp = { read_command = 'GLP?'; read_function = read_glp; property real_data = ' '; } var glp = { read_command = 'GLP?'; read_function = read_glp; property real_data = ' '; }
} }
@@ -33,69 +33,61 @@ driver knauer_pump = {
read_command = ' '; read_command = ' ';
fetch_function = status_fetch; fetch_function = status_fetch;
} }
var volume_pv = { group volume = {
type = float; var pval = {
readable = 1; type = float;
read_command = ' '; readable = 1;
fetch_function = volume_fetch; read_command = ' ';
fetch_function = volume_fetch;
#checkrange_function = volume_reject; #checkrange_function = volume_reject;
property 'units' = 'mL'; property 'units' = 'mL';
}
var setp = {
type = float;
writeable = 1;
write_command = ' ';
write_function = pump_write;
driveable = pump/volume/pval;
checkstatus_function = pump_checkstatus;
halt_function = pump_halt;
lowerlimit = 0; upperlimit = 100; tolerance = 0.01;
readable = 1;
read_command = ' ';
fetch_function = pump_fetch;
property 'units' = 'mL';
property this_state = 0;
}
} }
var pump_sp = { group ratio = {
type = float; var pval = {
writeable = 1; type = text;
write_command = ' '; readable = 1; read_command = ' '; fetch_function = ratio_fetch;
write_function = pump_write; property 'units' = 'percent';
driveable = pump/volume_pv; }
checkstatus_function = pump_checkstatus; var setp = {
halt_function = pump_halt; type = text;
lowerlimit = 0; upperlimit = 100; tolerance = 0.01; value = '25/25/25/25';
readable = 1; writeable = 1; write_command = ' '; write_function = ratio_write; checkrange_function = ratio_check;
read_command = ' '; property 'units' = 'percent';
fetch_function = pump_fetch; }
property 'units' = 'mL';
property this_state = 0;
} }
var volume_sp = { group flow = {
type = float; var pval = {
writeable = 1; type = float;
write_command = ' '; readable = 1; read_command = ' '; fetch_function = flow_fetch;
write_function = volume_write; property 'units' = 'mL/min';
driveable = pump/volume_pv; }
checkstatus_function = volume_checkstatus; var setp = {
halt_function = volume_halt; type = float;
lowerlimit = 0; upperlimit = 100; tolerance = 0.01; value = 1.0;
readable = 1; writeable = 1; write_command = ' '; write_function = flow_write;
read_command = ' '; lowerlimit = 0; upperlimit = 10;
fetch_function = volume_checkpumping; property 'units' = 'mL/min';
property 'units' = 'mL'; }
}
var ratio_pv = {
type = text;
readable = 1; read_command = ' '; fetch_function = ratios_fetch;
property 'units' = 'percent';
}
var ratio_sp = {
type = text;
value = '25/25/25/25';
writeable = 1; write_command = ' '; write_function = ratios_write; checkrange_function = ratios_check;
property 'units' = 'percent';
}
var flow_pv = {
type = float;
readable = 1; read_command = ' '; fetch_function = flow_fetch;
property 'units' = 'mL/min';
}
var flow_sp = {
type = float;
value = 1.0;
writeable = 1; write_command = ' '; write_function = flow_write;
lowerlimit = 0; upperlimit = 10;
property 'units' = 'mL/min';
} }
} }
group stuff = { group grp_stuff = {
readable = 600; readable = 600;
type = text; type = text;
data = false; control = false; nxsave = false; data = false; control = false; nxsave = false;
@@ -124,7 +116,7 @@ driver knauer_pump = {
var 'units' = { read_command = 'UNITS?'; } var 'units' = { read_command = 'UNITS?'; }
var valves = { read_command = 'VALVES?'; } var valves = { read_command = 'VALVES?'; }
} }
group glp = { group grp_glp = {
type = text; type = text;
readable = 1; readable = 1;
fetch_function = fetch_from_glp; fetch_function = fetch_from_glp;
@@ -142,7 +134,7 @@ driver knauer_pump = {
var pump_pwrhi = { read_command = '12'; } var pump_pwrhi = { read_command = '12'; }
var pump_pwrlo = { read_command = '13'; } var pump_pwrlo = { read_command = '13'; }
} }
group status = { group grp_status = {
type = text; type = text;
readable = 1; readable = 1;
fetch_function = fetch_from_status; fetch_function = fetch_from_status;
@@ -167,6 +159,24 @@ driver knauer_pump = {
var error_in = { read_command = '19'; } var error_in = { read_command = '19'; }
} }
#
# Ensure the pump starts up in REMOTE mode
#
code mkDriver = {%%
hset ${scobj_hpath}/pump/remote 1
%%}
#
# These functions handle the real_data returned by the pump for the GLP? command
#
code read_glp = {%%
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"
}
%%}
code fetch_from_glp = {%% code fetch_from_glp = {%%
set index ${cmd_str} set index ${cmd_str}
set data [hgetpropval ${tc_root}/dummy/glp real_data] set data [hgetpropval ${tc_root}/dummy/glp real_data]
@@ -179,6 +189,15 @@ driver knauer_pump = {
set cmd "@@NOSEND@@" set cmd "@@NOSEND@@"
%%} %%}
#
# These functions handle the real_data returned by the pump for the STATUS? command
#
code read_status = {%%
set dlist [split [lindex [split ${data} ":"] 1] ","]
sct real_data "[join [lrange ${dlist} 0 end] ,]"
set data "Hidden in real_data property"
%%}
code fetch_from_status = {%% code fetch_from_status = {%%
set index ${cmd_str} set index ${cmd_str}
set data [hgetpropval ${tc_root}/dummy/status real_data] set data [hgetpropval ${tc_root}/dummy/status real_data]
@@ -191,19 +210,9 @@ driver knauer_pump = {
set cmd "@@NOSEND@@" set cmd "@@NOSEND@@"
%%} %%}
code read_glp = {%% #
if { [string equal -nocase -length 6 ${data} "ERROR:"] } { # Decode the status from the real_data to PUMPING if it is pumping else IDLE
} else { #
set dlist [split [lindex [split ${data} ":"] 1] ","]
sct real_data "[join [lrange ${dlist} 0 end] ,]"
set data "Hidden in real_data property"
}
%%}
code read_status = {%%
set dlist [split [lindex [split ${data} ":"] 1] ","]
sct real_data "[join [lrange ${dlist} 0 end] ,]"
set data "Hidden in real_data property"
%%}
code status_fetch = {%% code status_fetch = {%%
set index 1 set index 1
set data [hgetpropval ${tc_root}/dummy/status real_data] set data [hgetpropval ${tc_root}/dummy/status real_data]
@@ -216,11 +225,19 @@ driver knauer_pump = {
sct result "IDLE" sct result "IDLE"
} }
%%} %%}
#
# Decode the state from the real_data to one of the documented strings
#
code state_fetch = {%% code state_fetch = {%%
set index 1 set index 1
set data [hgetpropval ${tc_root}/dummy/status real_data] set data [hgetpropval ${tc_root}/dummy/status real_data]
set dlist [split ${data} ","] set dlist [split ${data} ","]
set state_code [lindex ${dlist} ${index}] if { [llength ${dlist}] > ${index} } {
set state_code [lindex ${dlist} ${index}]
} else {
set state_code "0"
}
set cmd "@@NOSEND@@" set cmd "@@NOSEND@@"
if { ${state_code} < 0 || ${state_code} > 9 } { if { ${state_code} < 0 || ${state_code} > 9 } {
sct geterror "Invalid device_state ${state_code}" sct geterror "Invalid device_state ${state_code}"
@@ -239,16 +256,17 @@ driver knauer_pump = {
sct result [lindex ${slist} ${state_code}] sct result [lindex ${slist} ${state_code}]
%%} %%}
code halt = {%% #
set rlist [hval ${tc_root}/pump/ratio_sp] #
set ratio_tgt [join [split ${rlist} /] ,]
set cmd "RAMP:0,0,${ratio_tgt},0,0,0,0,0,0,0,0,2"
%%}
code flow_fetch = {%% code flow_fetch = {%%
set index 4
set data [hgetpropval ${tc_root}/dummy/status real_data] set data [hgetpropval ${tc_root}/dummy/status real_data]
set dlist [split ${data} ","] set dlist [split ${data} ","]
set flow_pv [lindex ${dlist} 4] if { [llength ${dlist}] > ${index} } {
set flow_pv [lindex ${dlist} 4]
} else {
set flow_pv 0.0
}
sct result [expr {0.001 * ${flow_pv}}] sct result [expr {0.001 * ${flow_pv}}]
set cmd "@@NOSEND@@" set cmd "@@NOSEND@@"
%%} %%}
@@ -264,7 +282,9 @@ driver knauer_pump = {
} }
%%} %%}
code ratios_check = {%% #
#
code ratio_check = {%%
set rlist [split ${setpoint} /] set rlist [split ${setpoint} /]
if { [llength ${rlist}] != 4 } { if { [llength ${rlist}] != 4 } {
sct geterror "${setpoint} has [llength ${rlist}] components, needs 4" sct geterror "${setpoint} has [llength ${rlist}] components, needs 4"
@@ -277,14 +297,14 @@ driver knauer_pump = {
} }
%%} %%}
code ratios_fetch = {%% code ratio_fetch = {%%
set data [hgetpropval ${tc_root}/dummy/status real_data] set data [hgetpropval ${tc_root}/dummy/status real_data]
set dlist [split ${data} ","] set dlist [split ${data} ","]
set ratio_vals "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" set ratio_vals "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]"
sct result ${ratio_vals} sct result ${ratio_vals}
set cmd "@@NOSEND@@" set cmd "@@NOSEND@@"
%%} %%}
code ratios_write = {%% code ratio_write = {%%
set data [sct target] set data [sct target]
set cmd "@@NOSEND@@" set cmd "@@NOSEND@@"
set nextState idle set nextState idle
@@ -296,6 +316,8 @@ driver knauer_pump = {
} }
%%} %%}
#
#
code remote_read = {%% code remote_read = {%%
if { [string equal -length 7 ${data} "REMOTE:"] } { if { [string equal -length 7 ${data} "REMOTE:"] } {
set data [lindex [split ${data} :] 1] set data [lindex [split ${data} :] 1]
@@ -313,6 +335,8 @@ driver knauer_pump = {
} }
%%} %%}
#
#
code volume_fetch = {%% code volume_fetch = {%%
set data [hgetpropval ${tc_root}/dummy/glp real_data] set data [hgetpropval ${tc_root}/dummy/glp real_data]
set dlist [split ${data} ","] set dlist [split ${data} ","]
@@ -351,8 +375,8 @@ driver knauer_pump = {
code pump_fetch = {%% code pump_fetch = {%%
if { [sct this_state] > 0 } { if { [sct this_state] > 0 } {
set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow_sp])}] set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow/setp])}]
set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] set ratio_tgt [join [split [hval ${tc_root}/pump/ratio/setp] /] ,]
set time_tgt [expr {int(60000.0 * 1000.0 * [sct target] / ${flow_tgt})}] set time_tgt [expr {int(60000.0 * 1000.0 * [sct target] / ${flow_tgt})}]
set time_1 [expr {${time_tgt} - 500}] set time_1 [expr {${time_tgt} - 500}]
set time_2 [expr {${time_tgt} + 500}] set time_2 [expr {${time_tgt} + 500}]

File diff suppressed because it is too large Load Diff