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