Update generated driver code

This commit is contained in:
Douglas Clowes
2014-04-14 10:34:43 +10:00
parent ff43028b1a
commit d08f5b6541
5 changed files with 263 additions and 20 deletions

View File

@ -1,5 +1,5 @@
# Generated driver for shutters
# vim: tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::shutters {
@ -34,6 +34,7 @@ proc ::scobj::shutters::checkrange {tc_root} {
# upperlimit not set, use target
set hilimit [sct target]
}
# hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
@ -50,8 +51,11 @@ proc ::scobj::shutters::getValue {tc_root nextState cmd_str} {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -61,6 +65,7 @@ proc ::scobj::shutters::getValue {tc_root nextState cmd_str} {
proc ::scobj::shutters::noResponse {tc_root} {
set catch_status [ catch {
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -127,6 +132,7 @@ proc ::scobj::shutters::setValue {tc_root nextState cmd_str} {
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
@ -273,10 +279,39 @@ proc add_shutters {name IP port} {
}
${ns}::debug_log 1 "mk_sct_shutters sct_${name} ${name}"
${ns}::mk_sct_shutters sct_${name} ${name}
close ${fd}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_shutters.tcl"
::scobj::shutters::debug_log 1 "file evaluation of sct_shutters.tcl"
proc ::scobj::shutters::read_config {} {
set catch_status [ catch {
set ns "::scobj::shutters"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "shutters" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_shutters ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::shutters::read_config
} else {
::scobj::shutters:debug_log 1 "No config dict"
}

View File

@ -1,5 +1,5 @@
# Generated driver for tank
# vim: tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::tank {
@ -34,6 +34,7 @@ proc ::scobj::tank::checkrange {tc_root} {
# upperlimit not set, use target
set hilimit [sct target]
}
# hook code goes here
if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } {
error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]"
}
@ -50,8 +51,11 @@ proc ::scobj::tank::getValue {tc_root nextState cmd_str} {
hdelprop [sct] geterror
}
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -61,6 +65,7 @@ proc ::scobj::tank::getValue {tc_root nextState cmd_str} {
proc ::scobj::tank::noResponse {tc_root} {
set catch_status [ catch {
debug_log 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]"
# hook code goes here
return "idle"
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -124,6 +129,7 @@ proc ::scobj::tank::setValue {tc_root nextState cmd_str} {
}
set par [sct target]
set cmd "${cmd_str}${par}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
@ -160,7 +166,9 @@ proc ::scobj::tank::mk_sct_tank { sct_controller name } {
hsetprop ${scobj_hpath}/limits/forward mutable false
hsetprop ${scobj_hpath}/limits/forward nxsave true
hsetprop ${scobj_hpath}/limits/forward oldval UNKNOWN
hsetprop ${scobj_hpath}/limits/forward sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/limits/forward type "part"
hsetprop ${scobj_hpath}/limits/forward nxalias "${name}_limits_forward"
hfactory ${scobj_hpath}/limits/reverse plain user text
hsetprop ${scobj_hpath}/limits/reverse read ${ns}::getValue ${scobj_hpath} read_switch {MG _LRH}
@ -170,7 +178,9 @@ proc ::scobj::tank::mk_sct_tank { sct_controller name } {
hsetprop ${scobj_hpath}/limits/reverse mutable false
hsetprop ${scobj_hpath}/limits/reverse nxsave true
hsetprop ${scobj_hpath}/limits/reverse oldval UNKNOWN
hsetprop ${scobj_hpath}/limits/reverse sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/limits/reverse type "part"
hsetprop ${scobj_hpath}/limits/reverse nxalias "${name}_limits_reverse"
if {[SplitReply [motor_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/limits/forward 1
@ -187,7 +197,9 @@ proc ::scobj::tank::mk_sct_tank { sct_controller name } {
hsetprop ${scobj_hpath}/switches/forward mutable false
hsetprop ${scobj_hpath}/switches/forward nxsave true
hsetprop ${scobj_hpath}/switches/forward oldval UNKNOWN
hsetprop ${scobj_hpath}/switches/forward sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/switches/forward type "part"
hsetprop ${scobj_hpath}/switches/forward nxalias "${name}_switches_forward"
hfactory ${scobj_hpath}/switches/reverse plain user text
hsetprop ${scobj_hpath}/switches/reverse read ${ns}::getValue ${scobj_hpath} read_switch {MG @IN[6]}
@ -197,7 +209,9 @@ proc ::scobj::tank::mk_sct_tank { sct_controller name } {
hsetprop ${scobj_hpath}/switches/reverse mutable false
hsetprop ${scobj_hpath}/switches/reverse nxsave true
hsetprop ${scobj_hpath}/switches/reverse oldval UNKNOWN
hsetprop ${scobj_hpath}/switches/reverse sdsinfo "::nexus::scobj::sdsinfo"
hsetprop ${scobj_hpath}/switches/reverse type "part"
hsetprop ${scobj_hpath}/switches/reverse nxalias "${name}_switches_reverse"
if {[SplitReply [motor_simulation]]=="false"} {
${sct_controller} poll ${scobj_hpath}/switches/forward 1
@ -230,10 +244,39 @@ proc add_tank {name IP port} {
}
${ns}::debug_log 1 "mk_sct_tank sct_${name} ${name}"
${ns}::mk_sct_tank sct_${name} ${name}
close ${fd}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_tank.tcl"
::scobj::tank::debug_log 1 "file evaluation of sct_tank.tcl"
proc ::scobj::tank::read_config {} {
set catch_status [ catch {
set ns "::scobj::tank"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "tank" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_tank ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::tank::read_config
} else {
::scobj::tank:debug_log 1 "No config dict"
}

View File

@ -1,5 +1,5 @@
# Generated driver for hiden_xcs
# vim: tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::hiden_xcs {
@ -154,6 +154,7 @@ proc ::scobj::hiden_xcs::fetch_flow {tc_root nextState cmd_str} {
sct targets ${targets}
if { [hpropexists [sct] target] } {
set pid [pid_flow ${tc_root} [sct target] ${data}]
}
# cut this function short
return ${nextState}
# hook code ends
@ -162,7 +163,9 @@ proc ::scobj::hiden_xcs::fetch_flow {tc_root nextState cmd_str} {
error "[sct geterror]"
}
debug_log 1 "fetch_flow sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -178,7 +181,9 @@ proc ::scobj::hiden_xcs::getValue {tc_root nextState cmd_str} {
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -206,6 +211,36 @@ proc ::scobj::hiden_xcs::noResponse {tc_root} {
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::hiden_xcs::no_op {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 1 "no_op 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}"
# hook code starts
set cmd "@@NOSEND@@"
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
error "[sct geterror]"
}
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 1 "no_op sct send ${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
# pid function for PID control
proc ::scobj::hiden_xcs::pid_flow {tc_root sp pv} {
set catch_status [ catch {
@ -336,6 +371,7 @@ proc ::scobj::hiden_xcs::read_all_data {tc_root} {
}
if { [hpropexists [sct] target] } {
set pid [pid_humidity ${tc_root} [sct target] ${data}]
}
# hook code ends
if { [hpropexists [sct] geterror] } {
debug_log 1 "[sct] error: [sct geterror]"
@ -701,7 +737,7 @@ proc ::scobj::hiden_xcs::write_twelve {tc_root nextState cmd_str} {
}
proc ::scobj::hiden_xcs::mk_sct_hiden_xcs { sct_controller name tol } {
debug_log 1 "mk_sct_hiden_xcs for ${name}"
debug_log 1 "mk_sct_hiden_xcs ${sct_controller} ${name} ${tol}"
set ns "[namespace current]"
set catch_status [ catch {
@ -858,9 +894,9 @@ proc ::scobj::hiden_xcs::mk_sct_hiden_xcs { sct_controller name tol } {
${sct_controller} poll ${scobj_hpath}/humidity 1
${sct_controller} write ${scobj_hpath}/enabled
${sct_controller} write ${scobj_hpath}/flow
ansto_makesctdrive ${name}_flow ${scobj_hpath}/flow ${scobj_hpath}/flow ${sct_controller}
ansto_makesctdrive ${name}_temperature ${scobj_hpath}/flow ${scobj_hpath}/flow ${sct_controller}
${sct_controller} write ${scobj_hpath}/humidity
ansto_makesctdrive ${name}_humidity ${scobj_hpath}/humidity ${scobj_hpath}/humidity ${sct_controller}
ansto_makesctdrive ${name}_temperature ${scobj_hpath}/humidity ${scobj_hpath}/humidity ${sct_controller}
}
hfactory ${scobj_hpath}/analog plain spy none
@ -1029,7 +1065,7 @@ namespace eval ::scobj::hiden_xcs {
proc add_hiden_xcs {name IP port terminator {tol 0.5}} {
set catch_status [ catch {
set ns "::scobj::hiden_xcs"
${ns}::debug_log 1 "add_hiden_xcs ${name} ${IP} ${port}"
${ns}::debug_log 1 "add_hiden_xcs ${name} ${IP} ${port} ${tol}"
if {[SplitReply [environment_simulation]]=="false"} {
if {[string equal -nocase "aqadapter" "${IP}"]} {
${ns}::debug_log 1 "makesctcontroller sct_${name} aqadapter ${port}"
@ -1041,10 +1077,50 @@ proc add_hiden_xcs {name IP port terminator {tol 0.5}} {
}
${ns}::debug_log 1 "mk_sct_hiden_xcs sct_${name} ${name} ${tol}"
${ns}::mk_sct_hiden_xcs sct_${name} ${name} ${tol}
close ${fd}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_hiden_xcs.tcl"
::scobj::hiden_xcs::debug_log 1 "file evaluation of sct_hiden_xcs.tcl"
proc ::scobj::hiden_xcs::read_config {} {
set catch_status [ catch {
set ns "::scobj::hiden_xcs"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "hiden_xcs" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
set arg_list [list]
foreach arg {tol} {
if {[dict exists $v $arg]} {
lappend arg_list "[dict get $v $arg]"
} else {
${ns}::debug_log 1 "Missing configuration value $arg"
error "Missing configuration value $arg"
}
}
${ns}::debug_log 1 "arg_list = $arg_list"
${ns}::debug_log 1 "add_hiden_xcs ${name} aqadapter ${name}_queue $arg_list"
add_hiden_xcs ${name} "aqadapter" ${name}_queue {*}$arg_list
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::hiden_xcs::read_config
} else {
::scobj::hiden_xcs:debug_log 1 "No config dict"
}

View File

@ -1,5 +1,5 @@
# Generated driver for isotech_ps
# vim: tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::isotech_ps {
@ -53,7 +53,9 @@ proc ::scobj::isotech_ps::getValue {tc_root nextState cmd_str} {
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -317,10 +319,39 @@ proc add_isotech_ps {name IP port} {
}
${ns}::debug_log 1 "mk_sct_isotech_ps sct_${name} ${name}"
${ns}::mk_sct_isotech_ps sct_${name} ${name}
close ${fd}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
puts stdout "file evaluation of sct_isotech_ps.tcl"
::scobj::isotech_ps::debug_log 1 "file evaluation of sct_isotech_ps.tcl"
proc ::scobj::isotech_ps::read_config {} {
set catch_status [ catch {
set ns "::scobj::isotech_ps"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "isotech_ps" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_isotech_ps ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::isotech_ps::read_config
} else {
::scobj::isotech_ps:debug_log 1 "No config dict"
}

View File

@ -1,5 +1,5 @@
# Generated driver for reactor_status
# vim: tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent
#
namespace eval ::scobj::reactor_status {
@ -53,7 +53,9 @@ proc ::scobj::reactor_status::getState {tc_root nextState cmd_str} {
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getState sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -69,7 +71,9 @@ proc ::scobj::reactor_status::getValue {tc_root nextState cmd_str} {
set cmd "${cmd_str}"
# hook code goes here
debug_log 1 "getValue sct send ${cmd}"
sct send "${cmd}"
if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} {
sct send "${cmd}"
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@ -154,6 +158,30 @@ proc ::scobj::reactor_status::rdValue {tc_root} {
handle_exception ${catch_status} ${catch_message}
}
# function to write a parameter value on a device
proc ::scobj::reactor_status::setPoint {tc_root nextState cmd_str} {
set catch_status [ catch {
debug_log 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}"
# hook code goes here
if { [hpropexists [sct] driving] } {
if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } {
sct driving 1
}
}
debug_log 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::reactor_status::setValue {tc_root nextState cmd_str} {
set catch_status [ catch {
@ -296,3 +324,33 @@ proc add_reactor_status {name IP port} {
puts stdout "file evaluation of sct_reactor_status.tcl"
::scobj::reactor_status::debug_log 1 "file evaluation of sct_reactor_status.tcl"
proc ::scobj::reactor_status::read_config {} {
set catch_status [ catch {
set ns "::scobj::reactor_status"
${ns}::debug_log 1 "Processing Config"
dict for {k v} $::config_dict {
${ns}::debug_log 1 "Inspecting $k:$v"
if { [dict exists $v "driver"] } {
${ns}::debug_log 1 "Has driver [dict get $v driver]"
if { [dict get $v "driver"] == "reactor_status" } {
${ns}::debug_log 1 "Correct driver, enabled = [dict get $v enabled]"
if { [dict get $v enabled] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
set name [dict get $v name]
MakeAsyncProtocol ${name}_protocol
MakeAsyncQueue ${name}_queue ${name}_protocol ${IP} ${PORT}
add_reactor_status ${name} "aqadapter" ${name}_queue
}
}
}
}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
}
if { [info exists ::config_dict] } {
::scobj::reactor_status::read_config
} else {
::scobj::reactor_status:debug_log 1 "No config dict"
}