72 lines
2.2 KiB
Plaintext
72 lines
2.2 KiB
Plaintext
|
|
driver pfeiffer_hg = {
|
|
vendor = pfeiffer; device = hg; protocol = std; class = environment; simulation_group = environment_simulation;
|
|
|
|
Group = {
|
|
var status = { type = int; }
|
|
}
|
|
|
|
Group pressure = {
|
|
priv = user; type = float;
|
|
|
|
var sensor = {
|
|
readable = 1;
|
|
permlink = 'P.S01';
|
|
read_command = 'PR1'; fetch_function = sendPR1; read_function = readPR1;
|
|
pid_function = pid_pressure;
|
|
property pid_error = 0 property pid_deriv = 0 property pid_integ = 0
|
|
property pid_pvalue = 0.2 property pid_ivalue = 0.1 property pid_dvalue = 0.0
|
|
property pid_imax = 30
|
|
property pid_setpoint = 'pressure/setpoint'
|
|
property pid_control = '/sample/tc9/Valve/Setpoint'
|
|
}
|
|
|
|
var setpoint = {
|
|
permlink = 'P.SP01';
|
|
writeable = 1; write_function = setPoint; write_command = '@';
|
|
driveable = 'pressure/sensor'; lowerlimit = 0; upperlimit = 1000; tolerance = 100; property settle_time = 90;
|
|
}
|
|
}
|
|
|
|
code pid_function pid_pressure = {
|
|
@ if { [hpropexists [sct] pid_control] } {
|
|
@ hsetprop [hgetpropval [sct] pid_control] pid_bias ${pid}
|
|
@ if { [hpropexists [hgetpropval [sct] pid_control] target] } {
|
|
@ hset [hgetpropval [sct] pid_control] [hgetpropval [hgetpropval [sct] pid_control] target]
|
|
@ } else {
|
|
@ hset [hgetpropval [sct] pid_control] [hval [hgetpropval [sct] pid_control]]
|
|
@ }
|
|
@ }
|
|
}
|
|
|
|
code read_function ack_enq = {
|
|
@ if {[string equal -nocase -length 1 ${data} "\x06"]} {
|
|
@ debug_log 1 "ack_enq received ACK, send ENQ"
|
|
@ sct send "\x05"
|
|
@ }
|
|
@ return "readPR1"
|
|
}
|
|
|
|
code read_function readPR1 = {
|
|
@ set val [string range $data 3 12]
|
|
@ set status [string range $data 0 0]
|
|
@ set data ${val}
|
|
@ hupdate ${tc_root}/status $status
|
|
@ if { [hpropexists [sct] pid_control] && [hpropexists [sct] pid_setpoint] } {
|
|
@ set sp [hval ${tc_root}/[sct pid_setpoint]]
|
|
@ set pv $val
|
|
@ pid_pressure ${tc_root} ${sp} ${pv}
|
|
@ }
|
|
}
|
|
|
|
code write_function setPoint = {
|
|
@ sct pid_control /sample/tc9/Valve/Setpoint
|
|
}
|
|
|
|
code mkDriver = {
|
|
@ hsetprop ${scobj_hpath}/pressure/sensor read ${ns}::sendPR1 ${scobj_hpath} ack_enq {PR1}
|
|
@ hsetprop ${scobj_hpath}/pressure/sensor ack_enq ${ns}::ack_enq ${scobj_hpath}
|
|
}
|
|
}
|
|
|