Make all sct drivers.

This commit is contained in:
Ferdi Franceschini
2014-07-15 10:56:27 +10:00
parent ac136f3426
commit c1b5b558f0
20 changed files with 882 additions and 652 deletions

View File

@@ -180,7 +180,7 @@ proc ::scobj::mercury_temp::rdText {tc_root} {
sct oldval ${data}
sct update ${data}
sct utime readtime
}
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@@ -212,7 +212,7 @@ proc ::scobj::mercury_temp::rdValue {tc_root} {
sct oldval ${data}
sct update ${data}
sct utime readtime
}
}
return ${nextState}
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@@ -350,12 +350,14 @@ proc ::scobj::mercury_temp::mkDriver { sct_controller name id tol } {
${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}
} else {
::scobj::mercury_temp::sics_log 9 "[environment_simulation] => No poll/write for mercury_temp"
}
hsetprop ${scobj_hpath} klass environment
hsetprop ${scobj_hpath} debug_threshold 5
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller}
}
# mkDriver hook code goes here
} catch_message ]
handle_exception ${catch_status} ${catch_message}
@@ -394,14 +396,17 @@ clientput "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 "implementation"] } {
if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {
dict for {k u} $::config_dict {
if { [dict exists $u "implementation"] } {
if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {
continue
}
set name [dict get $v name]
set enabled [string tolower [dict get $v "enabled"]]
set implementation [dict get $v "implementation"]
set enabled [string tolower [dict get $u "enabled"]]
if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {
continue
}
set name [dict get $u name]
set implementation [dict get $u "implementation"]
if { !([dict exists $::config_dict $implementation]) } {
continue
}
@@ -410,40 +415,52 @@ proc ::scobj::mercury_temp::read_config {} {
continue
}
if { [string equal -nocase [dict get $v "driver"] "mercury_temp"] } {
if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
} elseif { [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
if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } {
set asyncqueue "null"
${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue"
} elseif { [dict exists $v "asyncqueue"] } {
set asyncqueue [dict get $v "asyncqueue"]
if { [string equal -nocase ${asyncqueue} "sct"] } {
set IP [dict get $v ip]
set PORT [dict get $v port]
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
} 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 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"
}
set asyncqueue ${name}_queue
set IP [dict get $v ip]
set PORT [dict get $v port]
MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT}
if { [dict exists $v "timeout"] } {
${asyncqueue} timeout "[dict get $v "timeout"]"
}
}
set arg_list [list]
set missing_list [list]
foreach arg {id tol} {
if {[dict exists $u $arg]} {
lappend arg_list "[dict get $u $arg]"
} elseif {[dict exists $v $arg]} {
lappend arg_list "[dict get $v $arg]"
} else {
${ns}::sics_log 9 "Missing configuration value $arg"
lappend missing_list $arg
}
}
if { [llength $missing_list] > 0 } {
error "$name is missing configuration values $missing_list"
}
if { [string equal -nocase ${asyncqueue} "sct"] } {
add_mercury_temp ${name} ${IP} ${PORT} {*}$arg_list
} else {
add_mercury_temp ${name} "aqadapter" ${asyncqueue} {*}$arg_list
}
}