Major revision of the Knauer pump driver

This commit is contained in:
Douglas Clowes
2014-10-07 15:03:28 +11:00
parent 591c602da2
commit a51ce71999
2 changed files with 321 additions and 119 deletions

View File

@@ -1,6 +1,6 @@
#
# Template driver for the Knauer BlueShadow Pump 40P
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
# vim: ft=tcl ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
#
driver knauer_pump = {
debug_threshold = 0;
@@ -19,6 +19,7 @@ driver knauer_pump = {
type = int;
readable = 1; read_command = 'REMOTE?'; read_function = remote_read;
writeable = 1; write_function = remote_write;
allowed = '0,1';
}
var state = {
type = text;
@@ -40,13 +41,28 @@ driver knauer_pump = {
#checkrange_function = volume_reject;
property 'units' = 'mL';
}
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;
}
var volume_sp = {
type = float;
writeable = 1;
write_command = ' ';
write_function = volume_write;
driveable = pump/volume_pv
checkstatus_function = volume_checkstatus;
driveable = pump/volume_pv;
checkstatus_function = volume_checkstatus;
halt_function = volume_halt;
lowerlimit = 0; upperlimit = 100; tolerance = 0.01;
readable = 1;
@@ -61,6 +77,7 @@ driver knauer_pump = {
}
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';
}
@@ -71,6 +88,7 @@ driver knauer_pump = {
}
var flow_sp = {
type = float;
value = 1.0;
writeable = 1; write_command = ' '; write_function = flow_write;
lowerlimit = 0; upperlimit = 10;
property 'units' = 'mL/min';
@@ -78,7 +96,7 @@ driver knauer_pump = {
}
group stuff = {
readable = 60;
readable = 600;
type = text;
data = false; control = false; nxsave = false;
var an_out = { read_command = 'AN_OUT?'; }
@@ -106,15 +124,6 @@ driver knauer_pump = {
var 'units' = { read_command = 'UNITS?'; }
var valves = { read_command = 'VALVES?'; }
}
group prog = {
readable = 30;
type = text;
var line_01 = { read_command = "TT_GET:1,1"; }
var line_02 = { read_command = "TT_GET:1,2"; }
var line_03 = { read_command = "TT_GET:1,3"; }
var line_04 = { read_command = "TT_GET:1,4"; }
var line_05 = { read_command = "TT_GET:1,5"; }
}
group glp = {
type = text;
readable = 1;
@@ -303,6 +312,7 @@ driver knauer_pump = {
set cmd "REMOTE"
}
%%}
code volume_fetch = {%%
set data [hgetpropval ${tc_root}/dummy/glp real_data]
set dlist [split ${data} ","]
@@ -322,6 +332,81 @@ driver knauer_pump = {
sct result [format "%.2f" ${pump_volume}]
set cmd "@@NOSEND@@"
%%}
##########
code pump_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"
sct this_state 1
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 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 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}]
set nextState noResponse
if { [sct this_state] == 1 } {
set cmd "TT_LOAD:1"
sct this_state [expr {[sct this_state] + 1}]
} elseif { [sct this_state] == 2 } {
set cmd "TT_SET:0,0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0"
sct this_state [expr {[sct this_state] + 1}]
} elseif { [sct this_state] == 3 } {
set cmd "TT_SET:1,${time_1},${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0"
sct this_state [expr {[sct this_state] + 1}]
} elseif { [sct this_state] == 4 } {
set cmd "TT_SET:2,${time_2},0,${ratio_tgt},0,0,0,0,0,0,0,0"
sct this_state [expr {[sct this_state] + 1}]
} elseif { [sct this_state] == 5 } {
set cmd "START:1,0"
sct this_state 0
} else {
sct this_state 0
set cmd "@@NOSEND@@"
set nextState idle
}
} else {
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 nextState noResponse
sct result ""
sct driving 0
sct pumping 0
}
}
}
}
%%}
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
@@ -352,6 +437,7 @@ driver knauer_pump = {
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
}