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 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"
}