Make all sct drivers.
This commit is contained in:
@@ -250,19 +250,19 @@ proc ::scobj::hiden_xcs::no_op {tc_root nextState cmd_str} {
|
||||
proc ::scobj::hiden_xcs::pid_flow {tc_root sp pv} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "pid_flow tc_root=${tc_root} sct=[sct] pv=${pv} sp=${sp}"
|
||||
sct pid_error [expr ${sp} - ${pv}]
|
||||
set p_value [expr [sct pid_pvalue] * [sct pid_error]]
|
||||
set d_value [expr [sct pid_dvalue] * (${pv} - [sct oldval])]
|
||||
sct pid_error [expr {${sp} - ${pv}}]
|
||||
set p_value [expr {[sct pid_pvalue] * [sct pid_error]}]
|
||||
set d_value [expr {[sct pid_dvalue] * (${pv} - [sct oldval])}]
|
||||
sct pid_deriv [sct pid_error]
|
||||
sct pid_integ [expr [sct pid_integ] + [sct pid_error]]
|
||||
sct pid_integ [expr {[sct pid_integ] + [sct pid_error]}]
|
||||
if { [sct pid_integ] > [sct pid_imax] } {
|
||||
sct pid_integ [sct pid_imax]
|
||||
}
|
||||
if { [sct pid_integ] < -[sct pid_imax] } {
|
||||
sct pid_integ -[sct pid_imax]
|
||||
}
|
||||
set i_value [expr [sct pid_ivalue] * [sct pid_integ]]
|
||||
set pid [expr ${p_value} + ${i_value} + ${d_value}]
|
||||
set i_value [expr {[sct pid_ivalue] * [sct pid_integ]}]
|
||||
set pid [expr {${p_value} + ${i_value} + ${d_value}}]
|
||||
# pid_flow hook code starts
|
||||
foreach node [list ${tc_root}/analog/sp1 ${tc_root}/analog/sp2] {
|
||||
if { !([hpropexists ${node} bias_flow] && [hgetpropval ${node} bias_flow] == ${pid}) } {
|
||||
@@ -285,19 +285,19 @@ proc ::scobj::hiden_xcs::pid_flow {tc_root sp pv} {
|
||||
proc ::scobj::hiden_xcs::pid_humidity {tc_root sp pv} {
|
||||
set catch_status [ catch {
|
||||
debug_log ${tc_root} 1 "pid_humidity tc_root=${tc_root} sct=[sct] pv=${pv} sp=${sp}"
|
||||
sct pid_error [expr ${sp} - ${pv}]
|
||||
set p_value [expr [sct pid_pvalue] * [sct pid_error]]
|
||||
set d_value [expr [sct pid_dvalue] * (${pv} - [sct oldval])]
|
||||
sct pid_error [expr {${sp} - ${pv}}]
|
||||
set p_value [expr {[sct pid_pvalue] * [sct pid_error]}]
|
||||
set d_value [expr {[sct pid_dvalue] * (${pv} - [sct oldval])}]
|
||||
sct pid_deriv [sct pid_error]
|
||||
sct pid_integ [expr [sct pid_integ] + [sct pid_error]]
|
||||
sct pid_integ [expr {[sct pid_integ] + [sct pid_error]}]
|
||||
if { [sct pid_integ] > [sct pid_imax] } {
|
||||
sct pid_integ [sct pid_imax]
|
||||
}
|
||||
if { [sct pid_integ] < -[sct pid_imax] } {
|
||||
sct pid_integ -[sct pid_imax]
|
||||
}
|
||||
set i_value [expr [sct pid_ivalue] * [sct pid_integ]]
|
||||
set pid [expr ${p_value} + ${i_value} + ${d_value}]
|
||||
set i_value [expr {[sct pid_ivalue] * [sct pid_integ]}]
|
||||
set pid [expr {${p_value} + ${i_value} + ${d_value}}]
|
||||
# pid_humidity hook code starts
|
||||
set sign 1
|
||||
foreach node [list ${tc_root}/analog/sp1 ${tc_root}/analog/sp2] {
|
||||
@@ -339,7 +339,7 @@ proc ::scobj::hiden_xcs::rdValue {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -389,7 +389,7 @@ proc ::scobj::hiden_xcs::read_all_data {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -430,7 +430,7 @@ proc ::scobj::hiden_xcs::read_digital {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -456,7 +456,7 @@ proc ::scobj::hiden_xcs::read_flow {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -507,7 +507,7 @@ proc ::scobj::hiden_xcs::read_sixteen {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -558,7 +558,7 @@ proc ::scobj::hiden_xcs::read_twelve {tc_root} {
|
||||
sct oldval ${data}
|
||||
sct update ${data}
|
||||
sct utime readtime
|
||||
}
|
||||
}
|
||||
return ${nextState}
|
||||
} catch_message ]
|
||||
handle_exception ${catch_status} ${catch_message}
|
||||
@@ -1050,7 +1050,6 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name id } {
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/flow/sensor 1
|
||||
${sct_controller} write ${scobj_hpath}/flow/setpoint
|
||||
ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs"
|
||||
}
|
||||
@@ -1109,12 +1108,15 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name id } {
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
${sct_controller} poll ${scobj_hpath}/humidity/sensor 1
|
||||
${sct_controller} write ${scobj_hpath}/humidity/setpoint
|
||||
ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller}
|
||||
} else {
|
||||
::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs"
|
||||
}
|
||||
hsetprop ${scobj_hpath} klass environment
|
||||
hsetprop ${scobj_hpath} debug_threshold 5
|
||||
if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} {
|
||||
ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller}
|
||||
ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller}
|
||||
}
|
||||
# mkDriver hook code starts
|
||||
# mkDriver hook code ends
|
||||
} catch_message ]
|
||||
@@ -1154,14 +1156,17 @@ clientput "file evaluation of sct_hiden_xcs.tcl"
|
||||
proc ::scobj::hiden_xcs::read_config {} {
|
||||
set catch_status [ catch {
|
||||
set ns "::scobj::hiden_xcs"
|
||||
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
|
||||
}
|
||||
@@ -1170,40 +1175,52 @@ proc ::scobj::hiden_xcs::read_config {} {
|
||||
continue
|
||||
}
|
||||
if { [string equal -nocase [dict get $v "driver"] "hiden_xcs"] } {
|
||||
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} {
|
||||
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} {
|
||||
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_hiden_xcs ${name} ${IP} ${PORT} {*}$arg_list
|
||||
} else {
|
||||
add_hiden_xcs ${name} "aqadapter" ${asyncqueue} {*}$arg_list
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user