Generated modular mercury drivers

This commit is contained in:
Douglas Clowes
2014-05-14 17:28:58 +10:00
parent abafa6a2e6
commit cf8a08ea7e
11 changed files with 2305 additions and 0 deletions

View File

@ -0,0 +1,53 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver mercury_base = {
vendor = oxford; device = mercury; protocol = std;
class = environment; simulation_group = environment_simulation;
add_args = '{id 99} {tol 1}'
make_args = 'id tol'
group Loop1 = {
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:MB1.T1:TEMP:SIG:TEMP'; permlink = 'T.S01'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:MB1.T1:TEMP:NICK'; read_function = rdText; }
var power = { read_command = 'READ:DEV:MB0.H1:HTR:SIG:POWR'; }
var setpoint = { read_command = 'READ:DEV:MB1.T1:TEMP:LOOP:TSET';
driveable = Loop1/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${tol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:MB1.T1:TEMP:LOOP:TSET:';
permlink = 'T.SP01';
}
}
group Loop2 = {
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:DB6.T1:TEMP:SIG:TEMP'; permlink = 'T.S02'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB6.T1:TEMP:NICK'; read_function = rdText; }
var power = { read_command = 'READ:DEV:DB1.H1:HTR:SIG:POWR'; }
var setpoint = { read_command = 'READ:DEV:DB6.T1:TEMP:LOOP:TSET';
driveable = Loop2/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${tol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB6.T1:TEMP:LOOP:TSET:';
permlink = 'T.SP02';
}
}
group Loop3 = {
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:DB7.T1:TEMP:SIG:TEMP'; permlink = 'T.S03'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB7.T1:TEMP:NICK'; read_function = rdText; }
var power = { read_command = 'READ:DEV:DB2.H1:HTR:SIG:POWR'; }
var setpoint = { read_command = 'READ:DEV:DB7.T1:TEMP:LOOP:TSET';
driveable = Loop3/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${tol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB7.T1:TEMP:LOOP:TSET:';
permlink = 'T.SP03';
}
}
code read_function rdValue = {
@ scan [lindex [split "$data" ":"] end] "%g" data
}
code read_function rdText = {
@ scan [lindex [split "$data" ":"] end] "%s" data
}
code Write_function setPoint = {
}
}

View File

@ -0,0 +1,17 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver mercury_level = {
vendor = oxford; device = mercury; protocol = std;
class = environment; simulation_group = environment_simulation;
add_args = '{id 99}'
make_args = 'id'
group Level = {
priv = user; type = float; readable = 15;
var Nitrogen = { read_command = 'READ:DEV:DB5.L1:LVL:SIG:NIT:LEV'; permlink = 'L.S01'; }
var Helium = { read_command = 'READ:DEV:DB5.L1:LVL:SIG:HEL:LEV'; permlink = 'L.S02'; }
}
code read_function rdValue = {
@ scan [lindex [split "$data" ":"] end] "%g" data
}
}

View File

@ -0,0 +1,31 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver mercury_pres = {
vendor = oxford; device = mercury; protocol = std;
class = environment; simulation_group = environment_simulation;
add_args = '{id 99} {tol 1}'
make_args = 'id tol'
group Loop4 = {
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:DB8.T1:TEMP:SIG:TEMP'; permlink = 'T.S04'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB8.T1:TEMP:NICK'; read_function = rdText; }
var power = { read_command = 'READ:DEV:DB3.H1:HTR:SIG:POWR'; }
var setpoint = { read_command = 'READ:DEV:DB8.T1:TEMP:LOOP:TSET';
driveable = Loop4/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${tol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB8.T1:TEMP:LOOP:TSET:';
permlink = 'T.SP04';
}
}
code read_function rdValue = {
@ scan [lindex [split "$data" ":"] end] "%g" data
}
code read_function rdText = {
@ scan [lindex [split "$data" ":"] end] "%s" data
}
code Write_function setPoint = {
}
}

View File

@ -0,0 +1,31 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver mercury_temp = {
vendor = oxford; device = mercury; protocol = std;
class = environment; simulation_group = environment_simulation;
add_args = '{id 99} {tol 1}'
make_args = 'id tol'
group Loop4 = {
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:DB8.T1:TEMP:SIG:TEMP'; permlink = 'T.S04'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB8.T1:TEMP:NICK'; read_function = rdText; }
var power = { read_command = 'READ:DEV:DB3.H1:HTR:SIG:POWR'; }
var setpoint = { read_command = 'READ:DEV:DB8.T1:TEMP:LOOP:TSET';
driveable = Loop4/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${tol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB8.T1:TEMP:LOOP:TSET:';
permlink = 'T.SP04';
}
}
code read_function rdValue = {
@ scan [lindex [split "$data" ":"] end] "%g" data
}
code read_function rdText = {
@ scan [lindex [split "$data" ":"] end] "%s" data
}
code Write_function setPoint = {
}
}

View File

@ -0,0 +1,33 @@
# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent
driver mercury_valve = {
vendor = oxford; device = mercury; protocol = std;
class = environment; simulation_group = environment_simulation;
add_args = '{id 99} {valve_tol 2}'
make_args = 'id valve_tol'
group Valve = {
priv = user; type = float;
var sensor = {
readable = 5;
read_command = 'READ:DEV:DB4.G1:AUX:SIG:OPEN';
permlink = 'G.S07';
}
var setpoint = {
driveable = Valve/sensor; lowerlimit = 0; upperlimit = 100; tolerance = '${valve_tol}'; property settle_time = 30;
writeable = 1; write_function = setValve; write_command = 'SET:DEV:DB4.G1:AUX:SIG:OPEN:';
permlink = 'G.SP07';
}
}
code read_function rdValue = {
@ scan [lindex [split "$data" ":"] end] "%g" data
}
code Write_function setValve = {
@ if { [hpropexists [sct] pid_bias] } {
@ set par [expr ${par} + [hgetpropval [sct] pid_bias]]
@ set cmd "${cmd_str}${par}"
@ }
@ sct update [sct target]
}
}

View File

@ -0,0 +1,591 @@
# Generated driver for mercury_base
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::mercury_base {
set debug_threshold 5
}
proc ::scobj::mercury_base::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 "/tmp/mercury_base_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::mercury_base::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::mercury_base::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::mercury_base::${debug_string}"
}
} catch_message ]
}
# checklimits function for driveable interface
proc ::scobj::mercury_base::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::mercury_base::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::mercury_base::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::mercury_base::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::mercury_base::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::mercury_base::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::mercury_base::rdText {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "rdText 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]"
}
# rdText hook code starts
scan [lindex [split "$data" ":"] end] "%s" data
# rdText 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::mercury_base::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 starts
scan [lindex [split "$data" ":"] end] "%g" data
# rdValue 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 write a parameter value on a device
proc ::scobj::mercury_base::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 goes here
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::mercury_base::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 goes here
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::mercury_base::mkDriver { sct_controller name id tol } {
::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::mkDriver ${sct_controller} ${name} ${id} ${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}/Loop1 plain spy none
hfactory ${scobj_hpath}/Loop1/nick plain user text
hsetprop ${scobj_hpath}/Loop1/nick read ${ns}::getValue ${scobj_hpath} rdText {READ:DEV:MB1.T1:TEMP:NICK}
hsetprop ${scobj_hpath}/Loop1/nick rdText ${ns}::rdText ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/nick control true
hsetprop ${scobj_hpath}/Loop1/nick data true
hsetprop ${scobj_hpath}/Loop1/nick mutable false
hsetprop ${scobj_hpath}/Loop1/nick nxsave true
hsetprop ${scobj_hpath}/Loop1/nick oldval UNKNOWN
hsetprop ${scobj_hpath}/Loop1/nick sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop1/nick type "part"
hsetprop ${scobj_hpath}/Loop1/nick nxalias "${name}_Loop1_nick"
hfactory ${scobj_hpath}/Loop1/power plain user float
hsetprop ${scobj_hpath}/Loop1/power read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:MB0.H1:HTR:SIG:POWR}
hsetprop ${scobj_hpath}/Loop1/power rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/power control true
hsetprop ${scobj_hpath}/Loop1/power data true
hsetprop ${scobj_hpath}/Loop1/power mutable false
hsetprop ${scobj_hpath}/Loop1/power nxsave true
hsetprop ${scobj_hpath}/Loop1/power oldval 0.0
hsetprop ${scobj_hpath}/Loop1/power sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop1/power type "part"
hsetprop ${scobj_hpath}/Loop1/power nxalias "${name}_Loop1_power"
hfactory ${scobj_hpath}/Loop1/sensor plain user float
hsetprop ${scobj_hpath}/Loop1/sensor read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:MB1.T1:TEMP:SIG:TEMP}
hsetprop ${scobj_hpath}/Loop1/sensor rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/sensor control true
hsetprop ${scobj_hpath}/Loop1/sensor data true
hsetprop ${scobj_hpath}/Loop1/sensor mutable false
hsetprop ${scobj_hpath}/Loop1/sensor nxsave true
hsetprop ${scobj_hpath}/Loop1/sensor permlink data_set "T[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/Loop1/sensor @description "T[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/Loop1/sensor oldval 0.0
hsetprop ${scobj_hpath}/Loop1/sensor sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop1/sensor type "part"
hsetprop ${scobj_hpath}/Loop1/sensor nxalias "${name}_Loop1_sensor"
hfactory ${scobj_hpath}/Loop1/setpoint plain user float
hsetprop ${scobj_hpath}/Loop1/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:MB1.T1:TEMP:LOOP:TSET}
hsetprop ${scobj_hpath}/Loop1/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/setpoint write ${ns}::setPoint ${scobj_hpath} noResponse {SET:DEV:MB1.T1:TEMP:LOOP:TSET:}
hsetprop ${scobj_hpath}/Loop1/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/setpoint driving 0
hsetprop ${scobj_hpath}/Loop1/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop1/setpoint driveable Loop1/sensor
hsetprop ${scobj_hpath}/Loop1/setpoint control true
hsetprop ${scobj_hpath}/Loop1/setpoint data true
hsetprop ${scobj_hpath}/Loop1/setpoint mutable false
hsetprop ${scobj_hpath}/Loop1/setpoint nxsave true
hsetprop ${scobj_hpath}/Loop1/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/Loop1/setpoint upperlimit 333
hsetprop ${scobj_hpath}/Loop1/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/Loop1/setpoint @description "T[format "%02d" ${id}]SP01"
hsetprop ${scobj_hpath}/Loop1/setpoint oldval 0.0
hsetprop ${scobj_hpath}/Loop1/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop1/setpoint settle_time "15"
hsetprop ${scobj_hpath}/Loop1/setpoint type "drivable"
hsetprop ${scobj_hpath}/Loop1/setpoint nxalias "${name}_Loop1_setpoint"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Loop1/nick 15
${sct_controller} poll ${scobj_hpath}/Loop1/power 5
${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1
${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5
${sct_controller} write ${scobj_hpath}/Loop1/setpoint
ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller}
}
hfactory ${scobj_hpath}/Loop2 plain spy none
hfactory ${scobj_hpath}/Loop2/nick plain user text
hsetprop ${scobj_hpath}/Loop2/nick read ${ns}::getValue ${scobj_hpath} rdText {READ:DEV:DB6.T1:TEMP:NICK}
hsetprop ${scobj_hpath}/Loop2/nick rdText ${ns}::rdText ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/nick control true
hsetprop ${scobj_hpath}/Loop2/nick data true
hsetprop ${scobj_hpath}/Loop2/nick mutable false
hsetprop ${scobj_hpath}/Loop2/nick nxsave true
hsetprop ${scobj_hpath}/Loop2/nick oldval UNKNOWN
hsetprop ${scobj_hpath}/Loop2/nick sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop2/nick type "part"
hsetprop ${scobj_hpath}/Loop2/nick nxalias "${name}_Loop2_nick"
hfactory ${scobj_hpath}/Loop2/power plain user float
hsetprop ${scobj_hpath}/Loop2/power read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB1.H1:HTR:SIG:POWR}
hsetprop ${scobj_hpath}/Loop2/power rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/power control true
hsetprop ${scobj_hpath}/Loop2/power data true
hsetprop ${scobj_hpath}/Loop2/power mutable false
hsetprop ${scobj_hpath}/Loop2/power nxsave true
hsetprop ${scobj_hpath}/Loop2/power oldval 0.0
hsetprop ${scobj_hpath}/Loop2/power sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop2/power type "part"
hsetprop ${scobj_hpath}/Loop2/power nxalias "${name}_Loop2_power"
hfactory ${scobj_hpath}/Loop2/sensor plain user float
hsetprop ${scobj_hpath}/Loop2/sensor read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB6.T1:TEMP:SIG:TEMP}
hsetprop ${scobj_hpath}/Loop2/sensor rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/sensor control true
hsetprop ${scobj_hpath}/Loop2/sensor data true
hsetprop ${scobj_hpath}/Loop2/sensor mutable false
hsetprop ${scobj_hpath}/Loop2/sensor nxsave true
hsetprop ${scobj_hpath}/Loop2/sensor permlink data_set "T[format "%02d" ${id}]S02"
hsetprop ${scobj_hpath}/Loop2/sensor @description "T[format "%02d" ${id}]S02"
hsetprop ${scobj_hpath}/Loop2/sensor oldval 0.0
hsetprop ${scobj_hpath}/Loop2/sensor sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop2/sensor type "part"
hsetprop ${scobj_hpath}/Loop2/sensor nxalias "${name}_Loop2_sensor"
hfactory ${scobj_hpath}/Loop2/setpoint plain user float
hsetprop ${scobj_hpath}/Loop2/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB6.T1:TEMP:LOOP:TSET}
hsetprop ${scobj_hpath}/Loop2/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/setpoint write ${ns}::setPoint ${scobj_hpath} noResponse {SET:DEV:DB6.T1:TEMP:LOOP:TSET:}
hsetprop ${scobj_hpath}/Loop2/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/setpoint driving 0
hsetprop ${scobj_hpath}/Loop2/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop2/setpoint driveable Loop2/sensor
hsetprop ${scobj_hpath}/Loop2/setpoint control true
hsetprop ${scobj_hpath}/Loop2/setpoint data true
hsetprop ${scobj_hpath}/Loop2/setpoint mutable false
hsetprop ${scobj_hpath}/Loop2/setpoint nxsave true
hsetprop ${scobj_hpath}/Loop2/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/Loop2/setpoint upperlimit 333
hsetprop ${scobj_hpath}/Loop2/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/Loop2/setpoint permlink data_set "T[format "%02d" ${id}]SP02"
hsetprop ${scobj_hpath}/Loop2/setpoint @description "T[format "%02d" ${id}]SP02"
hsetprop ${scobj_hpath}/Loop2/setpoint oldval 0.0
hsetprop ${scobj_hpath}/Loop2/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop2/setpoint settle_time "15"
hsetprop ${scobj_hpath}/Loop2/setpoint type "drivable"
hsetprop ${scobj_hpath}/Loop2/setpoint nxalias "${name}_Loop2_setpoint"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Loop2/nick 15
${sct_controller} poll ${scobj_hpath}/Loop2/power 5
${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1
${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5
${sct_controller} write ${scobj_hpath}/Loop2/setpoint
ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller}
}
hfactory ${scobj_hpath}/Loop3 plain spy none
hfactory ${scobj_hpath}/Loop3/nick plain user text
hsetprop ${scobj_hpath}/Loop3/nick read ${ns}::getValue ${scobj_hpath} rdText {READ:DEV:DB7.T1:TEMP:NICK}
hsetprop ${scobj_hpath}/Loop3/nick rdText ${ns}::rdText ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/nick control true
hsetprop ${scobj_hpath}/Loop3/nick data true
hsetprop ${scobj_hpath}/Loop3/nick mutable false
hsetprop ${scobj_hpath}/Loop3/nick nxsave true
hsetprop ${scobj_hpath}/Loop3/nick oldval UNKNOWN
hsetprop ${scobj_hpath}/Loop3/nick sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop3/nick type "part"
hsetprop ${scobj_hpath}/Loop3/nick nxalias "${name}_Loop3_nick"
hfactory ${scobj_hpath}/Loop3/power plain user float
hsetprop ${scobj_hpath}/Loop3/power read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB2.H1:HTR:SIG:POWR}
hsetprop ${scobj_hpath}/Loop3/power rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/power control true
hsetprop ${scobj_hpath}/Loop3/power data true
hsetprop ${scobj_hpath}/Loop3/power mutable false
hsetprop ${scobj_hpath}/Loop3/power nxsave true
hsetprop ${scobj_hpath}/Loop3/power oldval 0.0
hsetprop ${scobj_hpath}/Loop3/power sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop3/power type "part"
hsetprop ${scobj_hpath}/Loop3/power nxalias "${name}_Loop3_power"
hfactory ${scobj_hpath}/Loop3/sensor plain user float
hsetprop ${scobj_hpath}/Loop3/sensor read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB7.T1:TEMP:SIG:TEMP}
hsetprop ${scobj_hpath}/Loop3/sensor rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/sensor control true
hsetprop ${scobj_hpath}/Loop3/sensor data true
hsetprop ${scobj_hpath}/Loop3/sensor mutable false
hsetprop ${scobj_hpath}/Loop3/sensor nxsave true
hsetprop ${scobj_hpath}/Loop3/sensor permlink data_set "T[format "%02d" ${id}]S03"
hsetprop ${scobj_hpath}/Loop3/sensor @description "T[format "%02d" ${id}]S03"
hsetprop ${scobj_hpath}/Loop3/sensor oldval 0.0
hsetprop ${scobj_hpath}/Loop3/sensor sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop3/sensor type "part"
hsetprop ${scobj_hpath}/Loop3/sensor nxalias "${name}_Loop3_sensor"
hfactory ${scobj_hpath}/Loop3/setpoint plain user float
hsetprop ${scobj_hpath}/Loop3/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB7.T1:TEMP:LOOP:TSET}
hsetprop ${scobj_hpath}/Loop3/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/setpoint write ${ns}::setPoint ${scobj_hpath} noResponse {SET:DEV:DB7.T1:TEMP:LOOP:TSET:}
hsetprop ${scobj_hpath}/Loop3/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/setpoint driving 0
hsetprop ${scobj_hpath}/Loop3/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop3/setpoint driveable Loop3/sensor
hsetprop ${scobj_hpath}/Loop3/setpoint control true
hsetprop ${scobj_hpath}/Loop3/setpoint data true
hsetprop ${scobj_hpath}/Loop3/setpoint mutable false
hsetprop ${scobj_hpath}/Loop3/setpoint nxsave true
hsetprop ${scobj_hpath}/Loop3/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/Loop3/setpoint upperlimit 333
hsetprop ${scobj_hpath}/Loop3/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/Loop3/setpoint permlink data_set "T[format "%02d" ${id}]SP03"
hsetprop ${scobj_hpath}/Loop3/setpoint @description "T[format "%02d" ${id}]SP03"
hsetprop ${scobj_hpath}/Loop3/setpoint oldval 0.0
hsetprop ${scobj_hpath}/Loop3/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop3/setpoint settle_time "15"
hsetprop ${scobj_hpath}/Loop3/setpoint type "drivable"
hsetprop ${scobj_hpath}/Loop3/setpoint nxalias "${name}_Loop3_setpoint"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Loop3/nick 15
${sct_controller} poll ${scobj_hpath}/Loop3/power 5
${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1
${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5
${sct_controller} write ${scobj_hpath}/Loop3/setpoint
ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller}
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::mercury_base {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_mercury_base {name IP port {id 99} {tol 1}} {
set catch_status [ catch {
::scobj::mercury_base::sics_log 9 "add_mercury_base ${name} ${IP} ${port} ${id} ${tol}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::mercury_base::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::mercury_base::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
}
::scobj::mercury_base::sics_log 1 "::scobj::mercury_base::mkDriver sct_${name} ${name} ${id} ${tol}"
::scobj::mercury_base::mkDriver sct_${name} ${name} ${id} ${tol}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_mercury_base.tcl"
::scobj::mercury_base::sics_log 9 "file evaluation of sct_mercury_base.tcl"
proc ::scobj::mercury_base::read_config {} {
set catch_status [ catch {
set ns "::scobj::mercury_base"
dict for {k v} $::config_dict {
if { [dict exists $v "driver"] } {
if { [dict get $v "driver"] == "mercury_base" } {
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
if { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
} 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
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {id 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"
}
}
add_mercury_base ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::mercury_base::read_config
} else {
::scobj::mercury_base::sics_log 5 "No config dict"
}

View File

@ -0,0 +1,272 @@
# Generated driver for mercury_level
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::mercury_level {
set debug_threshold 5
}
proc ::scobj::mercury_level::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 "/tmp/mercury_level_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::mercury_level::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::mercury_level::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::mercury_level::${debug_string}"
}
} catch_message ]
}
# check function for hset change
proc ::scobj::mercury_level::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}
}
# function to request the read of a parameter on a device
proc ::scobj::mercury_level::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}
}
# function to check the write parameter on a device
proc ::scobj::mercury_level::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::mercury_level::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 starts
scan [lindex [split "$data" ":"] end] "%g" data
# rdValue 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 write a parameter value on a device
proc ::scobj::mercury_level::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 goes here
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::mercury_level::mkDriver { sct_controller name id } {
::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::mkDriver ${sct_controller} ${name} ${id}"
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}/Level plain spy none
hfactory ${scobj_hpath}/Level/Helium plain user float
hsetprop ${scobj_hpath}/Level/Helium read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB5.L1:LVL:SIG:HEL:LEV}
hsetprop ${scobj_hpath}/Level/Helium rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Level/Helium control true
hsetprop ${scobj_hpath}/Level/Helium data true
hsetprop ${scobj_hpath}/Level/Helium mutable false
hsetprop ${scobj_hpath}/Level/Helium nxsave true
hsetprop ${scobj_hpath}/Level/Helium permlink data_set "L[format "%02d" ${id}]S02"
hsetprop ${scobj_hpath}/Level/Helium @description "L[format "%02d" ${id}]S02"
hsetprop ${scobj_hpath}/Level/Helium oldval 0.0
hsetprop ${scobj_hpath}/Level/Helium sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Level/Helium type "part"
hsetprop ${scobj_hpath}/Level/Helium nxalias "${name}_Level_Helium"
hfactory ${scobj_hpath}/Level/Nitrogen plain user float
hsetprop ${scobj_hpath}/Level/Nitrogen read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB5.L1:LVL:SIG:NIT:LEV}
hsetprop ${scobj_hpath}/Level/Nitrogen rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Level/Nitrogen control true
hsetprop ${scobj_hpath}/Level/Nitrogen data true
hsetprop ${scobj_hpath}/Level/Nitrogen mutable false
hsetprop ${scobj_hpath}/Level/Nitrogen nxsave true
hsetprop ${scobj_hpath}/Level/Nitrogen permlink data_set "L[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/Level/Nitrogen @description "L[format "%02d" ${id}]S01"
hsetprop ${scobj_hpath}/Level/Nitrogen oldval 0.0
hsetprop ${scobj_hpath}/Level/Nitrogen sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Level/Nitrogen type "part"
hsetprop ${scobj_hpath}/Level/Nitrogen nxalias "${name}_Level_Nitrogen"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Level/Helium 15
${sct_controller} poll ${scobj_hpath}/Level/Nitrogen 15
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::mercury_level {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_mercury_level {name IP port {id 99}} {
set catch_status [ catch {
::scobj::mercury_level::sics_log 9 "add_mercury_level ${name} ${IP} ${port} ${id}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
}
::scobj::mercury_level::sics_log 1 "::scobj::mercury_level::mkDriver sct_${name} ${name} ${id}"
::scobj::mercury_level::mkDriver sct_${name} ${name} ${id}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_mercury_level.tcl"
::scobj::mercury_level::sics_log 9 "file evaluation of sct_mercury_level.tcl"
proc ::scobj::mercury_level::read_config {} {
set catch_status [ catch {
set ns "::scobj::mercury_level"
dict for {k v} $::config_dict {
if { [dict exists $v "driver"] } {
if { [dict get $v "driver"] == "mercury_level" } {
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
if { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
} 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
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {id} {
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"
}
}
add_mercury_level ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::mercury_level::read_config
} else {
::scobj::mercury_level::sics_log 5 "No config dict"
}

View File

@ -0,0 +1,441 @@
# Generated driver for mercury_pres
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::mercury_pres {
set debug_threshold 5
}
proc ::scobj::mercury_pres::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 "/tmp/mercury_pres_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::mercury_pres::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::mercury_pres::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::mercury_pres::${debug_string}"
}
} catch_message ]
}
# checklimits function for driveable interface
proc ::scobj::mercury_pres::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::mercury_pres::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::mercury_pres::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::mercury_pres::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::mercury_pres::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::mercury_pres::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::mercury_pres::rdText {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "rdText 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]"
}
# rdText hook code starts
scan [lindex [split "$data" ":"] end] "%s" data
# rdText 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::mercury_pres::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 starts
scan [lindex [split "$data" ":"] end] "%g" data
# rdValue 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 write a parameter value on a device
proc ::scobj::mercury_pres::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 goes here
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::mercury_pres::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 goes here
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::mercury_pres::mkDriver { sct_controller name id tol } {
::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::mkDriver ${sct_controller} ${name} ${id} ${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}/Loop4 plain spy none
hfactory ${scobj_hpath}/Loop4/nick plain user text
hsetprop ${scobj_hpath}/Loop4/nick read ${ns}::getValue ${scobj_hpath} rdText {READ:DEV:DB8.T1:TEMP:NICK}
hsetprop ${scobj_hpath}/Loop4/nick rdText ${ns}::rdText ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/nick control true
hsetprop ${scobj_hpath}/Loop4/nick data true
hsetprop ${scobj_hpath}/Loop4/nick mutable false
hsetprop ${scobj_hpath}/Loop4/nick nxsave true
hsetprop ${scobj_hpath}/Loop4/nick oldval UNKNOWN
hsetprop ${scobj_hpath}/Loop4/nick sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/nick type "part"
hsetprop ${scobj_hpath}/Loop4/nick nxalias "${name}_Loop4_nick"
hfactory ${scobj_hpath}/Loop4/power plain user float
hsetprop ${scobj_hpath}/Loop4/power read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB3.H1:HTR:SIG:POWR}
hsetprop ${scobj_hpath}/Loop4/power rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/power control true
hsetprop ${scobj_hpath}/Loop4/power data true
hsetprop ${scobj_hpath}/Loop4/power mutable false
hsetprop ${scobj_hpath}/Loop4/power nxsave true
hsetprop ${scobj_hpath}/Loop4/power oldval 0.0
hsetprop ${scobj_hpath}/Loop4/power sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/power type "part"
hsetprop ${scobj_hpath}/Loop4/power nxalias "${name}_Loop4_power"
hfactory ${scobj_hpath}/Loop4/sensor plain user float
hsetprop ${scobj_hpath}/Loop4/sensor read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB8.T1:TEMP:SIG:TEMP}
hsetprop ${scobj_hpath}/Loop4/sensor rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/sensor control true
hsetprop ${scobj_hpath}/Loop4/sensor data true
hsetprop ${scobj_hpath}/Loop4/sensor mutable false
hsetprop ${scobj_hpath}/Loop4/sensor nxsave true
hsetprop ${scobj_hpath}/Loop4/sensor permlink data_set "T[format "%02d" ${id}]S04"
hsetprop ${scobj_hpath}/Loop4/sensor @description "T[format "%02d" ${id}]S04"
hsetprop ${scobj_hpath}/Loop4/sensor oldval 0.0
hsetprop ${scobj_hpath}/Loop4/sensor sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/sensor type "part"
hsetprop ${scobj_hpath}/Loop4/sensor nxalias "${name}_Loop4_sensor"
hfactory ${scobj_hpath}/Loop4/setpoint plain user float
hsetprop ${scobj_hpath}/Loop4/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB8.T1:TEMP:LOOP:TSET}
hsetprop ${scobj_hpath}/Loop4/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint write ${ns}::setPoint ${scobj_hpath} noResponse {SET:DEV:DB8.T1:TEMP:LOOP:TSET:}
hsetprop ${scobj_hpath}/Loop4/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint driving 0
hsetprop ${scobj_hpath}/Loop4/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint driveable Loop4/sensor
hsetprop ${scobj_hpath}/Loop4/setpoint control true
hsetprop ${scobj_hpath}/Loop4/setpoint data true
hsetprop ${scobj_hpath}/Loop4/setpoint mutable false
hsetprop ${scobj_hpath}/Loop4/setpoint nxsave true
hsetprop ${scobj_hpath}/Loop4/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/Loop4/setpoint upperlimit 333
hsetprop ${scobj_hpath}/Loop4/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/Loop4/setpoint permlink data_set "T[format "%02d" ${id}]SP04"
hsetprop ${scobj_hpath}/Loop4/setpoint @description "T[format "%02d" ${id}]SP04"
hsetprop ${scobj_hpath}/Loop4/setpoint oldval 0.0
hsetprop ${scobj_hpath}/Loop4/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/setpoint settle_time "15"
hsetprop ${scobj_hpath}/Loop4/setpoint type "drivable"
hsetprop ${scobj_hpath}/Loop4/setpoint nxalias "${name}_Loop4_setpoint"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Loop4/nick 15
${sct_controller} poll ${scobj_hpath}/Loop4/power 5
${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1
${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5
${sct_controller} write ${scobj_hpath}/Loop4/setpoint
ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller}
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::mercury_pres {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_mercury_pres {name IP port {id 99} {tol 1}} {
set catch_status [ catch {
::scobj::mercury_pres::sics_log 9 "add_mercury_pres ${name} ${IP} ${port} ${id} ${tol}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
}
::scobj::mercury_pres::sics_log 1 "::scobj::mercury_pres::mkDriver sct_${name} ${name} ${id} ${tol}"
::scobj::mercury_pres::mkDriver sct_${name} ${name} ${id} ${tol}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_mercury_pres.tcl"
::scobj::mercury_pres::sics_log 9 "file evaluation of sct_mercury_pres.tcl"
proc ::scobj::mercury_pres::read_config {} {
set catch_status [ catch {
set ns "::scobj::mercury_pres"
dict for {k v} $::config_dict {
if { [dict exists $v "driver"] } {
if { [dict get $v "driver"] == "mercury_pres" } {
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
if { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
} 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
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {id 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"
}
}
add_mercury_pres ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::mercury_pres::read_config
} else {
::scobj::mercury_pres::sics_log 5 "No config dict"
}

View File

@ -0,0 +1,441 @@
# Generated driver for mercury_temp
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::mercury_temp {
set debug_threshold 5
}
proc ::scobj::mercury_temp::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 "/tmp/mercury_temp_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::mercury_temp::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::mercury_temp::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::mercury_temp::${debug_string}"
}
} catch_message ]
}
# checklimits function for driveable interface
proc ::scobj::mercury_temp::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::mercury_temp::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::mercury_temp::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::mercury_temp::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::mercury_temp::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::mercury_temp::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::mercury_temp::rdText {tc_root} {
set catch_status [ catch {
debug_log ${tc_root} 1 "rdText 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]"
}
# rdText hook code starts
scan [lindex [split "$data" ":"] end] "%s" data
# rdText 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::mercury_temp::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 starts
scan [lindex [split "$data" ":"] end] "%g" data
# rdValue 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 write a parameter value on a device
proc ::scobj::mercury_temp::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 goes here
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::mercury_temp::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 goes here
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::mercury_temp::mkDriver { sct_controller name id tol } {
::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::mkDriver ${sct_controller} ${name} ${id} ${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}/Loop4 plain spy none
hfactory ${scobj_hpath}/Loop4/nick plain user text
hsetprop ${scobj_hpath}/Loop4/nick read ${ns}::getValue ${scobj_hpath} rdText {READ:DEV:DB8.T1:TEMP:NICK}
hsetprop ${scobj_hpath}/Loop4/nick rdText ${ns}::rdText ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/nick control true
hsetprop ${scobj_hpath}/Loop4/nick data true
hsetprop ${scobj_hpath}/Loop4/nick mutable false
hsetprop ${scobj_hpath}/Loop4/nick nxsave true
hsetprop ${scobj_hpath}/Loop4/nick oldval UNKNOWN
hsetprop ${scobj_hpath}/Loop4/nick sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/nick type "part"
hsetprop ${scobj_hpath}/Loop4/nick nxalias "${name}_Loop4_nick"
hfactory ${scobj_hpath}/Loop4/power plain user float
hsetprop ${scobj_hpath}/Loop4/power read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB3.H1:HTR:SIG:POWR}
hsetprop ${scobj_hpath}/Loop4/power rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/power control true
hsetprop ${scobj_hpath}/Loop4/power data true
hsetprop ${scobj_hpath}/Loop4/power mutable false
hsetprop ${scobj_hpath}/Loop4/power nxsave true
hsetprop ${scobj_hpath}/Loop4/power oldval 0.0
hsetprop ${scobj_hpath}/Loop4/power sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/power type "part"
hsetprop ${scobj_hpath}/Loop4/power nxalias "${name}_Loop4_power"
hfactory ${scobj_hpath}/Loop4/sensor plain user float
hsetprop ${scobj_hpath}/Loop4/sensor read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB8.T1:TEMP:SIG:TEMP}
hsetprop ${scobj_hpath}/Loop4/sensor rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/sensor control true
hsetprop ${scobj_hpath}/Loop4/sensor data true
hsetprop ${scobj_hpath}/Loop4/sensor mutable false
hsetprop ${scobj_hpath}/Loop4/sensor nxsave true
hsetprop ${scobj_hpath}/Loop4/sensor permlink data_set "T[format "%02d" ${id}]S04"
hsetprop ${scobj_hpath}/Loop4/sensor @description "T[format "%02d" ${id}]S04"
hsetprop ${scobj_hpath}/Loop4/sensor oldval 0.0
hsetprop ${scobj_hpath}/Loop4/sensor sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/sensor type "part"
hsetprop ${scobj_hpath}/Loop4/sensor nxalias "${name}_Loop4_sensor"
hfactory ${scobj_hpath}/Loop4/setpoint plain user float
hsetprop ${scobj_hpath}/Loop4/setpoint read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB8.T1:TEMP:LOOP:TSET}
hsetprop ${scobj_hpath}/Loop4/setpoint rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint write ${ns}::setPoint ${scobj_hpath} noResponse {SET:DEV:DB8.T1:TEMP:LOOP:TSET:}
hsetprop ${scobj_hpath}/Loop4/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint driving 0
hsetprop ${scobj_hpath}/Loop4/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/Loop4/setpoint driveable Loop4/sensor
hsetprop ${scobj_hpath}/Loop4/setpoint control true
hsetprop ${scobj_hpath}/Loop4/setpoint data true
hsetprop ${scobj_hpath}/Loop4/setpoint mutable false
hsetprop ${scobj_hpath}/Loop4/setpoint nxsave true
hsetprop ${scobj_hpath}/Loop4/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/Loop4/setpoint upperlimit 333
hsetprop ${scobj_hpath}/Loop4/setpoint tolerance ${tol}
hsetprop ${scobj_hpath}/Loop4/setpoint permlink data_set "T[format "%02d" ${id}]SP04"
hsetprop ${scobj_hpath}/Loop4/setpoint @description "T[format "%02d" ${id}]SP04"
hsetprop ${scobj_hpath}/Loop4/setpoint oldval 0.0
hsetprop ${scobj_hpath}/Loop4/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Loop4/setpoint settle_time "15"
hsetprop ${scobj_hpath}/Loop4/setpoint type "drivable"
hsetprop ${scobj_hpath}/Loop4/setpoint nxalias "${name}_Loop4_setpoint"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Loop4/nick 15
${sct_controller} poll ${scobj_hpath}/Loop4/power 5
${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1
${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5
${sct_controller} write ${scobj_hpath}/Loop4/setpoint
ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller}
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::mercury_temp {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_mercury_temp {name IP port {id 99} {tol 1}} {
set catch_status [ catch {
::scobj::mercury_temp::sics_log 9 "add_mercury_temp ${name} ${IP} ${port} ${id} ${tol}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
}
::scobj::mercury_temp::sics_log 1 "::scobj::mercury_temp::mkDriver sct_${name} ${name} ${id} ${tol}"
::scobj::mercury_temp::mkDriver sct_${name} ${name} ${id} ${tol}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_mercury_temp.tcl"
::scobj::mercury_temp::sics_log 9 "file evaluation of sct_mercury_temp.tcl"
proc ::scobj::mercury_temp::read_config {} {
set catch_status [ catch {
set ns "::scobj::mercury_temp"
dict for {k v} $::config_dict {
if { [dict exists $v "driver"] } {
if { [dict get $v "driver"] == "mercury_temp" } {
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
if { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
} 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
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {id 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"
}
}
add_mercury_temp ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::mercury_temp::read_config
} else {
::scobj::mercury_temp::sics_log 5 "No config dict"
}

View File

@ -0,0 +1,390 @@
# Generated driver for mercury_valve
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::mercury_valve {
set debug_threshold 5
}
proc ::scobj::mercury_valve::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 "/tmp/mercury_valve_[basename ${tc_root}].log" "a"]
set line "[clock format [clock seconds] -format "%T"] ${debug_string}"
puts ${fd} "${line}"
close ${fd}
}
} catch_message ]
}
proc ::scobj::mercury_valve::sics_log {debug_level debug_string} {
set catch_status [ catch {
set debug_threshold ${::scobj::mercury_valve::debug_threshold}
if {${debug_level} >= ${debug_threshold}} {
sicslog "::scobj::mercury_valve::${debug_string}"
}
} catch_message ]
}
# checklimits function for driveable interface
proc ::scobj::mercury_valve::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::mercury_valve::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::mercury_valve::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::mercury_valve::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::mercury_valve::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::mercury_valve::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::mercury_valve::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 starts
scan [lindex [split "$data" ":"] end] "%g" data
# rdValue 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 write a parameter value on a device
proc ::scobj::mercury_valve::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 goes here
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}
}
# function to write a parameter value on a device
proc ::scobj::mercury_valve::setValve {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log ${tc_root} 1 "setValve 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}"
# setValve hook code starts
if { [hpropexists [sct] pid_bias] } {
set par [expr ${par} + [hgetpropval [sct] pid_bias]]
set cmd "${cmd_str}${par}"
}
sct update [sct target]
# setValve 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 "setValve 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::mercury_valve::mkDriver { sct_controller name id valve_tol } {
::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::mkDriver ${sct_controller} ${name} ${id} ${valve_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}/Valve plain spy none
hfactory ${scobj_hpath}/Valve/sensor plain user float
hsetprop ${scobj_hpath}/Valve/sensor read ${ns}::getValue ${scobj_hpath} rdValue {READ:DEV:DB4.G1:AUX:SIG:OPEN}
hsetprop ${scobj_hpath}/Valve/sensor rdValue ${ns}::rdValue ${scobj_hpath}
hsetprop ${scobj_hpath}/Valve/sensor control true
hsetprop ${scobj_hpath}/Valve/sensor data true
hsetprop ${scobj_hpath}/Valve/sensor mutable false
hsetprop ${scobj_hpath}/Valve/sensor nxsave true
hsetprop ${scobj_hpath}/Valve/sensor permlink data_set "G[format "%02d" ${id}]S07"
hsetprop ${scobj_hpath}/Valve/sensor @description "G[format "%02d" ${id}]S07"
hsetprop ${scobj_hpath}/Valve/sensor oldval 0.0
hsetprop ${scobj_hpath}/Valve/sensor sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Valve/sensor type "part"
hsetprop ${scobj_hpath}/Valve/sensor nxalias "${name}_Valve_sensor"
hfactory ${scobj_hpath}/Valve/setpoint plain user float
hsetprop ${scobj_hpath}/Valve/setpoint write ${ns}::setValve ${scobj_hpath} noResponse {SET:DEV:DB4.G1:AUX:SIG:OPEN:}
hsetprop ${scobj_hpath}/Valve/setpoint noResponse ${ns}::noResponse ${scobj_hpath}
hsetprop ${scobj_hpath}/Valve/setpoint check ${ns}::checkrange ${scobj_hpath}
hsetprop ${scobj_hpath}/Valve/setpoint driving 0
hsetprop ${scobj_hpath}/Valve/setpoint checklimits ${ns}::checklimits ${scobj_hpath}
hsetprop ${scobj_hpath}/Valve/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath}
hsetprop ${scobj_hpath}/Valve/setpoint halt ${ns}::halt ${scobj_hpath}
hsetprop ${scobj_hpath}/Valve/setpoint driveable Valve/sensor
hsetprop ${scobj_hpath}/Valve/setpoint control true
hsetprop ${scobj_hpath}/Valve/setpoint data true
hsetprop ${scobj_hpath}/Valve/setpoint mutable false
hsetprop ${scobj_hpath}/Valve/setpoint nxsave true
hsetprop ${scobj_hpath}/Valve/setpoint lowerlimit 0
hsetprop ${scobj_hpath}/Valve/setpoint upperlimit 100
hsetprop ${scobj_hpath}/Valve/setpoint tolerance ${valve_tol}
hsetprop ${scobj_hpath}/Valve/setpoint permlink data_set "G[format "%02d" ${id}]SP07"
hsetprop ${scobj_hpath}/Valve/setpoint @description "G[format "%02d" ${id}]SP07"
hsetprop ${scobj_hpath}/Valve/setpoint oldval 0.0
hsetprop ${scobj_hpath}/Valve/setpoint sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/Valve/setpoint settle_time "30"
hsetprop ${scobj_hpath}/Valve/setpoint type "drivable"
hsetprop ${scobj_hpath}/Valve/setpoint nxalias "${name}_Valve_setpoint"
if {[SplitReply [environment_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/Valve/sensor 5
${sct_controller} write ${scobj_hpath}/Valve/setpoint
ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller}
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 5
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
namespace eval ::scobj::mercury_valve {
namespace export debug_threshold
namespace export debug_log
namespace export sics_log
namespace export mkDriver
}
proc add_mercury_valve {name IP port {id 99} {valve_tol 2}} {
set catch_status [ catch {
::scobj::mercury_valve::sics_log 9 "add_mercury_valve ${name} ${IP} ${port} ${id} ${valve_tol}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}"
makesctcontroller sct_${name} aqadapter ${port}
} else {
::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}"
makesctcontroller sct_${name} std ${IP}:${port}
}
}
::scobj::mercury_valve::sics_log 1 "::scobj::mercury_valve::mkDriver sct_${name} ${name} ${id} ${valve_tol}"
::scobj::mercury_valve::mkDriver sct_${name} ${name} ${id} ${valve_tol}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_mercury_valve.tcl"
::scobj::mercury_valve::sics_log 9 "file evaluation of sct_mercury_valve.tcl"
proc ::scobj::mercury_valve::read_config {} {
set catch_status [ catch {
set ns "::scobj::mercury_valve"
dict for {k v} $::config_dict {
if { [dict exists $v "driver"] } {
if { [dict get $v "driver"] == "mercury_valve" } {
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
if { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
} 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
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
foreach arg {id valve_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"
}
}
add_mercury_valve ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::mercury_valve::read_config
} else {
::scobj::mercury_valve::sics_log 5 "No config dict"
}

View File

@ -42,6 +42,11 @@ fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl
fileeval $cfPath(environment)/temperature/sct_lakeshore_370.tcl
fileeval $cfPath(environment)/temperature/sct_oxford_itc.tcl
fileeval $cfPath(environment)/temperature/sct_oxford_mercury.tcl
fileeval $cfPath(environment)/temperature/sct_mercury_base.tcl
fileeval $cfPath(environment)/temperature/sct_mercury_temp.tcl
fileeval $cfPath(environment)/temperature/sct_mercury_pres.tcl
fileeval $cfPath(environment)/temperature/sct_mercury_level.tcl
fileeval $cfPath(environment)/temperature/sct_mercury_valve.tcl
fileeval $cfPath(environment)/temperature/west400.tcl
fileeval $cfPath(environment)/he3/sct_he3.tcl
fileeval $cfPath(environment)/magneticField/oxford_labview.tcl