Reworking the Knauer
This commit is contained in:
@@ -10,7 +10,7 @@ driver knauer_pump = {
|
||||
#
|
||||
group dummy = {
|
||||
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 = ' '; }
|
||||
}
|
||||
|
||||
@@ -33,69 +33,61 @@ driver knauer_pump = {
|
||||
read_command = ' ';
|
||||
fetch_function = status_fetch;
|
||||
}
|
||||
var volume_pv = {
|
||||
type = float;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = volume_fetch;
|
||||
group volume = {
|
||||
var pval = {
|
||||
type = float;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = volume_fetch;
|
||||
#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 = {
|
||||
type = float;
|
||||
writeable = 1;
|
||||
write_command = ' ';
|
||||
write_function = pump_write;
|
||||
driveable = pump/volume_pv;
|
||||
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;
|
||||
group ratio = {
|
||||
var pval = {
|
||||
type = text;
|
||||
readable = 1; read_command = ' '; fetch_function = ratio_fetch;
|
||||
property 'units' = 'percent';
|
||||
}
|
||||
var setp = {
|
||||
type = text;
|
||||
value = '25/25/25/25';
|
||||
writeable = 1; write_command = ' '; write_function = ratio_write; checkrange_function = ratio_check;
|
||||
property 'units' = 'percent';
|
||||
}
|
||||
}
|
||||
var volume_sp = {
|
||||
type = float;
|
||||
writeable = 1;
|
||||
write_command = ' ';
|
||||
write_function = volume_write;
|
||||
driveable = pump/volume_pv;
|
||||
checkstatus_function = volume_checkstatus;
|
||||
halt_function = volume_halt;
|
||||
lowerlimit = 0; upperlimit = 100; tolerance = 0.01;
|
||||
readable = 1;
|
||||
read_command = ' ';
|
||||
fetch_function = volume_checkpumping;
|
||||
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 flow = {
|
||||
var pval = {
|
||||
type = float;
|
||||
readable = 1; read_command = ' '; fetch_function = flow_fetch;
|
||||
property 'units' = 'mL/min';
|
||||
}
|
||||
var setp = {
|
||||
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;
|
||||
type = text;
|
||||
data = false; control = false; nxsave = false;
|
||||
@@ -124,7 +116,7 @@ driver knauer_pump = {
|
||||
var 'units' = { read_command = 'UNITS?'; }
|
||||
var valves = { read_command = 'VALVES?'; }
|
||||
}
|
||||
group glp = {
|
||||
group grp_glp = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
fetch_function = fetch_from_glp;
|
||||
@@ -142,7 +134,7 @@ driver knauer_pump = {
|
||||
var pump_pwrhi = { read_command = '12'; }
|
||||
var pump_pwrlo = { read_command = '13'; }
|
||||
}
|
||||
group status = {
|
||||
group grp_status = {
|
||||
type = text;
|
||||
readable = 1;
|
||||
fetch_function = fetch_from_status;
|
||||
@@ -167,6 +159,24 @@ driver knauer_pump = {
|
||||
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 = {%%
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/glp real_data]
|
||||
@@ -179,6 +189,15 @@ driver knauer_pump = {
|
||||
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 = {%%
|
||||
set index ${cmd_str}
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
@@ -191,19 +210,9 @@ driver knauer_pump = {
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
|
||||
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 read_status = {%%
|
||||
set dlist [split [lindex [split ${data} ":"] 1] ","]
|
||||
sct real_data "[join [lrange ${dlist} 0 end] ,]"
|
||||
set data "Hidden in real_data property"
|
||||
%%}
|
||||
#
|
||||
# Decode the status from the real_data to PUMPING if it is pumping else IDLE
|
||||
#
|
||||
code status_fetch = {%%
|
||||
set index 1
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_data]
|
||||
@@ -216,11 +225,19 @@ driver knauer_pump = {
|
||||
sct result "IDLE"
|
||||
}
|
||||
%%}
|
||||
|
||||
#
|
||||
# Decode the state from the real_data to one of the documented strings
|
||||
#
|
||||
code state_fetch = {%%
|
||||
set index 1
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_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@@"
|
||||
if { ${state_code} < 0 || ${state_code} > 9 } {
|
||||
sct geterror "Invalid device_state ${state_code}"
|
||||
@@ -239,16 +256,17 @@ driver knauer_pump = {
|
||||
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 = {%%
|
||||
set index 4
|
||||
set data [hgetpropval ${tc_root}/dummy/status real_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}}]
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
@@ -264,7 +282,9 @@ driver knauer_pump = {
|
||||
}
|
||||
%%}
|
||||
|
||||
code ratios_check = {%%
|
||||
#
|
||||
#
|
||||
code ratio_check = {%%
|
||||
set rlist [split ${setpoint} /]
|
||||
if { [llength ${rlist}] != 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 dlist [split ${data} ","]
|
||||
set ratio_vals "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]"
|
||||
sct result ${ratio_vals}
|
||||
set cmd "@@NOSEND@@"
|
||||
%%}
|
||||
code ratios_write = {%%
|
||||
code ratio_write = {%%
|
||||
set data [sct target]
|
||||
set cmd "@@NOSEND@@"
|
||||
set nextState idle
|
||||
@@ -296,6 +316,8 @@ driver knauer_pump = {
|
||||
}
|
||||
%%}
|
||||
|
||||
#
|
||||
#
|
||||
code remote_read = {%%
|
||||
if { [string equal -length 7 ${data} "REMOTE:"] } {
|
||||
set data [lindex [split ${data} :] 1]
|
||||
@@ -313,6 +335,8 @@ driver knauer_pump = {
|
||||
}
|
||||
%%}
|
||||
|
||||
#
|
||||
#
|
||||
code volume_fetch = {%%
|
||||
set data [hgetpropval ${tc_root}/dummy/glp real_data]
|
||||
set dlist [split ${data} ","]
|
||||
@@ -351,8 +375,8 @@ driver knauer_pump = {
|
||||
|
||||
code pump_fetch = {%%
|
||||
if { [sct this_state] > 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 flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow/setp])}]
|
||||
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_1 [expr {${time_tgt} - 500}]
|
||||
set time_2 [expr {${time_tgt} + 500}]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user