# Generated driver for hiden_xcs # vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent # namespace eval ::scobj::hiden_xcs { set debug_threshold 5 } proc ::scobj::hiden_xcs::debug_log {tc_root debug_level debug_string} { set catch_status [ catch { set debug_threshold [hgetpropval ${tc_root} debug_threshold] if {${debug_level} >= ${debug_threshold}} { set now [clock seconds] set ts [clock format ${now} -format "%Y%m%d"] set log_file_name "../log/hiden_xcs_[basename ${tc_root}]_${ts}.log" set fd [open "${log_file_name}" "a"] set ts [clock format ${now} -format "%T"] puts ${fd} "${ts} ${debug_string}" close ${fd} } } catch_message ] } proc ::scobj::hiden_xcs::sics_log {debug_level debug_string} { set catch_status [ catch { set debug_threshold ${::scobj::hiden_xcs::debug_threshold} if {${debug_level} >= ${debug_threshold}} { sicslog "::scobj::hiden_xcs::${debug_string}" } } catch_message ] } # checklimits function for driveable interface proc ::scobj::hiden_xcs::checklimits {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "checklimits tc_root=${tc_root} sct=[sct] target=[sct target]" set setpoint [sct target] if { [hpropexists [sct] lowerlimit] } { set lolimit [sct lowerlimit] } else { # lowerlimit not set, use target set lolimit [sct target] } if { [hpropexists [sct] upperlimit] } { set hilimit [sct upperlimit] } else { # upperlimit not set, use target set hilimit [sct target] } # checklimits hook code goes here if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { sct driving 0 error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" } return OK } catch_message ] handle_exception ${catch_status} ${catch_message} } # check function for hset change proc ::scobj::hiden_xcs::checkrange {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]" set setpoint [sct target] if { [hpropexists [sct] lowerlimit] } { set lolimit [sct lowerlimit] } else { # lowerlimit not set, use target set lolimit [sct target] } if { [hpropexists [sct] upperlimit] } { set hilimit [sct upperlimit] } else { # upperlimit not set, use target set hilimit [sct target] } # checkrange hook code goes here if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" } return OK } catch_message ] handle_exception ${catch_status} ${catch_message} } # checkstatus function for driveable interface proc ::scobj::hiden_xcs::checkstatus {tc_root} { set catch_status [ catch { # checkstatus hook code goes here if {[sct driving]} { set sp "[sct target]" if {[hpropexists [sct] simulated] && [sct simulated] == "true"} { set pv "${sp}" hupdateif ${tc_root}/[sct driveable] ${sp} } else { set pv "[hval ${tc_root}/[sct driveable]]" } if { abs(${pv} - ${sp}) <= [sct tolerance] } { if { [hpropexists [sct] settle_time] } { if { [hpropexists [sct] settle_time_start] } { if { [sct utime] - [sct settle_time_start] >= [sct settle_time]} { sct driving 0 return "idle" } return "busy" } else { sct utime settle_time_start return "busy" } } sct driving 0 return "idle" } if { [hpropexists [sct] settle_time_start] } { hdelprop [sct] settle_time_start } return "busy" } else { return "idle" } } catch_message ] handle_exception ${catch_status} ${catch_message} } # check function for hset change proc ::scobj::hiden_xcs::chkrange_function {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "chkrange_function tc_root=${tc_root} sct=[sct] target=[sct target]" set setpoint [sct target] if { [hpropexists [sct] lowerlimit] } { set lolimit [sct lowerlimit] } else { # lowerlimit not set, use target set lolimit [sct target] } if { [hpropexists [sct] upperlimit] } { set hilimit [sct upperlimit] } else { # upperlimit not set, use target set hilimit [sct target] } # chkrange_function hook code starts # hooked # chkrange_function hook code ends if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" } return OK } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to request the read of a parameter on a device proc ::scobj::hiden_xcs::fetch_flow {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "fetch_flow tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set cmd "${cmd_str}" # fetch_flow hook code starts set data 0.0 foreach node [list flow1 flow2] { set data [expr ${data} + [hval ${tc_root}/${node}]] } sct result ${data} set sp [pathname [sct]]/setpoint if { [hpropexists ${sp} target] } { set sp [hgetpropval ${sp} target] pid_flow ${tc_root} ${sp} ${data} } set cmd "@@NOSEND@@" # fetch_flow hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } debug_log ${tc_root} 1 "fetch_flow 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 request the read of a parameter on a device proc ::scobj::hiden_xcs::getTarget {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "getTarget tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set cmd "${cmd_str}" # getTarget hook code starts if { [hpropexists [sct] target] } { sct result [sct target] } else { sct result [hval [sct]] } set cmd "@@NOSEND@@" # getTarget hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } debug_log ${tc_root} 1 "getTarget 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 request the read of a parameter on a device proc ::scobj::hiden_xcs::getValue {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set cmd "${cmd_str}" # getValue hook code goes here debug_log ${tc_root} 1 "getValue sct send ${cmd}" if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { sct send "${cmd}" } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # halt function for driveable interface proc ::scobj::hiden_xcs::halt {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "halt tc_root=${tc_root} sct=[sct] driving=[sct driving]" ### TODO hset [sct] [hval [sct]] # halt hook code goes here sct driving 0 return "idle" } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to check the write parameter on a device proc ::scobj::hiden_xcs::noResponse {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]" # noResponse hook code goes here return "idle" } catch_message ] 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 ${tc_root} 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}" # no_op hook code starts set cmd "@@NOSEND@@" # no_op hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { [hpropexists [sct] driving] } { if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { sct driving 1 } } debug_log ${tc_root} 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 { 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_deriv [sct pid_error] sct pid_integ [expr {[sct pid_integ] + [sct pid_error] * [sct pid_ivalue]}] 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 [sct pid_integ] set pid [expr {${p_value} + ${i_value} + ${d_value}}] # pid_flow hook code starts if { ![hval ${tc_root}/auto] } { set pid 0.0 sct pid_integ 0.0 } foreach node [list ${tc_root}/analog/sp1 ${tc_root}/analog/sp2] { if { !([hpropexists ${node} bias_flow] && [hgetpropval ${node} bias_flow] == ${pid}) } { hsetprop ${node} bias_flow ${pid} if { [hpropexists ${node} target] } { hset ${node} [hgetpropval ${node} target] } else { hset ${node} [hval ${node}] } } } # pid_flow hook code ends sct pid_output ${pid} } catch_message ] handle_exception ${catch_status} ${catch_message} return ${pid} } # pid function for PID control 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_deriv [sct pid_error] sct pid_integ [expr {[sct pid_integ] + [sct pid_error] * [sct pid_ivalue]}] 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 [sct pid_integ] set pid [expr {${p_value} + ${i_value} + ${d_value}}] # pid_humidity hook code starts if { ![hval ${tc_root}/auto] } { set pid 0.0 sct pid_integ 0.0 } set sign 1 foreach node [list ${tc_root}/analog/sp1 ${tc_root}/analog/sp2] { set sign [expr -${sign}] set signed_pid [expr ${sign} * ${pid}] if { !([hpropexists ${node} bias_humidity] && [hgetpropval ${node} bias_humidity] == ${signed_pid}) } { hsetprop ${node} bias_humidity ${signed_pid} if { [hpropexists ${node} target] } { hset ${node} [hgetpropval ${node} target] } else { hset ${node} [hval ${node}] } } } # pid_humidity hook code ends sct pid_output ${pid} } catch_message ] handle_exception ${catch_status} ${catch_message} return ${pid} } # function to parse the read of a parameter on a device proc ::scobj::hiden_xcs::rdValue {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "rdValue tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set data [sct result] set nextState "idle" if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { # the protocol driver has reported an error sct geterror "${data}" error "[sct geterror]" } # rdValue hook code goes here if { ${data} != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" sct oldval ${data} sct update ${data} sct utime readtime } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to parse the read of a parameter on a device proc ::scobj::hiden_xcs::read_all_data {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "read_all_data tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set data [sct result] set nextState "idle" if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { # the protocol driver has reported an error sct geterror "${data}" error "[sct geterror]" } # read_all_data hook code starts if { [string equal -nocase -length 2 "${data}" "A "] } { set data_list [split [string range "${data}" 2 end-3] ','] if { [llength ${data_list}] == 8 } { set data [expr [lindex ${data_list} 0]] hupdate ${tc_root}/temperature [expr [lindex ${data_list} 1]] hupdate ${tc_root}/flow1 [expr [lindex ${data_list} 3] / [hval ${tc_root}/gas_factor]] hupdate ${tc_root}/flow2 [expr [lindex ${data_list} 4] / [hval ${tc_root}/gas_factor]] hupdate ${tc_root}/flow3 [expr [lindex ${data_list} 5] / [hval ${tc_root}/gas_factor]] } else { sct geterror "Syntax error (not 8) for read_all_data in: '${data}'" } } else { sct geterror "Syntax error (not A) for read_all_data in: '${data}'" } set sp [pathname [sct]]/setpoint if { [hpropexists ${sp} target] } { set sp [hgetpropval ${sp} target] pid_humidity ${tc_root} ${sp} ${data} } # read_all_data hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { ${data} != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" sct oldval ${data} sct update ${data} sct utime readtime } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to parse the read of a parameter on a device proc ::scobj::hiden_xcs::read_digital {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "read_digital tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set data [sct result] set nextState "idle" if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { # the protocol driver has reported an error sct geterror "${data}" error "[sct geterror]" } # read_digital hook code starts if { [string equal -nocase -length 5 "${data}" "DOUT ="] } { set result [scan "${data}" "DOUT = %d OK" val] if { ${result} == 1 } { set data ${val} } else { sct geterror "Syntax error (Result=${result}) in: '${data}'" } } else { sct geterror "Syntax error in: '${data}'" } # read_digital hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { ${data} != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" sct oldval ${data} sct update ${data} sct utime readtime } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to parse the read of a parameter on a device proc ::scobj::hiden_xcs::read_flow {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "read_flow tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set data [sct result] set nextState "idle" if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { # the protocol driver has reported an error sct geterror "${data}" error "[sct geterror]" } # read_flow hook code goes here if { ${data} != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" sct oldval ${data} sct update ${data} sct utime readtime } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to parse the read of a parameter on a device proc ::scobj::hiden_xcs::read_sixteen {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "read_sixteen tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set data [sct result] set nextState "idle" if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { # the protocol driver has reported an error sct geterror "${data}" error "[sct geterror]" } # read_sixteen hook code starts if { [string equal -nocase -length 5 "${data}" "AIN ="] } { set result [scan "${data}" "AIN = %d OK" val] if { ${result} == 1 } { if { [hpropexists [sct] base] } { set base [sct base] } else { set base 0.0 } if { [hpropexists [sct] span] } { set span [sct span] } else { set span 500.0 } set data [expr (${span} * (${val} - ${base})) / 65535.0] } else { sct geterror "Syntax error (Result=${result}) in: '${data}'" } } else { sct geterror "Syntax error in: '${data}'" } # read_sixteen hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { ${data} != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" sct oldval ${data} sct update ${data} sct utime readtime } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to parse the read of a parameter on a device proc ::scobj::hiden_xcs::read_twelve {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "read_twelve tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { hdelprop [sct] geterror } set data [sct result] set nextState "idle" if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { # the protocol driver has reported an error sct geterror "${data}" error "[sct geterror]" } # read_twelve hook code starts if { [string equal -nocase -length 5 "${data}" "AOUT ="] } { set result [scan "${data}" "AOUT = %d OK" val] if { ${result} == 1 } { if { [hpropexists [sct] base] } { set base [sct base] } else { set base 0.0 } if { [hpropexists [sct] span] } { set span [sct span] } else { set span 500.0 } set data [expr (${span} * (${val} - ${base})) / 4095.0] } else { sct geterror "Syntax (Result=${result}) error in: '${data}'" } } else { sct geterror "Syntax error in: '${data}'" } # read_twelve hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { ${data} != [sct oldval] } { debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" sct oldval ${data} sct update ${data} sct utime readtime } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } # function to write a parameter value on a device proc ::scobj::hiden_xcs::setValue {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "setValue 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}" # setValue hook code goes here if { [hpropexists [sct] driving] } { if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { sct driving 1 } } debug_log ${tc_root} 1 "setValue 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::hiden_xcs::write_digital {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "write_digital 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}" # write_digital hook code goes here if { [hpropexists [sct] driving] } { if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { sct driving 1 } } debug_log ${tc_root} 1 "write_digital 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::hiden_xcs::write_flow {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "write_flow 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}" # write_flow hook code starts if { [hpropexists ${tc_root}/humidity/setpoint target] } { set humidity_target [hgetpropval ${tc_root}/humidity/setpoint target] } else { set humidity_target [hval ${tc_root}/humidity/setpoint] } set flow1_target [expr (0.01 * (100.0 - ${humidity_target})) * [sct target]] set flow2_target [expr (0.01 * ( ${humidity_target})) * [sct target]] hset ${tc_root}/analog/sp1 ${flow1_target} hset ${tc_root}/analog/sp2 ${flow2_target} set nextState "idle" set cmd "@@NOSEND@@" # write_flow hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { [hpropexists [sct] driving] } { if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { sct driving 1 } } debug_log ${tc_root} 1 "write_flow 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::hiden_xcs::write_humidity {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "write_humidity 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}" # write_humidity hook code starts if { [hpropexists ${tc_root}/flow/setpoint target] } { set flow_target [hgetpropval ${tc_root}/flow/setpoint target] } else { set flow_target [hval ${tc_root}/flow/setpoint] } set flow1_target [expr (0.01 * (100.0 - [sct target])) * ${flow_target}] set flow2_target [expr (0.01 * ( [sct target])) * ${flow_target}] hset ${tc_root}/analog/sp1 ${flow1_target} hset ${tc_root}/analog/sp2 ${flow2_target} set nextState "idle" set cmd "@@NOSEND@@" # write_humidity hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { [hpropexists [sct] driving] } { if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { sct driving 1 } } debug_log ${tc_root} 1 "write_humidity 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::hiden_xcs::write_twelve {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "write_twelve 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}" # write_twelve hook code starts if { [hpropexists [sct] base] } { set base [sct base] } else { set base 0.0 } if { [hpropexists [sct] span] } { set span [sct span] } else { set span 500.0 } if { [hpropexists [sct] bias_humidity] } { set par [expr ${par} + [sct bias_humidity]] } if { [hpropexists [sct] bias_flow] } { set par [expr ${par} + [sct bias_flow]] } if { ${par} < 0.0 } { set par 0.0 } if { ${par} > ${span} } { set par ${span} } set par [expr int(${base} + (4095.0 * ${par} / ${span}))] set cmd "${cmd_str}${par}" # write_twelve hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" error "[sct geterror]" } if { [hpropexists [sct] driving] } { if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { sct driving 1 } } debug_log ${tc_root} 1 "write_twelve sct send ${cmd}" if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { sct send "${cmd}" } return ${nextState} } catch_message ] handle_exception ${catch_status} ${catch_message} } proc ::scobj::hiden_xcs::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} hfactory ${scobj_hpath}/auto plain user int hsetprop ${scobj_hpath}/auto control true hsetprop ${scobj_hpath}/auto data true hsetprop ${scobj_hpath}/auto mutable true hsetprop ${scobj_hpath}/auto nxsave true hsetprop ${scobj_hpath}/auto values 0,1 hsetprop ${scobj_hpath}/auto oldval 0 hset ${scobj_hpath}/auto 0 hsetprop ${scobj_hpath}/auto klass "environment" hsetprop ${scobj_hpath}/auto sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/auto type "part" hsetprop ${scobj_hpath}/auto nxalias "${name}_auto" hfactory ${scobj_hpath}/enabled plain user int hsetprop ${scobj_hpath}/enabled read ${ns}::getValue ${scobj_hpath} read_digital {?DOUT,2} hsetprop ${scobj_hpath}/enabled read_digital ${ns}::read_digital ${scobj_hpath} hsetprop ${scobj_hpath}/enabled write ${ns}::write_digital ${scobj_hpath} noResponse {!DOUT,2,} hsetprop ${scobj_hpath}/enabled noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/enabled check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/enabled control true hsetprop ${scobj_hpath}/enabled data true hsetprop ${scobj_hpath}/enabled mutable true hsetprop ${scobj_hpath}/enabled nxsave true hsetprop ${scobj_hpath}/enabled values 0,1 hsetprop ${scobj_hpath}/enabled permlink data_set "G[format "%02d" ${id}]X02" hsetprop ${scobj_hpath}/enabled @description "G[format "%02d" ${id}]X02" hsetprop ${scobj_hpath}/enabled oldval 0 hsetprop ${scobj_hpath}/enabled klass "environment" hsetprop ${scobj_hpath}/enabled sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/enabled type "part" hsetprop ${scobj_hpath}/enabled nxalias "${name}_enabled" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/enabled 10 ${sct_controller} write ${scobj_hpath}/enabled hsetprop ${scobj_hpath}/enabled simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/enabled simulated true } hfactory ${scobj_hpath}/flow1 plain user float hsetprop ${scobj_hpath}/flow1 control false hsetprop ${scobj_hpath}/flow1 data false hsetprop ${scobj_hpath}/flow1 mutable true hsetprop ${scobj_hpath}/flow1 nxsave false hsetprop ${scobj_hpath}/flow1 oldval 0.0 hsetprop ${scobj_hpath}/flow1 klass "environment" hsetprop ${scobj_hpath}/flow1 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/flow1 type "part" hsetprop ${scobj_hpath}/flow1 nxalias "${name}_flow1" hfactory ${scobj_hpath}/flow2 plain user float hsetprop ${scobj_hpath}/flow2 control false hsetprop ${scobj_hpath}/flow2 data false hsetprop ${scobj_hpath}/flow2 mutable true hsetprop ${scobj_hpath}/flow2 nxsave false hsetprop ${scobj_hpath}/flow2 oldval 0.0 hsetprop ${scobj_hpath}/flow2 klass "environment" hsetprop ${scobj_hpath}/flow2 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/flow2 type "part" hsetprop ${scobj_hpath}/flow2 nxalias "${name}_flow2" hfactory ${scobj_hpath}/flow3 plain user float hsetprop ${scobj_hpath}/flow3 control false hsetprop ${scobj_hpath}/flow3 data false hsetprop ${scobj_hpath}/flow3 mutable true hsetprop ${scobj_hpath}/flow3 nxsave false hsetprop ${scobj_hpath}/flow3 oldval 0.0 hsetprop ${scobj_hpath}/flow3 klass "environment" hsetprop ${scobj_hpath}/flow3 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/flow3 type "part" hsetprop ${scobj_hpath}/flow3 nxalias "${name}_flow3" hfactory ${scobj_hpath}/gas_factor plain user float hsetprop ${scobj_hpath}/gas_factor control true hsetprop ${scobj_hpath}/gas_factor data true hsetprop ${scobj_hpath}/gas_factor mutable true hsetprop ${scobj_hpath}/gas_factor nxsave true hsetprop ${scobj_hpath}/gas_factor oldval 1.0 hset ${scobj_hpath}/gas_factor 1.0 hsetprop ${scobj_hpath}/gas_factor klass "environment" hsetprop ${scobj_hpath}/gas_factor sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/gas_factor type "part" hsetprop ${scobj_hpath}/gas_factor nxalias "${name}_gas_factor" hfactory ${scobj_hpath}/temperature plain user float hsetprop ${scobj_hpath}/temperature control false hsetprop ${scobj_hpath}/temperature data false hsetprop ${scobj_hpath}/temperature mutable true hsetprop ${scobj_hpath}/temperature nxsave false hsetprop ${scobj_hpath}/temperature oldval 0.0 hsetprop ${scobj_hpath}/temperature klass "environment" hsetprop ${scobj_hpath}/temperature sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/temperature type "part" hsetprop ${scobj_hpath}/temperature nxalias "${name}_temperature" hsetprop ${scobj_hpath} data "true" hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} nxsave "true" hsetprop ${scobj_hpath} type "part" hfactory ${scobj_hpath}/analog plain spy none hfactory ${scobj_hpath}/analog/ansto_temp plain user float hsetprop ${scobj_hpath}/analog/ansto_temp read ${ns}::getValue ${scobj_hpath} read_sixteen {?AIN,12} hsetprop ${scobj_hpath}/analog/ansto_temp read_sixteen ${ns}::read_sixteen ${scobj_hpath} hsetprop ${scobj_hpath}/analog/ansto_temp control false hsetprop ${scobj_hpath}/analog/ansto_temp data false hsetprop ${scobj_hpath}/analog/ansto_temp mutable true hsetprop ${scobj_hpath}/analog/ansto_temp nxsave false hsetprop ${scobj_hpath}/analog/ansto_temp oldval 0.0 hsetprop ${scobj_hpath}/analog/ansto_temp base "0" hsetprop ${scobj_hpath}/analog/ansto_temp sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/ansto_temp span "100" hsetprop ${scobj_hpath}/analog/ansto_temp type "part" hsetprop ${scobj_hpath}/analog/ansto_temp nxalias "${name}_analog_ansto_temp" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/ansto_temp 5 hsetprop ${scobj_hpath}/analog/ansto_temp simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/ansto_temp simulated true } hfactory ${scobj_hpath}/analog/pv1 plain user float hsetprop ${scobj_hpath}/analog/pv1 read ${ns}::getValue ${scobj_hpath} read_sixteen {?AIN,0} hsetprop ${scobj_hpath}/analog/pv1 read_sixteen ${ns}::read_sixteen ${scobj_hpath} hsetprop ${scobj_hpath}/analog/pv1 control false hsetprop ${scobj_hpath}/analog/pv1 data false hsetprop ${scobj_hpath}/analog/pv1 mutable true hsetprop ${scobj_hpath}/analog/pv1 nxsave false hsetprop ${scobj_hpath}/analog/pv1 oldval 0.0 hsetprop ${scobj_hpath}/analog/pv1 base "0" hsetprop ${scobj_hpath}/analog/pv1 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/pv1 span "500" hsetprop ${scobj_hpath}/analog/pv1 type "part" hsetprop ${scobj_hpath}/analog/pv1 nxalias "${name}_analog_pv1" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/pv1 5 hsetprop ${scobj_hpath}/analog/pv1 simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/pv1 simulated true } hfactory ${scobj_hpath}/analog/pv2 plain user float hsetprop ${scobj_hpath}/analog/pv2 read ${ns}::getValue ${scobj_hpath} read_sixteen {?AIN,1} hsetprop ${scobj_hpath}/analog/pv2 read_sixteen ${ns}::read_sixteen ${scobj_hpath} hsetprop ${scobj_hpath}/analog/pv2 control false hsetprop ${scobj_hpath}/analog/pv2 data false hsetprop ${scobj_hpath}/analog/pv2 mutable true hsetprop ${scobj_hpath}/analog/pv2 nxsave false hsetprop ${scobj_hpath}/analog/pv2 oldval 0.0 hsetprop ${scobj_hpath}/analog/pv2 base "0" hsetprop ${scobj_hpath}/analog/pv2 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/pv2 span "500" hsetprop ${scobj_hpath}/analog/pv2 type "part" hsetprop ${scobj_hpath}/analog/pv2 nxalias "${name}_analog_pv2" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/pv2 5 hsetprop ${scobj_hpath}/analog/pv2 simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/pv2 simulated true } hfactory ${scobj_hpath}/analog/pv3 plain user float hsetprop ${scobj_hpath}/analog/pv3 read ${ns}::getValue ${scobj_hpath} read_sixteen {?AIN,2} hsetprop ${scobj_hpath}/analog/pv3 read_sixteen ${ns}::read_sixteen ${scobj_hpath} hsetprop ${scobj_hpath}/analog/pv3 control false hsetprop ${scobj_hpath}/analog/pv3 data false hsetprop ${scobj_hpath}/analog/pv3 mutable true hsetprop ${scobj_hpath}/analog/pv3 nxsave false hsetprop ${scobj_hpath}/analog/pv3 oldval 0.0 hsetprop ${scobj_hpath}/analog/pv3 base "0" hsetprop ${scobj_hpath}/analog/pv3 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/pv3 span "500" hsetprop ${scobj_hpath}/analog/pv3 type "part" hsetprop ${scobj_hpath}/analog/pv3 nxalias "${name}_analog_pv3" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/pv3 5 hsetprop ${scobj_hpath}/analog/pv3 simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/pv3 simulated true } hfactory ${scobj_hpath}/analog/rhsense plain user float hsetprop ${scobj_hpath}/analog/rhsense read ${ns}::getValue ${scobj_hpath} read_sixteen {?AIN,9} hsetprop ${scobj_hpath}/analog/rhsense read_sixteen ${ns}::read_sixteen ${scobj_hpath} hsetprop ${scobj_hpath}/analog/rhsense control false hsetprop ${scobj_hpath}/analog/rhsense data false hsetprop ${scobj_hpath}/analog/rhsense mutable true hsetprop ${scobj_hpath}/analog/rhsense nxsave false hsetprop ${scobj_hpath}/analog/rhsense oldval 0.0 hsetprop ${scobj_hpath}/analog/rhsense base "0" hsetprop ${scobj_hpath}/analog/rhsense sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/rhsense span "100" hsetprop ${scobj_hpath}/analog/rhsense type "part" hsetprop ${scobj_hpath}/analog/rhsense nxalias "${name}_analog_rhsense" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/rhsense 5 hsetprop ${scobj_hpath}/analog/rhsense simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/rhsense simulated true } hfactory ${scobj_hpath}/analog/rhtemp plain user float hsetprop ${scobj_hpath}/analog/rhtemp read ${ns}::getValue ${scobj_hpath} read_sixteen {?AIN,8} hsetprop ${scobj_hpath}/analog/rhtemp read_sixteen ${ns}::read_sixteen ${scobj_hpath} hsetprop ${scobj_hpath}/analog/rhtemp control false hsetprop ${scobj_hpath}/analog/rhtemp data false hsetprop ${scobj_hpath}/analog/rhtemp mutable true hsetprop ${scobj_hpath}/analog/rhtemp nxsave false hsetprop ${scobj_hpath}/analog/rhtemp oldval 0.0 hsetprop ${scobj_hpath}/analog/rhtemp base "0" hsetprop ${scobj_hpath}/analog/rhtemp sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/rhtemp span "100" hsetprop ${scobj_hpath}/analog/rhtemp type "part" hsetprop ${scobj_hpath}/analog/rhtemp nxalias "${name}_analog_rhtemp" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/rhtemp 5 hsetprop ${scobj_hpath}/analog/rhtemp simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/rhtemp simulated true } hfactory ${scobj_hpath}/analog/sp1 plain user float hsetprop ${scobj_hpath}/analog/sp1 read ${ns}::getValue ${scobj_hpath} read_twelve {?AOUT,0} hsetprop ${scobj_hpath}/analog/sp1 read_twelve ${ns}::read_twelve ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp1 write ${ns}::write_twelve ${scobj_hpath} noResponse {!AOUT,0,} hsetprop ${scobj_hpath}/analog/sp1 noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp1 check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp1 control false hsetprop ${scobj_hpath}/analog/sp1 data false hsetprop ${scobj_hpath}/analog/sp1 mutable true hsetprop ${scobj_hpath}/analog/sp1 nxsave false hsetprop ${scobj_hpath}/analog/sp1 oldval 0.0 hsetprop ${scobj_hpath}/analog/sp1 base "0" hsetprop ${scobj_hpath}/analog/sp1 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/sp1 span "500" hsetprop ${scobj_hpath}/analog/sp1 type "part" hsetprop ${scobj_hpath}/analog/sp1 nxalias "${name}_analog_sp1" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/sp1 5 ${sct_controller} write ${scobj_hpath}/analog/sp1 hsetprop ${scobj_hpath}/analog/sp1 simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/sp1 simulated true } hfactory ${scobj_hpath}/analog/sp2 plain user float hsetprop ${scobj_hpath}/analog/sp2 read ${ns}::getValue ${scobj_hpath} read_twelve {?AOUT,1} hsetprop ${scobj_hpath}/analog/sp2 read_twelve ${ns}::read_twelve ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp2 write ${ns}::write_twelve ${scobj_hpath} noResponse {!AOUT,1,} hsetprop ${scobj_hpath}/analog/sp2 noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp2 check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp2 control false hsetprop ${scobj_hpath}/analog/sp2 data false hsetprop ${scobj_hpath}/analog/sp2 mutable true hsetprop ${scobj_hpath}/analog/sp2 nxsave false hsetprop ${scobj_hpath}/analog/sp2 oldval 0.0 hsetprop ${scobj_hpath}/analog/sp2 base "0" hsetprop ${scobj_hpath}/analog/sp2 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/sp2 span "500" hsetprop ${scobj_hpath}/analog/sp2 type "part" hsetprop ${scobj_hpath}/analog/sp2 nxalias "${name}_analog_sp2" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/sp2 5 ${sct_controller} write ${scobj_hpath}/analog/sp2 hsetprop ${scobj_hpath}/analog/sp2 simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/sp2 simulated true } hfactory ${scobj_hpath}/analog/sp3 plain user float hsetprop ${scobj_hpath}/analog/sp3 read ${ns}::getValue ${scobj_hpath} read_twelve {?AOUT,2} hsetprop ${scobj_hpath}/analog/sp3 read_twelve ${ns}::read_twelve ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp3 write ${ns}::write_twelve ${scobj_hpath} noResponse {!AOUT,2,} hsetprop ${scobj_hpath}/analog/sp3 noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp3 check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/analog/sp3 control false hsetprop ${scobj_hpath}/analog/sp3 data false hsetprop ${scobj_hpath}/analog/sp3 mutable true hsetprop ${scobj_hpath}/analog/sp3 nxsave false hsetprop ${scobj_hpath}/analog/sp3 oldval 0.0 hsetprop ${scobj_hpath}/analog/sp3 base "0" hsetprop ${scobj_hpath}/analog/sp3 sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/analog/sp3 span "500" hsetprop ${scobj_hpath}/analog/sp3 type "part" hsetprop ${scobj_hpath}/analog/sp3 nxalias "${name}_analog_sp3" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/sp3 5 ${sct_controller} write ${scobj_hpath}/analog/sp3 hsetprop ${scobj_hpath}/analog/sp3 simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/analog/sp3 simulated true } hsetprop ${scobj_hpath}/analog data "false" hsetprop ${scobj_hpath}/analog klass "@none" hsetprop ${scobj_hpath}/analog type "part" hfactory ${scobj_hpath}/flow plain spy none hfactory ${scobj_hpath}/flow/sensor plain user float hsetprop ${scobj_hpath}/flow/sensor read ${ns}::fetch_flow ${scobj_hpath} read_flow {None} hsetprop ${scobj_hpath}/flow/sensor read_flow ${ns}::read_flow ${scobj_hpath} hsetprop ${scobj_hpath}/flow/sensor control true hsetprop ${scobj_hpath}/flow/sensor data true hsetprop ${scobj_hpath}/flow/sensor mutable true hsetprop ${scobj_hpath}/flow/sensor nxsave true hsetprop ${scobj_hpath}/flow/sensor permlink data_set "G[format "%02d" ${id}]S01" hsetprop ${scobj_hpath}/flow/sensor @description "G[format "%02d" ${id}]S01" hsetprop ${scobj_hpath}/flow/sensor oldval 0.0 hsetprop ${scobj_hpath}/flow/sensor klass "environment" hsetprop ${scobj_hpath}/flow/sensor pid_deriv "0" hsetprop ${scobj_hpath}/flow/sensor pid_dvalue "0.0" hsetprop ${scobj_hpath}/flow/sensor pid_error "0" hsetprop ${scobj_hpath}/flow/sensor pid_imax "50" hsetprop ${scobj_hpath}/flow/sensor pid_integ "0" hsetprop ${scobj_hpath}/flow/sensor pid_ivalue "0.1" hsetprop ${scobj_hpath}/flow/sensor pid_pvalue "0.1" hsetprop ${scobj_hpath}/flow/sensor sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/flow/sensor type "part" hsetprop ${scobj_hpath}/flow/sensor nxalias "${name}_flow_sensor" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/flow/sensor 1 hsetprop ${scobj_hpath}/flow/sensor simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/flow/sensor simulated true } hfactory ${scobj_hpath}/flow/setpoint plain user float hsetprop ${scobj_hpath}/flow/setpoint read ${ns}::getTarget ${scobj_hpath} rdValue {@} hsetprop ${scobj_hpath}/flow/setpoint rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/flow/setpoint write ${ns}::write_flow ${scobj_hpath} noResponse {} hsetprop ${scobj_hpath}/flow/setpoint noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/flow/setpoint check ${ns}::checkrange ${scobj_hpath} hsetprop ${scobj_hpath}/flow/setpoint driving 0 hsetprop ${scobj_hpath}/flow/setpoint checklimits ${ns}::checklimits ${scobj_hpath} hsetprop ${scobj_hpath}/flow/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath} hsetprop ${scobj_hpath}/flow/setpoint halt ${ns}::halt ${scobj_hpath} hsetprop ${scobj_hpath}/flow/setpoint driveable flow/sensor hsetprop ${scobj_hpath}/flow/setpoint control true hsetprop ${scobj_hpath}/flow/setpoint data true hsetprop ${scobj_hpath}/flow/setpoint mutable true hsetprop ${scobj_hpath}/flow/setpoint nxsave true hsetprop ${scobj_hpath}/flow/setpoint lowerlimit 0 hsetprop ${scobj_hpath}/flow/setpoint upperlimit 500 hsetprop ${scobj_hpath}/flow/setpoint tolerance 1 hsetprop ${scobj_hpath}/flow/setpoint permlink data_set "G[format "%02d" ${id}]SP01" hsetprop ${scobj_hpath}/flow/setpoint @description "G[format "%02d" ${id}]SP01" hsetprop ${scobj_hpath}/flow/setpoint oldval 100 hset ${scobj_hpath}/flow/setpoint 100 hsetprop ${scobj_hpath}/flow/setpoint klass "environment" hsetprop ${scobj_hpath}/flow/setpoint sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/flow/setpoint type "drivable" hsetprop ${scobj_hpath}/flow/setpoint nxalias "${name}_flow_setpoint" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/flow/setpoint 1 ${sct_controller} write ${scobj_hpath}/flow/setpoint hsetprop ${scobj_hpath}/flow/setpoint simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/flow/setpoint simulated true } hsetprop ${scobj_hpath}/flow data "true" hsetprop ${scobj_hpath}/flow klass "@none" hsetprop ${scobj_hpath}/flow nxsave "true" hsetprop ${scobj_hpath}/flow type "part" ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller} hfactory ${scobj_hpath}/humidity plain spy none hfactory ${scobj_hpath}/humidity/sensor plain user float hsetprop ${scobj_hpath}/humidity/sensor read ${ns}::getValue ${scobj_hpath} read_all_data {?ALL DATA} hsetprop ${scobj_hpath}/humidity/sensor read_all_data ${ns}::read_all_data ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/sensor control true hsetprop ${scobj_hpath}/humidity/sensor data true hsetprop ${scobj_hpath}/humidity/sensor mutable true hsetprop ${scobj_hpath}/humidity/sensor nxsave true hsetprop ${scobj_hpath}/humidity/sensor permlink data_set "G[format "%02d" ${id}]S02" hsetprop ${scobj_hpath}/humidity/sensor @description "G[format "%02d" ${id}]S02" hsetprop ${scobj_hpath}/humidity/sensor oldval 0.0 hsetprop ${scobj_hpath}/humidity/sensor klass "environment" hsetprop ${scobj_hpath}/humidity/sensor pid_deriv "0" hsetprop ${scobj_hpath}/humidity/sensor pid_dvalue "0.0" hsetprop ${scobj_hpath}/humidity/sensor pid_error "0" hsetprop ${scobj_hpath}/humidity/sensor pid_imax "20" hsetprop ${scobj_hpath}/humidity/sensor pid_integ "0" hsetprop ${scobj_hpath}/humidity/sensor pid_ivalue "0.1" hsetprop ${scobj_hpath}/humidity/sensor pid_pvalue "1.0" hsetprop ${scobj_hpath}/humidity/sensor sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/humidity/sensor type "part" hsetprop ${scobj_hpath}/humidity/sensor nxalias "${name}_humidity_sensor" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/humidity/sensor 1 hsetprop ${scobj_hpath}/humidity/sensor simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/humidity/sensor simulated true } hfactory ${scobj_hpath}/humidity/setpoint plain user float hsetprop ${scobj_hpath}/humidity/setpoint read ${ns}::getTarget ${scobj_hpath} rdValue {@} hsetprop ${scobj_hpath}/humidity/setpoint rdValue ${ns}::rdValue ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/setpoint write ${ns}::write_humidity ${scobj_hpath} noResponse {} hsetprop ${scobj_hpath}/humidity/setpoint noResponse ${ns}::noResponse ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/setpoint check ${ns}::chkrange_function ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/setpoint driving 0 hsetprop ${scobj_hpath}/humidity/setpoint checklimits ${ns}::checklimits ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/setpoint checkstatus ${ns}::checkstatus ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/setpoint halt ${ns}::halt ${scobj_hpath} hsetprop ${scobj_hpath}/humidity/setpoint driveable humidity/sensor hsetprop ${scobj_hpath}/humidity/setpoint control true hsetprop ${scobj_hpath}/humidity/setpoint data true hsetprop ${scobj_hpath}/humidity/setpoint mutable true hsetprop ${scobj_hpath}/humidity/setpoint nxsave true hsetprop ${scobj_hpath}/humidity/setpoint lowerlimit 0 hsetprop ${scobj_hpath}/humidity/setpoint upperlimit 100 hsetprop ${scobj_hpath}/humidity/setpoint tolerance 1 hsetprop ${scobj_hpath}/humidity/setpoint permlink data_set "G[format "%02d" ${id}]SP02" hsetprop ${scobj_hpath}/humidity/setpoint @description "G[format "%02d" ${id}]SP02" hsetprop ${scobj_hpath}/humidity/setpoint oldval 50 hset ${scobj_hpath}/humidity/setpoint 50 hsetprop ${scobj_hpath}/humidity/setpoint klass "environment" hsetprop ${scobj_hpath}/humidity/setpoint sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/humidity/setpoint type "drivable" hsetprop ${scobj_hpath}/humidity/setpoint nxalias "${name}_humidity_setpoint" if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/humidity/setpoint 1 ${sct_controller} write ${scobj_hpath}/humidity/setpoint hsetprop ${scobj_hpath}/humidity/setpoint simulated false } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" hsetprop ${scobj_hpath}/humidity/setpoint simulated true } hsetprop ${scobj_hpath}/humidity data "true" hsetprop ${scobj_hpath}/humidity klass "@none" hsetprop ${scobj_hpath}/humidity nxsave "true" hsetprop ${scobj_hpath}/humidity type "part" ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller} hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts # mkDriver hook code ends } catch_message ] handle_exception ${catch_status} ${catch_message} } proc ::scobj::hiden_xcs::add_driver {name device_class simulation_flag ip_address tcp_port id} { set catch_status [ catch { ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::hiden_xcs::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} } else { ::scobj::hiden_xcs::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => Null sctcontroller for hiden_xcs" ::scobj::hiden_xcs::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } ::scobj::hiden_xcs::sics_log 1 "::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" ::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} } catch_message ] handle_exception ${catch_status} ${catch_message} } namespace eval ::scobj::hiden_xcs { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver namespace export add_driver } proc add_hiden_xcs {name ip_address tcp_port id} { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" ::scobj::hiden_xcs::add_driver ${name} "environment" ${simulation_flag} ${ip_address} ${tcp_port} ${id} } clientput "file evaluation of hiden_xcs_sct.tcl" ::scobj::hiden_xcs::sics_log 9 "file evaluation of hiden_xcs_sct.tcl" proc ::scobj::hiden_xcs::read_config {} { set catch_status [ catch { set ns "::scobj::hiden_xcs" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } set enabled [string tolower [dict get $u "enabled"]] if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } if { [dict exists $u "simulation_group"] } { set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] } if { [dict exists $u "device_class"] } { set device_class "[dict get $u "device_class"]" } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { continue } set v [dict get $::config_dict $implementation] if { !([dict exists $v "driver"]) } { continue } if { [string equal -nocase [dict get $v "driver"] "hiden_xcs"] } { if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" ${ns}::sics_log 9 "makesctcontroller sct_${name} aqadapter NULL" makesctcontroller sct_${name} aqadapter NULL } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { set ip_address [dict get $v ip] set tcp_port [dict get $v port] makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } else { makesctcontroller sct_${name} aqadapter ${asyncqueue} } } else { if { [dict exists $v "asyncprotocol"] } { set asyncprotocol [dict get $v "asyncprotocol"] } else { set asyncprotocol ${name}_protocol MakeAsyncProtocol ${asyncprotocol} if { [dict exists $v "sendterminator"] } { ${asyncprotocol} sendterminator "[dict get $v "sendterminator"]" } elseif { [dict exists $v "terminator"] } { ${asyncprotocol} sendterminator "[dict get $v "terminator"]" } if { [dict exists $v "replyterminator"] } { ${asyncprotocol} replyterminator "[dict get $v "replyterminator"]" } elseif { [dict exists $v "terminator"] } { ${asyncprotocol} replyterminator "[dict get $v "terminator"]" } } set asyncqueue ${name}_queue set ip_address [dict get $v ip] set tcp_port [dict get $v port] MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } makesctcontroller sct_${name} aqadapter ${asyncqueue} } 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" } ${ns}::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } } } } catch_message ] handle_exception ${catch_status} ${catch_message} } if { [info exists ::config_dict] } { ::scobj::hiden_xcs::read_config } else { ::scobj::hiden_xcs::sics_log 5 "No config dict" }