Updated julabo SCT template

This commit is contained in:
Douglas Clowes
2014-07-11 18:28:31 +10:00
parent 47fbb1979e
commit f916462be6
2 changed files with 817 additions and 65 deletions

View File

@ -4,53 +4,45 @@
#
driver julabo_lh45_gen = {
vendor = julabo; device = lh45; protocol = std;
class = environment
class = environment;
simulation_group = environment_simulation
add_args = '{sensor "bath"} {tol 5.0}';
make_args = 'sensor tol';
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
priv = user;
type = float;
readable = 1;
var setpoint = {
driveable = sensor/'value'
readable = 1
read_command = 'in_sp_00'
write_function = setPoint
write_command = 'out_sp_00'
lowerlimit = 10
upperlimit = 90
tolerance = 2
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 = {
readable = 1
read_command = 'in_sp_03'
#write_command = 'out_sp_03'
read_command = 'in_sp_03';
# writeable = 1; write_command = 'out_sp_03';
}
var subtemp_warnlimit = {
readable = 1
read_command = 'in_sp_04'
#write_command = 'out_sp_04'
read_command = 'in_sp_04';
# writeable = 1; write_command = 'out_sp_04';
}
var heating_power_percent = {
readable = 1
read_command = 'in_pv_01';
};
var power = {
readable = 1
read_command = 'in_mode_05';
writeable = 1;
write_command = 'out_mode_05';
};
var lh45_state = {
readable = 1
type = text;
read_command = 'status';
fetch_function = getState
read_function = rdState
fetch_function = getState;
read_function = rdState;
}
readable = 0;
var lh45_lasterror = { type = text; }
var remote_ctrl = { type = text; priv = spy; }
}
@ -61,51 +53,94 @@ driver julabo_lh45_gen = {
type = float;
priv = internal;
readable = 1;
var 'value' = { read_command = 'in_pv_00'; units = 'C' };
var bathtemp = { read_command = 'in_pv_00'; units = 'C' };
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 rdValue = {
}
code Write_function setPoint = {
}
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}\r\nversion"
%%}
code Write_function setValue = {%%
# Put a space between command and param
set cmd "${cmd_str} ${par}"
# Hack to get a response
set cmd "${cmd}\r\nversion"
%%}
#
# This code is after database creation
#
code mkDriver = {
@# TODO use the ${sensor} and ${tol} arguments
}
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 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}
@ }
@ }
@ }
}
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}
}
}
}
%%}
};

View File

@ -0,0 +1,717 @@
# Generated driver for julabo_lh45_gen
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::julabo_lh45_gen {
set debug_threshold 1
}
proc ::scobj::julabo_lh45_gen::debug_log {tc_root debug_level debug_string} {
set catch_status [ catch {
set debug_threshold [hgetpropval ${tc_root} debug_threshold]
if {${debug_level} >= ${debug_threshold}} {
set fd [open "../log/julabo_lh45_gen_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::julabo_lh45_gen::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::julabo_lh45_gen::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::julabo_lh45_gen::${debug_string}"
}
} catch_message ]
}
# checklimits function for driveable interface
proc ::scobj::julabo_lh45_gen::checklimits {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "checklimits tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# checklimits hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
sct driving 0
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# check function for hset change
proc ::scobj::julabo_lh45_gen::checkrange {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]"
set setpoint [sct target]
if { [hpropexists [sct] lowerlimit] } {
set lolimit [sct lowerlimit]
} else {
# lowerlimit not set, use target
set lolimit [sct target]
}
if { [hpropexists [sct] upperlimit] } {
set hilimit [sct upperlimit]
} else {
# upperlimit not set, use target
set hilimit [sct target]
}
# checkrange hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
return OK
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# checkstatus function for driveable interface
proc ::scobj::julabo_lh45_gen::checkstatus {tc_root} {
set catch_status [ catch {
# checkstatus hook code goes here
if {[sct driving]} {
set sp "[sct target]"
set pv "[hval ${tc_root}/[sct driveable]]"
if { abs(${pv} - ${sp}) <= [sct tolerance] } {
if { [hpropexists [sct] settle_time] } {
if { [hpropexists [sct] settle_time_start] } {
if { [sct utime] - [sct settle_time_start] >= [sct settle_time]} {
sct driving 0
return "idle"
}
return "busy"
} else {
sct utime settle_time_start
return "busy"
}
}
sct driving 0
return "idle"
}
if { [hpropexists [sct] settle_time_start] } {
hdelprop [sct] settle_time_start
}
return "busy"
} else {
return "idle"
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::julabo_lh45_gen::getState {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log ${tc_root} 1 "getState tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# getState hook code goes here
debug_log ${tc_root} 1 "getState sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to request the read of a parameter on a device
proc ::scobj::julabo_lh45_gen::getValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log ${tc_root} 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# getValue hook code goes here
debug_log ${tc_root} 1 "getValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# halt function for driveable interface
proc ::scobj::julabo_lh45_gen::halt {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "halt tc_root=${tc_root} sct=[sct] driving=[sct driving]"
### TODO hset [sct] [hval [sct]]
# halt hook code goes here
sct driving 0
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to check the write parameter on a device
proc ::scobj::julabo_lh45_gen::noResponse {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# noResponse hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::julabo_lh45_gen::rdSensor {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "rdSensor tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# rdSensor hook code starts
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]
}
}
# rdSensor hook code ends
if { [hpropexists [sct] geterror] } {
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
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
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::julabo_lh45_gen::rdState {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "rdState tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# rdState hook code starts
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}
}
}
}
# rdState hook code ends
if { [hpropexists [sct] geterror] } {
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
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
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to parse the read of a parameter on a device
proc ::scobj::julabo_lh45_gen::rdValue {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "rdValue tc_root=${tc_root} sct=[sct] result=[sct result]"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set data [sct result]
set nextState "idle"
if {[string equal -nocase -length 7 ${data} "ASCERR:"]} {
# the protocol driver has reported an error
sct geterror "${data}"
error "[sct geterror]"
}
# rdValue hook code goes here
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
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::julabo_lh45_gen::setPoint {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log ${tc_root} 1 "setPoint tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# setPoint hook code starts
# Put a space between command and param
set cmd "${cmd_str} ${par}"
# Hack to get a response
set cmd "${cmd}\r\nversion"
# setPoint hook code ends
if { [hpropexists [sct] geterror] } {
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log ${tc_root} 1 "setPoint sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::julabo_lh45_gen::setValue {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}"
if { [hpropexists [sct] geterror] } {
hdelprop [sct] geterror
}
set par [sct target]
set cmd "${cmd_str}${par}"
# setValue hook code starts
# Put a space between command and param
set cmd "${cmd_str} ${par}"
# Hack to get a response
set cmd "${cmd}\r\nversion"
# setValue hook code ends
if { [hpropexists [sct] geterror] } {
debug_log ${tc_root} 9 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log ${tc_root} 1 "setValue sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name id ctrl_sensor tol } {
::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::mkDriver ${sct_controller} ${name} ${id} ${ctrl_sensor} ${tol}"
set ns "[namespace current]"
set catch_status [ catch {
MakeSICSObj ${name} SCT_OBJECT
sicslist setatt ${name} klass environment
sicslist setatt ${name} long_name ${name}
set scobj_hpath /sics/${name}
hfactory ${scobj_hpath}/heating_power_percent plain user float
hsetprop ${scobj_hpath}/heating_power_percent read ${ns}::getValue ${scobj_hpath} rdValue {in_pv_01}
hsetprop ${scobj_hpath}/heating_power_percent rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/heating_power_percent control true
hsetprop ${scobj_hpath}/heating_power_percent data true
hsetprop ${scobj_hpath}/heating_power_percent mutable false
hsetprop ${scobj_hpath}/heating_power_percent nxsave true
hsetprop ${scobj_hpath}/heating_power_percent oldval 0.0
hsetprop ${scobj_hpath}/heating_power_percent sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/heating_power_percent type "part"
hsetprop ${scobj_hpath}/heating_power_percent nxalias "${name}_heating_power_percent"
hfactory ${scobj_hpath}/lh45_lasterror plain user text
hsetprop ${scobj_hpath}/lh45_lasterror control true
hsetprop ${scobj_hpath}/lh45_lasterror data true
hsetprop ${scobj_hpath}/lh45_lasterror mutable false
hsetprop ${scobj_hpath}/lh45_lasterror nxsave true
hsetprop ${scobj_hpath}/lh45_lasterror oldval UNKNOWN
hsetprop ${scobj_hpath}/lh45_lasterror sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/lh45_lasterror type "part"
hsetprop ${scobj_hpath}/lh45_lasterror nxalias "${name}_lh45_lasterror"
hfactory ${scobj_hpath}/lh45_state plain user text
hsetprop ${scobj_hpath}/lh45_state read ${ns}::getState ${scobj_hpath} rdState {status}
hsetprop ${scobj_hpath}/lh45_state rdState ${ns}::rdState ${scobj_hpath}
hsetprop ${scobj_hpath}/lh45_state control true
hsetprop ${scobj_hpath}/lh45_state data true
hsetprop ${scobj_hpath}/lh45_state mutable false
hsetprop ${scobj_hpath}/lh45_state nxsave true
hsetprop ${scobj_hpath}/lh45_state oldval UNKNOWN
hsetprop ${scobj_hpath}/lh45_state sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/lh45_state type "part"
hsetprop ${scobj_hpath}/lh45_state nxalias "${name}_lh45_state"
hfactory ${scobj_hpath}/overtemp_warnlimit plain user float
hsetprop ${scobj_hpath}/overtemp_warnlimit read ${ns}::getValue ${scobj_hpath} rdValue {in_sp_03}
hsetprop ${scobj_hpath}/overtemp_warnlimit rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/overtemp_warnlimit control true
hsetprop ${scobj_hpath}/overtemp_warnlimit data true
hsetprop ${scobj_hpath}/overtemp_warnlimit mutable false
hsetprop ${scobj_hpath}/overtemp_warnlimit nxsave true
hsetprop ${scobj_hpath}/overtemp_warnlimit oldval 0.0
hsetprop ${scobj_hpath}/overtemp_warnlimit sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/overtemp_warnlimit type "part"
hsetprop ${scobj_hpath}/overtemp_warnlimit nxalias "${name}_overtemp_warnlimit"
hfactory ${scobj_hpath}/remote_ctrl plain spy text
hsetprop ${scobj_hpath}/remote_ctrl control true
hsetprop ${scobj_hpath}/remote_ctrl data true
hsetprop ${scobj_hpath}/remote_ctrl mutable false
hsetprop ${scobj_hpath}/remote_ctrl nxsave true
hsetprop ${scobj_hpath}/remote_ctrl oldval UNKNOWN
hsetprop ${scobj_hpath}/remote_ctrl sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/remote_ctrl type "part"
hsetprop ${scobj_hpath}/remote_ctrl nxalias "${name}_remote_ctrl"
hfactory ${scobj_hpath}/setpoint plain user float
hsetprop ${scobj_hpath}/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {in_sp_00}
hsetprop ${scobj_hpath}/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint write ${ns}::setPoint ${scobj_hpath} noResponse {out_sp_00}
hsetprop ${scobj_hpath}/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint driving 0
hsetprop ${scobj_hpath}/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/setpoint driveable sensor/value
hsetprop ${scobj_hpath}/setpoint control true
hsetprop ${scobj_hpath}/setpoint data true
hsetprop ${scobj_hpath}/setpoint mutable false
hsetprop ${scobj_hpath}/setpoint nxsave true
hsetprop ${scobj_hpath}/setpoint lowerlimit 10
hsetprop ${scobj_hpath}/setpoint upperlimit 90
hsetprop ${scobj_hpath}/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/setpoint permlink data_set "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/setpoint @description "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/setpoint oldval 0.0
hsetprop ${scobj_hpath}/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/setpoint type "drivable"
hsetprop ${scobj_hpath}/setpoint units "C"
hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint"
hfactory ${scobj_hpath}/subtemp_warnlimit plain user float
hsetprop ${scobj_hpath}/subtemp_warnlimit read ${ns}::getValue ${scobj_hpath} rdValue {in_sp_04}
hsetprop ${scobj_hpath}/subtemp_warnlimit rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/subtemp_warnlimit control true
hsetprop ${scobj_hpath}/subtemp_warnlimit data true
hsetprop ${scobj_hpath}/subtemp_warnlimit mutable false
hsetprop ${scobj_hpath}/subtemp_warnlimit nxsave true
hsetprop ${scobj_hpath}/subtemp_warnlimit oldval 0.0
hsetprop ${scobj_hpath}/subtemp_warnlimit sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/subtemp_warnlimit type "part"
hsetprop ${scobj_hpath}/subtemp_warnlimit nxalias "${name}_subtemp_warnlimit"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
${sct_controller} poll ${scobj_hpath}/heating_power_percent 1
${sct_controller} poll ${scobj_hpath}/lh45_state 1
${sct_controller} poll ${scobj_hpath}/overtemp_warnlimit 1
${sct_controller} poll ${scobj_hpath}/setpoint 1
${sct_controller} poll ${scobj_hpath}/subtemp_warnlimit 1
${sct_controller} write ${scobj_hpath}/setpoint
} else {
::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen"
}
hfactory ${scobj_hpath}/mode plain spy none
hfactory ${scobj_hpath}/mode/ext_else_bath plain user int
hsetprop ${scobj_hpath}/mode/ext_else_bath read ${ns}::getValue ${scobj_hpath} rdValue {in_mode_04}
hsetprop ${scobj_hpath}/mode/ext_else_bath rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/mode/ext_else_bath write ${ns}::setValue ${scobj_hpath} noResponse {out_mode_04}
hsetprop ${scobj_hpath}/mode/ext_else_bath noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/mode/ext_else_bath check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/mode/ext_else_bath control true
hsetprop ${scobj_hpath}/mode/ext_else_bath data true
hsetprop ${scobj_hpath}/mode/ext_else_bath mutable false
hsetprop ${scobj_hpath}/mode/ext_else_bath nxsave true
hsetprop ${scobj_hpath}/mode/ext_else_bath oldval 0
hsetprop ${scobj_hpath}/mode/ext_else_bath sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/mode/ext_else_bath type "part"
hsetprop ${scobj_hpath}/mode/ext_else_bath nxalias "${name}_mode_ext_else_bath"
hfactory ${scobj_hpath}/mode/on_else_off plain user int
hsetprop ${scobj_hpath}/mode/on_else_off read ${ns}::getValue ${scobj_hpath} rdValue {in_mode_05}
hsetprop ${scobj_hpath}/mode/on_else_off rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/mode/on_else_off write ${ns}::setValue ${scobj_hpath} noResponse {out_mode_05}
hsetprop ${scobj_hpath}/mode/on_else_off noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/mode/on_else_off check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/mode/on_else_off control true
hsetprop ${scobj_hpath}/mode/on_else_off data true
hsetprop ${scobj_hpath}/mode/on_else_off mutable false
hsetprop ${scobj_hpath}/mode/on_else_off nxsave true
hsetprop ${scobj_hpath}/mode/on_else_off oldval 0
hsetprop ${scobj_hpath}/mode/on_else_off sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/mode/on_else_off type "part"
hsetprop ${scobj_hpath}/mode/on_else_off nxalias "${name}_mode_on_else_off"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
${sct_controller} poll ${scobj_hpath}/mode/ext_else_bath 1
${sct_controller} poll ${scobj_hpath}/mode/on_else_off 1
${sct_controller} write ${scobj_hpath}/mode/ext_else_bath
${sct_controller} write ${scobj_hpath}/mode/on_else_off
} else {
::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen"
}
hfactory ${scobj_hpath}/sensor plain spy none
hfactory ${scobj_hpath}/sensor/bathtemp plain internal float
hsetprop ${scobj_hpath}/sensor/bathtemp read ${ns}::getValue ${scobj_hpath} rdSensor {in_pv_00}
hsetprop ${scobj_hpath}/sensor/bathtemp rdSensor ${ns}::rdSensor ${scobj_hpath}
hsetprop ${scobj_hpath}/sensor/bathtemp control true
hsetprop ${scobj_hpath}/sensor/bathtemp data true
hsetprop ${scobj_hpath}/sensor/bathtemp mutable false
hsetprop ${scobj_hpath}/sensor/bathtemp nxsave true
hsetprop ${scobj_hpath}/sensor/bathtemp oldval 0.0
hsetprop ${scobj_hpath}/sensor/bathtemp external "0"
hsetprop ${scobj_hpath}/sensor/bathtemp sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/sensor/bathtemp type "part"
hsetprop ${scobj_hpath}/sensor/bathtemp units "C"
hsetprop ${scobj_hpath}/sensor/bathtemp nxalias "${name}_sensor_bathtemp"
hfactory ${scobj_hpath}/sensor/end_temperature plain internal float
hsetprop ${scobj_hpath}/sensor/end_temperature control true
hsetprop ${scobj_hpath}/sensor/end_temperature data true
hsetprop ${scobj_hpath}/sensor/end_temperature mutable false
hsetprop ${scobj_hpath}/sensor/end_temperature nxsave true
hsetprop ${scobj_hpath}/sensor/end_temperature oldval 0.0
hsetprop ${scobj_hpath}/sensor/end_temperature sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/sensor/end_temperature type "part"
hsetprop ${scobj_hpath}/sensor/end_temperature units "C"
hsetprop ${scobj_hpath}/sensor/end_temperature nxalias "${name}_sensor_end_temperature"
hfactory ${scobj_hpath}/sensor/external plain internal float
hsetprop ${scobj_hpath}/sensor/external read ${ns}::getValue ${scobj_hpath} rdSensor {in_pv_02}
hsetprop ${scobj_hpath}/sensor/external rdSensor ${ns}::rdSensor ${scobj_hpath}
hsetprop ${scobj_hpath}/sensor/external control true
hsetprop ${scobj_hpath}/sensor/external data true
hsetprop ${scobj_hpath}/sensor/external mutable false
hsetprop ${scobj_hpath}/sensor/external nxsave true
hsetprop ${scobj_hpath}/sensor/external oldval 0.0
hsetprop ${scobj_hpath}/sensor/external external "1"
hsetprop ${scobj_hpath}/sensor/external sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/sensor/external type "part"
hsetprop ${scobj_hpath}/sensor/external units "C"
hsetprop ${scobj_hpath}/sensor/external nxalias "${name}_sensor_external"
hfactory ${scobj_hpath}/sensor/start_temperature plain internal float
hsetprop ${scobj_hpath}/sensor/start_temperature control true
hsetprop ${scobj_hpath}/sensor/start_temperature data true
hsetprop ${scobj_hpath}/sensor/start_temperature mutable false
hsetprop ${scobj_hpath}/sensor/start_temperature nxsave true
hsetprop ${scobj_hpath}/sensor/start_temperature oldval 0.0
hsetprop ${scobj_hpath}/sensor/start_temperature sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/sensor/start_temperature type "part"
hsetprop ${scobj_hpath}/sensor/start_temperature units "C"
hsetprop ${scobj_hpath}/sensor/start_temperature nxalias "${name}_sensor_start_temperature"
hfactory ${scobj_hpath}/sensor/value plain internal float
hsetprop ${scobj_hpath}/sensor/value control true
hsetprop ${scobj_hpath}/sensor/value data true
hsetprop ${scobj_hpath}/sensor/value mutable false
hsetprop ${scobj_hpath}/sensor/value nxsave true
hsetprop ${scobj_hpath}/sensor/value permlink data_set "T[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/sensor/value @description "T[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/sensor/value oldval 0.0
hsetprop ${scobj_hpath}/sensor/value sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/sensor/value type "part"
hsetprop ${scobj_hpath}/sensor/value units "C"
hsetprop ${scobj_hpath}/sensor/value nxalias "${name}_sensor_value"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
${sct_controller} poll ${scobj_hpath}/sensor/bathtemp 1
${sct_controller} poll ${scobj_hpath}/sensor/external 1
} else {
::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen"
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 1
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor/value ${sct_controller}
}
# mkDriver hook code starts
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}
# mkDriver hook code ends
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::julabo_lh45_gen {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_julabo_lh45_gen {name IP port {id 1} {ctrl_sensor "bath"} {tol 5.0}} {
set catch_status [ catch {
::scobj::julabo_lh45_gen::sics_log 9 "add_julabo_lh45_gen ${name} ${IP} ${port} ${id} ${ctrl_sensor} ${tol}"
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::julabo_lh45_gen::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::julabo_lh45_gen::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port} \"\\r\""
makesctcontroller sct_${name} std ${IP}:${port} "\r"
}
} else {
::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No sctcontroller for julabo_lh45_gen"
}
::scobj::julabo_lh45_gen::sics_log 1 "::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${id} ${ctrl_sensor} ${tol}"
::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${id} ${ctrl_sensor} ${tol}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
clientput "file evaluation of sct_julabo_lh45_gen.tcl"
::scobj::julabo_lh45_gen::sics_log 9 "file evaluation of sct_julabo_lh45_gen.tcl"
proc ::scobj::julabo_lh45_gen::read_config {} {
set catch_status [ catch {
set ns "::scobj::julabo_lh45_gen"
dict for {k v} $::config_dict {
if { [dict exists $v "implementation"] } {
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
continue
}
set name [dict get $v name]
set enabled [string tolower [dict get $v "enabled"]]
set implementation [dict get $v "implementation"]
if { !([dict exists $::config_dict $implementation]) } {
continue
}
set v [dict get $::config_dict $implementation]
if { !([dict exists $v "driver"]) } {
continue
}
if { [string equal -nocase [dict get $v "driver"] "julabo_lh45_gen"] } {
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
}
} else {
if { [dict exists $v "asyncprotocol"] } {
set asyncprotocol [dict get $v "asyncprotocol"]
} else {
set asyncprotocol ${name}_protocol
MakeAsyncProtocol ${asyncprotocol}
if { [dict exists $v "terminator"] } {
${asyncprotocol} sendterminator "[dict get $v "terminator"]"
${asyncprotocol} replyterminator "[dict get $v "terminator"]"
}
}
set asyncqueue ${name}_queue
set IP [dict get $v ip]
set PORT [dict get $v port]
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {id ctrl_sensor tol} {
if {[dict exists $v $arg]} {
lappend arg_list "[dict get $v $arg]"
} else {
${ns}::sics_log 9 "Missing configuration value $arg"
error "Missing configuration value $arg"
}
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
add_julabo_lh45_gen ${name} ${IP} ${PORT} {*}$arg_list
} else {
add_julabo_lh45_gen ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::julabo_lh45_gen::read_config
} else {
::scobj::julabo_lh45_gen::sics_log 5 "No config dict"
}