# # Simple driver generator for the Julabo LH45 # vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent # driver julabo_lh45_gen = { vendor = julabo; device = lh45; protocol = std; class = environment; simulation_group = environment_simulation debug_threshold = 1; add_args = '{id 1} {ctrl_sensor "bath"} {tol 5.0}'; make_args = 'id ctrl_sensor tol'; protocol_args = '"\r"'; # # Unnamed group has variables at device level # group = { priv = user; type = float; readable = 1; var setpoint = { property 'units' = C; read_command = 'in_sp_00'; permlink = 'T.SP01'; writeable = 1; write_function = setPoint; write_command = 'out_sp_00'; driveable = sensor/'value'; lowerlimit = 10; upperlimit = 90; tolerance = '${tol}'; } var overtemp_warnlimit = { read_command = 'in_sp_03'; # writeable = 1; write_command = 'out_sp_03'; } var subtemp_warnlimit = { read_command = 'in_sp_04'; # writeable = 1; write_command = 'out_sp_04'; } var heating_power_percent = { read_command = 'in_pv_01'; }; var lh45_state = { type = text; read_command = 'status'; fetch_function = getState; read_function = rdState; } readable = 0; var lh45_lasterror = { type = text; } var remote_ctrl = { type = text; priv = spy; } } # # The named group is at the device level, variables below that # group sensor = { type = float; priv = internal; readable = 1; property 'units' = 'C'; var bathtemp = { read_function = rdSensor; read_command = 'in_pv_00'; property external = 0; }; var external = { read_function = rdSensor; read_command = 'in_pv_02'; property external = 1; }; readable = 0; var 'value' = { permlink = 'T.S01'; }; var start_temperature = {}; var end_temperature; }; group mode = { type = int; priv = user; readable = 1; writeable = 1; var on_else_off = { read_command = 'in_mode_05'; write_command = 'out_mode_05'; }; var ext_else_bath = { read_command = 'in_mode_04'; write_command = 'out_mode_04'; }; }; # # Code lines start with '@' which is stripped before being emitted into generated driver # The code is emitted at the appropriate place in the given function # code read_function rdSensor = {%% if { [string equal -length 6 [sct result] "---.--"] } { return ${nextState} } if { [hval ${tc_root}/mode/ext_else_bath] == [sct external] } { set target [pathname [sct]]/value set oldval [hgetpropval ${target} oldval] if {${data} != ${oldval} } { debug_log ${tc_root} 1 "[sct] changed ${target} to new:${data}, from old:${oldval}" hsetprop ${target} oldval ${data} hupdate ${target} ${data} hsetprop ${target} readtime [sct utime] } } %%} code Write_function setPoint = {%% # Put a space between command and param set cmd "${cmd_str} ${par}" # Hack to get a response set cmd "${cmd}@@NOREPLY@@" %%} code Write_function setValue = {%% # Put a space between command and param set cmd "${cmd_str} ${par}" # Hack to get a response set cmd "${cmd}@@NOREPLY@@" %%} # # This code is after database creation # code mkDriver = {%% if { ${ctrl_sensor} == "external" } { hset ${scobj_hpath}/mode/ext_else_bath 1 } else { hset ${scobj_hpath}/mode/ext_else_bath 0 } hsetprop ${scobj_hpath}/setpoint tolerance ${tol} %%} code read_function rdState = {%% 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 switch -- [lindex ${data} 0] { "00" { hset ${tc_root}/remote_ctrl False } "01" { hset ${tc_root}/remote_ctrl False } "02" { hset ${tc_root}/remote_ctrl True } "03" { hset ${tc_root}/remote_ctrl True } default { hset ${tc_root}/remote_ctrl UNKNOWN hset ${tc_root}/lh45_lasterror ${data} sct geterror ${data} } } } %%} };