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] } { @ set co [hgetpropval [sct] pid_control] @ if { !([hpropexists ${co} pid_bias] && [hgetpropval ${co} pid_bias] == ${pid}) } { @ hsetprop ${co} pid_bias ${pid} @ if { [hpropexists ${co} target] } { @ hset ${co} [hgetpropval ${co} target] @ } else { @ hset ${co} [hval ${co}] @ } @ } @ } } code read_function ack_enq = { @ if {[string equal -nocase -length 1 ${data} "\x06"]} { @ debug_log ${tc_root} 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 @ sct update [sct target] @ set cmd "@@NOSEND@@" @ set nextState "idle" } 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} } }