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